Split query pusher command w/ admin_command macros.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
use clap::Subcommand;
|
use clap::Subcommand;
|
||||||
use ruma::OwnedUserId;
|
use ruma::OwnedUserId;
|
||||||
use tuwunel_core::Result;
|
use tuwunel_core::Result;
|
||||||
|
use tuwunel_macros::{admin_command, admin_command_dispatch};
|
||||||
|
|
||||||
use crate::Context;
|
#[admin_command_dispatch]
|
||||||
|
|
||||||
#[derive(Debug, Subcommand)]
|
#[derive(Debug, Subcommand)]
|
||||||
pub(crate) enum PusherCommand {
|
pub(crate) enum PusherCommand {
|
||||||
/// - Returns all the pushers for the user.
|
/// - Returns all the pushers for the user.
|
||||||
@@ -13,17 +13,12 @@ pub(crate) enum PusherCommand {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn process(subcommand: PusherCommand, context: &Context<'_>) -> Result {
|
#[admin_command]
|
||||||
let services = context.services;
|
pub(super) async fn get_pushers(&self, user_id: OwnedUserId) -> Result {
|
||||||
|
let timer = tokio::time::Instant::now();
|
||||||
|
let results = self.services.pusher.get_pushers(&user_id).await;
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
match subcommand {
|
self.write_string(format!("Query completed in {query_time:?}:\n\n```rs\n{results:#?}```"))
|
||||||
| PusherCommand::GetPushers { user_id } => {
|
.await
|
||||||
let timer = tokio::time::Instant::now();
|
|
||||||
let results = services.pusher.get_pushers(&user_id).await;
|
|
||||||
let query_time = timer.elapsed();
|
|
||||||
|
|
||||||
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user