mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-22 05:23:09 -06:00
Add NotificationData to all rooms in a sync response; Only remove
UnreadNotifications if everything else is empty
This commit is contained in:
parent
088ad1dd21
commit
7132766c26
|
|
@ -3,6 +3,7 @@ package streams
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal/eventutil"
|
||||||
"github.com/matrix-org/dendrite/syncapi/storage"
|
"github.com/matrix-org/dendrite/syncapi/storage"
|
||||||
"github.com/matrix-org/dendrite/syncapi/types"
|
"github.com/matrix-org/dendrite/syncapi/types"
|
||||||
)
|
)
|
||||||
|
|
@ -53,7 +54,7 @@ func (p *NotificationDataStreamProvider) IncrementalSync(
|
||||||
for roomID, jr := range req.Response.Rooms.Join {
|
for roomID, jr := range req.Response.Rooms.Join {
|
||||||
counts := countsByRoom[roomID]
|
counts := countsByRoom[roomID]
|
||||||
if counts == nil {
|
if counts == nil {
|
||||||
continue
|
counts = &eventutil.NotificationData{}
|
||||||
}
|
}
|
||||||
jr.UnreadNotifications = &types.UnreadNotifications{
|
jr.UnreadNotifications = &types.UnreadNotifications{
|
||||||
HighlightCount: counts.UnreadHighlightCount,
|
HighlightCount: counts.UnreadHighlightCount,
|
||||||
|
|
|
||||||
|
|
@ -492,9 +492,11 @@ func (jr JoinResponse) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if jr.UnreadNotifications != nil &&
|
if jr.UnreadNotifications != nil {
|
||||||
jr.UnreadNotifications.NotificationCount == 0 && jr.UnreadNotifications.HighlightCount == 0 {
|
// if everything else is nil, also remove UnreadNotifications
|
||||||
a.UnreadNotifications = nil
|
if a.State == nil && a.Ephemeral == nil && a.AccountData == nil && a.Timeline == nil && a.Summary == nil {
|
||||||
|
a.UnreadNotifications = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return json.Marshal(a)
|
return json.Marshal(a)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue