|
|
|
@ -2,7 +2,7 @@ use crate::{client_server, utils, ConduitResult, Database, Error, PduEvent, Resu |
|
|
|
use http::header::{HeaderValue, AUTHORIZATION, HOST}; |
|
|
|
use http::header::{HeaderValue, AUTHORIZATION, HOST}; |
|
|
|
use log::{info, warn}; |
|
|
|
use log::{info, warn}; |
|
|
|
use regex::Regex; |
|
|
|
use regex::Regex; |
|
|
|
use rocket::{get, post, put, response::content::Json, State}; |
|
|
|
use rocket::{response::content::Json, State}; |
|
|
|
use ruma::{ |
|
|
|
use ruma::{ |
|
|
|
api::{ |
|
|
|
api::{ |
|
|
|
federation::{ |
|
|
|
federation::{ |
|
|
|
@ -28,6 +28,10 @@ use std::{ |
|
|
|
net::{IpAddr, SocketAddr}, |
|
|
|
net::{IpAddr, SocketAddr}, |
|
|
|
time::{Duration, SystemTime}, |
|
|
|
time::{Duration, SystemTime}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
#[cfg(feature = "conduit_bin")] |
|
|
|
|
|
|
|
use { |
|
|
|
|
|
|
|
rocket::{get, post, put} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#[tracing::instrument(skip(globals))] |
|
|
|
#[tracing::instrument(skip(globals))] |
|
|
|
pub async fn send_request<T: OutgoingRequest>( |
|
|
|
pub async fn send_request<T: OutgoingRequest>( |
|
|
|
@ -553,6 +557,12 @@ pub async fn send_transaction_message_route<'a>( |
|
|
|
// TODO: redact event if hashing fails
|
|
|
|
// TODO: redact event if hashing fails
|
|
|
|
let (event_id, value) = crate::pdu::process_incoming_pdu(pdu); |
|
|
|
let (event_id, value) = crate::pdu::process_incoming_pdu(pdu); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the pdu if we already know about it
|
|
|
|
|
|
|
|
if db.rooms.get_pdu_id(&event_id)?.is_some() { |
|
|
|
|
|
|
|
resolved_map.insert(event_id, Err("We already know about this event".into())); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let pdu = serde_json::from_value::<PduEvent>( |
|
|
|
let pdu = serde_json::from_value::<PduEvent>( |
|
|
|
serde_json::to_value(&value).expect("CanonicalJsonObj is a valid JsonValue"), |
|
|
|
serde_json::to_value(&value).expect("CanonicalJsonObj is a valid JsonValue"), |
|
|
|
) |
|
|
|
) |
|
|
|
@ -583,7 +593,7 @@ pub async fn send_transaction_message_route<'a>( |
|
|
|
.get("users") |
|
|
|
.get("users") |
|
|
|
.and_then(|users| users.as_sequence()) |
|
|
|
.and_then(|users| users.as_sequence()) |
|
|
|
.map_or_else( |
|
|
|
.map_or_else( |
|
|
|
|| Vec::new(), |
|
|
|
Vec::new, |
|
|
|
|users| { |
|
|
|
|users| { |
|
|
|
users |
|
|
|
users |
|
|
|
.iter() |
|
|
|
.iter() |
|
|
|
@ -615,7 +625,7 @@ pub async fn send_transaction_message_route<'a>( |
|
|
|
.and_then(|string| { |
|
|
|
.and_then(|string| { |
|
|
|
UserId::parse_with_server_name(string, db.globals.server_name()).ok() |
|
|
|
UserId::parse_with_server_name(string, db.globals.server_name()).ok() |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
#[allow(clippy::blocks_in_if_conditions)] |
|
|
|
if bridge_user_id.map_or(false, |bridge_user_id| { |
|
|
|
if bridge_user_id.map_or(false, |bridge_user_id| { |
|
|
|
db.rooms |
|
|
|
db.rooms |
|
|
|
.is_joined(&bridge_user_id, room_id) |
|
|
|
.is_joined(&bridge_user_id, room_id) |
|
|
|
|