mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-07-08 11:40:01 +02:00
The first part of getting admin command docs on the website. There's also the beginnings of manpage generation here, although it's kinda sus and I'm not sure how it's supposed to work. I'll leave that to anyone who wants to package it. We introduce the beginings of the xtask pattern here - we do a lot of file generation, I thought it would be best to avoid doing that on every compilation. It also helps avoid lots of runtime deps. We'll need to document generating this stuff & probably add pre-commit hooks for it, though.
39 lines
887 B
Rust
39 lines
887 B
Rust
use clap::Subcommand;
|
|
use conduwuit::Result;
|
|
use ruma::{OwnedEventId, OwnedRoomOrAliasId};
|
|
|
|
use crate::{admin_command, admin_command_dispatch};
|
|
|
|
#[admin_command_dispatch]
|
|
#[derive(Debug, Subcommand)]
|
|
/// Query tables from database
|
|
pub enum ShortCommand {
|
|
ShortEventId {
|
|
event_id: OwnedEventId,
|
|
},
|
|
|
|
ShortRoomId {
|
|
room_id: OwnedRoomOrAliasId,
|
|
},
|
|
}
|
|
|
|
#[admin_command]
|
|
pub(super) async fn short_event_id(&self, event_id: OwnedEventId) -> Result {
|
|
let shortid = self
|
|
.services
|
|
.rooms
|
|
.short
|
|
.get_shorteventid(&event_id)
|
|
.await?;
|
|
|
|
self.write_str(&format!("{shortid:#?}")).await
|
|
}
|
|
|
|
#[admin_command]
|
|
pub(super) async fn short_room_id(&self, room_id: OwnedRoomOrAliasId) -> Result {
|
|
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
|
|
|
let shortid = self.services.rooms.short.get_shortroomid(&room_id).await?;
|
|
|
|
self.write_str(&format!("{shortid:#?}")).await
|
|
}
|