From 44002e033fa57e2fa5115d4be04e7afbcd8981f9 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:53:00 +0200 Subject: [PATCH] Add join response if we're actually joined to the room --- syncapi/streams/stream_notificationdata.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/syncapi/streams/stream_notificationdata.go b/syncapi/streams/stream_notificationdata.go index c789d7a23..1f178f4d0 100644 --- a/syncapi/streams/stream_notificationdata.go +++ b/syncapi/streams/stream_notificationdata.go @@ -3,6 +3,8 @@ package streams import ( "context" + "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/dendrite/syncapi/types" ) @@ -39,12 +41,17 @@ func (p *NotificationDataStreamProvider) IncrementalSync( return from } - // We're merely decorating existing rooms. - for roomID, jr := range req.Response.Rooms.Join { - counts := countsByRoom[roomID] - if counts == nil { + // Add notification data based on the membership of the user + for roomID, counts := range countsByRoom { + if req.Rooms[roomID] != gomatrixserverlib.Join { continue } + // If there's no join response, add a new one + jr, ok := req.Response.Rooms.Join[roomID] + if !ok { + jr = *types.NewJoinResponse() + } + jr.UnreadNotifications = &types.UnreadNotifications{ HighlightCount: counts.UnreadHighlightCount, NotificationCount: counts.UnreadNotificationCount,