Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit f59e3f4

Browse files
authored
Mark remote device list updates as already handled (#12557)
1 parent 6d89f12 commit f59e3f4

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

changelog.d/12557.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reduce unnecessary work when handling remote device list updates.

synapse/handlers/device.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,9 @@ async def notify_device_update(
505505
"device_list_key", position, users={user_id}, rooms=room_ids
506506
)
507507

508-
# We may need to do some processing asynchronously.
509-
self._handle_new_device_update_async()
508+
# We may need to do some processing asynchronously for local user IDs.
509+
if self.hs.is_mine_id(user_id):
510+
self._handle_new_device_update_async()
510511

511512
async def notify_user_signature_update(
512513
self, from_user_id: str, user_ids: List[str]

synapse/storage/databases/main/devices.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,8 @@ def _add_device_outbound_room_poke_txn(
17481748
device_id,
17491749
room_id,
17501750
stream_id,
1751-
False,
1751+
# We only need to calculate outbound pokes for local users
1752+
not self.hs.is_mine_id(user_id),
17521753
encoded_context,
17531754
)
17541755
for room_id in room_ids

tests/storage/test_devices.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def add_device_change(self, user_id, device_ids, host):
2929
for device_id in device_ids:
3030
stream_id = self.get_success(
3131
self.store.add_device_change_to_streams(
32-
"user_id", [device_id], ["!some:room"]
32+
user_id, [device_id], ["!some:room"]
3333
)
3434
)
3535

0 commit comments

Comments
 (0)