mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-06 04:54:15 -04:00
Another batch of type annotations (#12726)
This commit is contained in:
parent
39bed28b28
commit
aec69d2481
11 changed files with 144 additions and 79 deletions
|
@ -15,7 +15,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Tuple
|
||||
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple
|
||||
|
||||
import attr
|
||||
from canonicaljson import encode_canonical_json
|
||||
|
@ -1105,22 +1105,19 @@ class E2eKeysHandler:
|
|||
# can request over federation
|
||||
raise NotFoundError("No %s key found for %s" % (key_type, user_id))
|
||||
|
||||
(
|
||||
key,
|
||||
key_id,
|
||||
verify_key,
|
||||
) = await self._retrieve_cross_signing_keys_for_remote_user(user, key_type)
|
||||
|
||||
if key is None:
|
||||
cross_signing_keys = await self._retrieve_cross_signing_keys_for_remote_user(
|
||||
user, key_type
|
||||
)
|
||||
if cross_signing_keys is None:
|
||||
raise NotFoundError("No %s key found for %s" % (key_type, user_id))
|
||||
|
||||
return key, key_id, verify_key
|
||||
return cross_signing_keys
|
||||
|
||||
async def _retrieve_cross_signing_keys_for_remote_user(
|
||||
self,
|
||||
user: UserID,
|
||||
desired_key_type: str,
|
||||
) -> Tuple[Optional[dict], Optional[str], Optional[VerifyKey]]:
|
||||
) -> Optional[Tuple[Dict[str, Any], str, VerifyKey]]:
|
||||
"""Queries cross-signing keys for a remote user and saves them to the database
|
||||
|
||||
Only the key specified by `key_type` will be returned, while all retrieved keys
|
||||
|
@ -1146,12 +1143,10 @@ class E2eKeysHandler:
|
|||
type(e),
|
||||
e,
|
||||
)
|
||||
return None, None, None
|
||||
return None
|
||||
|
||||
# Process each of the retrieved cross-signing keys
|
||||
desired_key = None
|
||||
desired_key_id = None
|
||||
desired_verify_key = None
|
||||
desired_key_data = None
|
||||
retrieved_device_ids = []
|
||||
for key_type in ["master", "self_signing"]:
|
||||
key_content = remote_result.get(key_type + "_key")
|
||||
|
@ -1196,9 +1191,7 @@ class E2eKeysHandler:
|
|||
|
||||
# If this is the desired key type, save it and its ID/VerifyKey
|
||||
if key_type == desired_key_type:
|
||||
desired_key = key_content
|
||||
desired_verify_key = verify_key
|
||||
desired_key_id = key_id
|
||||
desired_key_data = key_content, key_id, verify_key
|
||||
|
||||
# At the same time, store this key in the db for subsequent queries
|
||||
await self.store.set_e2e_cross_signing_key(
|
||||
|
@ -1212,7 +1205,7 @@ class E2eKeysHandler:
|
|||
user.to_string(), retrieved_device_ids
|
||||
)
|
||||
|
||||
return desired_key, desired_key_id, desired_verify_key
|
||||
return desired_key_data
|
||||
|
||||
|
||||
def _check_cross_signing_key(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue