2024-09-15 19:56:29 -04:00
|
|
|
use clap::Subcommand;
|
2025-04-08 04:39:01 +00:00
|
|
|
use ruma::OwnedUserId;
|
2025-04-22 01:41:02 +00:00
|
|
|
use tuwunel_core::Result;
|
2024-09-15 19:56:29 -04:00
|
|
|
|
2025-04-06 23:41:58 +00:00
|
|
|
use crate::Context;
|
2024-09-15 19:56:29 -04:00
|
|
|
|
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
|
|
|
pub(crate) enum PusherCommand {
|
|
|
|
|
/// - Returns all the pushers for the user.
|
|
|
|
|
GetPushers {
|
|
|
|
|
/// Full user ID
|
2025-04-08 04:39:01 +00:00
|
|
|
user_id: OwnedUserId,
|
2024-09-15 19:56:29 -04:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-06 23:41:58 +00:00
|
|
|
pub(super) async fn process(subcommand: PusherCommand, context: &Context<'_>) -> Result {
|
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();
|
|
|
|
|
|
2025-01-04 16:57:07 +00:00
|
|
|
write!(context, "Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```")
|
2024-09-15 19:56:29 -04:00
|
|
|
},
|
|
|
|
|
}
|
2025-01-04 16:57:07 +00:00
|
|
|
.await
|
2024-09-15 19:56:29 -04:00
|
|
|
}
|