mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
run black
This commit is contained in:
parent
561cbba057
commit
415d0a00e0
@ -686,17 +686,13 @@ class E2eKeysHandler(object):
|
|||||||
devices = devices[user_id]
|
devices = devices[user_id]
|
||||||
except SynapseError as e:
|
except SynapseError as e:
|
||||||
failures[user_id] = {
|
failures[user_id] = {
|
||||||
device: _exception_to_failure(e)
|
device: _exception_to_failure(e) for device in signatures.keys()
|
||||||
for device in signatures.keys()
|
|
||||||
}
|
}
|
||||||
return signature_list, failures
|
return signature_list, failures
|
||||||
|
|
||||||
for device_id, device in signatures.items():
|
for device_id, device in signatures.items():
|
||||||
try:
|
try:
|
||||||
if (
|
if "signatures" not in device or user_id not in device["signatures"]:
|
||||||
"signatures" not in device
|
|
||||||
or user_id not in device["signatures"]
|
|
||||||
):
|
|
||||||
# no signature was sent
|
# no signature was sent
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400, "Invalid signature", Codes.INVALID_SIGNATURE
|
400, "Invalid signature", Codes.INVALID_SIGNATURE
|
||||||
@ -725,9 +721,7 @@ class E2eKeysHandler(object):
|
|||||||
# signed by an unknown device, or the
|
# signed by an unknown device, or the
|
||||||
# device does not have the key
|
# device does not have the key
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400,
|
400, "Invalid signature", Codes.INVALID_SIGNATURE
|
||||||
"Invalid signature",
|
|
||||||
Codes.INVALID_SIGNATURE,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# get the key and check the signature
|
# get the key and check the signature
|
||||||
@ -760,9 +754,9 @@ class E2eKeysHandler(object):
|
|||||||
stored_device = devices[device_id]["keys"]
|
stored_device = devices[device_id]["keys"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise SynapseError(404, "Unknown device", Codes.NOT_FOUND)
|
raise SynapseError(404, "Unknown device", Codes.NOT_FOUND)
|
||||||
if self_signing_key_id in stored_device.get(
|
if self_signing_key_id in stored_device.get("signatures", {}).get(
|
||||||
"signatures", {}
|
user_id, {}
|
||||||
).get(user_id, {}):
|
):
|
||||||
# we already have a signature on this device, so we
|
# we already have a signature on this device, so we
|
||||||
# can skip it, since it should be exactly the same
|
# can skip it, since it should be exactly the same
|
||||||
continue
|
continue
|
||||||
@ -776,9 +770,7 @@ class E2eKeysHandler(object):
|
|||||||
(self_signing_key_id, user_id, device_id, signature)
|
(self_signing_key_id, user_id, device_id, signature)
|
||||||
)
|
)
|
||||||
except SynapseError as e:
|
except SynapseError as e:
|
||||||
failures.setdefault(user_id, {})[
|
failures.setdefault(user_id, {})[device_id] = _exception_to_failure(e)
|
||||||
device_id
|
|
||||||
] = _exception_to_failure(e)
|
|
||||||
|
|
||||||
return signature_list, failures
|
return signature_list, failures
|
||||||
|
|
||||||
@ -799,9 +791,7 @@ class E2eKeysHandler(object):
|
|||||||
except SynapseError as e:
|
except SynapseError as e:
|
||||||
failure = _exception_to_failure(e)
|
failure = _exception_to_failure(e)
|
||||||
for user, devicemap in signatures.items():
|
for user, devicemap in signatures.items():
|
||||||
failures[user] = {
|
failures[user] = {device_id: failure for device_id in devicemap.keys()}
|
||||||
device_id: failure for device_id in devicemap.keys()
|
|
||||||
}
|
|
||||||
return signature_list, failures
|
return signature_list, failures
|
||||||
|
|
||||||
for user, devicemap in signatures.items():
|
for user, devicemap in signatures.items():
|
||||||
@ -833,9 +823,7 @@ class E2eKeysHandler(object):
|
|||||||
failure = _exception_to_failure(
|
failure = _exception_to_failure(
|
||||||
SynapseError(404, "Unknown device", Codes.NOT_FOUND)
|
SynapseError(404, "Unknown device", Codes.NOT_FOUND)
|
||||||
)
|
)
|
||||||
failures[user] = {
|
failures[user] = {device: failure for device in other_devices}
|
||||||
device: failure for device in other_devices
|
|
||||||
}
|
|
||||||
|
|
||||||
if user_signing_key_id in stored_key.get("signatures", {}).get(
|
if user_signing_key_id in stored_key.get("signatures", {}).get(
|
||||||
user_id, {}
|
user_id, {}
|
||||||
@ -848,9 +836,7 @@ class E2eKeysHandler(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
signature = key["signatures"][user_id][user_signing_key_id]
|
signature = key["signatures"][user_id][user_signing_key_id]
|
||||||
signature_list.append(
|
signature_list.append((user_signing_key_id, user, device_id, signature))
|
||||||
(user_signing_key_id, user, device_id, signature)
|
|
||||||
)
|
|
||||||
except SynapseError as e:
|
except SynapseError as e:
|
||||||
failure = _exception_to_failure(e)
|
failure = _exception_to_failure(e)
|
||||||
if device_id is None:
|
if device_id is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user