Use the multi-user device resync to batch requests

pull/14716/head
Olivier Wilkinson (reivilibre) 2022-12-21 13:12:53 +00:00
parent 55a4d7e1ce
commit 62e4ad7991
1 changed files with 19 additions and 12 deletions

View File

@ -320,18 +320,25 @@ class E2eKeysHandler:
destination, 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: try:
resync_results = ( user_resync_results = (
await self.device_handler.device_list_updater.user_device_resync( await self.device_handler.device_list_updater.multi_user_device_resync(
user_id 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: 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. # Add the device keys to the results.
user_devices = resync_results["devices"] user_devices = resync_results["devices"]