diff options
author | Erik Johnston <erik@matrix.org> | 2014-09-06 01:10:07 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-09-06 01:10:07 +0100 |
commit | f47f42090d58ec5c49b3e14c50a62e96744980ca (patch) | |
tree | 4a444308dad7532c9db541d8d9b9393f81a333ee | |
parent | Better call bar (visually: still lacks ring[back] tones). (diff) | |
download | synapse-f47f42090d58ec5c49b3e14c50a62e96744980ca.tar.xz |
Add support for inviting people when you create a room
-rw-r--r-- | synapse/handlers/room.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 3fa12841cf..a0d0f2af16 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -65,6 +65,13 @@ class RoomCreationHandler(BaseHandler): else: room_alias = None + invite_list = config.get("invite", []) + for i in invite_list: + try: + self.hs.parse_userid(i) + except: + raise SynapseError(400, "Invalid user_id: %s" % (i,)) + is_public = config.get("visibility", None) == "public" if room_id: @@ -178,6 +185,25 @@ class RoomCreationHandler(BaseHandler): do_auth=False ) + content = {"membership": Membership.INVITE} + for invitee in invite_list: + invite_event = self.event_factory.create_event( + etype=RoomMemberEvent.TYPE, + state_key=invitee, + room_id=room_id, + 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 + ) result = {"room_id": room_id} if room_alias: result["room_alias"] = room_alias.to_string() |