summary refs log tree commit diff
path: root/synapse/handlers/sync.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-03-15 14:27:34 +0000
committerErik Johnston <erik@matrix.org>2017-03-15 14:27:34 +0000
commit6c82de51002575e974907ab0a7d4fc6b0123bc8f (patch)
tree7338a0d9c64ae83255404a7527bbdf90705a1a44 /synapse/handlers/sync.py
parentMerge pull request #1997 from matrix-org/dbkr/cas_partialdownload (diff)
downloadsynapse-6c82de51002575e974907ab0a7d4fc6b0123bc8f.tar.xz
Format presence events on the edges instead of reformatting them multiple times
Diffstat (limited to 'synapse/handlers/sync.py')
-rw-r--r--synapse/handlers/sync.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 5572cb883f..33b7fdfe8d 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -721,14 +721,14 @@ class SyncHandler(object):
             extra_users_ids.update(users)
         extra_users_ids.discard(user.to_string())
 
-        states = yield self.presence_handler.get_states(
-            extra_users_ids,
-            as_event=True,
-        )
-        presence.extend(states)
+        if extra_users_ids:
+            states = yield self.presence_handler.get_states(
+                extra_users_ids,
+            )
+            presence.extend(states)
 
-        # Deduplicate the presence entries so that there's at most one per user
-        presence = {p["content"]["user_id"]: p for p in presence}.values()
+            # Deduplicate the presence entries so that there's at most one per user
+            presence = {p.user_id: p for p in presence}.values()
 
         presence = sync_config.filter_collection.filter_presence(
             presence