From 1f2f42494ce216a4ad5c551d84cefb1018b2450f Mon Sep 17 00:00:00 2001 From: texuf Date: Wed, 7 Sep 2022 18:01:08 -0700 Subject: [PATCH] Fix broken notification incremental sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I was not seeing unread notifications in sync, even if they were written to the db Notifications are in their own stream, but the code was trying to tack them onto the join room stream. If the offsets “happened” to line up, you might get a count here or there, but they would be totally wrong (jump from 1 to 0 to 2, etc) To fix, put them in their own top level object, handle them on the client. Signed-off-by: Austin Ellis --- syncapi/types/types.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/syncapi/types/types.go b/syncapi/types/types.go index 75194d3f6..a8ae18fde 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -442,6 +442,16 @@ func (r *Response) IsEmpty() bool { len(r.ToDevice.Events) == 0 } +type UnreadNotificationsResponse struct { + HighlightCount int `json:"highlight_count"` + NotificationCount int `json:"notification_count"` +} + +func NewUnreadNotificationsResponse() *UnreadNotificationsResponse { + res := UnreadNotificationsResponse{} + return &res +} + type UnreadNotifications struct { HighlightCount int `json:"highlight_count"` NotificationCount int `json:"notification_count"` @@ -518,16 +528,6 @@ func NewJoinResponse() *JoinResponse { } } -type UnreadNotificationsResponse struct { - HighlightCount int `json:"highlight_count"` - NotificationCount int `json:"notification_count"` -} - -func NewUnreadNotificationsResponse() *UnreadNotificationsResponse { - res := UnreadNotificationsResponse{} - return &res -} - // InviteResponse represents a /sync response for a room which is under the 'invite' key. type InviteResponse struct { InviteState struct {