diff options
author | David Robertson <davidr@element.io> | 2023-02-23 23:57:24 +0000 |
---|---|---|
committer | David Robertson <davidr@element.io> | 2023-02-23 23:57:24 +0000 |
commit | e0841c5d3f01e7796d833baf1df7a1ce0dd27a34 (patch) | |
tree | 1d2ec3da968c1e26903da0fad32117e157cde874 | |
parent | Pull out _FetchKeyRequest (diff) | |
download | synapse-e0841c5d3f01e7796d833baf1df7a1ce0dd27a34.tar.xz |
Keyring: isolate the keyfetching mechanism
So I can call it from federation senders
-rw-r--r-- | synapse/crypto/keyring.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index 8e8dbaaf55..b5b57378ef 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -273,9 +273,7 @@ class Keyring: minimum_valid_until_ts=verify_request.minimum_valid_until_ts, key_ids=list(key_ids_to_find), ) - found_keys_by_server = await self._fetch_keys_queue.add_to_queue( - key_request, key=verify_request.server_name - ) + found_keys_by_server = await self.fetch_keys(key_request) # Since we batch up requests the returned set of keys may contain keys # from other servers, so we pull out only the ones we care about. @@ -302,6 +300,15 @@ class Keyring: Codes.UNAUTHORIZED, ) + async def fetch_keys( + self, key_request: _FetchKeyRequest + ) -> Dict[str, Dict[str, FetchKeyResult]]: + """Returns: {server name: {key id: fetch key result}}""" + found_keys_by_server = await self._fetch_keys_queue.add_to_queue( + key_request, key=key_request.server_name + ) + return found_keys_by_server + async def _process_json( self, verify_key: VerifyKey, verify_request: VerifyJsonRequest ) -> None: |