summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-01-30 17:11:24 +0000
committerErik Johnston <erik@matrix.org>2017-01-30 17:11:24 +0000
commitc7a26b7c3243c3187a8d12060cb2d2a02d318260 (patch)
treeb60df0912b0ae6e71f48f897d77aab7683223e2d /synapse
parentNoop device key changes if they're the same (diff)
downloadsynapse-c7a26b7c3243c3187a8d12060cb2d2a02d318260.tar.xz
Fix unit tests
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/e2e_keys.py2
-rw-r--r--synapse/storage/end_to_end_keys.py12
2 files changed, 11 insertions, 3 deletions
diff --git a/synapse/handlers/e2e_keys.py b/synapse/handlers/e2e_keys.py
index 49b277a1af..e40495d1ab 100644
--- a/synapse/handlers/e2e_keys.py
+++ b/synapse/handlers/e2e_keys.py
@@ -194,7 +194,7 @@ class E2eKeysHandler(object):
         # "unsigned" section
         for user_id, device_keys in results.items():
             for device_id, device_info in device_keys.items():
-                r = json.loads(device_info["key_json"])
+                r = dict(device_info["keys"])
                 r["unsigned"] = {}
                 display_name = device_info["device_display_name"]
                 if display_name is not None:
diff --git a/synapse/storage/end_to_end_keys.py b/synapse/storage/end_to_end_keys.py
index aa54d7637c..2040e022fa 100644
--- a/synapse/storage/end_to_end_keys.py
+++ b/synapse/storage/end_to_end_keys.py
@@ -15,6 +15,7 @@
 from twisted.internet import defer
 
 from canonicaljson import encode_canonical_json
+import ujson as json
 
 from ._base import SQLBaseStore
 
@@ -59,6 +60,7 @@ class EndToEndKeyStore(SQLBaseStore):
             "set_e2e_device_keys", _set_e2e_device_keys_txn
         )
 
+    @defer.inlineCallbacks
     def get_e2e_device_keys(self, query_list, include_all_devices=False):
         """Fetch a list of device keys.
         Args:
@@ -70,13 +72,19 @@ class EndToEndKeyStore(SQLBaseStore):
             dict containing "key_json", "device_display_name".
         """
         if not query_list:
-            return {}
+            defer.returnValue({})
 
-        return self.runInteraction(
+        results = yield self.runInteraction(
             "get_e2e_device_keys", self._get_e2e_device_keys_txn,
             query_list, include_all_devices,
         )
 
+        for user_id, device_keys in results.iteritems():
+            for device_id, device_info in device_keys.iteritems():
+                device_info["keys"] = json.loads(device_info.pop("key_json"))
+
+        defer.returnValue(results)
+
     def _get_e2e_device_keys_txn(self, txn, query_list, include_all_devices):
         query_clauses = []
         query_params = []