diff options
author | David Robertson <davidr@element.io> | 2023-02-23 23:55:53 +0000 |
---|---|---|
committer | David Robertson <davidr@element.io> | 2023-02-23 23:55:53 +0000 |
commit | 9a7f925a848322a91b524cbe3d7e83a2a4303000 (patch) | |
tree | 4a3e2fa9c5884f735cdb4a26c978619e96b42414 | |
parent | Fix a bug introduced in Synapse v1.74.0 where searching with colons when usin... (diff) | |
download | synapse-9a7f925a848322a91b524cbe3d7e83a2a4303000.tar.xz |
Pull out _FetchKeyRequest
This will help to break an import cycle
-rw-r--r-- | synapse/crypto/keyring.py | 20 | ||||
-rw-r--r-- | synapse/crypto/types.py | 35 |
2 files changed, 36 insertions, 19 deletions
diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index 86cd4af9bd..8e8dbaaf55 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -41,6 +41,7 @@ from synapse.api.errors import ( SynapseError, ) from synapse.config.key import TrustedKeyServer +from synapse.crypto.types import _FetchKeyRequest from synapse.events import EventBase from synapse.events.utils import prune_event_dict from synapse.logging.context import make_deferred_yieldable, run_in_background @@ -123,25 +124,6 @@ class KeyLookupError(ValueError): pass -@attr.s(slots=True, frozen=True, auto_attribs=True) -class _FetchKeyRequest: - """A request for keys for a given server. - - We will continue to try and fetch until we have all the keys listed under - `key_ids` (with an appropriate `valid_until_ts` property) or we run out of - places to fetch keys from. - - Attributes: - server_name: The name of the server that owns the keys. - minimum_valid_until_ts: The timestamp which the keys must be valid until. - key_ids: The IDs of the keys to attempt to fetch - """ - - server_name: str - minimum_valid_until_ts: int - key_ids: List[str] - - class Keyring: """Handles verifying signed JSON objects and fetching the keys needed to do so. diff --git a/synapse/crypto/types.py b/synapse/crypto/types.py new file mode 100644 index 0000000000..2342a8a125 --- /dev/null +++ b/synapse/crypto/types.py @@ -0,0 +1,35 @@ +# Copyright 2023- The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from typing import List + +import attr + + +@attr.s(slots=True, frozen=True, auto_attribs=True) +class _FetchKeyRequest: + """A request for keys for a given server. + + We will continue to try and fetch until we have all the keys listed under + `key_ids` (with an appropriate `valid_until_ts` property) or we run out of + places to fetch keys from. + + Attributes: + server_name: The name of the server that owns the keys. + minimum_valid_until_ts: The timestamp which the keys must be valid until. + key_ids: The IDs of the keys to attempt to fetch + """ + + server_name: str + minimum_valid_until_ts: int + key_ids: List[str] |