mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
untested stab at autocreating autojoin rooms
This commit is contained in:
parent
36c62a67c4
commit
07340cdaca
@ -44,6 +44,7 @@ class RegistrationConfig(Config):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.auto_join_rooms = config.get("auto_join_rooms", [])
|
self.auto_join_rooms = config.get("auto_join_rooms", [])
|
||||||
|
self.autocreate_auto_join_rooms = config.get("autocreate_auto_join_rooms", true)
|
||||||
|
|
||||||
def default_config(self, **kwargs):
|
def default_config(self, **kwargs):
|
||||||
registration_shared_secret = random_string_with_symbols(50)
|
registration_shared_secret = random_string_with_symbols(50)
|
||||||
@ -98,6 +99,9 @@ class RegistrationConfig(Config):
|
|||||||
# to these rooms
|
# to these rooms
|
||||||
#auto_join_rooms:
|
#auto_join_rooms:
|
||||||
# - "#example:example.com"
|
# - "#example:example.com"
|
||||||
|
|
||||||
|
# Have first user on server autocreate autojoin rooms
|
||||||
|
autocreate_auto_join_rooms: true
|
||||||
""" % locals()
|
""" % locals()
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
|
@ -50,6 +50,8 @@ class RegistrationHandler(BaseHandler):
|
|||||||
self._auth_handler = hs.get_auth_handler()
|
self._auth_handler = hs.get_auth_handler()
|
||||||
self.profile_handler = hs.get_profile_handler()
|
self.profile_handler = hs.get_profile_handler()
|
||||||
self.user_directory_handler = hs.get_user_directory_handler()
|
self.user_directory_handler = hs.get_user_directory_handler()
|
||||||
|
self._room_creation_handler = hs.get_room_creation_handler()
|
||||||
|
self._directory_handler = hs.get_handlers().directory_handler
|
||||||
self.captcha_client = CaptchaServerHttpClient(hs)
|
self.captcha_client = CaptchaServerHttpClient(hs)
|
||||||
|
|
||||||
self._next_generated_user_id = None
|
self._next_generated_user_id = None
|
||||||
@ -513,6 +515,22 @@ class RegistrationHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _join_user_to_room(self, requester, room_identifier):
|
def _join_user_to_room(self, requester, room_identifier):
|
||||||
|
|
||||||
|
# try to create the room if we're the first user on the server
|
||||||
|
if self.config.autocreate_auto_join_rooms:
|
||||||
|
count = yield self.store.count_all_users()
|
||||||
|
if count == 1 and RoomAlias.is_valid(room_identifier):
|
||||||
|
info = yield self._room_creation_handler.create_room(
|
||||||
|
requester,
|
||||||
|
config={
|
||||||
|
"preset": "public_chat",
|
||||||
|
},
|
||||||
|
ratelimit=False,
|
||||||
|
)
|
||||||
|
room_id = info["room_id"]
|
||||||
|
|
||||||
|
yield create_association(self, requester.user, room_identifier, room_id)
|
||||||
|
|
||||||
room_id = None
|
room_id = None
|
||||||
room_member_handler = self.hs.get_room_member_handler()
|
room_member_handler = self.hs.get_room_member_handler()
|
||||||
if RoomID.is_valid(room_identifier):
|
if RoomID.is_valid(room_identifier):
|
||||||
|
Loading…
Reference in New Issue
Block a user