From 78b71756774df37d5f5da831cd5228e8d7fe59bd Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Sat, 19 Jul 2025 20:54:06 +0100 Subject: [PATCH] feat(policy-server): Soft-fail redactions for failed events --- .../event_handler/upgrade_outlier_pdu.rs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/service/rooms/event_handler/upgrade_outlier_pdu.rs b/src/service/rooms/event_handler/upgrade_outlier_pdu.rs index abb5c116..e8e22fe9 100644 --- a/src/service/rooms/event_handler/upgrade_outlier_pdu.rs +++ b/src/service/rooms/event_handler/upgrade_outlier_pdu.rs @@ -222,9 +222,7 @@ where } // 14-pre. If the event is not a state event, ask the policy server about it - if incoming_pdu.state_key.is_none() - && incoming_pdu.sender().server_name() != self.services.globals.server_name() - { + if incoming_pdu.state_key.is_none() { debug!("Checking policy server for event {}", incoming_pdu.event_id); let policy = self.policyserv_check(&incoming_pdu, room_id); if let Err(e) = policy.await { @@ -236,6 +234,24 @@ where debug!("Policy server check passed for event {}", incoming_pdu.event_id); } + // Additionally, if this is a redaction for a soft-failed event, we soft-fail it + // also + if let Some(redact_id) = incoming_pdu.redacts_id(&room_version_id) { + debug!("Checking if redaction {} is for a soft-failed event", redact_id); + if self + .services + .pdu_metadata + .is_event_soft_failed(&redact_id) + .await + { + warn!( + "Redaction {} is for a soft-failed event, soft failing the redaction", + redact_id + ); + soft_fail = true; + } + } + // 14. Check if the event passes auth based on the "current state" of the room, // if not soft fail it if soft_fail {