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 6 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
12 changes: 10 additions & 2 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,16 @@ 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)
context = yield self.state_handler.compute_event_context(
event, old_state=state, outlier=event.internal_metadata.is_outlier()
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have the context as its returned by _handle_new_event (at line 180)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done c2c70f7

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