From d0b218181794b7444dbf01a8363fa064e41bdd6f Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 15 Jan 2026 22:05:44 +0000 Subject: [PATCH] Split query pusher command w/ admin_command macros. Signed-off-by: Jason Volk --- src/admin/query/pusher.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/admin/query/pusher.rs b/src/admin/query/pusher.rs index ce33639a..1672e945 100644 --- a/src/admin/query/pusher.rs +++ b/src/admin/query/pusher.rs @@ -1,9 +1,9 @@ use clap::Subcommand; use ruma::OwnedUserId; use tuwunel_core::Result; +use tuwunel_macros::{admin_command, admin_command_dispatch}; -use crate::Context; - +#[admin_command_dispatch] #[derive(Debug, Subcommand)] pub(crate) enum PusherCommand { /// - 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 { - let services = context.services; +#[admin_command] +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 { - | PusherCommand::GetPushers { user_id } => { - 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 + self.write_string(format!("Query completed in {query_time:?}:\n\n```rs\n{results:#?}```")) + .await }