diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2022-05-11 18:15:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-11 17:15:18 +0100 |
commit | 58af7f61b6c3719e15cb4088a343cd08b404f5be (patch) | |
tree | f175b60da826dafaf58499dd3f1dbce5a7c3d6cc /syncapi | |
parent | 24f7be968d6459e887de7c18e17a2c7bb8294796 (diff) |
Fix OTK upload spam (#2448)
* Fix OTK spam
* Update comment
* Optimize selectKeysCountSQL to only return max 100 keys
* Return CurrentPosition if the request timed out
* Revert "Return CurrentPosition if the request timed out"
This reverts commit 7dbdda964189f5542048c06ce5ffc6d4da1814e6.
Co-authored-by: kegsay <kegan@matrix.org>
Diffstat (limited to 'syncapi')
-rw-r--r-- | syncapi/sync/requestpool.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go index 8ab13091..30c490df 100644 --- a/syncapi/sync/requestpool.go +++ b/syncapi/sync/requestpool.go @@ -248,7 +248,15 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi. defer userStreamListener.Close() giveup := func() util.JSONResponse { + syncReq.Log.Debugln("Responding to sync since client gave up or timeout was reached") syncReq.Response.NextBatch = syncReq.Since + // We should always try to include OTKs in sync responses, otherwise clients might upload keys + // even if that's not required. See also: + // https://github.com/matrix-org/synapse/blob/29f06704b8871a44926f7c99e73cf4a978fb8e81/synapse/rest/client/sync.py#L276-L281 + err = internal.DeviceOTKCounts(syncReq.Context, rp.keyAPI, syncReq.Device.UserID, syncReq.Device.ID, syncReq.Response) + if err != nil { + syncReq.Log.WithError(err).Error("failed to get OTK counts") + } return util.JSONResponse{ Code: http.StatusOK, JSON: syncReq.Response, |