diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-03-01 17:27:22 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-03-01 17:27:22 +0000 |
commit | 8a1d3b86af5a6b23bd45ed137a4eb2b53c274297 (patch) | |
tree | c9f8115b5b750ada36e655ba47a2eab837638c54 /synapse/handlers/room.py | |
parent | Merge pull request #607 from matrix-org/dbkr/send_inviter_member_event (diff) | |
download | synapse-8a1d3b86af5a6b23bd45ed137a4eb2b53c274297.tar.xz |
Handle rejections of invites from local users locally
Slightly hacky fix to SYN-642, which avoids the federation codepath when trying to reject invites from local users.
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/room.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index d2de23a6cc..714bff1750 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -521,8 +521,24 @@ class RoomMemberHandler(BaseHandler): action = "remote_join" elif event.membership == Membership.LEAVE: is_host_in_room = self.is_host_in_room(context.current_state) + if not is_host_in_room: - action = "remote_reject" + # perhaps we've been invited + inviter = self.get_inviter(target_user.to_string(), context.current_state) + if not inviter: + raise SynapseError(404, "Not a known room") + + if inviter.domain == self.server_name: + # the inviter was on our server, but has now left. Carry on + # with the normal rejection codepath. + # + # This is a bit of a hack, because the room might still be + # active on other servers. + pass + else: + # send the rejection to the inviter's HS. + remote_room_hosts = [inviter.domain] + action = "remote_reject" federation_handler = self.hs.get_handlers().federation_handler @@ -541,11 +557,8 @@ class RoomMemberHandler(BaseHandler): event.content, ) elif action == "remote_reject": - inviter = self.get_inviter(target_user.to_string(), context.current_state) - if not inviter: - raise SynapseError(404, "No known servers") yield federation_handler.do_remotely_reject_invite( - [inviter.domain], + remote_room_hosts, room_id, event.user_id ) |