admincmd: leave all rooms if deactivating all users with --force
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
83220b43a2
commit
b29a8791de
2 changed files with 5 additions and 5 deletions
|
@ -38,7 +38,7 @@ pub(crate) enum UserCommand {
|
||||||
/// Recommended to use in conjunction with list-local-users.
|
/// Recommended to use in conjunction with list-local-users.
|
||||||
///
|
///
|
||||||
/// Users will not be removed from joined rooms by default.
|
/// 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
|
/// 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
|
/// amount of leave events. The time to leave rooms may depend significantly
|
||||||
/// on joined rooms and servers.
|
/// on joined rooms and servers.
|
||||||
|
@ -50,7 +50,7 @@ pub(crate) enum UserCommand {
|
||||||
/// Remove users from their joined rooms
|
/// Remove users from their joined rooms
|
||||||
leave_rooms: bool,
|
leave_rooms: bool,
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
/// Also deactivate admin accounts
|
/// Also deactivate admin accounts and will assume leave all rooms too
|
||||||
force: bool,
|
force: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -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();
|
let mut admins = Vec::new();
|
||||||
|
|
||||||
if !force {
|
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 {
|
for &user_id in &user_ids {
|
||||||
leave_all_rooms(user_id).await;
|
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 {
|
} else {
|
||||||
Ok(RoomMessageEventContent::text_plain(format!(
|
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,
|
deactivation_count,
|
||||||
admins.join(", ")
|
admins.join(", ")
|
||||||
)))
|
)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue