summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-04-16 13:54:59 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2020-04-16 13:54:59 +0100
commit44cf7cf56e4102ac8db5e599836ddf9106fbb571 (patch)
treebeef4520e1bdcfe42322fc8e7fe95e10002fc8b9 /synapse
parentAdd changelog (diff)
downloadsynapse-44cf7cf56e4102ac8db5e599836ddf9106fbb571.tar.xz
Save retrieved keys to the db
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/e2e_keys.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/handlers/e2e_keys.py b/synapse/handlers/e2e_keys.py
index 1111c17951..9c1fbaa9b5 100644
--- a/synapse/handlers/e2e_keys.py
+++ b/synapse/handlers/e2e_keys.py
@@ -996,6 +996,15 @@ class E2eKeysHandler(object):
                     user.domain, {"device_keys": {user_id: []}}, timeout=10 * 1000
                 )
 
+                # Save these keys to the database for subsequent queries
+                for key_type, remote_user_id in remote_result.items():
+                    if remote_user_id != user_id:
+                        continue
+                    key_contents = remote_result[key_type][remote_user_id]
+                    key_type = key_type[:-5]  # Remove the "_keys" from the key type
+
+                    yield self.store.set_e2e_cross_signing_key(user_id, key_type, key_contents)
+
                 # The key_type variable passed to this function is in the form
                 # "self_signing","master" etc. Whereas the results returned from
                 # the remote server use "self_signing_keys", "master_keys" etc.