add db query command to get all pushers for a user
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
e9e5fe2176
commit
032b199129
2 changed files with 38 additions and 1 deletions
|
@ -2,6 +2,7 @@ mod account_data;
|
||||||
mod appservice;
|
mod appservice;
|
||||||
mod globals;
|
mod globals;
|
||||||
mod presence;
|
mod presence;
|
||||||
|
mod pusher;
|
||||||
mod resolver;
|
mod resolver;
|
||||||
mod room_alias;
|
mod room_alias;
|
||||||
mod room_state_cache;
|
mod room_state_cache;
|
||||||
|
@ -13,7 +14,7 @@ use conduit::Result;
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
account_data::AccountDataCommand, appservice::AppserviceCommand, globals::GlobalsCommand,
|
account_data::AccountDataCommand, appservice::AppserviceCommand, globals::GlobalsCommand,
|
||||||
presence::PresenceCommand, resolver::ResolverCommand, room_alias::RoomAliasCommand,
|
presence::PresenceCommand, pusher::PusherCommand, resolver::ResolverCommand, room_alias::RoomAliasCommand,
|
||||||
room_state_cache::RoomStateCacheCommand, sending::SendingCommand, users::UsersCommand,
|
room_state_cache::RoomStateCacheCommand, sending::SendingCommand, users::UsersCommand,
|
||||||
};
|
};
|
||||||
use crate::admin_command_dispatch;
|
use crate::admin_command_dispatch;
|
||||||
|
@ -57,4 +58,8 @@ pub(super) enum QueryCommand {
|
||||||
/// - resolver service
|
/// - resolver service
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
Resolver(ResolverCommand),
|
Resolver(ResolverCommand),
|
||||||
|
|
||||||
|
/// - pusher service
|
||||||
|
#[command(subcommand)]
|
||||||
|
Pusher(PusherCommand),
|
||||||
}
|
}
|
||||||
|
|
32
src/admin/query/pusher.rs
Normal file
32
src/admin/query/pusher.rs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
use clap::Subcommand;
|
||||||
|
use conduit::Result;
|
||||||
|
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>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) async fn process(subcommand: PusherCommand, context: &Command<'_>) -> Result<RoomMessageEventContent> {
|
||||||
|
let services = context.services;
|
||||||
|
|
||||||
|
match subcommand {
|
||||||
|
PusherCommand::GetPushers {
|
||||||
|
user_id,
|
||||||
|
} => {
|
||||||
|
let timer = tokio::time::Instant::now();
|
||||||
|
let results = services.pusher.get_pushers(&user_id)?;
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
|
Ok(RoomMessageEventContent::notice_markdown(format!(
|
||||||
|
"Query completed in {query_time:?}:\n\n```rs\n{results:#?}\n```"
|
||||||
|
)))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue