admincmd: leave all rooms if deactivating all users with `--force`

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-06-02 19:29:08 -04:00
parent 83220b43a2
commit b29a8791de
2 changed files with 5 additions and 5 deletions

View File

@ -38,7 +38,7 @@ pub(crate) enum UserCommand {
/// Recommended to use in conjunction with list-local-users.
///
/// Users will not be removed from joined rooms by default.
/// Can be overridden with --leave-rooms flag.
/// Can be overridden with --leave-rooms OR the --force flag.
/// Removing a mass amount of users from a room may cause a significant
/// amount of leave events. The time to leave rooms may depend significantly
/// on joined rooms and servers.
@ -50,7 +50,7 @@ pub(crate) enum UserCommand {
/// Remove users from their joined rooms
leave_rooms: bool,
#[arg(short, long)]
/// Also deactivate admin accounts
/// Also deactivate admin accounts and will assume leave all rooms too
force: bool,
},

View File

@ -238,7 +238,7 @@ pub(crate) async fn deactivate_all(body: Vec<&str>, leave_rooms: bool, force: bo
}
}
let mut deactivation_count: u16 = 0;
let mut deactivation_count: usize = 0;
let mut admins = Vec::new();
if !force {
@ -279,7 +279,7 @@ pub(crate) async fn deactivate_all(body: Vec<&str>, leave_rooms: bool, force: bo
}
}
if leave_rooms {
if leave_rooms || force {
for &user_id in &user_ids {
leave_all_rooms(user_id).await;
}
@ -291,7 +291,7 @@ pub(crate) async fn deactivate_all(body: Vec<&str>, leave_rooms: bool, force: bo
)))
} else {
Ok(RoomMessageEventContent::text_plain(format!(
"Deactivated {} accounts.\nSkipped admin accounts: {:?}. Use --force to deactivate admin accounts",
"Deactivated {} accounts.\nSkipped admin accounts: {}. Use --force to deactivate admin accounts",
deactivation_count,
admins.join(", ")
)))