diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-11-18 15:29:48 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-11-18 15:29:48 +0000 |
commit | ae9c2ab1652511b36dc594882e88152b6067c816 (patch) | |
tree | c2823450bf67c3199df7f3b73d1387559e042bf4 /synapse/handlers/room.py | |
parent | Split out sending the room alias events from creating the alias so that we ca... (diff) | |
download | synapse-ae9c2ab1652511b36dc594882e88152b6067c816.tar.xz |
SYN-149: Send join event immediately after the room create event
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r-- | synapse/handlers/room.py | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index bfbd7f9783..4f47f5b6ae 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -120,15 +120,23 @@ class RoomCreationHandler(BaseHandler): user, room_id, is_public=is_public ) + room_member_handler = self.hs.get_handlers().room_member_handler + @defer.inlineCallbacks def handle_event(event): snapshot = yield self.store.snapshot_room(event) logger.debug("Event: %s", event) - yield self._on_new_room_event( - event, snapshot, extra_users=[user], suppress_auth=True - ) + if event.type == RoomMemberEvent.TYPE: + yield room_member_handler.change_membership( + event, + do_auth=False + ) + else: + yield self._on_new_room_event( + event, snapshot, extra_users=[user], suppress_auth=True + ) for event in creation_events: yield handle_event(event) @@ -155,16 +163,6 @@ class RoomCreationHandler(BaseHandler): yield handle_event(topic_event) - content = {"membership": Membership.JOIN} - join_event = self.event_factory.create_event( - etype=RoomMemberEvent.TYPE, - state_key=user_id, - room_id=room_id, - user_id=user_id, - membership=Membership.JOIN, - content=content - ) - content = {"membership": Membership.INVITE} for invitee in invite_list: invite_event = self.event_factory.create_event( @@ -174,16 +172,7 @@ class RoomCreationHandler(BaseHandler): user_id=user_id, content=content ) - - yield self.hs.get_handlers().room_member_handler.change_membership( - invite_event, - do_auth=False - ) - - yield self.hs.get_handlers().room_member_handler.change_membership( - join_event, - do_auth=False - ) + yield handle_event(invite_event) result = {"room_id": room_id} @@ -194,9 +183,11 @@ class RoomCreationHandler(BaseHandler): defer.returnValue(result) def _create_events_for_new_room(self, creator, room_id, is_public=False): + creator_id = creator.to_string() + event_keys = { "room_id": room_id, - "user_id": creator.to_string(), + "user_id": creator_id, } def create(etype, **content): @@ -211,6 +202,16 @@ class RoomCreationHandler(BaseHandler): creator=creator.to_string(), ) + join_event = self.event_factory.create_event( + etype=RoomMemberEvent.TYPE, + state_key=creator_id, + content={ + "membership": Membership.JOIN, + }, + **event_keys + ) + + power_levels_event = self.event_factory.create_event( etype=RoomPowerLevelsEvent.TYPE, content={ @@ -239,6 +240,7 @@ class RoomCreationHandler(BaseHandler): return [ creation_event, + join_event, power_levels_event, join_rules_event, ] |