Files
continuwuity/src/admin/admin.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

95 lines
2.5 KiB
Rust
Raw Normal View History

2024-07-22 22:24:17 +00:00
use clap::Parser;
2024-12-14 21:58:01 -05:00
use conduwuit::Result;
2024-07-22 22:24:17 +00:00
use crate::{
appservice::{self, AppserviceCommand},
check::{self, CheckCommand},
context::Context,
debug::{self, DebugCommand},
federation::{self, FederationCommand},
media::{self, MediaCommand},
query::{self, QueryCommand},
room::{self, RoomCommand},
server::{self, ServerCommand},
token::{self, TokenCommand},
user::{self, UserCommand},
2024-07-22 22:24:17 +00:00
};
#[derive(Debug, Parser)]
2025-06-24 23:16:48 +01:00
#[command(name = conduwuit_core::name(), version = conduwuit_core::version())]
2025-05-24 00:28:09 +01:00
pub enum AdminCommand {
2024-07-22 22:24:17 +00:00
#[command(subcommand)]
/// Commands for managing appservices
2024-07-22 22:24:17 +00:00
Appservices(AppserviceCommand),
#[command(subcommand)]
/// Commands for managing local users
2024-07-22 22:24:17 +00:00
Users(UserCommand),
#[command(subcommand)]
/// Commands for managing registration tokens
Token(TokenCommand),
2024-07-22 22:24:17 +00:00
#[command(subcommand)]
/// Commands for managing rooms
2024-07-22 22:24:17 +00:00
Rooms(RoomCommand),
#[command(subcommand)]
/// Commands for managing federation
2024-07-22 22:24:17 +00:00
Federation(FederationCommand),
#[command(subcommand)]
/// Commands for managing the server
2024-07-22 22:24:17 +00:00
Server(ServerCommand),
#[command(subcommand)]
/// Commands for managing media
2024-07-22 22:24:17 +00:00
Media(MediaCommand),
#[command(subcommand)]
/// Commands for checking integrity
2024-07-22 22:24:17 +00:00
Check(CheckCommand),
#[command(subcommand)]
/// Commands for debugging things
2024-07-22 22:24:17 +00:00
Debug(DebugCommand),
#[command(subcommand)]
/// Low-level queries for database getters and iterators
2024-07-22 22:24:17 +00:00
Query(QueryCommand),
}
2026-01-04 03:04:37 +00:00
#[tracing::instrument(skip_all, name = "command", level = "info")]
pub(super) async fn process(command: AdminCommand, context: &Context<'_>) -> Result {
2024-07-27 00:11:41 +00:00
use AdminCommand::*;
2024-07-22 22:24:17 +00:00
2025-01-04 16:57:07 +00:00
match command {
| Appservices(command) => {
// appservice commands are all restricted
context.bail_restricted()?;
appservice::process(command, context).await
},
| Media(command) => media::process(command, context).await,
| Users(command) => {
// user commands are all restricted
context.bail_restricted()?;
user::process(command, context).await
},
| Token(command) => {
// token commands are all restricted
context.bail_restricted()?;
token::process(command, context).await
},
| Rooms(command) => room::process(command, context).await,
| Federation(command) => federation::process(command, context).await,
| Server(command) => server::process(command, context).await,
| Debug(command) => debug::process(command, context).await,
| Query(command) => {
// query commands are all restricted
context.bail_restricted()?;
query::process(command, context).await
},
| Check(command) => check::process(command, context).await,
2025-02-25 18:38:12 +00:00
}
2024-07-22 22:24:17 +00:00
}