diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-12-02 13:17:15 +0000 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-12-02 13:17:15 +0000 |
commit | 58d092776717f0c84626e3925dc10b78b5b189ae (patch) | |
tree | 5c254b76f2e913d0ea824e9e3f1fa74e94509f49 /synapse/handlers | |
parent | Merge pull request #413 from matrix-org/markjh/reuse_http_client (diff) | |
parent | Use the context returned by _handle_new_event (diff) | |
download | synapse-58d092776717f0c84626e3925dc10b78b5b189ae.tar.xz |
Merge pull request #410 from matrix-org/markjh/edu_frequency
Only fire user_joined_room if the user has actually joined.
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/federation.py | 11 | ||||
-rw-r--r-- | synapse/handlers/room.py | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 6cb2f73ff4..2855f2d7c3 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -177,7 +177,7 @@ class FederationHandler(BaseHandler): ) 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, @@ -234,8 +234,13 @@ class FederationHandler(BaseHandler): 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): diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 38bf2ef711..116a998c42 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -525,8 +525,13 @@ class RoomMemberHandler(BaseHandler): 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): |