Fix log statements, docstrings

pull/7289/head
Andrew Morgan 2020-04-17 11:33:43 +01:00
parent 37ae6430f2
commit 83861c3a25
1 changed files with 22 additions and 13 deletions

View File

@ -962,16 +962,18 @@ class E2eKeysHandler(object):
@defer.inlineCallbacks @defer.inlineCallbacks
def _get_e2e_cross_signing_verify_key( def _get_e2e_cross_signing_verify_key(
self, user_id, desired_key_type, from_user_id=None self, user_id: str, desired_key_type: str, from_user_id:str = None
): ):
"""Fetch the cross-signing public key from storage and interpret it. """Fetch or request the given cross-signing public key.
If we cannot find the public key locally, we query the keys from the
homeserver they belong to, then update our local copy. First, attempt to fetch the cross-signing public key from storage.
If that fails, query the keys from the homeserver they belong to
and update our local copy.
Args: Args:
user_id (str): the user whose key should be fetched user_id: the user whose key should be fetched
desired_key_type (str): the type of key to fetch desired_key_type: the type of key to fetch
from_user_id (str): the user that we are fetching the keys for. from_user_id: the user that we are fetching the keys for.
This affects what signatures are fetched. This affects what signatures are fetched.
Returns: Returns:
@ -1022,21 +1024,28 @@ class E2eKeysHandler(object):
) )
except Exception as e: except Exception as e:
logger.warning( logger.warning(
"Unable to query %s for cross-signing keys of user %s: %s", "Unable to query %s for cross-signing keys of user %s: %s %s",
user.domain, user.domain,
user_id, user_id,
type(e),
e, e,
) )
if key is None: if key is None:
logger.debug("No %s key found for %s", key_type, user_id) logger.debug("No %s key found for %s", desired_key_type, user_id)
raise NotFoundError("No %s key found for %s" % (key_type, user_id)) raise NotFoundError("No %s key found for %s" % (desired_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)
return key, key_id, verify_key except ValueError as e:
except ValueError: logger.debug(
raise SynapseError(502, "Invalid %s key retrieved from remote server") "Invalid %s key retrieved: %s - %s %s", desired_key_type, key, type(e), e
)
raise SynapseError(
502, "Invalid %s key retrieved from remote server", desired_key_type
)
return key, key_id, verify_key
def _check_cross_signing_key(key, user_id, key_type, signing_key=None): def _check_cross_signing_key(key, user_id, key_type, signing_key=None):