diff options
author | Erik Johnston <erik@matrix.org> | 2022-04-26 17:07:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 17:07:21 +0100 |
commit | f59e3f4c900b3961e2b96592a67cd2f0821b00db (patch) | |
tree | 06407ee7ebadca9d531a01085c3696a95182f2db | |
parent | Comment out dodgy log-kv (#12554) (diff) | |
download | synapse-f59e3f4c900b3961e2b96592a67cd2f0821b00db.tar.xz |
Mark remote device list updates as already handled (#12557)
-rw-r--r-- | changelog.d/12557.misc | 1 | ||||
-rw-r--r-- | synapse/handlers/device.py | 5 | ||||
-rw-r--r-- | synapse/storage/databases/main/devices.py | 3 | ||||
-rw-r--r-- | tests/storage/test_devices.py | 2 |
4 files changed, 7 insertions, 4 deletions
diff --git a/changelog.d/12557.misc b/changelog.d/12557.misc new file mode 100644 index 0000000000..e4eb895ef5 --- /dev/null +++ b/changelog.d/12557.misc @@ -0,0 +1 @@ +Reduce unnecessary work when handling remote device list updates. diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py index 319836da2b..a91b1ee4d5 100644 --- a/synapse/handlers/device.py +++ b/synapse/handlers/device.py @@ -505,8 +505,9 @@ class DeviceHandler(DeviceWorkerHandler): "device_list_key", position, users={user_id}, rooms=room_ids ) - # We may need to do some processing asynchronously. - self._handle_new_device_update_async() + # We may need to do some processing asynchronously for local user IDs. + if self.hs.is_mine_id(user_id): + self._handle_new_device_update_async() async def notify_user_signature_update( self, from_user_id: str, user_ids: List[str] diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py index 59d223a900..483dd80406 100644 --- a/synapse/storage/databases/main/devices.py +++ b/synapse/storage/databases/main/devices.py @@ -1748,7 +1748,8 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore): device_id, room_id, stream_id, - False, + # We only need to calculate outbound pokes for local users + not self.hs.is_mine_id(user_id), encoded_context, ) for room_id in room_ids diff --git a/tests/storage/test_devices.py b/tests/storage/test_devices.py index ccc3893869..bbf079b25b 100644 --- a/tests/storage/test_devices.py +++ b/tests/storage/test_devices.py @@ -29,7 +29,7 @@ class DeviceStoreTestCase(HomeserverTestCase): for device_id in device_ids: stream_id = self.get_success( self.store.add_device_change_to_streams( - "user_id", [device_id], ["!some:room"] + user_id, [device_id], ["!some:room"] ) ) |