Add notifications even without existing room in the response

This commit is contained in:
Till Faelligen 2022-08-31 08:28:01 +02:00
parent 78828edd46
commit 6a992eaa80
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -39,16 +39,16 @@ func (p *NotificationDataStreamProvider) IncrementalSync(
return from return from
} }
// We're merely decorating existing rooms. Note that the Join map // Add notification data to rooms.
// values are not pointers. // Create an empty JoinResponse if the room isn't in this response
for roomID, jr := range req.Response.Rooms.Join { for roomID, notificationData := range countsByRoom {
counts := countsByRoom[roomID] jr, exists := req.Response.Rooms.Join[roomID]
if counts == nil { if !exists {
continue jr = *types.NewJoinResponse()
} }
jr.UnreadNotifications = &types.UnreadNotifications{ jr.UnreadNotifications = &types.UnreadNotifications{
HighlightCount: counts.UnreadHighlightCount, HighlightCount: notificationData.UnreadHighlightCount,
NotificationCount: counts.UnreadNotificationCount, NotificationCount: notificationData.UnreadNotificationCount,
} }
req.Response.Rooms.Join[roomID] = jr req.Response.Rooms.Join[roomID] = jr
} }