Fix broken notification incremental sync

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 <austin@hntlabs.com>
This commit is contained in:
texuf 2022-09-07 18:01:08 -07:00 committed by Tak Wai Wong
parent fbfde86914
commit 1f2f42494c
No known key found for this signature in database
GPG key ID: 222E4AF2AA1F467D

View file

@ -442,6 +442,16 @@ func (r *Response) IsEmpty() bool {
len(r.ToDevice.Events) == 0 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 { type UnreadNotifications struct {
HighlightCount int `json:"highlight_count"` HighlightCount int `json:"highlight_count"`
NotificationCount int `json:"notification_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. // InviteResponse represents a /sync response for a room which is under the 'invite' key.
type InviteResponse struct { type InviteResponse struct {
InviteState struct { InviteState struct {