mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
syncapi: don't return early for no-op incremental syncs (#2473)
* syncapi: don't return early for no-op incremental syncs Comments explain why, but basically it's an inefficient use of bandwidth and some sytests rely on /sync to block. * Honour timeouts * Actually return a response with timeout=0
This commit is contained in:
parent
f321a7d55e
commit
21dd5a7176
2 changed files with 149 additions and 110 deletions
|
@ -350,6 +350,19 @@ type Response struct {
|
|||
DeviceListsOTKCount map[string]int `json:"device_one_time_keys_count,omitempty"`
|
||||
}
|
||||
|
||||
func (r *Response) HasUpdates() bool {
|
||||
// purposefully exclude DeviceListsOTKCount as we always include them
|
||||
return (len(r.AccountData.Events) > 0 ||
|
||||
len(r.Presence.Events) > 0 ||
|
||||
len(r.Rooms.Invite) > 0 ||
|
||||
len(r.Rooms.Join) > 0 ||
|
||||
len(r.Rooms.Leave) > 0 ||
|
||||
len(r.Rooms.Peek) > 0 ||
|
||||
len(r.ToDevice.Events) > 0 ||
|
||||
len(r.DeviceLists.Changed) > 0 ||
|
||||
len(r.DeviceLists.Left) > 0)
|
||||
}
|
||||
|
||||
// NewResponse creates an empty response with initialised maps.
|
||||
func NewResponse() *Response {
|
||||
res := Response{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue