summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-02-22 13:18:06 +0000
committerErik Johnston <erik@matrix.org>2016-02-22 13:18:06 +0000
commit60bec240834eeee145c23f0402c14c3ba5f3d8ae (patch)
treea639d663d79c5af8c09453c7506525edc41f90b7
parentMerge pull request #590 from matrix-org/markjh/formatting (diff)
parentCorrectly filter states (diff)
downloadsynapse-60bec240834eeee145c23f0402c14c3ba5f3d8ae.tar.xz
Merge pull request #589 from matrix-org/erikj/presence
Only send presence updates to remote hosts if user is ours
-rw-r--r--synapse/handlers/presence.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 44bdc97ccb..aed640450f 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -428,13 +428,21 @@ class PresenceHandler(BaseHandler):
 
         hosts_to_states = {}
         for room_id, states in room_ids_to_states.items():
+            local_states = filter(lambda s: self.hs.is_mine_id(s.user_id), states)
+            if not local_states:
+                continue
+
             hosts = yield self.store.get_joined_hosts_for_room(room_id)
             for host in hosts:
-                hosts_to_states.setdefault(host, []).extend(states)
+                hosts_to_states.setdefault(host, []).extend(local_states)
 
         for user_id, states in users_to_states.items():
+            local_states = filter(lambda s: self.hs.is_mine_id(s.user_id), states)
+            if not local_states:
+                continue
+
             host = UserID.from_string(user_id).domain
-            hosts_to_states.setdefault(host, []).extend(states)
+            hosts_to_states.setdefault(host, []).extend(local_states)
 
         # TODO: de-dup hosts_to_states, as a single host might have multiple
         # of same presence