Resolve review comments

pull/7289/head
Andrew Morgan 2020-04-20 16:05:44 +01:00
parent 328242364b
commit 95dd9d55b7
2 changed files with 10 additions and 9 deletions

View File

@ -1005,22 +1005,22 @@ class E2eKeysHandler(object):
# We only get "master" and "self_signing" keys from remote servers # We only get "master" and "self_signing" keys from remote servers
and key_type in ["master", "self_signing"] and key_type in ["master", "self_signing"]
): ):
key = yield self._retrieve_cross_signing_keys_for_remote_user( key, key_id, verify_key = yield self._retrieve_cross_signing_keys_for_remote_user(
user, key_type user, key_type
) )
if key is None: if key is None:
logger.debug("No %s key found for %s", key_type, user_id) logger.warning("No %s key found for %s", key_type, user_id)
raise NotFoundError("No %s key found for %s" % (key_type, user_id)) raise NotFoundError("No %s key found for %s" % (key_type, user_id))
try: try:
key_id, verify_key = get_verify_key_from_cross_signing_key(key) key_id, verify_key = get_verify_key_from_cross_signing_key(key)
except ValueError as e: except ValueError as e:
logger.debug( logger.warning(
"Invalid %s key retrieved: %s - %s %s", key_type, key, type(e), e, "Invalid %s key retrieved: %s - %s %s", key_type, key, type(e), e,
) )
raise SynapseError( raise SynapseError(
502, "Invalid %s key retrieved from remote server", key_type 502, "Invalid %s key retrieved from remote server" % (key_type,)
) )
return key, key_id, verify_key return key, key_id, verify_key
@ -1028,7 +1028,7 @@ class E2eKeysHandler(object):
@defer.inlineCallbacks @defer.inlineCallbacks
def _retrieve_cross_signing_keys_for_remote_user( def _retrieve_cross_signing_keys_for_remote_user(
self, user: UserID, desired_key_type: str, self, user: UserID, desired_key_type: str,
) -> Tuple[Optional[Dict], Optional[str], Optional[VerifyKey]]: ):
"""Queries cross-signing keys for a remote user and saves them to the database """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 Only the key specified by `key_type` will be returned, while all retrieved keys
@ -1039,7 +1039,8 @@ class E2eKeysHandler(object):
desired_key_type: The type of key to receive. One of "master", "self_signing" desired_key_type: The type of key to receive. One of "master", "self_signing"
Returns: Returns:
A tuple of the retrieved key content, the key's ID and the matching VerifyKey. Deferred[Tuple[Optional[Dict], Optional[str], Optional[VerifyKey]]]: A tuple
of the retrieved key content, the key's ID and the matching VerifyKey.
If the key cannot be retrieved, all values in the tuple will instead be None. If the key cannot be retrieved, all values in the tuple will instead be None.
""" """
try: try:
@ -1054,7 +1055,7 @@ class E2eKeysHandler(object):
type(e), type(e),
e, e,
) )
return None return None, None, None
# Process each of the retrieved cross-signing keys # Process each of the retrieved cross-signing keys
final_key = None final_key = None
@ -1079,7 +1080,7 @@ class E2eKeysHandler(object):
# algorithm and colon, which is the device ID # algorithm and colon, which is the device ID
key_id, verify_key = get_verify_key_from_cross_signing_key(key_content) key_id, verify_key = get_verify_key_from_cross_signing_key(key_content)
except ValueError as e: except ValueError as e:
logger.debug( logger.warning(
"Invalid %s key retrieved: %s - %s %s", "Invalid %s key retrieved: %s - %s %s",
key_type, key_type,
key_content, key_content,