mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Pull dendrite fork into the harmony repo (#423)
Austin's notification fix Signed-off-by: Brian Meek <brian@hntlabs.com> Signed-off-by: Austin Ellis <austin@hntlabs.com> Co-authored-by: Brian Meek <brian@hntlabs.com> Co-authored-by: texuf <texuf.eth@gmail.com> Co-authored-by: Tak Wai Wong <tak@hntlabs.com>
This commit is contained in:
parent
cda7734660
commit
fbfde86914
|
|
@ -62,6 +62,14 @@ func (p *NotificationDataStreamProvider) IncrementalSync(
|
|||
}
|
||||
req.Response.Rooms.Join[roomID] = jr
|
||||
}
|
||||
// BEGIN ZION CODE but return all notifications regardless of whether they're in a room we're in.
|
||||
for roomID, counts := range countsByRoom {
|
||||
unreadNotificationsData := *types.NewUnreadNotificationsResponse()
|
||||
|
||||
unreadNotificationsData.HighlightCount = counts.UnreadHighlightCount
|
||||
unreadNotificationsData.NotificationCount = counts.UnreadNotificationCount
|
||||
req.Response.Rooms.UnreadNotifications[roomID] = unreadNotificationsData
|
||||
}
|
||||
// END ZION CODE
|
||||
return p.LatestPosition(ctx)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -345,6 +345,7 @@ type RoomsResponse struct {
|
|||
Peek map[string]*JoinResponse `json:"peek,omitempty"`
|
||||
Invite map[string]*InviteResponse `json:"invite,omitempty"`
|
||||
Leave map[string]*LeaveResponse `json:"leave,omitempty"`
|
||||
UnreadNotifications map[string]UnreadNotificationsResponse `json:"unread_notifications,omitempty"`
|
||||
}
|
||||
|
||||
type ToDeviceResponse struct {
|
||||
|
|
@ -396,6 +397,7 @@ func (r *Response) HasUpdates() bool {
|
|||
len(r.Rooms.Join) > 0 ||
|
||||
len(r.Rooms.Leave) > 0 ||
|
||||
len(r.Rooms.Peek) > 0 ||
|
||||
len(r.Rooms.UnreadNotifications) > 0 ||
|
||||
len(r.ToDevice.Events) > 0 ||
|
||||
len(r.DeviceLists.Changed) > 0 ||
|
||||
len(r.DeviceLists.Left) > 0)
|
||||
|
|
@ -406,11 +408,13 @@ func NewResponse() *Response {
|
|||
res := Response{}
|
||||
// Pre-initialise the maps. Synapse will return {} even if there are no rooms under a specific section,
|
||||
// so let's do the same thing. Bonus: this means we can't get dreaded 'assignment to entry in nil map' errors.
|
||||
|
||||
res.Rooms = &RoomsResponse{
|
||||
Join: map[string]*JoinResponse{},
|
||||
Peek: map[string]*JoinResponse{},
|
||||
Invite: map[string]*InviteResponse{},
|
||||
Leave: map[string]*LeaveResponse{},
|
||||
UnreadNotifications: map[string]UnreadNotificationsResponse{},
|
||||
}
|
||||
|
||||
// Also pre-intialise empty slices or else we'll insert 'null' instead of '[]' for the value.
|
||||
|
|
@ -432,6 +436,7 @@ func (r *Response) IsEmpty() bool {
|
|||
return len(r.Rooms.Join) == 0 &&
|
||||
len(r.Rooms.Invite) == 0 &&
|
||||
len(r.Rooms.Leave) == 0 &&
|
||||
len(r.Rooms.UnreadNotifications) == 0 &&
|
||||
len(r.AccountData.Events) == 0 &&
|
||||
len(r.Presence.Events) == 0 &&
|
||||
len(r.ToDevice.Events) == 0
|
||||
|
|
@ -513,6 +518,16 @@ 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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue