diff --git a/conduwuit-example.toml b/conduwuit-example.toml index a2c61d37..65a0985d 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -156,13 +156,17 @@ ip_range_denylist = [ ### Moderation / Privacy / Security # 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 # Set to true to log guest registrations in the admin room. # Defaults to false as it may be noisy or unnecessary. 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. # No default. # prevent_media_downloads_from = ["example.com", "example.local"] diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs index 13a75e69..92e778dc 100644 --- a/src/api/client_server/account.rs +++ b/src/api/client_server/account.rs @@ -319,7 +319,9 @@ pub async fn register_route(body: Ruma) -> Result) -> Result) -> Result { - info!("Automatically joined room {room} for user {user_id}"); - }, - Err(e) => { - // don't return this error so we don't fail registrations - error!("Failed to automatically join room {room} for user {user_id}: {e}"); - }, + // don't return this error so we don't fail registrations + error!("Failed to automatically join room {room} for user {user_id}: {e}"); + } else { + info!("Automatically joined room {room} for user {user_id}"); }; } } diff --git a/src/config/mod.rs b/src/config/mod.rs index 16a3dbfe..38171f62 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -260,6 +260,8 @@ pub struct Config { pub allow_guest_registration: bool, #[serde(default)] pub log_guest_registrations: bool, + #[serde(default)] + pub allow_guests_auto_join_rooms: bool, #[serde(default = "Vec::new")] pub prevent_media_downloads_from: Vec, @@ -515,6 +517,10 @@ impl fmt::Display for Config { "Log guest registrations in admin room", &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), ("Allow encryption", &self.allow_encryption.to_string()), ("Allow federation", &self.allow_federation.to_string()), diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index 644cc2c6..f1b3ea64 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -209,6 +209,8 @@ impl Service<'_> { 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 allow_encryption(&self) -> bool { self.config.allow_encryption }