mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-16 05:36:50 +00:00
refactor: Ruma upstreaming, half-baked edition
Co-authored-by: Jade Ellis <jade@ellis.link>
This commit is contained in:
141 files changed
+2714
-2278
No files matched your search
+30
-15
@@ -19,7 +19,7 @@ use conduwuit::{
|
||||
warn,
|
||||
};
|
||||
use futures::{FutureExt, Stream, StreamExt};
|
||||
use ruma::{RoomId, ServerName, UserId, api::OutgoingRequest};
|
||||
use ruma::{OwnedServerName, RoomId, ServerName, UserId, api::{OutgoingRequest, auth_scheme::NoAuthentication, federation::authentication::ServerSignatures, path_builder::PathBuilder}};
|
||||
use tokio::{task, task::JoinSet};
|
||||
|
||||
use self::data::Data;
|
||||
@@ -28,8 +28,8 @@ pub use self::{
|
||||
sender::{EDU_LIMIT, PDU_LIMIT},
|
||||
};
|
||||
use crate::{
|
||||
Dep, account_data, client, federation, globals, presence, pusher, rooms,
|
||||
rooms::timeline::RawPduId, users,
|
||||
Dep, account_data, client, federation::{self, FederationPathBuilderInput}, globals, presence, pusher, rooms::{self, timeline::RawPduId},
|
||||
users,
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
@@ -187,9 +187,9 @@ impl Service {
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, servers, pdu_id), level = "debug")]
|
||||
pub async fn send_pdu_servers<'a, S>(&self, servers: S, pdu_id: &RawPduId) -> Result
|
||||
pub async fn send_pdu_servers<S>(&self, servers: S, pdu_id: &RawPduId) -> Result
|
||||
where
|
||||
S: Stream<Item = &'a ServerName> + Send + 'a,
|
||||
S: Stream<Item = OwnedServerName> + Send,
|
||||
{
|
||||
let requests = servers
|
||||
.map(|server| {
|
||||
@@ -233,14 +233,14 @@ impl Service {
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, servers, serialized), level = "debug")]
|
||||
pub async fn send_edu_servers<'a, S>(&self, servers: S, serialized: EduBuf) -> Result
|
||||
pub async fn send_edu_servers<S>(&self, servers: S, serialized: EduBuf) -> Result
|
||||
where
|
||||
S: Stream<Item = &'a ServerName> + Send + 'a,
|
||||
S: Stream<Item = OwnedServerName> + Send,
|
||||
{
|
||||
let requests = servers
|
||||
.map(|server| {
|
||||
(
|
||||
Destination::Federation(server.to_owned()),
|
||||
Destination::Federation(server),
|
||||
SendingEvent::Edu(serialized.clone()),
|
||||
)
|
||||
})
|
||||
@@ -269,12 +269,11 @@ impl Service {
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, servers), level = "debug")]
|
||||
pub async fn flush_servers<'a, S>(&self, servers: S) -> Result<()>
|
||||
pub async fn flush_servers<S>(&self, servers: S) -> Result<()>
|
||||
where
|
||||
S: Stream<Item = &'a ServerName> + Send + 'a,
|
||||
S: Stream<Item = OwnedServerName> + Send,
|
||||
{
|
||||
servers
|
||||
.map(ToOwned::to_owned)
|
||||
.map(Destination::Federation)
|
||||
.map(Ok)
|
||||
.ready_try_for_each(|dest| {
|
||||
@@ -289,26 +288,26 @@ impl Service {
|
||||
|
||||
/// Sends a request to a federation server
|
||||
#[inline]
|
||||
pub async fn send_federation_request<T>(
|
||||
pub async fn send_federation_request<'i, T>(
|
||||
&self,
|
||||
dest: &ServerName,
|
||||
request: T,
|
||||
) -> Result<T::IncomingResponse>
|
||||
where
|
||||
T: OutgoingRequest + Debug + Send,
|
||||
T: OutgoingRequest::<Authentication = ServerSignatures, PathBuilder: PathBuilder<Input<'i>: FederationPathBuilderInput>> + 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>(
|
||||
pub async fn send_synapse_request<'i, T>(
|
||||
&self,
|
||||
dest: &ServerName,
|
||||
request: T,
|
||||
) -> Result<T::IncomingResponse>
|
||||
where
|
||||
T: OutgoingRequest + Debug + Send,
|
||||
T: OutgoingRequest::<Authentication = ServerSignatures, PathBuilder: PathBuilder<Input<'i>: FederationPathBuilderInput>> + Debug + Send,
|
||||
{
|
||||
self.services
|
||||
.federation
|
||||
@@ -316,6 +315,22 @@ impl Service {
|
||||
.await
|
||||
}
|
||||
|
||||
/// Send an unauthenticated federation request with no X-Matrix header.
|
||||
#[inline]
|
||||
pub async fn send_unauthenticated_request<'i, T>(
|
||||
&self,
|
||||
dest: &ServerName,
|
||||
request: T,
|
||||
) -> Result<T::IncomingResponse>
|
||||
where
|
||||
T: OutgoingRequest::<Authentication = NoAuthentication, PathBuilder: PathBuilder<Input<'i>: FederationPathBuilderInput>> + Debug + Send,
|
||||
{
|
||||
self.services
|
||||
.federation
|
||||
.execute_unauthenticated(dest, request)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Clean up queued sending event data
|
||||
///
|
||||
/// Used after we remove an appservice registration or a user deletes a push
|
||||
|
||||
Reference in new issue
Block a user