diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-06-13 12:07:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-13 18:07:55 +0200 |
commit | df945e0d7cd3cc78e54002115ae5e5793ed0a116 (patch) | |
tree | ae435150d0f3cb9f8b91fd86e214dc426050c895 | |
parent | Bump regex from 1.7.3 to 1.8.4 (#15769) (diff) | |
download | synapse-df945e0d7cd3cc78e54002115ae5e5793ed0a116.tar.xz |
Fix MSC3983 support: Use the unstable /keys/claim federation endpoint if multiple keys are requested (#15755)
Diffstat (limited to '')
-rw-r--r-- | changelog.d/15755.misc | 1 | ||||
-rw-r--r-- | synapse/federation/federation_client.py | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/changelog.d/15755.misc b/changelog.d/15755.misc new file mode 100644 index 0000000000..a65340d380 --- /dev/null +++ b/changelog.d/15755.misc @@ -0,0 +1 @@ +Fix requesting multiple keys at once over federation, related to [MSC3983](https://github.com/matrix-org/matrix-spec-proposals/pull/3983). diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index a2cf3a96c6..e5359ca558 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -260,7 +260,9 @@ class FederationClient(FederationBase): use_unstable = False for user_id, one_time_keys in query.items(): for device_id, algorithms in one_time_keys.items(): - if any(count > 1 for count in algorithms.values()): + # If more than one algorithm is requested, attempt to use the unstable + # endpoint. + if sum(algorithms.values()) > 1: use_unstable = True if algorithms: # For the stable query, choose only the first algorithm. @@ -296,6 +298,7 @@ class FederationClient(FederationBase): else: logger.debug("Skipping unstable claim client keys API") + # TODO Potentially attempt multiple queries and combine the results? return await self.transport_layer.claim_client_keys( user, destination, content, timeout ) |