-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat.go
50 lines (42 loc) · 1.55 KB
/
chat.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
package models
import (
"encoding/gob"
"github.com/gage-technologies/gigo-lib/db/models"
)
// we have to register the custom types with gob
// so that they can be marshaled and unmarshaled
func init() {
gob.Register(&NewChatMsg{})
gob.Register(&NewMessageMsg{})
gob.Register(&ChatKickMsg{})
gob.Register(&ChatUpdatedEventMsg{})
}
type ChatUpdateEvent int
const (
ChatUpdateEventNameChange ChatUpdateEvent = iota
ChatUpdateEventUserAdd
ChatUpdateEventUserRemove
ChatUpdateEventDeleted
)
type NewChatMsg struct {
Chat models.Chat `json:"chat"`
}
type NewMessageMsg struct {
Message models.ChatMessage `json:"message"`
}
type ChatKickMsg struct {
ChatID int64 `json:"chat_id"`
}
type ChatUpdatedEventMsg struct {
Chat *models.ChatFrontend `json:"chat"`
UpdateEvents []ChatUpdateEvent `json:"update_events"`
OldName string `json:"old_name"`
AddedUsers []string `json:"added_users"`
RemovedUsers []string `json:"removed_users"`
Updater string `json:"updater"`
UpdaterIcon string `json:"updater_icon"`
UpdaterBackground string `json:"updater_background"`
UpdaterBackgroundRenderInFront bool `json:"updater_background_render_in_front"`
UpdaterBackgroundPalette string `json:"updater_background_palette"`
UpdaterPro bool `json:"updater_pro"`
}