This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
99 lines (86 loc) · 3.44 KB
/
data.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
// Copyright (C) 2022 Alexander Sowitzki
//
// This program is free software: you can redistribute it and/or modify it under the terms of the
// GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
// details.
//
// You should have received a copy of the GNU Affero General Public License along with this program.
// If not, see <https://www.gnu.org/licenses/>.
package sync
import (
"eqrx.net/matrix"
"eqrx.net/matrix/event"
)
// Response of a sync request.
type Response struct {
matrix.Response
AccountData EventContainer `json:"account_data"`
DeviceLists DeviceLists `json:"device_lists"`
DeviceOneTimeKeysCount map[string]int `json:"device_one_time_keys_count"`
NextBatch string `json:"next_batch"`
Presence EventContainer `json:"presence"`
Rooms Rooms `json:"rooms"`
ToDevice EventContainer `json:"to_device"`
}
// EventContainer represents map that just contains an event field.
//
// There is a lot of those in Response...
type EventContainer struct {
Events []event.Opaque `json:"events"`
}
// DeviceLists contains information about device changes.
type DeviceLists struct {
Changed []string `json:"changed"`
Left []string `json:"left"`
}
// Rooms contains information about rooms the client has interacted with, grouped by state.
type Rooms struct {
Invited map[string]InvitedRoom `json:"invite"`
Joined map[string]JoinedRoom `json:"join"`
Knocked map[string]KnockedRoom `json:"knock"`
Left map[string]LeftRoom `json:"leave"`
}
// InvitedRoom is a room the client was invited to.
type InvitedRoom struct {
State EventContainer `json:"invite_state"`
}
// JoinedRoom is a room the client has joined.
type JoinedRoom struct {
AccountData EventContainer `json:"account_data"`
Ephemeral EventContainer `json:"ephemeral"`
State EventContainer `json:"state"`
Summary RoomSummary `json:"summary"`
Timeline Timeline `json:"timeline"`
UnreadNotificationsCounts UnreadNotificationsCounts `json:"unread_notifications"`
}
// UnreadNotificationsCounts contains notication counts of a joined room.
type UnreadNotificationsCounts struct {
Highlighted int `json:"highlight_count"`
Total int `json:"total"`
}
// RoomSummary for joined rooms.
type RoomSummary struct {
Heros []string `json:"m.heroes"`
InvitedMemberCount int `json:"m.invited_member_count"`
JoinedMemeberCount int `json:"m.joined_member_count"`
}
// Timeline represents events of a room.
type Timeline struct {
Events []event.Opaque `json:"events"`
Limited bool `json:"limited"`
PreviousBatch string `json:"prev_batch"`
}
// KnockedRoom is a room the client has knocked on.
type KnockedRoom struct {
KnockState EventContainer `json:"knock_state"`
}
// LeftRoom is a room the client has left.
type LeftRoom struct {
AccountData EventContainer `json:"account_data"`
State EventContainer `json:"ephemeral"`
Timeline Timeline `json:"timeline"`
}