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): Optimise policy server lookups

This commit is contained in:
nexy7574 2025-07-19 23:50:32 +01:00 committed by Jade Ellis
parent 586075f6fc
commit 58afce3ba3
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
2 changed files with 14 additions and 0 deletions

View file

@ -11,6 +11,10 @@ use ruma::{
#[implement(super::Service)]
#[tracing::instrument(skip_all, level = "debug")]
pub async fn policyserv_check(&self, pdu: &PduEvent, room_id: &RoomId) -> Result {
if pdu.event_type().to_owned() == StateEventType::RoomPolicy.into() {
debug!("Skipping spam check for policy server meta-event in room {room_id}");
return Ok(());
}
let Ok(policyserver) = self
.services
.state_accessor
@ -28,6 +32,14 @@ pub async fn policyserv_check(&self, pdu: &PduEvent, room_id: &RoomId) -> Result
return Ok(());
},
};
if via.is_empty() {
debug!("Policy server is empty for room {room_id}, skipping spam check");
return Ok(());
}
if !self.services.state_cache.server_in_room(via, room_id).await {
debug!("Policy server {via} is not in the room {room_id}, skipping spam check");
return Ok(());
}
let outgoing = self
.services
.sending

View file

@ -38,6 +38,7 @@ struct Services {
server_keys: Dep<server_keys::Service>,
short: Dep<rooms::short::Service>,
state: Dep<rooms::state::Service>,
state_cache: Dep<rooms::state_cache::Service>,
state_accessor: Dep<rooms::state_accessor::Service>,
state_compressor: Dep<rooms::state_compressor::Service>,
timeline: Dep<rooms::timeline::Service>,
@ -63,6 +64,7 @@ impl crate::Service for Service {
pdu_metadata: args.depend::<rooms::pdu_metadata::Service>("rooms::pdu_metadata"),
short: args.depend::<rooms::short::Service>("rooms::short"),
state: args.depend::<rooms::state::Service>("rooms::state"),
state_cache: args.depend::<rooms::state_cache::Service>("rooms::state_cache"),
state_accessor: args
.depend::<rooms::state_accessor::Service>("rooms::state_accessor"),
state_compressor: args