Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
run black
Browse files Browse the repository at this point in the history
  • Loading branch information
uhoreg committed Sep 6, 2019
1 parent 561cbba commit 415d0a0
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions synapse/handlers/e2e_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,17 +686,13 @@ def _process_self_signatures(self, user_id, signatures):
devices = devices[user_id]
except SynapseError as e:
failures[user_id] = {
device: _exception_to_failure(e)
for device in signatures.keys()
device: _exception_to_failure(e) for device in signatures.keys()
}
return signature_list, failures

for device_id, device in signatures.items():
try:
if (
"signatures" not in device
or user_id not in device["signatures"]
):
if "signatures" not in device or user_id not in device["signatures"]:
# no signature was sent
raise SynapseError(
400, "Invalid signature", Codes.INVALID_SIGNATURE
Expand Down Expand Up @@ -725,9 +721,7 @@ def _process_self_signatures(self, user_id, signatures):
# signed by an unknown device, or the
# device does not have the key
raise SynapseError(
400,
"Invalid signature",
Codes.INVALID_SIGNATURE,
400, "Invalid signature", Codes.INVALID_SIGNATURE
)

# get the key and check the signature
Expand Down Expand Up @@ -760,9 +754,9 @@ def _process_self_signatures(self, user_id, signatures):
stored_device = devices[device_id]["keys"]
except KeyError:
raise SynapseError(404, "Unknown device", Codes.NOT_FOUND)
if self_signing_key_id in stored_device.get(
"signatures", {}
).get(user_id, {}):
if self_signing_key_id in stored_device.get("signatures", {}).get(
user_id, {}
):
# we already have a signature on this device, so we
# can skip it, since it should be exactly the same
continue
Expand All @@ -776,9 +770,7 @@ def _process_self_signatures(self, user_id, signatures):
(self_signing_key_id, user_id, device_id, signature)
)
except SynapseError as e:
failures.setdefault(user_id, {})[
device_id
] = _exception_to_failure(e)
failures.setdefault(user_id, {})[device_id] = _exception_to_failure(e)

return signature_list, failures

Expand All @@ -799,9 +791,7 @@ def _process_other_signatures(self, user_id, signatures):
except SynapseError as e:
failure = _exception_to_failure(e)
for user, devicemap in signatures.items():
failures[user] = {
device_id: failure for device_id in devicemap.keys()
}
failures[user] = {device_id: failure for device_id in devicemap.keys()}
return signature_list, failures

for user, devicemap in signatures.items():
Expand Down Expand Up @@ -833,9 +823,7 @@ def _process_other_signatures(self, user_id, signatures):
failure = _exception_to_failure(
SynapseError(404, "Unknown device", Codes.NOT_FOUND)
)
failures[user] = {
device: failure for device in other_devices
}
failures[user] = {device: failure for device in other_devices}

if user_signing_key_id in stored_key.get("signatures", {}).get(
user_id, {}
Expand All @@ -848,9 +836,7 @@ def _process_other_signatures(self, user_id, signatures):
)

signature = key["signatures"][user_id][user_signing_key_id]
signature_list.append(
(user_signing_key_id, user, device_id, signature)
)
signature_list.append((user_signing_key_id, user, device_id, signature))
except SynapseError as e:
failure = _exception_to_failure(e)
if device_id is None:
Expand Down

0 comments on commit 415d0a0

Please sign in to comment.