mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-28 15:35:36 +00: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 {
|
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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue