perf: Avoid cloning incoming PDUs to check them

Also allows us to store signatures on PDUs received over federation that we got a fresh signature for
This commit is contained in:
timedout
2026-05-21 21:24:00 +01:00
parent 40cecca103
commit ae37f218a2
@@ -9,10 +9,8 @@ use conduwuit::{
Err, Err,
Result, Result,
}; };
use futures::{FutureExt, StreamExt, future::ready}; use futures::{future::ready, FutureExt, StreamExt};
use ruma::{ use ruma::{api::error::ErrorKind, events::StateEventType, CanonicalJsonObject, CanonicalJsonValue, RoomId, ServerName};
CanonicalJsonValue, RoomId, ServerName, api::error::ErrorKind, events::StateEventType,
};
use tokio::join; use tokio::join;
use super::get_room_version_rules; use super::get_room_version_rules;
@@ -25,7 +23,7 @@ use crate::rooms::{
pub(super) async fn upgrade_outlier_to_timeline_pdu<Pdu>( pub(super) async fn upgrade_outlier_to_timeline_pdu<Pdu>(
&self, &self,
incoming_pdu: PduEvent, incoming_pdu: PduEvent,
val: BTreeMap<String, CanonicalJsonValue>, mut val: CanonicalJsonObject,
create_event: &Pdu, create_event: &Pdu,
origin: &ServerName, origin: &ServerName,
room_id: &RoomId, room_id: &RoomId,
@@ -250,11 +248,10 @@ where
// no reason to re-calculate that. // no reason to re-calculate that.
// 14-pre. ask the policy server to sign the event, if possible // 14-pre. ask the policy server to sign the event, if possible
debug!(event_id = %incoming_pdu.event_id, "Checking policy server for event"); debug!(event_id = %incoming_pdu.event_id, "Checking policy server for event");
let mut mutable_object = incoming_pdu.to_canonical_object();
if let Err(e) = self if let Err(e) = self
.policy_server_allows_event( .policy_server_allows_event(
&incoming_pdu, &incoming_pdu,
&mut mutable_object, &mut val,
room_id, room_id,
&room_version_rules, &room_version_rules,
true, true,