mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-15 10:03:09 -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
78920828c3
commit
ad658f8aa4
|
|
@ -46,10 +46,19 @@ func (p *NotificationDataStreamProvider) IncrementalSync(
|
||||||
if counts == nil {
|
if counts == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
jr.UnreadNotifications.HighlightCount = counts.UnreadHighlightCount
|
jr.UnreadNotifications.HighlightCount = counts.UnreadHighlightCount
|
||||||
jr.UnreadNotifications.NotificationCount = counts.UnreadNotificationCount
|
jr.UnreadNotifications.NotificationCount = counts.UnreadNotificationCount
|
||||||
req.Response.Rooms.Join[roomID] = jr
|
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 to
|
return to
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -337,10 +337,11 @@ type Response struct {
|
||||||
Events []gomatrixserverlib.ClientEvent `json:"events,omitempty"`
|
Events []gomatrixserverlib.ClientEvent `json:"events,omitempty"`
|
||||||
} `json:"presence,omitempty"`
|
} `json:"presence,omitempty"`
|
||||||
Rooms struct {
|
Rooms struct {
|
||||||
Join map[string]JoinResponse `json:"join,omitempty"`
|
Join map[string]JoinResponse `json:"join,omitempty"`
|
||||||
Peek map[string]JoinResponse `json:"peek,omitempty"`
|
Peek map[string]JoinResponse `json:"peek,omitempty"`
|
||||||
Invite map[string]InviteResponse `json:"invite,omitempty"`
|
Invite map[string]InviteResponse `json:"invite,omitempty"`
|
||||||
Leave map[string]LeaveResponse `json:"leave,omitempty"`
|
Leave map[string]LeaveResponse `json:"leave,omitempty"`
|
||||||
|
UnreadNotifications map[string]UnreadNotificationsResponse `json:"unread_notifications,omitempty"`
|
||||||
} `json:"rooms,omitempty"`
|
} `json:"rooms,omitempty"`
|
||||||
ToDevice struct {
|
ToDevice struct {
|
||||||
Events []gomatrixserverlib.SendToDeviceEvent `json:"events,omitempty"`
|
Events []gomatrixserverlib.SendToDeviceEvent `json:"events,omitempty"`
|
||||||
|
|
@ -360,6 +361,7 @@ func (r *Response) HasUpdates() bool {
|
||||||
len(r.Rooms.Join) > 0 ||
|
len(r.Rooms.Join) > 0 ||
|
||||||
len(r.Rooms.Leave) > 0 ||
|
len(r.Rooms.Leave) > 0 ||
|
||||||
len(r.Rooms.Peek) > 0 ||
|
len(r.Rooms.Peek) > 0 ||
|
||||||
|
len(r.Rooms.UnreadNotifications) > 0 ||
|
||||||
len(r.ToDevice.Events) > 0 ||
|
len(r.ToDevice.Events) > 0 ||
|
||||||
len(r.DeviceLists.Changed) > 0 ||
|
len(r.DeviceLists.Changed) > 0 ||
|
||||||
len(r.DeviceLists.Left) > 0)
|
len(r.DeviceLists.Left) > 0)
|
||||||
|
|
@ -374,6 +376,7 @@ func NewResponse() *Response {
|
||||||
res.Rooms.Peek = map[string]JoinResponse{}
|
res.Rooms.Peek = map[string]JoinResponse{}
|
||||||
res.Rooms.Invite = map[string]InviteResponse{}
|
res.Rooms.Invite = map[string]InviteResponse{}
|
||||||
res.Rooms.Leave = map[string]LeaveResponse{}
|
res.Rooms.Leave = map[string]LeaveResponse{}
|
||||||
|
res.Rooms.UnreadNotifications = map[string]UnreadNotificationsResponse{}
|
||||||
|
|
||||||
// Also pre-intialise empty slices or else we'll insert 'null' instead of '[]' for the value.
|
// Also pre-intialise empty slices or else we'll insert 'null' instead of '[]' for the value.
|
||||||
// TODO: We really shouldn't have to do all this to coerce encoding/json to Do The Right Thing. We should
|
// TODO: We really shouldn't have to do all this to coerce encoding/json to Do The Right Thing. We should
|
||||||
|
|
@ -393,6 +396,7 @@ func (r *Response) IsEmpty() bool {
|
||||||
return len(r.Rooms.Join) == 0 &&
|
return len(r.Rooms.Join) == 0 &&
|
||||||
len(r.Rooms.Invite) == 0 &&
|
len(r.Rooms.Invite) == 0 &&
|
||||||
len(r.Rooms.Leave) == 0 &&
|
len(r.Rooms.Leave) == 0 &&
|
||||||
|
len(r.Rooms.UnreadNotifications) == 0 &&
|
||||||
len(r.AccountData.Events) == 0 &&
|
len(r.AccountData.Events) == 0 &&
|
||||||
len(r.Presence.Events) == 0 &&
|
len(r.Presence.Events) == 0 &&
|
||||||
len(r.ToDevice.Events) == 0
|
len(r.ToDevice.Events) == 0
|
||||||
|
|
@ -435,6 +439,16 @@ func NewJoinResponse() *JoinResponse {
|
||||||
return &res
|
return &res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue