mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
perf: Remove extraneous policy server check
This commit is contained in:
@@ -267,9 +267,9 @@ pub async fn create_hash_and_sign_event(
|
|||||||
| _ => Err!(Request(Unknown(warn!("Signing event failed: {e}")))),
|
| _ => Err!(Request(Unknown(warn!("Signing event failed: {e}")))),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Check with the policy server
|
|
||||||
// Generate event id
|
// Generate event id
|
||||||
pdu.event_id = gen_event_id(&pdu_json, &room_version_id)?;
|
pdu.event_id = gen_event_id(&pdu_json, &room_version_id)?;
|
||||||
|
// Check with the policy server
|
||||||
pdu_json.insert("event_id".into(), CanonicalJsonValue::String(pdu.event_id.clone().into()));
|
pdu_json.insert("event_id".into(), CanonicalJsonValue::String(pdu.event_id.clone().into()));
|
||||||
if room_id.is_some() {
|
if room_id.is_some() {
|
||||||
trace!(
|
trace!(
|
||||||
@@ -295,32 +295,6 @@ pub async fn create_hash_and_sign_event(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check with the policy server
|
|
||||||
if room_id.is_some() {
|
|
||||||
trace!(
|
|
||||||
"Checking event {} in room {} with policy server",
|
|
||||||
pdu.event_id,
|
|
||||||
pdu.room_id.as_ref().map_or("None", |id| id.as_str())
|
|
||||||
);
|
|
||||||
match self
|
|
||||||
.services
|
|
||||||
.event_handler
|
|
||||||
.ask_policy_server(&pdu, &pdu_json, &pdu.room_id_or_hash())
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
| Ok(true) => {},
|
|
||||||
| Ok(false) => {
|
|
||||||
return Err!(Request(Forbidden(debug_warn!(
|
|
||||||
"Policy server marked this event as spam"
|
|
||||||
))));
|
|
||||||
},
|
|
||||||
| Err(e) => {
|
|
||||||
// fail open
|
|
||||||
warn!("Failed to check event with policy server: {e}");
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate short event id
|
// Generate short event id
|
||||||
trace!(
|
trace!(
|
||||||
"Generating short event ID for {} in room {}",
|
"Generating short event ID for {} in room {}",
|
||||||
|
|||||||
Reference in New Issue
Block a user