summary refs log tree commit diff
path: root/synapse/handlers/register.py
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2018-09-28 01:42:53 +0100
committerMatthew Hodgson <matthew@matrix.org>2018-09-28 01:42:53 +0100
commit07340cdacad901a55abd0811a1fca86061b752bd (patch)
tree96616162925ea4fa8558dc34727636856b773353 /synapse/handlers/register.py
parentMerge pull request #3794 from matrix-org/erikj/faster_typing (diff)
downloadsynapse-07340cdacad901a55abd0811a1fca86061b752bd.tar.xz
untested stab at autocreating autojoin rooms
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r--synapse/handlers/register.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py
index da914c46ff..0e5337d26c 100644
--- a/synapse/handlers/register.py
+++ b/synapse/handlers/register.py
@@ -50,6 +50,8 @@ class RegistrationHandler(BaseHandler):
         self._auth_handler = hs.get_auth_handler()
         self.profile_handler = hs.get_profile_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._next_generated_user_id = None
@@ -513,6 +515,22 @@ class RegistrationHandler(BaseHandler):
 
     @defer.inlineCallbacks
     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_member_handler = self.hs.get_room_member_handler()
         if RoomID.is_valid(room_identifier):