1
0
Fork 0
mirror of https://forgejo.ellis.link/continuwuation/continuwuity.git synced 2025-07-27 18:28:31 +00:00

feat(policy-server): Soft-fail redactions for failed events

This commit is contained in:
nexy7574 2025-07-19 20:54:06 +01:00
parent 74d60f256b
commit 78b7175677
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F

View file

@ -222,9 +222,7 @@ where
} }
// 14-pre. If the event is not a state event, ask the policy server about it // 14-pre. If the event is not a state event, ask the policy server about it
if incoming_pdu.state_key.is_none() if incoming_pdu.state_key.is_none() {
&& incoming_pdu.sender().server_name() != self.services.globals.server_name()
{
debug!("Checking policy server for event {}", incoming_pdu.event_id); debug!("Checking policy server for event {}", incoming_pdu.event_id);
let policy = self.policyserv_check(&incoming_pdu, room_id); let policy = self.policyserv_check(&incoming_pdu, room_id);
if let Err(e) = policy.await { if let Err(e) = policy.await {
@ -236,6 +234,24 @@ where
debug!("Policy server check passed for event {}", incoming_pdu.event_id); 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, // 14. Check if the event passes auth based on the "current state" of the room,
// if not soft fail it // if not soft fail it
if soft_fail { if soft_fail {