-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Autocreate autojoin rooms #3975
Changes from 5 commits
07340cd
8f646f2
5b68f29
23b6a05
faa462e
2dadc09
ed82043
a2bfb77
1ccafb0
c6584f4
a67d8ac
9f72c20
94a49e0
9532caf
9ec2186
f7f487e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
First user should autocreate autojoin rooms | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ def read_config(self, config): | |
) | ||
|
||
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): | ||
registration_shared_secret = random_string_with_symbols(50) | ||
|
@@ -98,6 +99,9 @@ def default_config(self, **kwargs): | |
# to these rooms | ||
#auto_join_rooms: | ||
# - "#example:example.com" | ||
|
||
# Have first user on server autocreate autojoin rooms | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe explain what will happen if it is false, and conversely what happens if it is true? |
||
autocreate_auto_join_rooms: true | ||
""" % locals() | ||
|
||
def add_arguments(self, parser): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -513,6 +513,34 @@ def get_or_register_3pid_guest(self, medium, address, inviter_user_id): | |
|
||
@defer.inlineCallbacks | ||
def _join_user_to_room(self, requester, room_identifier): | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was oversight I promise! |
||
# try to create the room if we're the first user on the server | ||
if self.hs.config.autocreate_auto_join_rooms: | ||
count = yield self.store.count_all_users() | ||
if count == 1 and RoomAlias.is_valid(room_identifier): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it feels very random to be doing this at this point. (Which is when the first user is registered? when they log in?). what if two users register at once? what if the first user didn't qualify for autojoining for some reason? Can we not do this when the HS first starts, somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the only way to do it at start would be if we also autocreated an admin user, which in turn then means shared-secret registering them and then setting up their profile and 3pid and passwords etc correctly. agreed this would be cleaner, but this is intended as a fast fix to avoid having to do that in the provisioning process, on the basis that the first user who signs in is 99% always going to be the server admin, and if it isn't, then you can always repoint the alias. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, fair enough, but still, having can we pull out the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
or just call |
||
room_creation_handler = self.hs.get_room_creation_handler() | ||
info = yield room_creation_handler.create_room( | ||
requester, | ||
config={ | ||
"preset": "public_chat", | ||
}, | ||
ratelimit=False, | ||
) | ||
room_id = info["room_id"] | ||
|
||
directory_handler = self.hs.get_handlers().directory_handler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we not do the alias bits by passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, possibly. |
||
room_alias = RoomAlias.from_string(room_identifier) | ||
yield directory_handler.create_association( | ||
user_id=requester.user.to_string(), | ||
room_alias=room_alias, | ||
room_id=room_id, | ||
servers=[self.hs.hostname], | ||
) | ||
|
||
yield directory_handler.send_room_alias_update_event( | ||
requester, requester.user.to_string(), room_id | ||
) | ||
|
||
room_id = None | ||
room_member_handler = self.hs.get_room_member_handler() | ||
if RoomID.is_valid(room_identifier): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you expand on this a bit so that it makes sense for users, please?