github.com/tada-team/tdproto@v1.51.57/counters.go (about)

     1  package tdproto
     2  
     3  // Unread messages counter
     4  type ChatCounters struct {
     5  	Jid                JID               `json:"jid"`
     6  	ChatType           ChatType          `json:"chat_type"`
     7  	Gentime            int64             `json:"gentime"`
     8  	NumUnread          uint              `json:"num_unread"`
     9  	NumUnreadNotices   uint              `json:"num_unread_notices"`
    10  	LastReadMessageUid *string           `json:"last_read_message_id"`
    11  	LastActivity       ISODateTimeString `json:"last_activity,omitempty"`
    12  }
    13  
    14  // Unread message counters
    15  type Unread struct {
    16  	// Total unread messages
    17  	NumMessages uint `json:"messages"`
    18  
    19  	// Total unread messages with mentions
    20  	NumNoticeMessages uint `json:"notice_messages"`
    21  
    22  	// Total chats with unread messages
    23  	NumChats uint `json:"chats"`
    24  }
    25  
    26  type TeamUnread map[ChatType]*Unread
    27  
    28  // Unread message counters
    29  type TeamCounter struct {
    30  	// Team id
    31  	Uid string `json:"uid"`
    32  
    33  	// Unread message counters
    34  	Unreads TeamUnread `json:"unread"`
    35  }
    36  
    37  func EmptyTeamUnread() TeamUnread {
    38  	return TeamUnread{
    39  		DirectChatType:  new(Unread),
    40  		GroupChatType:   new(Unread),
    41  		TaskChatType:    new(Unread),
    42  		MeetingChatType: new(Unread),
    43  		ThreadChatType:  new(Unread),
    44  	}
    45  }
    46  
    47  func (unread TeamUnread) Empty() bool {
    48  	for _, v := range unread {
    49  		if v.NumMessages > 0 {
    50  			return false
    51  		}
    52  	}
    53  	return true
    54  }