-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentities.go
234 lines (211 loc) · 6.94 KB
/
entities.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
package dogehousego
import "bytes"
type UUID string;
type NullString string;
type ChatMode string;
type WhisperPrivacySetting string;
const (
ChatModeDefault ChatMode = "default"
ChatModeDisabled ChatMode = "disabled"
ChatModeFollowerOnly ChatMode = "follower_only"
WhisperPrivacyOn WhisperPrivacySetting = "on"
WhisperPrivacyOff WhisperPrivacySetting = "off"
)
// Make UUID and NullString types nullable
func (c UUID) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
if len(string(c)) == 0 {
buf.WriteString(`null`)
} else {
buf.WriteString(`"` + string(c) + `"`)
}
return buf.Bytes(), nil
}
func (c *UUID)UnmarshalJSON(in []byte) error {
str := string(in)
if str == `null` {
*c = ""
return nil
}
res := UUID(str)
if len(res) >= 2 {
res = res[1:len(res)-1]
}
*c = res
return nil
}
func (c NullString) MarshalJSON() ([]byte, error) {
var buf bytes.Buffer
if len(string(c)) == 0 {
buf.WriteString(`null`)
} else {
buf.WriteString(`"` + string(c) + `"`)
}
return buf.Bytes(), nil
}
func (c *NullString)UnmarshalJSON(in []byte) error {
str := string(in)
if str == `null` {
*c = ""
return nil
}
res := NullString(str)
if len(res) >= 2 {
res = res[1:len(res)-1]
}
*c = res
return nil
}
type UserPreview struct {
Id UUID `json:"id"`
DisplayName string `json:"displayName"`
NumFollowers int `json:"numFollowers"`
AvatarUrl NullString `json:"avatarUrl"`
};
type Room struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
IsPrivate bool `json:"isPrivate"`
NumPeopleInside int `json:"numPeopleInside"`
VoiceServerId string `json:"voiceServerId"`
CreatorId string `json:"creatorId"`
PeoplePreviewList []UserPreview `json:"peoplePreviewList"`
AutoSpeaker bool `json:"autoSpeaker"`
InsertedAt string `json:"inserted_at"`
ChatMode ChatMode `json:"chatMode"`
ChatThrottle int `json:"chatThrottle"`
}
type ScheduledRoom struct {
RoomId UUID `json:"roomId"`
Description string `json:"description"`
ScheduledFor string `json:"scheduledFor"`
NumAttending int `json:"numAttending"`
Name string `json:"name"`
Id UUID `json:"id"`
CreatorId UUID `json:"creatorId"`
Creator User `json:"creator"`
}
type User struct {
YouAreFollowing bool `json:"youAreFollowing"`
Username string `json:"username"`
Online bool `json:"online"`
NumFollowing int `json:"numFollowing"`
NumFollowers int `json:"numFollowers"`
LastOnline string `json:"lastOnline"`
Id UUID `json:"id"`
FollowsYou bool `json:"followsYou"`
BotOwnerId NullString `json:"botOwnerId"`
DisplayName string `json:"displayName"`
CurrentRoomId UUID `json:"currentRoomId"`
CurrentRoom Room `json:"currentRoom"`
Bio NullString `json:"bio"`
AvatarUrl string `json:"avatarUrl"`
BannerUrl NullString `json:"bannerUrl"`
WhisperPrivacySetting WhisperPrivacySetting `json:"whisperPrivacySetting"`
}
type MessageToken struct {
T string `json:"t"`
V interface{} `json:"v"`
}
type Message struct {
Id UUID `json:"id"`
UserId UUID `json:"userId"`
AvatarUrl UUID `json:"avatarUrl"`
Color string `json:"color"`
DisplayName string `json:"displayName"`
Tokens []MessageToken `json:"tokens"`
Username string `json:"username"`
Deleted bool `json:"deleted"`
DeleterId UUID `json:"deleterId"`
SentAt string `json:"sentAt"`
IsWhisper bool `json:"isWhisper"`
}
func (m *Message) GetMessageString() string {
return TokensToString(m.Tokens);
}
type BaseUser struct {
Username string `json:"username"`
Online bool `json:"online"`
LastOnline string `json:"lastOnline"`
Id string `json:"id"`
Bio string `json:"bio"`
DisplayName string `json:"displayName"`
AvatarUrl string `json:"avatarUrl"`
BannerUrl string `json:"bannerUrl"`
NumFollowing int `json:"numFollowing"`
NumFollowers int `json:"numFollowers"`
CurrentRoom *Room `json:"currentRoom"`
BotOwnerId NullString `json:"botOwnerId"`
}
type PaginatedBaseUsers struct {
Users []BaseUser `json:"users"`
NextCursor *int `json:"nextCursor"`
}
type RoomPermissions struct {
AskedToSpeak bool `json:"askedToSpeak"`
IsSpeaker bool `json:"isSpeaker"`
IsMod bool `json:"isMod"`
}
type UserWithFollowInfo struct {
Username string `json:"username"`
Online bool `json:"online"`
LastOnline string `json:"lastOnline"`
Id string `json:"id"`
Bio string `json:"bio"`
DisplayName string `json:"displayName"`
AvatarUrl string `json:"avatarUrl"`
BannerUrl string `json:"bannerUrl"`
NumFollowing int `json:"numFollowing"`
NumFollowers int `json:"numFollowers"`
CurrentRoom *Room `json:"currentRoom"`
BotOwnerId NullString `json:"botOwnerId"`
FollowsYou *bool `json:"followsYou"`
YouAreFollowing *bool `json:"youAreFollowing"`
IBlockedThem *bool `json:"iBlockedThem"`
}
type RoomUser struct {
Username string `json:"username"`
Online bool `json:"online"`
LastOnline string `json:"lastOnline"`
Id string `json:"id"`
Bio string `json:"bio"`
DisplayName string `json:"displayName"`
AvatarUrl string `json:"avatarUrl"`
BannerUrl string `json:"bannerUrl"`
NumFollowing int `json:"numFollowing"`
NumFollowers int `json:"numFollowers"`
CurrentRoom *Room `json:"currentRoom"`
BotOwnerId NullString `json:"botOwnerId"`
FollowsYou *bool `json:"followsYou"`
YouAreFollowing *bool `json:"youAreFollowing"`
IBlockedThem *bool `json:"iBlockedThem"`
RoomPermissions *RoomPermissions `json:"roomPermissions"`
}
type BooleanMap map[UUID]bool
type CurrentRoom struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
IsPrivate bool `json:"isPrivate"`
NumPeopleInside int `json:"numPeopleInside"`
VoiceServerId string `json:"voiceServerId"`
CreatorId string `json:"creatorId"`
PeoplePreviewList []UserPreview `json:"peoplePreviewList"`
InsertedAt string `json:"inserted_at"`
ChatMode ChatMode `json:"chatMode"`
ChatThrottle int `json:"chatThrottle"`
Users []RoomUser `json:"users"`
MuteMap BooleanMap `json:"muteMap"`
DeafMap BooleanMap `json:"deafMap"`
ActiveSpeakerMap BooleanMap `json:"activeSpeakerMap"`
AutoSpeaker bool `json:"autoSpeaker"`
}
type RoomUpdateArgs struct {
Name *string `json:"name,omitempty"`
Privacy *string `json:"privacy,omitempty"`
ChatThrottle *int `json:"chatThrottle,omitempty"`
Description *string `json:"description,omitempty"`
AutoSpeaker *bool `json:"autoSpeaker,omitempty"`
ChatMode *ChatMode `json:"chatMode,omitempty"`
}