Prepare to add an option to list local user accounts from your homeserver

This commit is contained in:
Torsten Flammiger 2021-12-24 23:06:54 +01:00
parent 9b57c89df6
commit 7c1b2625cf

View File

@ -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
}