Fix MSC3983 support: Use the unstable /keys/claim federation endpoint if multiple keys are requested (#15755)
This commit is contained in:
parent
99c850f798
commit
df945e0d7c
|
@ -0,0 +1 @@
|
||||||
|
Fix requesting multiple keys at once over federation, related to [MSC3983](https://github.com/matrix-org/matrix-spec-proposals/pull/3983).
|
|
@ -260,7 +260,9 @@ class FederationClient(FederationBase):
|
||||||
use_unstable = False
|
use_unstable = False
|
||||||
for user_id, one_time_keys in query.items():
|
for user_id, one_time_keys in query.items():
|
||||||
for device_id, algorithms in one_time_keys.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
|
use_unstable = True
|
||||||
if algorithms:
|
if algorithms:
|
||||||
# For the stable query, choose only the first algorithm.
|
# For the stable query, choose only the first algorithm.
|
||||||
|
@ -296,6 +298,7 @@ class FederationClient(FederationBase):
|
||||||
else:
|
else:
|
||||||
logger.debug("Skipping unstable claim client keys API")
|
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(
|
return await self.transport_layer.claim_client_keys(
|
||||||
user, destination, content, timeout
|
user, destination, content, timeout
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue