summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-12-21 13:12:53 +0000
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-12-21 13:12:53 +0000
commit62e4ad79914d02fff7e3ebe78a5ba1ebd017b8f5 (patch)
treeeddb6b4491cd20b9cce408c3f39ea642aa121f7f
parentTypo fix (diff)
downloadsynapse-62e4ad79914d02fff7e3ebe78a5ba1ebd017b8f5.tar.xz
Use the multi-user device resync to batch requests
-rw-r--r--synapse/handlers/e2e_keys.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/synapse/handlers/e2e_keys.py b/synapse/handlers/e2e_keys.py

index 21b009ed47..d2188ca08f 100644 --- a/synapse/handlers/e2e_keys.py +++ b/synapse/handlers/e2e_keys.py
@@ -320,18 +320,25 @@ class E2eKeysHandler: destination, ) - for user_id in users_to_resync_devices: - # We've decided we're sharing a room with this user and should - # probably be tracking their device lists. However, we haven't - # done an initial sync on the device list so we do it now. - try: - resync_results = ( - await self.device_handler.device_list_updater.user_device_resync( - user_id - ) + try: + user_resync_results = ( + await self.device_handler.device_list_updater.multi_user_device_resync( + list(users_to_resync_devices) ) + ) + for user_id in users_to_resync_devices: + resync_results = user_resync_results[user_id] + if resync_results is None: - raise ValueError("Device resync failed") + # TODO: It's weird that we'll store a failure against a + # destination, yet continue processing users from that + # destination. + # We might want to consider changing this, but for now + # I'm leaving it as I found it. + failures[destination] = _exception_to_failure( + ValueError(f"Device resync failed for {user_id!r}") + ) + continue # Add the device keys to the results. user_devices = resync_results["devices"] @@ -349,8 +356,8 @@ class E2eKeysHandler: if self_signing_key: cross_signing_keys["self_signing_keys"][user_id] = self_signing_key - except Exception as e: - failures[destination] = _exception_to_failure(e) + except Exception as e: + failures[destination] = _exception_to_failure(e) if len(destination_query) == len(user_ids_updated): # We've updated all the users in the query and we do not need to