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

feat(policy-server): Prevent local events that fail the policy check

This commit is contained in:
nexy7574 2025-07-19 21:09:23 +01:00
parent 78b7175677
commit a3d62ed0d9
No known key found for this signature in database
GPG key ID: 0FA334385D0B689F

View file

@ -165,6 +165,17 @@ pub async fn create_hash_and_sign_event(
return Err!(Request(Forbidden("Event is not authorized."))); return Err!(Request(Forbidden("Event is not authorized.")));
} }
// Check with the policy server
if self
.services
.event_handler
.policyserv_check(&pdu, room_id)
.await
.is_err()
{
return Err!(Request(Forbidden(debug_warn!("Policy server marked this event as spam"))));
}
// Hash and sign // Hash and sign
let mut pdu_json = utils::to_canonical_object(&pdu).map_err(|e| { let mut pdu_json = utils::to_canonical_object(&pdu).map_err(|e| {
err!(Request(BadJson(warn!("Failed to convert PDU to canonical JSON: {e}")))) err!(Request(BadJson(warn!("Failed to convert PDU to canonical JSON: {e}"))))