tuwunel_service/sending/
queue.rs1use ruma::OwnedUserId;
2use tokio::sync::oneshot::{Sender, channel};
3use tuwunel_core::{Result, err, implement};
4
5use super::{Destination, Service};
6
7pub(super) struct Control {
8 pub dest: Destination,
9 pub drop: bool,
10 pub done: Sender<Result>,
11}
12
13#[implement(Service)]
19pub async fn drop_push_queue(&self, user_id: OwnedUserId, pushkey: String) -> Result {
20 self.control_push_queue(user_id, pushkey, true)
21 .await
22}
23
24#[implement(Service)]
29pub async fn retry_push_queue(&self, user_id: OwnedUserId, pushkey: String) -> Result {
30 self.control_push_queue(user_id, pushkey, false)
31 .await
32}
33
34#[implement(Service)]
35async fn control_push_queue(&self, user_id: OwnedUserId, pushkey: String, drop: bool) -> Result {
36 let dest = Destination::Push(user_id, pushkey);
37 let shard = self.shard_id(&dest);
38 let (done, response) = channel();
39
40 self.controls[shard]
41 .0
42 .send(Control { dest, drop, done })
43 .map_err(|e| err!("{e}"))?;
44
45 response.await.map_err(|e| err!("{e}"))?
46}