Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 032b199

Browse files
committed
add db query command to get all pushers for a user
Signed-off-by: strawberry <[email protected]>
1 parent e9e5fe2 commit 032b199

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/admin/query/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod account_data;
22
mod appservice;
33
mod globals;
44
mod presence;
5+
mod pusher;
56
mod resolver;
67
mod room_alias;
78
mod room_state_cache;
@@ -13,7 +14,7 @@ use conduit::Result;
1314

1415
use self::{
1516
account_data::AccountDataCommand, appservice::AppserviceCommand, globals::GlobalsCommand,
16-
presence::PresenceCommand, resolver::ResolverCommand, room_alias::RoomAliasCommand,
17+
presence::PresenceCommand, pusher::PusherCommand, resolver::ResolverCommand, room_alias::RoomAliasCommand,
1718
room_state_cache::RoomStateCacheCommand, sending::SendingCommand, users::UsersCommand,
1819
};
1920
use crate::admin_command_dispatch;
@@ -57,4 +58,8 @@ pub(super) enum QueryCommand {
5758
/// - resolver service
5859
#[command(subcommand)]
5960
Resolver(ResolverCommand),
61+
62+
/// - pusher service
63+
#[command(subcommand)]
64+
Pusher(PusherCommand),
6065
}

src/admin/query/pusher.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use clap::Subcommand;
2+
use conduit::Result;
3+
use ruma::{events::room::message::RoomMessageEventContent, UserId};
4+
5+
use crate::Command;
6+
7+
#[derive(Debug, Subcommand)]
8+
pub(crate) enum PusherCommand {
9+
/// - Returns all the pushers for the user.
10+
GetPushers {
11+
/// Full user ID
12+
user_id: Box<UserId>,
13+
},
14+
}
15+
16+
pub(super) async fn process(subcommand: PusherCommand, context: &Command<'_>) -> Result<RoomMessageEventContent> {
17+
let services = context.services;
18+
19+
match subcommand {
20+
PusherCommand::GetPushers {
21+
user_id,
22+
} => {
23+
let timer = tokio::time::Instant::now();
24+
let results = services.pusher.get_pushers(&user_id)?;
25+
let query_time = timer.elapsed();
26+
27+
Ok(RoomMessageEventContent::notice_markdown(format!(
28+
"Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```"
29+
)))
30+
},
31+
}
32+
}

0 commit comments

Comments
 (0)