|
|
@ -13,6 +13,7 @@ use tracing::warn;
|
|
|
|
pub enum AdminCommand {
|
|
|
|
pub enum AdminCommand {
|
|
|
|
RegisterAppservice(serde_yaml::Value),
|
|
|
|
RegisterAppservice(serde_yaml::Value),
|
|
|
|
ListAppservices,
|
|
|
|
ListAppservices,
|
|
|
|
|
|
|
|
CountUsers,
|
|
|
|
SendMessage(RoomMessageEventContent),
|
|
|
|
SendMessage(RoomMessageEventContent),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -93,6 +94,16 @@ impl Admin {
|
|
|
|
let state_lock = mutex_state.lock().await;
|
|
|
|
let state_lock = mutex_state.lock().await;
|
|
|
|
|
|
|
|
|
|
|
|
match event {
|
|
|
|
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) => {
|
|
|
|
AdminCommand::RegisterAppservice(yaml) => {
|
|
|
|
guard.appservice.register_appservice(yaml).unwrap(); // TODO handle error
|
|
|
|
guard.appservice.register_appservice(yaml).unwrap(); // TODO handle error
|
|
|
|
}
|
|
|
|
}
|
|
|
|