2024-09-15 19:56:29 -04:00
|
|
|
use clap::Subcommand;
|
2024-12-14 21:58:01 -05:00
|
|
|
use conduwuit::Result;
|
2024-09-15 19:56:29 -04:00
|
|
|
use ruma::{events::room::message::RoomMessageEventContent, UserId};
|
|
|
|
|
|
|
|
|
|
use crate::Command;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
|
|
|
pub(crate) enum PusherCommand {
|
|
|
|
|
/// - Returns all the pushers for the user.
|
|
|
|
|
GetPushers {
|
|
|
|
|
/// Full user ID
|
|
|
|
|
user_id: Box<UserId>,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-15 00:05:47 -05:00
|
|
|
pub(super) async fn process(
|
|
|
|
|
subcommand: PusherCommand,
|
|
|
|
|
context: &Command<'_>,
|
|
|
|
|
) -> Result<RoomMessageEventContent> {
|
2024-09-15 19:56:29 -04:00
|
|
|
let services = context.services;
|
|
|
|
|
|
|
|
|
|
match subcommand {
|
2024-12-15 00:05:47 -05:00
|
|
|
| PusherCommand::GetPushers { user_id } => {
|
2024-09-15 19:56:29 -04:00
|
|
|
let timer = tokio::time::Instant::now();
|
2024-08-08 17:18:30 +00:00
|
|
|
let results = services.pusher.get_pushers(&user_id).await;
|
2024-09-15 19:56:29 -04:00
|
|
|
let query_time = timer.elapsed();
|
|
|
|
|
|
|
|
|
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
|
|
|
|
"Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```"
|
|
|
|
|
)))
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|