From 6a992eaa80bd86e9024ea494a14d143131b7ec13 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Wed, 31 Aug 2022 08:28:01 +0200 Subject: [PATCH] Add notifications even without existing room in the response --- syncapi/streams/stream_notificationdata.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/syncapi/streams/stream_notificationdata.go b/syncapi/streams/stream_notificationdata.go index 61973d3a6..e2e1051e0 100644 --- a/syncapi/streams/stream_notificationdata.go +++ b/syncapi/streams/stream_notificationdata.go @@ -39,16 +39,16 @@ func (p *NotificationDataStreamProvider) IncrementalSync( return from } - // We're merely decorating existing rooms. Note that the Join map - // values are not pointers. - for roomID, jr := range req.Response.Rooms.Join { - counts := countsByRoom[roomID] - if counts == nil { - continue + // Add notification data to rooms. + // Create an empty JoinResponse if the room isn't in this response + for roomID, notificationData := range countsByRoom { + jr, exists := req.Response.Rooms.Join[roomID] + if !exists { + jr = *types.NewJoinResponse() } jr.UnreadNotifications = &types.UnreadNotifications{ - HighlightCount: counts.UnreadHighlightCount, - NotificationCount: counts.UnreadNotificationCount, + HighlightCount: notificationData.UnreadHighlightCount, + NotificationCount: notificationData.UnreadNotificationCount, } req.Response.Rooms.Join[roomID] = jr }