add config option to control sending admin notices of alerts

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-10-24 22:19:18 -04:00
parent 0760150822
commit 75be68fa61
No known key found for this signature in database
6 changed files with 128 additions and 76 deletions

View file

@ -146,14 +146,17 @@ pub(crate) async fn set_room_visibility_route(
\"lockdown_public_room_directory\" is enabled",
body.room_id
);
services
.admin
.send_text(&format!(
"Non-admin user {sender_user} tried to publish {0} to the room directory while \
\"lockdown_public_room_directory\" is enabled",
body.room_id
))
.await;
if services.globals.config.admin_room_notices {
services
.admin
.send_text(&format!(
"Non-admin user {sender_user} tried to publish {0} to the room directory while \
\"lockdown_public_room_directory\" is enabled",
body.room_id
))
.await;
}
return Err(Error::BadRequest(
ErrorKind::forbidden(),
@ -162,10 +165,13 @@ pub(crate) async fn set_room_visibility_route(
}
services.rooms.directory.set_public(&body.room_id)?;
services
.admin
.send_text(&format!("{sender_user} made {} public to the room directory", body.room_id))
.await;
if services.globals.config.admin_room_notices {
services
.admin
.send_text(&format!("{sender_user} made {} public to the room directory", body.room_id))
.await;
}
info!("{sender_user} made {0} public to the room directory", body.room_id);
},
room::Visibility::Private => services.rooms.directory.set_not_public(&body.room_id)?,