summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-01-05 13:33:28 +0000
committerGitHub <noreply@github.com>2022-01-05 13:33:28 +0000
commit88a78c6577086527e4569541b09e437a1ca0d1a9 (patch)
tree18e4072e9ce696bb45553df3f8988cd03ac1d737 /synapse/handlers
parentRefactor the way we set `outlier` (#11634) (diff)
downloadsynapse-88a78c6577086527e4569541b09e437a1ca0d1a9.tar.xz
Cache empty responses from `/user/devices` (#11587)
If we've never made a request to a remote homeserver, we should cache the response---even if the response is "this user has no devices".
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/device.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py

index 7665425232..b184a48cb1 100644 --- a/synapse/handlers/device.py +++ b/synapse/handlers/device.py
@@ -948,8 +948,16 @@ class DeviceListUpdater: devices = [] ignore_devices = True else: + prev_stream_id = await self.store.get_device_list_last_stream_id_for_remote( + user_id + ) cached_devices = await self.store.get_cached_devices_for_user(user_id) - if cached_devices == {d["device_id"]: d for d in devices}: + + # To ensure that a user with no devices is cached, we skip the resync only + # if we have a stream_id from previously writing a cache entry. + if prev_stream_id is not None and cached_devices == { + d["device_id"]: d for d in devices + }: logging.info( "Skipping device list resync for %s, as our cache matches already", user_id,