Use a pointer to UnreadNotifications

This commit is contained in:
Till Faelligen 2022-08-31 07:53:46 +02:00
parent 175f65407a
commit 78828edd46
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E
2 changed files with 10 additions and 7 deletions

View file

@ -46,9 +46,10 @@ func (p *NotificationDataStreamProvider) IncrementalSync(
if counts == nil { if counts == nil {
continue continue
} }
jr.UnreadNotifications = &types.UnreadNotifications{
jr.UnreadNotifications.HighlightCount = counts.UnreadHighlightCount HighlightCount: counts.UnreadHighlightCount,
jr.UnreadNotifications.NotificationCount = counts.UnreadNotificationCount NotificationCount: counts.UnreadNotificationCount,
}
req.Response.Rooms.Join[roomID] = jr req.Response.Rooms.Join[roomID] = jr
} }
return to return to

View file

@ -398,6 +398,11 @@ func (r *Response) IsEmpty() bool {
len(r.ToDevice.Events) == 0 len(r.ToDevice.Events) == 0
} }
type UnreadNotifications struct {
HighlightCount int `json:"highlight_count"`
NotificationCount int `json:"notification_count"`
}
// JoinResponse represents a /sync response for a room which is under the 'join' or 'peek' key. // JoinResponse represents a /sync response for a room which is under the 'join' or 'peek' key.
type JoinResponse struct { type JoinResponse struct {
Summary struct { Summary struct {
@ -419,10 +424,7 @@ type JoinResponse struct {
AccountData struct { AccountData struct {
Events []gomatrixserverlib.ClientEvent `json:"events"` Events []gomatrixserverlib.ClientEvent `json:"events"`
} `json:"account_data"` } `json:"account_data"`
UnreadNotifications struct { *UnreadNotifications `json:"unread_notifications,omitempty"`
HighlightCount int `json:"highlight_count"`
NotificationCount int `json:"notification_count"`
} `json:"unread_notifications"`
} }
// NewJoinResponse creates an empty response with initialised arrays. // NewJoinResponse creates an empty response with initialised arrays.