Run Black. (#5482)

This commit is contained in:
Amber Brown 2019-06-20 19:32:02 +10:00 committed by GitHub
parent 7dcf984075
commit 32e7c9e7f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
376 changed files with 9142 additions and 10388 deletions

View file

@ -65,6 +65,7 @@ UPDATE_ATTESTATION_TIME_MS = 1 * 24 * 60 * 60 * 1000
class GroupAttestationSigning(object):
"""Creates and verifies group attestations.
"""
def __init__(self, hs):
self.keyring = hs.get_keyring()
self.clock = hs.get_clock()
@ -113,11 +114,15 @@ class GroupAttestationSigning(object):
validity_period *= random.uniform(*DEFAULT_ATTESTATION_JITTER)
valid_until_ms = int(self.clock.time_msec() + validity_period)
return sign_json({
"group_id": group_id,
"user_id": user_id,
"valid_until_ms": valid_until_ms,
}, self.server_name, self.signing_key)
return sign_json(
{
"group_id": group_id,
"user_id": user_id,
"valid_until_ms": valid_until_ms,
},
self.server_name,
self.signing_key,
)
class GroupAttestionRenewer(object):
@ -134,7 +139,7 @@ class GroupAttestionRenewer(object):
if not hs.config.worker_app:
self._renew_attestations_loop = self.clock.looping_call(
self._start_renew_attestations, 30 * 60 * 1000,
self._start_renew_attestations, 30 * 60 * 1000
)
@defer.inlineCallbacks
@ -147,9 +152,7 @@ class GroupAttestionRenewer(object):
raise SynapseError(400, "Neither user not group are on this server")
yield self.attestations.verify_attestation(
attestation,
user_id=user_id,
group_id=group_id,
attestation, user_id=user_id, group_id=group_id
)
yield self.store.update_remote_attestion(group_id, user_id, attestation)
@ -180,7 +183,8 @@ class GroupAttestionRenewer(object):
else:
logger.warn(
"Incorrectly trying to do attestations for user: %r in %r",
user_id, group_id,
user_id,
group_id,
)
yield self.store.remove_attestation_renewal(group_id, user_id)
return
@ -188,8 +192,7 @@ class GroupAttestionRenewer(object):
attestation = self.attestations.create_attestation(group_id, user_id)
yield self.transport_client.renew_group_attestation(
destination, group_id, user_id,
content={"attestation": attestation},
destination, group_id, user_id, content={"attestation": attestation}
)
yield self.store.update_attestation_renewal(
@ -197,12 +200,12 @@ class GroupAttestionRenewer(object):
)
except (RequestSendFailed, HttpResponseException) as e:
logger.warning(
"Failed to renew attestation of %r in %r: %s",
user_id, group_id, e,
"Failed to renew attestation of %r in %r: %s", user_id, group_id, e
)
except Exception:
logger.exception("Error renewing attestation of %r in %r",
user_id, group_id)
logger.exception(
"Error renewing attestation of %r in %r", user_id, group_id
)
for row in rows:
group_id = row["group_id"]