This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
synapse/storage/data_stores/main Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change
1
+ Fix bug which lead to exceptions being thrown in a loop when a cross-signed device is deleted.
Original file line number Diff line number Diff line change @@ -145,13 +145,28 @@ def _get_e2e_device_keys_txn(
145
145
txn .execute (signature_sql , signature_query_params )
146
146
rows = self .cursor_to_dict (txn )
147
147
148
+ # add each cross-signing signature to the correct device in the result dict.
148
149
for row in rows :
150
+ signing_user_id = row ["user_id" ]
151
+ signing_key_id = row ["key_id" ]
149
152
target_user_id = row ["target_user_id" ]
150
153
target_device_id = row ["target_device_id" ]
151
- if target_user_id in result and target_device_id in result [target_user_id ]:
152
- result [target_user_id ][target_device_id ].setdefault (
153
- "signatures" , {}
154
- ).setdefault (row ["user_id" ], {})[row ["key_id" ]] = row ["signature" ]
154
+ signature = row ["signature" ]
155
+
156
+ target_user_result = result .get (target_user_id )
157
+ if not target_user_result :
158
+ continue
159
+
160
+ target_device_result = target_user_result .get (target_device_id )
161
+ if not target_device_result :
162
+ # note that target_device_result will be None for deleted devices.
163
+ continue
164
+
165
+ target_device_signatures = target_device_result .setdefault ("signatures" , {})
166
+ signing_user_signatures = target_device_signatures .setdefault (
167
+ signing_user_id , {}
168
+ )
169
+ signing_user_signatures [signing_key_id ] = signature
155
170
156
171
log_kv (result )
157
172
return result
You can’t perform that action at this time.
0 commit comments