mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-24 07:39:24 -05:00
Add support for inviting people when you create a room
This commit is contained in:
parent
c03c255304
commit
f47f42090d
@ -65,6 +65,13 @@ class RoomCreationHandler(BaseHandler):
|
|||||||
else:
|
else:
|
||||||
room_alias = None
|
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"
|
is_public = config.get("visibility", None) == "public"
|
||||||
|
|
||||||
if room_id:
|
if room_id:
|
||||||
@ -178,6 +185,25 @@ class RoomCreationHandler(BaseHandler):
|
|||||||
do_auth=False
|
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}
|
result = {"room_id": room_id}
|
||||||
if room_alias:
|
if room_alias:
|
||||||
result["room_alias"] = room_alias.to_string()
|
result["room_alias"] = room_alias.to_string()
|
||||||
|
Loading…
Reference in New Issue
Block a user