-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add db query command to get all pushers for a user
Signed-off-by: strawberry <[email protected]>
- Loading branch information
1 parent
e9e5fe2
commit 032b199
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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```" | ||
))) | ||
}, | ||
} | ||
} |