From ba5e36c6f5ebd2f6453a6236de8d48055a88435d Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 1 Sep 2020 12:53:03 +0100 Subject: [PATCH 1/2] Rename `_get_e2e_device_keys_txn` ... to `_get_e2e_device_keys_and_signatures_txn`, to better reflect what it does. --- changelog.d/8223.misc | 1 + synapse/storage/databases/main/devices.py | 4 ++-- synapse/storage/databases/main/end_to_end_keys.py | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 changelog.d/8223.misc diff --git a/changelog.d/8223.misc b/changelog.d/8223.misc new file mode 100644 index 000000000000..979c8b227bbc --- /dev/null +++ b/changelog.d/8223.misc @@ -0,0 +1 @@ +Refactor queries for device keys and cross-signatures. diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py index e8379c73c460..8db2f9f7feda 100644 --- a/synapse/storage/databases/main/devices.py +++ b/synapse/storage/databases/main/devices.py @@ -256,8 +256,8 @@ async def _get_device_update_edus_by_remote( """ devices = ( await self.db_pool.runInteraction( - "_get_e2e_device_keys_txn", - self._get_e2e_device_keys_txn, + "get_e2e_device_keys_and_signatures_txn", + self._get_e2e_device_keys_and_signatures_txn, query_map.keys(), include_all_devices=True, include_deleted_devices=True, diff --git a/synapse/storage/databases/main/end_to_end_keys.py b/synapse/storage/databases/main/end_to_end_keys.py index fb3b1f94de92..1ee062e3c499 100644 --- a/synapse/storage/databases/main/end_to_end_keys.py +++ b/synapse/storage/databases/main/end_to_end_keys.py @@ -51,7 +51,7 @@ def _get_e2e_device_keys_for_federation_query_txn( ) -> Tuple[int, List[JsonDict]]: now_stream_id = self.get_device_stream_token() - devices = self._get_e2e_device_keys_txn(txn, [(user_id, None)]) + devices = self._get_e2e_device_keys_and_signatures_txn(txn, [(user_id, None)]) if devices: user_devices = devices[user_id] @@ -96,7 +96,9 @@ async def get_e2e_device_keys_for_cs_api( return {} results = await self.db_pool.runInteraction( - "get_e2e_device_keys", self._get_e2e_device_keys_txn, query_list, + "get_e2e_device_keys_and_signatures_txn", + self._get_e2e_device_keys_and_signatures_txn, + query_list, ) # Build the result structure, un-jsonify the results, and add the @@ -120,9 +122,9 @@ async def get_e2e_device_keys_for_cs_api( return rv @trace - def _get_e2e_device_keys_txn( + def _get_e2e_device_keys_and_signatures_txn( self, txn, query_list, include_all_devices=False, include_deleted_devices=False - ): + ) -> Dict[str, Dict[str, Optional[Dict]]]: set_tag("include_all_devices", include_all_devices) set_tag("include_deleted_devices", include_deleted_devices) From 1c5fa5d9413c523555d0be1cbb37375f487cdbae Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 1 Sep 2020 14:59:08 +0100 Subject: [PATCH 2/2] fix changelog name --- changelog.d/{8223.misc => 8222.misc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{8223.misc => 8222.misc} (100%) diff --git a/changelog.d/8223.misc b/changelog.d/8222.misc similarity index 100% rename from changelog.d/8223.misc rename to changelog.d/8222.misc