feat: Allow controlling client message filtering
This commit is contained in:
parent
c203c1fead
commit
dcbacb5b78
4 changed files with 90 additions and 32 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{Result, Server, implement};
|
||||
use conduwuit::{Result, implement};
|
||||
use ruma::ServerName;
|
||||
|
||||
use crate::{Dep, config};
|
||||
|
@ -10,7 +10,7 @@ pub struct Service {
|
|||
}
|
||||
|
||||
struct Services {
|
||||
pub server: Arc<Server>,
|
||||
// pub server: Arc<Server>,
|
||||
pub config: Dep<config::Service>,
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ impl crate::Service for Service {
|
|||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||
Ok(Arc::new(Self {
|
||||
services: Services {
|
||||
server: args.server.clone(),
|
||||
// server: args.server.clone(),
|
||||
config: args.depend::<config::Service>("config"),
|
||||
},
|
||||
}))
|
||||
|
@ -27,6 +27,20 @@ impl crate::Service for Service {
|
|||
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
#[must_use]
|
||||
pub fn is_remote_server_ignored(&self, server_name: &ServerName) -> bool {
|
||||
// We must never block federating with ourselves
|
||||
if server_name == self.services.config.server_name {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.services
|
||||
.config
|
||||
.ignore_messages_from_server_names
|
||||
.is_match(server_name.host())
|
||||
}
|
||||
|
||||
#[implement(Service)]
|
||||
#[must_use]
|
||||
pub fn is_remote_server_forbidden(&self, server_name: &ServerName) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue