diff options
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/_base.py | 15 | ||||
-rw-r--r-- | synapse/handlers/federation.py | 2 | ||||
-rw-r--r-- | synapse/handlers/room.py | 16 | ||||
-rw-r--r-- | synapse/state.py | 4 |
4 files changed, 20 insertions, 17 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py index 46c2b0a690..2c737c8bf9 100644 --- a/synapse/handlers/_base.py +++ b/synapse/handlers/_base.py @@ -113,6 +113,20 @@ class BaseHandler(object): yield self.store.persist_event(event, context=context) + federation_handler = self.hs.get_handlers().federation_handler + + if event.type == EventTypes.Member: + if event.content["membership"] == Membership.INVITE: + invitee = self.hs.parse_userid(event.state_key) + if not self.hs.is_mine(invitee): + returned_invite = yield federation_handler.send_invite( + invitee.domain, + event, + ) + event.signatures.update( + returned_invite.signatures + ) + destinations = set(extra_destinations) for k, s in context.current_state.items(): try: @@ -128,7 +142,6 @@ class BaseHandler(object): yield self.notifier.on_new_room_event(event, extra_users=extra_users) - federation_handler = self.hs.get_handlers().federation_handler yield federation_handler.handle_new_event( event, None, diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 2d015ccce6..827c86c9da 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -282,8 +282,6 @@ class FederationHandler(BaseHandler): pdu=event ) - - defer.returnValue(pdu) @defer.inlineCallbacks diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 6da084b3ac..215b9cc5ac 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -429,12 +429,9 @@ class RoomMemberHandler(BaseHandler): ) if prev_state and prev_state.membership == Membership.INVITE: - room = yield self.store.get_room(room_id) - inviter = UserID.from_string( - prev_state.user_id, self.hs - ) + inviter = UserID.from_string(prev_state.user_id) - should_do_dance = not self.hs.is_mine(inviter) and not room + should_do_dance = not self.hs.is_mine(inviter) room_host = inviter.domain else: should_do_dance = False @@ -511,14 +508,7 @@ class RoomMemberHandler(BaseHandler): do_auth): yield run_on_reactor() - # If we're inviting someone, then we should also send it to that - # HS. - target_user_id = event.state_key - target_user = self.hs.parse_userid(target_user_id) - if membership == Membership.INVITE and not self.hs.is_mine(target_user): - do_invite_host = target_user.domain - else: - do_invite_host = None + target_user = self.hs.parse_userid(event.state_key) yield self.handle_new_client_event( event, diff --git a/synapse/state.py b/synapse/state.py index d1d6f95246..ebec0ad9dc 100644 --- a/synapse/state.py +++ b/synapse/state.py @@ -166,13 +166,15 @@ class StateHandler(object): prev_state ) - if hasattr(event, "auth_events"): + if hasattr(event, "auth_events") and event.auth_events: auth_ids = zip(*event.auth_events)[0] context.auth_events = { k: v for k, v in context.current_state.items() if v.event_id in auth_ids } + else: + context.auth_events = {} defer.returnValue(prev_state) |