diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2022-10-14 10:38:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-14 10:38:12 +0200 |
commit | a8bc558a606266b2dc1d1c19cf0c052f3b733679 (patch) | |
tree | 1953cef207e00577beedd34def64041139f4a5d7 /syncapi | |
parent | fb44e33909660b5e37f2d422baf4ffa7ddc30b0a (diff) |
Always add `UnreadNotifications` to joined room reponses (#2793)
Fixes a minor bug, where we failed to add `UnreadNotifications` to the
join response, if it wasn't in
`GetUserUnreadNotificationCountsForRooms`.
Diffstat (limited to 'syncapi')
-rw-r--r-- | syncapi/streams/stream_notificationdata.go | 3 | ||||
-rw-r--r-- | syncapi/types/types.go | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/syncapi/streams/stream_notificationdata.go b/syncapi/streams/stream_notificationdata.go index 5a81fd09..66ee0ded 100644 --- a/syncapi/streams/stream_notificationdata.go +++ b/syncapi/streams/stream_notificationdata.go @@ -3,6 +3,7 @@ package streams import ( "context" + "github.com/matrix-org/dendrite/internal/eventutil" "github.com/matrix-org/dendrite/syncapi/storage" "github.com/matrix-org/dendrite/syncapi/types" ) @@ -53,7 +54,7 @@ func (p *NotificationDataStreamProvider) IncrementalSync( for roomID, jr := range req.Response.Rooms.Join { counts := countsByRoom[roomID] if counts == nil { - continue + counts = &eventutil.NotificationData{} } jr.UnreadNotifications = &types.UnreadNotifications{ HighlightCount: counts.UnreadHighlightCount, diff --git a/syncapi/types/types.go b/syncapi/types/types.go index 60a74a28..57ce7b6f 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -492,9 +492,11 @@ func (jr JoinResponse) MarshalJSON() ([]byte, error) { } } - if jr.UnreadNotifications != nil && - jr.UnreadNotifications.NotificationCount == 0 && jr.UnreadNotifications.HighlightCount == 0 { - a.UnreadNotifications = nil + if jr.UnreadNotifications != nil { + // if everything else is nil, also remove UnreadNotifications + if a.State == nil && a.Ephemeral == nil && a.AccountData == nil && a.Timeline == nil && a.Summary == nil { + a.UnreadNotifications = nil + } } return json.Marshal(a) } |