0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 23:03:51 +01:00

make black happy

This commit is contained in:
Hubert Chathi 2019-07-22 13:04:55 -04:00
parent a1aaf3eea6
commit cfdb84422d
2 changed files with 39 additions and 27 deletions

View file

@ -56,7 +56,7 @@ class E2eKeysHandler(object):
federation_registry = hs.get_federation_registry()
federation_registry.register_edu_handler(
"m.signing_key_update", self._edu_updater.incoming_signing_key_update,
"m.signing_key_update", self._edu_updater.incoming_signing_key_update
)
# doesn't really work as part of the generic query API, because the
# query request requires an object POST, but we abuse the
@ -1147,15 +1147,17 @@ class SigningKeyEduUpdater(object):
yield self.store.set_e2e_cross_signing_key(
user_id, "master", master_key
)
device_id = \
get_verify_key_from_cross_signing_key(master_key)[1].version
device_id = get_verify_key_from_cross_signing_key(master_key)[
1
].version
device_ids.append(device_id)
if self_signing_key:
yield self.store.set_e2e_cross_signing_key(
user_id, "self_signing", self_signing_key
)
device_id = \
get_verify_key_from_cross_signing_key(self_signing_key)[1].version
device_id = get_verify_key_from_cross_signing_key(self_signing_key)[
1
].version
device_ids.append(device_id)
yield device_handler.notify_device_update(user_id, device_ids)

View file

@ -37,6 +37,7 @@ from synapse.storage._base import (
make_in_list_sql_clause,
)
from synapse.storage.background_updates import BackgroundUpdateStore
from synapse.types import get_verify_key_from_cross_signing_key
from synapse.util import batch_iter
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks, cachedList
@ -142,17 +143,19 @@ class DeviceWorkerStore(SQLBaseStore):
)
master_key_by_user[user] = {
"key_info": cross_signing_key,
"pubkey": verify_key.version
"pubkey": verify_key.version,
}
cross_signing_key = yield self.get_e2e_cross_signing_key(user, "self_signing")
cross_signing_key = yield self.get_e2e_cross_signing_key(
user, "self_signing"
)
if cross_signing_key:
key_id, verify_key = get_verify_key_from_cross_signing_key(
cross_signing_key
)
self_signing_key_by_user[user] = {
"key_info": cross_signing_key,
"pubkey": verify_key.version
"pubkey": verify_key.version,
}
# if we have exceeded the limit, we need to exclude any results with the
@ -185,10 +188,13 @@ class DeviceWorkerStore(SQLBaseStore):
break
# skip over cross-signing keys
if (update[0] in master_key_by_user
and update[1] == master_key_by_user[update[0]]["pubkey"]) \
or (update[0] in master_key_by_user
and update[1] == self_signing_key_by_user[update[0]]["pubkey"]):
if (
update[0] in master_key_by_user
and update[1] == master_key_by_user[update[0]]["pubkey"]
) or (
update[0] in master_key_by_user
and update[1] == self_signing_key_by_user[update[0]]["pubkey"]
):
continue
key = (update[0], update[1])
@ -209,16 +215,16 @@ class DeviceWorkerStore(SQLBaseStore):
# update list with the master/self-signing key by user maps
cross_signing_keys_by_user = {}
for user_id, device_id, stream in updates:
if device_id == master_key_by_user.get(user_id, {}) \
.get("pubkey", None):
if device_id == master_key_by_user.get(user_id, {}).get("pubkey", None):
result = cross_signing_keys_by_user.setdefault(user_id, {})
result["master_key"] = \
master_key_by_user[user_id]["key_info"]
elif device_id == self_signing_key_by_user.get(user_id, {}) \
.get("pubkey", None):
result["master_key"] = master_key_by_user[user_id]["key_info"]
elif device_id == self_signing_key_by_user.get(user_id, {}).get(
"pubkey", None
):
result = cross_signing_keys_by_user.setdefault(user_id, {})
result["self_signing_key"] = \
self_signing_key_by_user[user_id]["key_info"]
result["self_signing_key"] = self_signing_key_by_user[user_id][
"key_info"
]
cross_signing_results = []
@ -282,13 +288,17 @@ class DeviceWorkerStore(SQLBaseStore):
List[Dict]: List of objects representing an device update EDU
"""
devices = yield self.runInteraction(
"_get_e2e_device_keys_txn",
self._get_e2e_device_keys_txn,
query_map.keys(),
include_all_devices=True,
include_deleted_devices=True,
) if query_map else {}
devices = (
yield self.runInteraction(
"_get_e2e_device_keys_txn",
self._get_e2e_device_keys_txn,
query_map.keys(),
include_all_devices=True,
include_deleted_devices=True,
)
if query_map
else {}
)
results = []
for user_id, user_devices in iteritems(devices):