forked from chanbakjsd/gotrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.go
95 lines (69 loc) · 3.43 KB
/
type.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
package event
import "encoding/json"
// Type is the type of the event that is contained in the contents field.
type Type string
// List of all known room events.
// NOTE: Update the 'parser' variable below as well.
const (
TypeRoomCanonicalAlias Type = "m.room.canonical_alias"
TypeRoomCreate Type = "m.room.create"
TypeRoomJoinRules Type = "m.room.join_rules"
TypeRoomMember Type = "m.room.member"
TypeRoomPowerLevels Type = "m.room.power_levels"
TypeRoomRedaction Type = "m.room.redaction"
// Events from the Instant Messaging module.
TypeRoomMessage Type = "m.room.message"
TypeRoomName Type = "m.room.name"
TypeRoomTopic Type = "m.room.topic"
TypeRoomAvatar Type = "m.room.avatar"
TypeRoomPinned Type = "m.room.pinned_events"
// Events from the Direct Messaging module.
TypeDirect Type = "m.direct"
// Events from the Voice over IP module.
TypeCallInvite Type = "m.call.invite"
TypeCallCandidates Type = "m.call.candidates"
TypeCallAnswer Type = "m.call.answer"
TypeCallHangup Type = "m.call.hangup"
// Events from the Typing Notifications module.
TypeTyping Type = "m.typing"
// Events from the Receipts module.
TypeReceipt Type = "m.receipt"
// Events from the Presence module.
TypePresence Type = "m.presence"
// Events from the History Visibility module.
TypeRoomHistoryVisibility Type = "m.room.history_visibility"
// Events from the Guest Access module.
TypeRoomGuestAccess Type = "m.room.guest_access"
// Events from the Tag module.
TypeTag = "m.tag"
// Events from the Room Upgrade module.
TypeRoomTombstone Type = "m.room.tombstone"
// Events from the Push Notifications module.
TypePushRules Type = "m.push_rules"
)
var parser = map[Type]func(RawEvent, json.RawMessage) (Event, error){
TypeRoomCanonicalAlias: defaultParse(func() Event { return new(RoomCanonicalAliasEvent) }),
TypeRoomCreate: defaultParse(func() Event { return new(RoomCreateEvent) }),
TypeRoomJoinRules: defaultParse(func() Event { return new(RoomJoinRulesEvent) }),
TypeRoomMember: parseRoomMemberEvent,
TypeRoomPowerLevels: defaultParse(func() Event { return new(RoomPowerLevelsEvent) }),
TypeRoomRedaction: parseRoomRedactionEvent,
TypeRoomMessage: defaultParse(func() Event { return new(RoomMessageEvent) }),
TypeRoomName: defaultParse(func() Event { return new(RoomNameEvent) }),
TypeRoomTopic: defaultParse(func() Event { return new(RoomTopicEvent) }),
TypeRoomAvatar: defaultParse(func() Event { return new(RoomAvatarEvent) }),
TypeRoomPinned: defaultParse(func() Event { return new(RoomPinnedEvent) }),
TypeDirect: parseDirectEvent,
TypeCallInvite: defaultParse(func() Event { return new(CallInviteEvent) }),
TypeCallCandidates: defaultParse(func() Event { return new(CallCandidatesEvent) }),
TypeCallAnswer: defaultParse(func() Event { return new(CallAnswerEvent) }),
TypeCallHangup: defaultParse(func() Event { return new(CallHangupEvent) }),
TypeTyping: parseTypingEvent,
TypeReceipt: parseReceiptEvent,
TypePresence: parsePresenceEvent,
TypeRoomHistoryVisibility: defaultParse(func() Event { return new(RoomHistoryVisibilityEvent) }),
TypeRoomGuestAccess: defaultParse(func() Event { return new(RoomGuestAccessEvent) }),
TypeTag: defaultParse(func() Event { return new(TagEvent) }),
TypeRoomTombstone: defaultParse(func() Event { return new(RoomTombstoneEvent) }),
TypePushRules: defaultParse(func() Event { return new(PushRulesEvent) }),
}