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:
parent
cc9202b0c4
commit
d7fa624fd2
2 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue