add config option for allowing guests to auto join rooms
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
d95c02f575
commit
eceef5efa2
4 changed files with 21 additions and 10 deletions
|
@ -156,13 +156,17 @@ ip_range_denylist = [
|
||||||
### Moderation / Privacy / Security
|
### Moderation / Privacy / Security
|
||||||
|
|
||||||
# Set to true to allow user type "guest" registrations. Element attempts to register guest users automatically.
|
# Set to true to allow user type "guest" registrations. Element attempts to register guest users automatically.
|
||||||
# For private homeservers, this is best at false.
|
# Defaults to false
|
||||||
allow_guest_registration = false
|
allow_guest_registration = false
|
||||||
|
|
||||||
# Set to true to log guest registrations in the admin room.
|
# Set to true to log guest registrations in the admin room.
|
||||||
# Defaults to false as it may be noisy or unnecessary.
|
# Defaults to false as it may be noisy or unnecessary.
|
||||||
log_guest_registrations = false
|
log_guest_registrations = false
|
||||||
|
|
||||||
|
# Set to true to allow guest registrations/users to auto join any rooms specified in `auto_join_rooms`
|
||||||
|
# Defaults to false
|
||||||
|
allow_guests_auto_join_rooms = false
|
||||||
|
|
||||||
# Vector list of servers that conduwuit will refuse to download remote media from.
|
# Vector list of servers that conduwuit will refuse to download remote media from.
|
||||||
# No default.
|
# No default.
|
||||||
# prevent_media_downloads_from = ["example.com", "example.local"]
|
# prevent_media_downloads_from = ["example.com", "example.local"]
|
||||||
|
|
|
@ -319,7 +319,9 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !services().globals.config.auto_join_rooms.is_empty() {
|
if !services().globals.config.auto_join_rooms.is_empty() && !is_guest
|
||||||
|
|| (services().globals.allow_guests_auto_join_rooms() && is_guest)
|
||||||
|
{
|
||||||
for room in &services().globals.config.auto_join_rooms {
|
for room in &services().globals.config.auto_join_rooms {
|
||||||
if !services()
|
if !services()
|
||||||
.rooms
|
.rooms
|
||||||
|
@ -331,7 +333,7 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(room_id_server_name) = room.server_name() {
|
if let Some(room_id_server_name) = room.server_name() {
|
||||||
match join_room_by_id_helper(
|
if let Err(e) = join_room_by_id_helper(
|
||||||
Some(&user_id),
|
Some(&user_id),
|
||||||
room,
|
room,
|
||||||
Some("Automatically joining this room upon registration".to_owned()),
|
Some("Automatically joining this room upon registration".to_owned()),
|
||||||
|
@ -340,13 +342,10 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => {
|
|
||||||
info!("Automatically joined room {room} for user {user_id}");
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
// don't return this error so we don't fail registrations
|
// don't return this error so we don't fail registrations
|
||||||
error!("Failed to automatically join room {room} for user {user_id}: {e}");
|
error!("Failed to automatically join room {room} for user {user_id}: {e}");
|
||||||
},
|
} else {
|
||||||
|
info!("Automatically joined room {room} for user {user_id}");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,8 @@ pub struct Config {
|
||||||
pub allow_guest_registration: bool,
|
pub allow_guest_registration: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub log_guest_registrations: bool,
|
pub log_guest_registrations: bool,
|
||||||
|
#[serde(default)]
|
||||||
|
pub allow_guests_auto_join_rooms: bool,
|
||||||
|
|
||||||
#[serde(default = "Vec::new")]
|
#[serde(default = "Vec::new")]
|
||||||
pub prevent_media_downloads_from: Vec<OwnedServerName>,
|
pub prevent_media_downloads_from: Vec<OwnedServerName>,
|
||||||
|
@ -515,6 +517,10 @@ impl fmt::Display for Config {
|
||||||
"Log guest registrations in admin room",
|
"Log guest registrations in admin room",
|
||||||
&self.log_guest_registrations.to_string(),
|
&self.log_guest_registrations.to_string(),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"Allow guests to auto join rooms",
|
||||||
|
&self.allow_guests_auto_join_rooms.to_string(),
|
||||||
|
),
|
||||||
("New user display name suffix", &self.new_user_displayname_suffix),
|
("New user display name suffix", &self.new_user_displayname_suffix),
|
||||||
("Allow encryption", &self.allow_encryption.to_string()),
|
("Allow encryption", &self.allow_encryption.to_string()),
|
||||||
("Allow federation", &self.allow_federation.to_string()),
|
("Allow federation", &self.allow_federation.to_string()),
|
||||||
|
|
|
@ -209,6 +209,8 @@ impl Service<'_> {
|
||||||
|
|
||||||
pub fn allow_guest_registration(&self) -> bool { self.config.allow_guest_registration }
|
pub fn allow_guest_registration(&self) -> bool { self.config.allow_guest_registration }
|
||||||
|
|
||||||
|
pub fn allow_guests_auto_join_rooms(&self) -> bool { self.config.allow_guests_auto_join_rooms }
|
||||||
|
|
||||||
pub fn log_guest_registrations(&self) -> bool { self.config.log_guest_registrations }
|
pub fn log_guest_registrations(&self) -> bool { self.config.log_guest_registrations }
|
||||||
|
|
||||||
pub fn allow_encryption(&self) -> bool { self.config.allow_encryption }
|
pub fn allow_encryption(&self) -> bool { self.config.allow_encryption }
|
||||||
|
|
Loading…
Add table
Reference in a new issue