|
|
|
|
@ -214,9 +214,9 @@ impl Service {
|
|
|
|
|
let conduit_user = UserId::parse(format!("@conduit:{}", services().globals.server_name())) |
|
|
|
|
.expect("@conduit:server_name is valid"); |
|
|
|
|
|
|
|
|
|
let conduit_room = services().admin.get_admin_room(); |
|
|
|
|
|
|
|
|
|
let send_message = |message: RoomMessageEventContent, mutex_lock: &MutexGuard<'_, ()>| { |
|
|
|
|
if let Ok(Some(conduit_room)) = services().admin.get_admin_room() { |
|
|
|
|
let send_message = |message: RoomMessageEventContent, |
|
|
|
|
mutex_lock: &MutexGuard<'_, ()>| { |
|
|
|
|
services() |
|
|
|
|
.rooms |
|
|
|
|
.timeline |
|
|
|
|
@ -262,6 +262,7 @@ impl Service {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn process_message(&self, room_message: String) { |
|
|
|
|
self.sender |
|
|
|
|
@ -1097,9 +1098,8 @@ impl Service {
|
|
|
|
|
|
|
|
|
|
/// Gets the room ID of the admin room
|
|
|
|
|
///
|
|
|
|
|
/// If the room does not exist, this function panics, since it should have been created on first run
|
|
|
|
|
// ^ was the case before this function when the following code was re-used in multiple places
|
|
|
|
|
pub(crate) fn get_admin_room(&self) -> OwnedRoomId { |
|
|
|
|
/// Errors are propagated from the database, and will have None if there is no admin room
|
|
|
|
|
pub(crate) fn get_admin_room(&self) -> Result<Option<OwnedRoomId>> { |
|
|
|
|
let admin_room_alias: Box<RoomAliasId> = |
|
|
|
|
format!("#admins:{}", services().globals.server_name()) |
|
|
|
|
.try_into() |
|
|
|
|
@ -1109,8 +1109,6 @@ impl Service {
|
|
|
|
|
.rooms |
|
|
|
|
.alias |
|
|
|
|
.resolve_local_alias(&admin_room_alias) |
|
|
|
|
.expect("Room ID should be valid unicode, since this server created it") |
|
|
|
|
.expect("Admin room must exist") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Invite the user to the conduit admin room.
|
|
|
|
|
@ -1121,8 +1119,7 @@ impl Service {
|
|
|
|
|
user_id: &UserId, |
|
|
|
|
displayname: String, |
|
|
|
|
) -> Result<()> { |
|
|
|
|
let room_id = services().admin.get_admin_room(); |
|
|
|
|
|
|
|
|
|
if let Some(room_id) = services().admin.get_admin_room()? { |
|
|
|
|
let mutex_state = Arc::clone( |
|
|
|
|
services() |
|
|
|
|
.globals |
|
|
|
|
@ -1226,6 +1223,9 @@ impl Service {
|
|
|
|
|
)?; |
|
|
|
|
|
|
|
|
|
Ok(()) |
|
|
|
|
} else { |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|