mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 10:48:18 -07:00
Prepare to add an option to list local user accounts from your homeserver
This commit is contained in:
parent
9b57c89df6
commit
7c1b2625cf
@ -13,6 +13,7 @@ use tracing::warn;
|
||||
pub enum AdminCommand {
|
||||
RegisterAppservice(serde_yaml::Value),
|
||||
ListAppservices,
|
||||
CountUsers,
|
||||
SendMessage(RoomMessageEventContent),
|
||||
}
|
||||
|
||||
@ -93,6 +94,16 @@ impl Admin {
|
||||
let state_lock = mutex_state.lock().await;
|
||||
|
||||
match event {
|
||||
AdminCommand::CountUsers => {
|
||||
// count() does not return an error on failure...
|
||||
if let Ok(usercount) = guard.users.count() {
|
||||
let message = format!("Found {} total user accounts", usercount);
|
||||
send_message(RoomMessageEventContent::text_plain(message), guard, &state_lock);
|
||||
} else {
|
||||
// ... so we simply spit out a generic non-explaining-info in case count() did not return Ok()
|
||||
send_message(RoomMessageEventContent::text_plain("Unable to count users"), guard, &state_lock);
|
||||
}
|
||||
}
|
||||
AdminCommand::RegisterAppservice(yaml) => {
|
||||
guard.appservice.register_appservice(yaml).unwrap(); // TODO handle error
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user