From f32f60d0567388cc5af3b2f5258bbb5c8da341e3 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Wed, 23 Jul 2025 18:01:46 +0100 Subject: [PATCH] fix(policy-server): Return the correct result when an event is marked as spam --- src/service/rooms/event_handler/policy_server.rs | 5 +++-- src/service/rooms/event_handler/upgrade_outlier_pdu.rs | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/service/rooms/event_handler/policy_server.rs b/src/service/rooms/event_handler/policy_server.rs index 2068dff7..80cb40f2 100644 --- a/src/service/rooms/event_handler/policy_server.rs +++ b/src/service/rooms/event_handler/policy_server.rs @@ -21,7 +21,8 @@ use ruma::{ /// /// If the policy server marks the event as spam, Ok(false) is returned, /// otherwise Ok(true) allows the event. If the policy server cannot be -/// contacted for whatever reason, Err(e) is returned. +/// contacted for whatever reason, Err(e) is returned, which generally is a +/// fail-open operation. #[implement(super::Service)] #[tracing::instrument(skip_all, level = "debug")] pub async fn ask_policy_server(&self, pdu: &PduEvent, room_id: &RoomId) -> Result { @@ -113,7 +114,7 @@ pub async fn ask_policy_server(&self, pdu: &PduEvent, room_id: &RoomId) -> Resul room_id = %room_id, "Event was marked as spam by policy server", ); - return Err!(Request(Forbidden("Event was marked as spam by policy server"))); + return Ok(false); } Ok(true) diff --git a/src/service/rooms/event_handler/upgrade_outlier_pdu.rs b/src/service/rooms/event_handler/upgrade_outlier_pdu.rs index 17a72f8c..d2e0623c 100644 --- a/src/service/rooms/event_handler/upgrade_outlier_pdu.rs +++ b/src/service/rooms/event_handler/upgrade_outlier_pdu.rs @@ -269,7 +269,11 @@ where } // Additionally, if this is a redaction for a soft-failed event, we soft-fail it - // also + // also. + + // TODO: this is supposed to hide redactions from policy servers, however, for + // full efficacy it also needs to hide redactions for unknown events. This + // needs to be investigated at a later time. if let Some(redact_id) = incoming_pdu.redacts_id(&room_version_id) { debug!( redact_id = %redact_id,