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

Commit df945e0

Browse files
authored
Fix MSC3983 support: Use the unstable /keys/claim federation endpoint if multiple keys are requested (#15755)
1 parent 99c850f commit df945e0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

changelog.d/15755.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix requesting multiple keys at once over federation, related to [MSC3983](https://github.com/matrix-org/matrix-spec-proposals/pull/3983).

synapse/federation/federation_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ async def claim_client_keys(
260260
use_unstable = False
261261
for user_id, one_time_keys in query.items():
262262
for device_id, algorithms in one_time_keys.items():
263-
if any(count > 1 for count in algorithms.values()):
263+
# If more than one algorithm is requested, attempt to use the unstable
264+
# endpoint.
265+
if sum(algorithms.values()) > 1:
264266
use_unstable = True
265267
if algorithms:
266268
# For the stable query, choose only the first algorithm.
@@ -296,6 +298,7 @@ async def claim_client_keys(
296298
else:
297299
logger.debug("Skipping unstable claim client keys API")
298300

301+
# TODO Potentially attempt multiple queries and combine the results?
299302
return await self.transport_layer.claim_client_keys(
300303
user, destination, content, timeout
301304
)

0 commit comments

Comments
 (0)