-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtypes.go
More file actions
68 lines (55 loc) · 2.04 KB
/
Copy pathtypes.go
File metadata and controls
68 lines (55 loc) · 2.04 KB
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
package shared
import "time"
// MessageType distinguishes between text and file messages
type MessageType string
const (
TextMessage MessageType = "text"
FileMessageType MessageType = "file"
AdminCommandType MessageType = "admin_command"
EditMessageType MessageType = "edit"
DeleteMessage MessageType = "delete"
TypingMessage MessageType = "typing"
ReactionMessage MessageType = "reaction"
DirectMessage MessageType = "dm"
SearchMessage MessageType = "search"
PinMessage MessageType = "pin"
ReadReceiptType MessageType = "read_receipt"
JoinChannelType MessageType = "join_channel"
LeaveChannelType MessageType = "leave_channel"
ListChannelsType MessageType = "list_channels"
)
type Message struct {
Sender string `json:"sender"`
Content string `json:"content"`
CreatedAt time.Time `json:"created_at"`
Type MessageType `json:"type,omitempty"`
Encrypted bool `json:"encrypted,omitempty"`
// MessageID uniquely identifies a message for edits, deletes, reactions, pins
MessageID int64 `json:"message_id,omitempty"`
// Recipient for direct messages (empty = broadcast to all)
Recipient string `json:"recipient,omitempty"`
// Edited indicates the message has been modified
Edited bool `json:"edited,omitempty"`
Channel string `json:"channel,omitempty"`
// Reaction metadata
Reaction *ReactionMeta `json:"reaction,omitempty"`
// For file messages, Content is empty and File is set
File *FileMeta `json:"file,omitempty"`
}
type FileMeta struct {
Filename string `json:"filename"`
Size int64 `json:"size"`
Data []byte `json:"data"` // raw bytes (base64-encoded in JSON)
}
// ReactionMeta contains reaction data for a message
type ReactionMeta struct {
Emoji string `json:"emoji"`
TargetID int64 `json:"target_id"`
IsRemoval bool `json:"is_removal,omitempty"`
}
// Handshake is sent by the client on WebSocket connect for authentication
type Handshake struct {
Username string `json:"username"`
Admin bool `json:"admin"`
AdminKey string `json:"admin_key,omitempty"`
}