diff --git a/src/admin/user/commands.rs b/src/admin/user/commands.rs index 531ce490..444a7f37 100644 --- a/src/admin/user/commands.rs +++ b/src/admin/user/commands.rs @@ -108,24 +108,29 @@ pub(super) async fn create_user(&self, username: String, password: Option { + self.services + .admin + .send_message(RoomMessageEventContent::text_plain(format!( + "Failed to automatically join room {room} for user {user_id}: {e}" + ))) + .await + .ok(); // don't return this error so we don't fail registrations error!("Failed to automatically join room {room} for user {user_id}: {e}"); }, diff --git a/src/api/client/account.rs b/src/api/client/account.rs index 87e73c5a..c340f529 100644 --- a/src/api/client/account.rs +++ b/src/api/client/account.rs @@ -398,23 +398,28 @@ pub(crate) async fn register_route( && (services.globals.allow_guests_auto_join_rooms() || !is_guest) { for room in &services.globals.config.auto_join_rooms { + let Ok(room_id) = services.rooms.alias.resolve(room).await else { + error!("Failed to resolve room alias to room ID when attempting to auto join {room}, skipping"); + continue; + }; + if !services .rooms .state_cache - .server_in_room(services.globals.server_name(), room) + .server_in_room(services.globals.server_name(), &room_id) .await { warn!("Skipping room {room} to automatically join as we have never joined before."); continue; } - if let Some(room_id_server_name) = room.server_name() { + if let Some(room_server_name) = room.server_name() { if let Err(e) = join_room_by_id_helper( &services, &user_id, - room, + &room_id, Some("Automatically joining this room upon registration".to_owned()), - &[room_id_server_name.to_owned(), services.globals.server_name().to_owned()], + &[services.globals.server_name().to_owned(), room_server_name.to_owned()], None, &body.appservice_info, ) diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 512cb48b..a6216da2 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -18,7 +18,8 @@ pub use figment::{value::Value as FigmentValue, Figment}; use itertools::Itertools; use regex::RegexSet; use ruma::{ - api::client::discovery::discover_support::ContactRole, OwnedRoomId, OwnedServerName, OwnedUserId, RoomVersionId, + api::client::discovery::discover_support::ContactRole, OwnedRoomOrAliasId, OwnedServerName, OwnedUserId, + RoomVersionId, }; use serde::{de::IgnoredAny, Deserialize}; use url::Url; @@ -653,13 +654,13 @@ pub struct Config { #[serde(default = "default_turn_ttl")] pub turn_ttl: u64, - /// List/vector of room **IDs** that conduwuit will make newly registered - /// users join. The room IDs specified must be rooms that you have joined - /// at least once on the server, and must be public. + /// List/vector of room IDs or room aliases that conduwuit will make newly + /// registered users join. The rooms specified must be rooms that you + /// have joined at least once on the server, and must be public. /// /// No default. #[serde(default = "Vec::new")] - pub auto_join_rooms: Vec, + pub auto_join_rooms: Vec, /// Config option to automatically deactivate the account of any user who /// attempts to join a: