mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-25 21:39:26 -05:00
don't crash if the user doesn't have cross-signing keys
This commit is contained in:
parent
8d3542a64e
commit
a1aaf3eea6
@ -136,18 +136,24 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||||||
self_signing_key_by_user = {}
|
self_signing_key_by_user = {}
|
||||||
for user in users:
|
for user in users:
|
||||||
cross_signing_key = yield self.get_e2e_cross_signing_key(user, "master")
|
cross_signing_key = yield self.get_e2e_cross_signing_key(user, "master")
|
||||||
key_id, verify_key = get_verify_key_from_cross_signing_key(cross_signing_key)
|
if cross_signing_key:
|
||||||
master_key_by_user[user] = {
|
key_id, verify_key = get_verify_key_from_cross_signing_key(
|
||||||
"key_info": cross_signing_key,
|
cross_signing_key
|
||||||
"pubkey": verify_key.version
|
)
|
||||||
}
|
master_key_by_user[user] = {
|
||||||
|
"key_info": cross_signing_key,
|
||||||
|
"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")
|
||||||
key_id, verify_key = get_verify_key_from_cross_signing_key(cross_signing_key)
|
if cross_signing_key:
|
||||||
self_signing_key_by_user[user] = {
|
key_id, verify_key = get_verify_key_from_cross_signing_key(
|
||||||
"key_info": cross_signing_key,
|
cross_signing_key
|
||||||
"pubkey": verify_key.version
|
)
|
||||||
}
|
self_signing_key_by_user[user] = {
|
||||||
|
"key_info": cross_signing_key,
|
||||||
|
"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
|
||||||
# same stream_id as the last row.
|
# same stream_id as the last row.
|
||||||
@ -178,8 +184,11 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||||||
# Stop processing updates
|
# Stop processing updates
|
||||||
break
|
break
|
||||||
|
|
||||||
if update[1] == master_key_by_user[update[0]]["pubkey"] or \
|
# skip over cross-signing keys
|
||||||
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
|
continue
|
||||||
|
|
||||||
key = (update[0], update[1])
|
key = (update[0], update[1])
|
||||||
@ -200,11 +209,13 @@ 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[user_id]["pubkey"]:
|
if device_id == master_key_by_user.get(user_id, {}) \
|
||||||
|
.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[user_id]["pubkey"]:
|
elif device_id == self_signing_key_by_user.get(user_id, {}) \
|
||||||
|
.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]["key_info"]
|
self_signing_key_by_user[user_id]["key_info"]
|
||||||
|
Loading…
Reference in New Issue
Block a user