summaryrefslogtreecommitdiff
path: root/synapse/crypto/keyring.py
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2021-12-14 17:36:00 +0100
committerAndrej Shadura <andrewsh@debian.org>2021-12-14 17:36:00 +0100
commite894f36b081e694a99c1829d05a2382edd8c4533 (patch)
tree094399067207ada06f538d472bf44b608e984cac /synapse/crypto/keyring.py
parent7eba982950257d89142cd5a793320be25c5d669a (diff)
New upstream version 1.49.0
Diffstat (limited to 'synapse/crypto/keyring.py')
-rw-r--r--synapse/crypto/keyring.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py
index 4cda439a..993b0409 100644
--- a/synapse/crypto/keyring.py
+++ b/synapse/crypto/keyring.py
@@ -667,21 +667,25 @@ class PerspectivesKeyFetcher(BaseV2KeyFetcher):
perspective_name,
)
+ request: JsonDict = {}
+ for queue_value in keys_to_fetch:
+ # there may be multiple requests for each server, so we have to merge
+ # them intelligently.
+ request_for_server = {
+ key_id: {
+ "minimum_valid_until_ts": queue_value.minimum_valid_until_ts,
+ }
+ for key_id in queue_value.key_ids
+ }
+ request.setdefault(queue_value.server_name, {}).update(request_for_server)
+
+ logger.debug("Request to notary server %s: %s", perspective_name, request)
+
try:
query_response = await self.client.post_json(
destination=perspective_name,
path="/_matrix/key/v2/query",
- data={
- "server_keys": {
- queue_value.server_name: {
- key_id: {
- "minimum_valid_until_ts": queue_value.minimum_valid_until_ts,
- }
- for key_id in queue_value.key_ids
- }
- for queue_value in keys_to_fetch
- }
- },
+ data={"server_keys": request},
)
except (NotRetryingDestination, RequestSendFailed) as e:
# these both have str() representations which we can't really improve upon
@@ -689,6 +693,10 @@ class PerspectivesKeyFetcher(BaseV2KeyFetcher):
except HttpResponseException as e:
raise KeyLookupError("Remote server returned an error: %s" % (e,))
+ logger.debug(
+ "Response from notary server %s: %s", perspective_name, query_response
+ )
+
keys: Dict[str, Dict[str, FetchKeyResult]] = {}
added_keys: List[Tuple[str, str, FetchKeyResult]] = []