mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-02-05 13:05:21 -05:00
Review comments
This commit is contained in:
parent
d5a5d1c632
commit
40e56997bc
@ -934,6 +934,9 @@ class PresenceHandler(object):
|
||||
joining rooms and require being sent presence.
|
||||
"""
|
||||
|
||||
if self._event_processing:
|
||||
return
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _process_presence():
|
||||
if self._event_processing:
|
||||
@ -993,14 +996,29 @@ class PresenceHandler(object):
|
||||
# Ignore changes to join events.
|
||||
continue
|
||||
|
||||
if self.is_mine_id(state_key):
|
||||
yield self._on_user_joined_room(room_id, state_key)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _on_user_joined_room(self, room_id, user_id):
|
||||
"""Called when we detect a user joining the room via the current state
|
||||
delta stream.
|
||||
|
||||
Args:
|
||||
room_id (str)
|
||||
user_id (str)
|
||||
|
||||
Returns:
|
||||
Deferred
|
||||
"""
|
||||
|
||||
if self.is_mine_id(user_id):
|
||||
# If this is a local user then we need to send their presence
|
||||
# out to hosts in the room (who don't already have it)
|
||||
|
||||
# TODO: We should be able to filter the hosts down to those that
|
||||
# haven't previously seen the user
|
||||
|
||||
state = yield self.current_state_for_user(state_key)
|
||||
state = yield self.current_state_for_user(user_id)
|
||||
hosts = yield self.state.get_current_hosts_in_room(room_id)
|
||||
|
||||
# Filter out ourselves.
|
||||
@ -1043,7 +1061,7 @@ class PresenceHandler(object):
|
||||
if states:
|
||||
self.federation.send_presence_to_destinations(
|
||||
states=states,
|
||||
destinations=[get_domain_from_id(state_key)],
|
||||
destinations=[get_domain_from_id(user_id)],
|
||||
)
|
||||
|
||||
|
||||
|
@ -461,7 +461,9 @@ class PresenceJoinTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
self.reactor.pump([0]) # Wait for presence updates to be handled
|
||||
|
||||
# Test that a new server gets told about existing presence #
|
||||
#
|
||||
# Test that a new server gets told about existing presence
|
||||
#
|
||||
|
||||
self.federation_sender.reset_mock()
|
||||
|
||||
@ -482,7 +484,9 @@ class PresenceJoinTestCase(unittest.HomeserverTestCase):
|
||||
destinations=["server2"], states=[expected_state]
|
||||
)
|
||||
|
||||
# Test that only the new server gets sent presence and not existing servers #
|
||||
#
|
||||
# Test that only the new server gets sent presence and not existing servers
|
||||
#
|
||||
|
||||
self.federation_sender.reset_mock()
|
||||
self._add_new_user(room_id, "@bob:server3")
|
||||
@ -517,7 +521,9 @@ class PresenceJoinTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
self.reactor.pump([0]) # Wait for presence updates to be handled
|
||||
|
||||
# Test that when a local join happens remote servers get told about it #
|
||||
#
|
||||
# Test that when a local join happens remote servers get told about it
|
||||
#
|
||||
|
||||
self.federation_sender.reset_mock()
|
||||
|
||||
@ -547,7 +553,6 @@ class PresenceJoinTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
room_version = self.get_success(self.store.get_room_version(room_id))
|
||||
|
||||
# No we want to have other servers "join"
|
||||
builder = EventBuilder(
|
||||
state=self.state,
|
||||
auth=self.auth,
|
||||
@ -555,7 +560,6 @@ class PresenceJoinTestCase(unittest.HomeserverTestCase):
|
||||
clock=self.clock,
|
||||
hostname=hostname,
|
||||
signing_key=self.random_signing_key,
|
||||
|
||||
format_version=room_version_to_event_format(room_version),
|
||||
room_id=room_id,
|
||||
type=EventTypes.Member,
|
||||
|
Loading…
x
Reference in New Issue
Block a user