diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2016-03-04 00:12:19 +0000 |
---|---|---|
committer | Richard van der Hoff <github@rvanderhoff.org.uk> | 2016-03-04 00:12:19 +0000 |
commit | fa6d6bbceba89b50bf18a5e748ec264cdeb2b4f4 (patch) | |
tree | 7f9c37afab5515c7ac67ac91ac86da1f6db398b0 /synapse/handlers/room.py | |
parent | jenkins-*.sh: set -x (diff) | |
parent | Merge branch 'develop' into rav/SYN-642 (diff) | |
download | synapse-fa6d6bbceba89b50bf18a5e748ec264cdeb2b4f4.tar.xz |
Merge pull request #615 from matrix-org/rav/SYN-642
Handle rejections of invites from local users locally
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r-- | synapse/handlers/room.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 91fe306cf4..6dd7a41f04 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -500,6 +500,8 @@ class RoomMemberHandler(BaseHandler): Raises: SynapseError if there was a problem changing the membership. """ + remote_room_hosts = remote_room_hosts or [] + target_user = UserID.from_string(event.state_key) room_id = event.room_id @@ -534,8 +536,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 self.hs.is_mine(inviter): + # 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 = remote_room_hosts + [inviter.domain] + action = "remote_reject" federation_handler = self.hs.get_handlers().federation_handler @@ -554,11 +572,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 ) |