diff options
author | Erik Johnston <erik@matrix.org> | 2017-04-12 10:11:43 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-04-12 10:16:26 +0100 |
commit | c7ddb5ef7ac3dc7370010ee6685497ee73f46fa2 (patch) | |
tree | cb0b7ea77f9709eebd95b34aa7f56bac3d300a52 /synapse/handlers/presence.py | |
parent | Move get_presence_list_* to SlaveStore (diff) | |
download | synapse-c7ddb5ef7ac3dc7370010ee6685497ee73f46fa2.tar.xz |
Reuse get_interested_parties
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/presence.py | 21 |
1 files changed, 5 insertions, 16 deletions
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)) |