aboutsummaryrefslogtreecommitdiff
path: root/syncapi/types/types.go
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2022-05-19 09:00:56 +0100
committerGitHub <noreply@github.com>2022-05-19 09:00:56 +0100
commit21dd5a7176e52d018b91854db273424e4430af7b (patch)
tree36f1d5f22bc6736d372b59b90e10b023ee143a45 /syncapi/types/types.go
parentf321a7d55ea75e6a5276cd88eddcbbc82ceeaaeb (diff)
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
Diffstat (limited to 'syncapi/types/types.go')
-rw-r--r--syncapi/types/types.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/syncapi/types/types.go b/syncapi/types/types.go
index ba6b4f8c..159fa08b 100644
--- a/syncapi/types/types.go
+++ b/syncapi/types/types.go
@@ -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{}