mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 04:43:51 +01:00
make black happy
This commit is contained in:
parent
a1aaf3eea6
commit
cfdb84422d
2 changed files with 39 additions and 27 deletions
|
@ -56,7 +56,7 @@ class E2eKeysHandler(object):
|
||||||
federation_registry = hs.get_federation_registry()
|
federation_registry = hs.get_federation_registry()
|
||||||
|
|
||||||
federation_registry.register_edu_handler(
|
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
|
# doesn't really work as part of the generic query API, because the
|
||||||
# query request requires an object POST, but we abuse 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(
|
yield self.store.set_e2e_cross_signing_key(
|
||||||
user_id, "master", master_key
|
user_id, "master", master_key
|
||||||
)
|
)
|
||||||
device_id = \
|
device_id = get_verify_key_from_cross_signing_key(master_key)[
|
||||||
get_verify_key_from_cross_signing_key(master_key)[1].version
|
1
|
||||||
|
].version
|
||||||
device_ids.append(device_id)
|
device_ids.append(device_id)
|
||||||
if self_signing_key:
|
if self_signing_key:
|
||||||
yield self.store.set_e2e_cross_signing_key(
|
yield self.store.set_e2e_cross_signing_key(
|
||||||
user_id, "self_signing", self_signing_key
|
user_id, "self_signing", self_signing_key
|
||||||
)
|
)
|
||||||
device_id = \
|
device_id = get_verify_key_from_cross_signing_key(self_signing_key)[
|
||||||
get_verify_key_from_cross_signing_key(self_signing_key)[1].version
|
1
|
||||||
|
].version
|
||||||
device_ids.append(device_id)
|
device_ids.append(device_id)
|
||||||
|
|
||||||
yield device_handler.notify_device_update(user_id, device_ids)
|
yield device_handler.notify_device_update(user_id, device_ids)
|
||||||
|
|
|
@ -37,6 +37,7 @@ from synapse.storage._base import (
|
||||||
make_in_list_sql_clause,
|
make_in_list_sql_clause,
|
||||||
)
|
)
|
||||||
from synapse.storage.background_updates import BackgroundUpdateStore
|
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 import batch_iter
|
||||||
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks, cachedList
|
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks, cachedList
|
||||||
|
|
||||||
|
@ -142,17 +143,19 @@ class DeviceWorkerStore(SQLBaseStore):
|
||||||
)
|
)
|
||||||
master_key_by_user[user] = {
|
master_key_by_user[user] = {
|
||||||
"key_info": cross_signing_key,
|
"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:
|
if cross_signing_key:
|
||||||
key_id, verify_key = get_verify_key_from_cross_signing_key(
|
key_id, verify_key = get_verify_key_from_cross_signing_key(
|
||||||
cross_signing_key
|
cross_signing_key
|
||||||
)
|
)
|
||||||
self_signing_key_by_user[user] = {
|
self_signing_key_by_user[user] = {
|
||||||
"key_info": cross_signing_key,
|
"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
|
# if we have exceeded the limit, we need to exclude any results with the
|
||||||
|
@ -185,10 +188,13 @@ class DeviceWorkerStore(SQLBaseStore):
|
||||||
break
|
break
|
||||||
|
|
||||||
# skip over cross-signing keys
|
# skip over cross-signing keys
|
||||||
if (update[0] in master_key_by_user
|
if (
|
||||||
and update[1] == master_key_by_user[update[0]]["pubkey"]) \
|
update[0] in master_key_by_user
|
||||||
or (update[0] in master_key_by_user
|
and update[1] == master_key_by_user[update[0]]["pubkey"]
|
||||||
and update[1] == self_signing_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
|
continue
|
||||||
|
|
||||||
key = (update[0], update[1])
|
key = (update[0], update[1])
|
||||||
|
@ -209,16 +215,16 @@ class DeviceWorkerStore(SQLBaseStore):
|
||||||
# update list with the master/self-signing key by user maps
|
# update list with the master/self-signing key by user maps
|
||||||
cross_signing_keys_by_user = {}
|
cross_signing_keys_by_user = {}
|
||||||
for user_id, device_id, stream in updates:
|
for user_id, device_id, stream in updates:
|
||||||
if device_id == master_key_by_user.get(user_id, {}) \
|
if device_id == master_key_by_user.get(user_id, {}).get("pubkey", None):
|
||||||
.get("pubkey", None):
|
|
||||||
result = cross_signing_keys_by_user.setdefault(user_id, {})
|
result = cross_signing_keys_by_user.setdefault(user_id, {})
|
||||||
result["master_key"] = \
|
result["master_key"] = master_key_by_user[user_id]["key_info"]
|
||||||
master_key_by_user[user_id]["key_info"]
|
elif device_id == self_signing_key_by_user.get(user_id, {}).get(
|
||||||
elif device_id == self_signing_key_by_user.get(user_id, {}) \
|
"pubkey", None
|
||||||
.get("pubkey", None):
|
):
|
||||||
result = cross_signing_keys_by_user.setdefault(user_id, {})
|
result = cross_signing_keys_by_user.setdefault(user_id, {})
|
||||||
result["self_signing_key"] = \
|
result["self_signing_key"] = self_signing_key_by_user[user_id][
|
||||||
self_signing_key_by_user[user_id]["key_info"]
|
"key_info"
|
||||||
|
]
|
||||||
|
|
||||||
cross_signing_results = []
|
cross_signing_results = []
|
||||||
|
|
||||||
|
@ -282,13 +288,17 @@ class DeviceWorkerStore(SQLBaseStore):
|
||||||
List[Dict]: List of objects representing an device update EDU
|
List[Dict]: List of objects representing an device update EDU
|
||||||
|
|
||||||
"""
|
"""
|
||||||
devices = yield self.runInteraction(
|
devices = (
|
||||||
|
yield self.runInteraction(
|
||||||
"_get_e2e_device_keys_txn",
|
"_get_e2e_device_keys_txn",
|
||||||
self._get_e2e_device_keys_txn,
|
self._get_e2e_device_keys_txn,
|
||||||
query_map.keys(),
|
query_map.keys(),
|
||||||
include_all_devices=True,
|
include_all_devices=True,
|
||||||
include_deleted_devices=True,
|
include_deleted_devices=True,
|
||||||
) if query_map else {}
|
)
|
||||||
|
if query_map
|
||||||
|
else {}
|
||||||
|
)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for user_id, user_devices in iteritems(devices):
|
for user_id, user_devices in iteritems(devices):
|
||||||
|
|
Loading…
Reference in a new issue