summary refs log tree commit diff
path: root/synapse/handlers/e2e_keys.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-04-17 11:36:08 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2020-04-17 11:36:08 +0100
commit2c881bf8a4d33b1e3da08e2690d5f12be1abee2d (patch)
tree0c0f95e310a4d9e8c50695c5082f37416b6b8981 /synapse/handlers/e2e_keys.py
parentFix log statements, docstrings (diff)
downloadsynapse-2c881bf8a4d33b1e3da08e2690d5f12be1abee2d.tar.xz
Remove extraneous items from remote query try/except
Diffstat (limited to '')
-rw-r--r--synapse/handlers/e2e_keys.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/synapse/handlers/e2e_keys.py b/synapse/handlers/e2e_keys.py
index 6094c6e259..863898cdf4 100644
--- a/synapse/handlers/e2e_keys.py
+++ b/synapse/handlers/e2e_keys.py
@@ -989,6 +989,7 @@ class E2eKeysHandler(object):
             user_id, desired_key_type, from_user_id
         )
 
+
         # If we still can't find the key, and we're looking for keys of another user,
         # then attempt to fetch the missing key from the remote user's server.
         #
@@ -996,19 +997,30 @@ class E2eKeysHandler(object):
         # cross-sign a remote user, but does not share any rooms with them yet.
         # Thus, we would not have their key list yet. We fetch the key here and
         # store it just in case.
+        supported_remote_key_types = ["master", "self_signing"]
         if (
             key is None
             and not self.is_mine(user)
             # We only get "master" and "self_signing" keys from remote servers
-            and desired_key_type in ["master", "self_signing"]
+            and desired_key_type in supported_remote_key_types
         ):
+            remote_result = None
             try:
                 remote_result = yield self.federation.query_user_devices(
                     user.domain, user_id
                 )
+            except Exception as e:
+                logger.warning(
+                    "Unable to query %s for cross-signing keys of user %s: %s %s",
+                    user.domain,
+                    user_id,
+                    type(e),
+                    e,
+                )
 
+            if remote_result is not None:
                 # Process each of the retrieved cross-signing keys
-                for key_type in ["master", "self_signing"]:
+                for key_type in supported_remote_key_types:
                     key_content = remote_result.get(key_type + "_key")
                     if not key_content:
                         continue
@@ -1022,14 +1034,6 @@ class E2eKeysHandler(object):
                     yield self.store.set_e2e_cross_signing_key(
                         user_id, key_type, key_content
                     )
-            except Exception as e:
-                logger.warning(
-                    "Unable to query %s for cross-signing keys of user %s: %s %s",
-                    user.domain,
-                    user_id,
-                    type(e),
-                    e,
-                )
 
         if key is None:
             logger.debug("No %s key found for %s", desired_key_type, user_id)