Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Make presence use cached users/hosts in room #2227

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion synapse/federation/transaction_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _process_presence_inner(self, states):
Args:
states (list(UserPresenceState))
"""
hosts_and_states = yield get_interested_remotes(self.store, states)
hosts_and_states = yield get_interested_remotes(self.store, states, self.state)

for destinations, states in hosts_and_states:
for destination in destinations:
Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,12 @@ def user_joined_room(self, user, room_id):
# don't need to send to local clients here, as that is done as part
# of the event stream/sync.
# TODO: Only send to servers not already in the room.
user_ids = yield self.store.get_users_in_room(room_id)
if self.is_mine(user):
state = yield self.current_state_for_user(user.to_string())

self._push_to_remotes([state])
else:
user_ids = yield self.store.get_users_in_room(room_id)
user_ids = filter(self.is_mine_id, user_ids)

states = yield self.current_state_for_users(user_ids)
Expand Down Expand Up @@ -1322,7 +1322,7 @@ def get_interested_parties(store, states):


@defer.inlineCallbacks
def get_interested_remotes(store, states):
def get_interested_remotes(store, states, state_handler):
"""Given a list of presence states figure out which remote servers
should be sent which.

Expand All @@ -1345,7 +1345,7 @@ def get_interested_remotes(store, states):
room_ids_to_states, users_to_states = yield get_interested_parties(store, states)

for room_id, states in room_ids_to_states.iteritems():
hosts = yield store.get_hosts_in_room(room_id)
hosts = yield state_handler.get_current_hosts_in_room(room_id)
hosts_and_states.append((hosts, states))

for user_id, states in users_to_states.iteritems():
Expand Down