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

Only fire user_joined_room if the user has actually joined. #410

Merged
merged 7 commits into from
Dec 2, 2015
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
11 changes: 8 additions & 3 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def on_receive_pdu(self, origin, pdu, backfilled, state=None,
)

try:
_, event_stream_id, max_stream_id = yield self._handle_new_event(
context, event_stream_id, max_stream_id = yield self._handle_new_event(
origin,
event,
state=state,
Expand Down Expand Up @@ -234,8 +234,13 @@ def log_failure(f):

if event.type == EventTypes.Member:
if event.membership == Membership.JOIN:
user = UserID.from_string(event.state_key)
yield user_joined_room(self.distributor, user, event.room_id)
prev_state = context.current_state.get((event.type, event.state_key))
if not prev_state or prev_state.membership != Membership.JOIN:
# Only fire user_joined_room if the user has acutally
# joined the room. Don't bother if the user is just
# changing their profile info.
user = UserID.from_string(event.state_key)
yield user_joined_room(self.distributor, user, event.room_id)

@defer.inlineCallbacks
def _filter_events_for_server(self, server_name, room_id, events):
Expand Down
9 changes: 7 additions & 2 deletions synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,13 @@ def _do_join(self, event, context, room_hosts=None, do_auth=True):
do_auth=do_auth,
)

user = UserID.from_string(event.user_id)
yield user_joined_room(self.distributor, user, room_id)
prev_state = context.current_state.get((event.type, event.state_key))
if not prev_state or prev_state.membership != Membership.JOIN:
# Only fire user_joined_room if the user has acutally joined the
# room. Don't bother if the user is just changing their profile
# info.
user = UserID.from_string(event.user_id)
yield user_joined_room(self.distributor, user, room_id)

@defer.inlineCallbacks
def get_inviter(self, event):
Expand Down