diff options
author | Erik Johnston <erik@matrix.org> | 2017-02-02 13:07:52 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-02-02 13:07:52 +0000 |
commit | 85f28744e8ea9eaf828f89328360c3c03803aceb (patch) | |
tree | f18957ca943320f35ac2fd09a1b1116d96547910 | |
parent | Make presence.get_new_events a bit faster (diff) | |
download | synapse-erikj/device_list_changes_perf.tar.xz |
Fix /keys/changes TypeError github/erikj/device_list_changes_perf erikj/device_list_changes_perf
We also use the new cache of users who share rooms with cache.
-rw-r--r-- | synapse/handlers/device.py | 13 | ||||
-rw-r--r-- | synapse/rest/client/v2_alpha/keys.py | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py index 815410969c..af28e1e009 100644 --- a/synapse/handlers/device.py +++ b/synapse/handlers/device.py @@ -266,13 +266,14 @@ class DeviceHandler(BaseHandler): if not prev_event_id or prev_event_id != event_id: possibly_changed.add(state_key) - user_ids_changed = set() - for other_user_id in possibly_changed: - other_rooms = yield self.store.get_rooms_for_user(other_user_id) - if room_ids.intersection(e.room_id for e in other_rooms): - user_ids_changed.add(other_user_id) + users_who_share_room = yield self.store.get_users_who_share_room_with_user( + user_id + ) - defer.returnValue(user_ids_changed) + # We return the intersection of users whose devices have changed (or + # membership has changeD) and the users who share a room with the + # requester + defer.returnValue(users_who_share_room & users_who_share_room) @defer.inlineCallbacks def _incoming_device_list_update(self, origin, edu_content): diff --git a/synapse/rest/client/v2_alpha/keys.py b/synapse/rest/client/v2_alpha/keys.py index f99b53530a..e3f3ea86b7 100644 --- a/synapse/rest/client/v2_alpha/keys.py +++ b/synapse/rest/client/v2_alpha/keys.py @@ -193,7 +193,7 @@ class KeyChangesServlet(RestServlet): ) defer.returnValue((200, { - "changed": changed + "changed": list(changed) })) |