Replace calls through sender request interface.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-11-25 08:49:49 +00:00
parent 71f3ccf140
commit 8bb0d02619
23 changed files with 119 additions and 197 deletions

View File

@@ -11,10 +11,7 @@ use std::{
use async_trait::async_trait;
use futures::{FutureExt, Stream, StreamExt};
use ruma::{
RoomId, ServerName, UserId,
api::{OutgoingRequest, appservice::Registration},
};
use ruma::{RoomId, ServerName, UserId};
use tokio::{task, task::JoinSet};
use tuwunel_core::{
Result, Server, debug, debug_warn, err, error,
@@ -28,7 +25,7 @@ pub use self::{
dest::Destination,
sender::{EDU_LIMIT, PDU_LIMIT},
};
use crate::{appservice, rooms::timeline::RawPduId};
use crate::rooms::timeline::RawPduId;
pub struct Service {
pub db: Data,
@@ -270,54 +267,6 @@ impl Service {
.await
}
/// Sends a request to a federation server
#[inline]
pub async fn send_federation_request<T>(
&self,
dest: &ServerName,
request: T,
) -> Result<T::IncomingResponse>
where
T: OutgoingRequest + Debug + Send,
{
self.services
.federation
.execute(dest, request)
.await
}
/// Like send_federation_request() but with a very large timeout
#[inline]
pub async fn send_synapse_request<T>(
&self,
dest: &ServerName,
request: T,
) -> Result<T::IncomingResponse>
where
T: OutgoingRequest + Debug + Send,
{
self.services
.federation
.execute_synapse(dest, request)
.await
}
/// Sends a request to an appservice
///
/// Only returns None if there is no url specified in the appservice
/// registration file
pub async fn send_appservice_request<T>(
&self,
registration: Registration,
request: T,
) -> Result<Option<T::IncomingResponse>>
where
T: OutgoingRequest + Debug + Send,
{
let client = &self.services.client.appservice;
appservice::send_request(client, registration, request).await
}
/// Clean up queued sending event data
///
/// Used after we remove an appservice registration or a user deletes a push

View File

@@ -51,7 +51,6 @@ use tuwunel_core::{
};
use super::{Destination, EduBuf, EduVec, Msg, SendingEvent, Service, data::QueueItem};
use crate::appservice;
#[derive(Debug)]
enum TransactionStatus {
@@ -759,18 +758,16 @@ impl Service {
//debug_assert!(pdu_jsons.len() + edu_jsons.len() > 0, "sending empty
// transaction");
let client = &self.services.client.appservice;
match appservice::send_request(
client,
appservice,
ruma::api::appservice::event::push_events::v1::Request {
match self
.services
.appservice
.send_request(appservice, ruma::api::appservice::event::push_events::v1::Request {
txn_id: txn_id.into(),
events: pdu_jsons,
ephemeral: edu_jsons,
to_device: Vec::new(), // TODO
},
)
.await
})
.await
{
| Ok(_) => Ok(Destination::Appservice(id)),
| Err(e) => Err((Destination::Appservice(id), e)),