-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounters.go
54 lines (45 loc) · 1.29 KB
/
counters.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
package tdproto
// Unread messages counter
type ChatCounters struct {
Jid JID `json:"jid"`
ChatType ChatType `json:"chat_type"`
Gentime int64 `json:"gentime"`
NumUnread uint `json:"num_unread"`
NumUnreadNotices uint `json:"num_unread_notices"`
LastReadMessageUid *string `json:"last_read_message_id"`
LastActivity ISODateTimeString `json:"last_activity,omitempty"`
}
// Unread message counters
type Unread struct {
// Total unread messages
NumMessages uint `json:"messages"`
// Total unread messages with mentions
NumNoticeMessages uint `json:"notice_messages"`
// Total chats with unread messages
NumChats uint `json:"chats"`
}
type TeamUnread map[ChatType]*Unread
// Unread message counters
type TeamCounter struct {
// Team id
Uid string `json:"uid"`
// Unread message counters
Unreads TeamUnread `json:"unread"`
}
func EmptyTeamUnread() TeamUnread {
return TeamUnread{
DirectChatType: new(Unread),
GroupChatType: new(Unread),
TaskChatType: new(Unread),
MeetingChatType: new(Unread),
ThreadChatType: new(Unread),
}
}
func (unread TeamUnread) Empty() bool {
for _, v := range unread {
if v.NumMessages > 0 {
return false
}
}
return true
}