mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2025-12-14 11:18:58 -05:00
37 lines
1 KiB
Rust
37 lines
1 KiB
Rust
|
|
use clap::Subcommand;
|
||
|
|
use ruma::events::room::message::RoomMessageEventContent;
|
||
|
|
|
||
|
|
use super::{
|
||
|
|
account_data::{account_data, AccountData},
|
||
|
|
appservice::{appservice, Appservice},
|
||
|
|
presence::{presence, Presence},
|
||
|
|
};
|
||
|
|
use crate::Result;
|
||
|
|
|
||
|
|
#[cfg_attr(test, derive(Debug))]
|
||
|
|
#[derive(Subcommand)]
|
||
|
|
/// Query tables from database
|
||
|
|
pub(crate) enum QueryCommand {
|
||
|
|
/// - account_data.rs iterators and getters
|
||
|
|
#[command(subcommand)]
|
||
|
|
AccountData(AccountData),
|
||
|
|
|
||
|
|
/// - appservice.rs iterators and getters
|
||
|
|
#[command(subcommand)]
|
||
|
|
Appservice(Appservice),
|
||
|
|
|
||
|
|
/// - presence.rs iterators and getters
|
||
|
|
#[command(subcommand)]
|
||
|
|
Presence(Presence),
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Processes admin query commands
|
||
|
|
#[allow(non_snake_case)]
|
||
|
|
pub(crate) async fn process(command: QueryCommand, _body: Vec<&str>) -> Result<RoomMessageEventContent> {
|
||
|
|
match command {
|
||
|
|
QueryCommand::AccountData(AccountData) => account_data(AccountData).await,
|
||
|
|
QueryCommand::Appservice(Appservice) => appservice(Appservice).await,
|
||
|
|
QueryCommand::Presence(Presence) => presence(Presence).await,
|
||
|
|
}
|
||
|
|
}
|