aboutsummaryrefslogtreecommitdiff
path: root/syncapi/sync/request.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-04-26 16:58:20 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-04-26 16:58:20 +0100
commitb527e33c16d70ee6f94ac12c077b43283ff1fd86 (patch)
treeb638c155536a06149b0b4a130c673173e9a81d96 /syncapi/sync/request.go
parentf6d07768a82cdea07c56cf4ae463449292fa9fe4 (diff)
Send all account data on complete sync by default
Squashed commit of the following: commit 0ec8de57261d573a5f88577aa9d7a1174d3999b9 Author: Neil Alexander <neilalexander@users.noreply.github.com> Date: Tue Apr 26 16:56:30 2022 +0100 Select filter onto provided target filter commit da40b6fffbf5737864b223f49900048f557941f9 Author: Neil Alexander <neilalexander@users.noreply.github.com> Date: Tue Apr 26 16:48:00 2022 +0100 Specify other field too commit ffc0b0801f63bb4d3061b6813e3ce5f3b4c8fbcb Author: Neil Alexander <neilalexander@users.noreply.github.com> Date: Tue Apr 26 16:45:44 2022 +0100 Send as much account data as possible during complete sync
Diffstat (limited to 'syncapi/sync/request.go')
-rw-r--r--syncapi/sync/request.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/syncapi/sync/request.go b/syncapi/sync/request.go
index f04f172d..c9ee8e4a 100644
--- a/syncapi/sync/request.go
+++ b/syncapi/sync/request.go
@@ -18,6 +18,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
+ "math"
"net/http"
"strconv"
"time"
@@ -47,6 +48,13 @@ func newSyncRequest(req *http.Request, device userapi.Device, syncDB storage.Dat
}
// TODO: read from stored filters too
filter := gomatrixserverlib.DefaultFilter()
+ if since.IsEmpty() {
+ // Send as much account data down for complete syncs as possible
+ // by default, otherwise clients do weird things while waiting
+ // for the rest of the data to trickle down.
+ filter.AccountData.Limit = math.MaxInt
+ filter.Room.AccountData.Limit = math.MaxInt
+ }
filterQuery := req.URL.Query().Get("filter")
if filterQuery != "" {
if filterQuery[0] == '{' {
@@ -61,11 +69,9 @@ func newSyncRequest(req *http.Request, device userapi.Device, syncDB storage.Dat
util.GetLogger(req.Context()).WithError(err).Error("gomatrixserverlib.SplitID failed")
return nil, fmt.Errorf("gomatrixserverlib.SplitID: %w", err)
}
- if f, err := syncDB.GetFilter(req.Context(), localpart, filterQuery); err != nil && err != sql.ErrNoRows {
+ if err := syncDB.GetFilter(req.Context(), &filter, localpart, filterQuery); err != nil && err != sql.ErrNoRows {
util.GetLogger(req.Context()).WithError(err).Error("syncDB.GetFilter failed")
return nil, fmt.Errorf("syncDB.GetFilter: %w", err)
- } else if f != nil {
- filter = *f
}
}
}