summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--synapse/federation/transaction_queue.py6
-rw-r--r--synapse/handlers/presence.py21
2 files changed, 8 insertions, 19 deletions
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py
index 260a472255..feb1605019 100644
--- a/synapse/federation/transaction_queue.py
+++ b/synapse/federation/transaction_queue.py
@@ -269,13 +269,13 @@ class TransactionQueue(object):
         self._processing_pending_presence = True
         try:
             while True:
-                states = self.pending_presence
+                states_map = self.pending_presence
                 self.pending_presence = {}
 
-                if not states:
+                if not states_map:
                     break
 
-                yield self._process_presence_inner(states)
+                yield self._process_presence_inner(states_map.values())
         finally:
             self._processing_pending_presence = False
 
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index b9ce997a94..f3707afcd0 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -641,7 +641,7 @@ class PresenceHandler(object):
         """Sends state updates to remote servers.
 
         Args:
-            hosts_to_states (list(UserPresenceState))
+            states (list(UserPresenceState))
         """
         self.federation.send_presence(states)
 
@@ -1337,29 +1337,18 @@ def get_interested_remotes(store, states):
         each row the list of UserPresenceState should be sent to each
         destination
     """
-    hosts_and_states = []  # Final result to return
+    hosts_and_states = []
 
     # First we look up the rooms each user is in (as well as any explicit
     # subscriptions), then for each distinct room we look up the remote
     # hosts in those rooms.
-    room_ids_to_states = {}
-    users_to_states = {}
-    for state in states.itervalues():
-        room_ids = yield store.get_rooms_for_user(state.user_id)
-        for room_id in room_ids:
-            room_ids_to_states.setdefault(room_id, []).append(state)
-
-        plist = yield store.get_presence_list_observers_accepted(
-            state.user_id,
-        )
-        for u in plist:
-            users_to_states.setdefault(u, []).append(state)
+    room_ids_to_states, users_to_states = yield get_interested_parties(store, states)
 
-    for room_id, states in room_ids_to_states.items():
+    for room_id, states in room_ids_to_states.iteritems():
         hosts = yield store.get_hosts_in_room(room_id)
         hosts_and_states.append((hosts, states))
 
-    for user_id, states in users_to_states.items():
+    for user_id, states in users_to_states.iteritems():
         host = get_domain_from_id(user_id)
         hosts_and_states.append(([host], states))