From 10c72a34d6dcfd31d1ca170f8b9ae41ba5c0369a Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 9 Jun 2023 12:26:48 -0400 Subject: [PATCH 1/3] Fix when to use unstable endpoint. --- synapse/federation/federation_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index a2cf3a96c611..e5359ca5588b 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -260,7 +260,9 @@ async def claim_client_keys( 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 @@ async def claim_client_keys( 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 ) From 12e82fc78f14728910e3a6745edaedf5cc7c1bbd Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 9 Jun 2023 12:28:18 -0400 Subject: [PATCH 2/3] Newsfragment --- changelog.d/15755.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15755.misc diff --git a/changelog.d/15755.misc b/changelog.d/15755.misc new file mode 100644 index 000000000000..09c7f1ce33d6 --- /dev/null +++ b/changelog.d/15755.misc @@ -0,0 +1 @@ +Fix requesting multiple keys at once over federation, related to [MSC3984](https://github.com/matrix-org/matrix-spec-proposals/pull/3984). From 3723c995c2b2c9792d6a16ebc5cafd8405bcc7fd Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Mon, 12 Jun 2023 18:20:58 +0200 Subject: [PATCH 3/3] Fix MSC ref --- changelog.d/15755.misc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/15755.misc b/changelog.d/15755.misc index 09c7f1ce33d6..a65340d380e3 100644 --- a/changelog.d/15755.misc +++ b/changelog.d/15755.misc @@ -1 +1 @@ -Fix requesting multiple keys at once over federation, related to [MSC3984](https://github.com/matrix-org/matrix-spec-proposals/pull/3984). +Fix requesting multiple keys at once over federation, related to [MSC3983](https://github.com/matrix-org/matrix-spec-proposals/pull/3983).