eliminate references to services.globals.config
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
7c6b8b132a
commit
5be07ebc0f
26 changed files with 116 additions and 114 deletions
|
@ -7,7 +7,7 @@ use std::{
|
|||
time::Instant,
|
||||
};
|
||||
|
||||
use conduwuit::{error, utils::bytes::pretty, Config, Result};
|
||||
use conduwuit::{error, utils::bytes::pretty, Result, Server};
|
||||
use data::Data;
|
||||
use regex::RegexSet;
|
||||
use ruma::{OwnedEventId, OwnedRoomAliasId, OwnedServerName, OwnedUserId, ServerName, UserId};
|
||||
|
@ -16,8 +16,8 @@ use crate::service;
|
|||
|
||||
pub struct Service {
|
||||
pub db: Data,
|
||||
server: Arc<Server>,
|
||||
|
||||
pub config: Config,
|
||||
pub bad_event_ratelimiter: Arc<RwLock<HashMap<OwnedEventId, RateLimitState>>>,
|
||||
pub server_user: OwnedUserId,
|
||||
pub admin_alias: OwnedRoomAliasId,
|
||||
|
@ -57,9 +57,9 @@ impl crate::Service for Service {
|
|||
},
|
||||
);
|
||||
|
||||
let mut s = Self {
|
||||
Ok(Arc::new(Self {
|
||||
db,
|
||||
config: config.clone(),
|
||||
server: args.server.clone(),
|
||||
bad_event_ratelimiter: Arc::new(RwLock::new(HashMap::new())),
|
||||
admin_alias: OwnedRoomAliasId::try_from(format!("#admins:{}", &config.server_name))
|
||||
.expect("#admins:server_name is valid alias name"),
|
||||
|
@ -70,9 +70,7 @@ impl crate::Service for Service {
|
|||
.expect("@conduit:server_name is valid"),
|
||||
turn_secret,
|
||||
registration_token,
|
||||
};
|
||||
|
||||
Ok(Arc::new(s))
|
||||
}))
|
||||
}
|
||||
|
||||
fn memory_usage(&self, out: &mut dyn Write) -> Result {
|
||||
|
@ -109,93 +107,97 @@ impl Service {
|
|||
pub fn current_count(&self) -> Result<u64> { Ok(self.db.current_count()) }
|
||||
|
||||
#[inline]
|
||||
pub fn server_name(&self) -> &ServerName { self.config.server_name.as_ref() }
|
||||
pub fn server_name(&self) -> &ServerName { self.server.config.server_name.as_ref() }
|
||||
|
||||
pub fn allow_registration(&self) -> bool { self.config.allow_registration }
|
||||
pub fn allow_registration(&self) -> bool { self.server.config.allow_registration }
|
||||
|
||||
pub fn allow_guest_registration(&self) -> bool { self.config.allow_guest_registration }
|
||||
pub fn allow_guest_registration(&self) -> bool { self.server.config.allow_guest_registration }
|
||||
|
||||
pub fn allow_guests_auto_join_rooms(&self) -> bool {
|
||||
self.config.allow_guests_auto_join_rooms
|
||||
self.server.config.allow_guests_auto_join_rooms
|
||||
}
|
||||
|
||||
pub fn log_guest_registrations(&self) -> bool { self.config.log_guest_registrations }
|
||||
pub fn log_guest_registrations(&self) -> bool { self.server.config.log_guest_registrations }
|
||||
|
||||
pub fn allow_encryption(&self) -> bool { self.config.allow_encryption }
|
||||
pub fn allow_encryption(&self) -> bool { self.server.config.allow_encryption }
|
||||
|
||||
pub fn allow_federation(&self) -> bool { self.config.allow_federation }
|
||||
pub fn allow_federation(&self) -> bool { self.server.config.allow_federation }
|
||||
|
||||
pub fn allow_public_room_directory_over_federation(&self) -> bool {
|
||||
self.config.allow_public_room_directory_over_federation
|
||||
self.server
|
||||
.config
|
||||
.allow_public_room_directory_over_federation
|
||||
}
|
||||
|
||||
pub fn allow_device_name_federation(&self) -> bool {
|
||||
self.config.allow_device_name_federation
|
||||
self.server.config.allow_device_name_federation
|
||||
}
|
||||
|
||||
pub fn allow_room_creation(&self) -> bool { self.config.allow_room_creation }
|
||||
pub fn allow_room_creation(&self) -> bool { self.server.config.allow_room_creation }
|
||||
|
||||
pub fn new_user_displayname_suffix(&self) -> &String {
|
||||
&self.config.new_user_displayname_suffix
|
||||
&self.server.config.new_user_displayname_suffix
|
||||
}
|
||||
|
||||
pub fn allow_check_for_updates(&self) -> bool { self.config.allow_check_for_updates }
|
||||
pub fn allow_check_for_updates(&self) -> bool { self.server.config.allow_check_for_updates }
|
||||
|
||||
pub fn trusted_servers(&self) -> &[OwnedServerName] { &self.config.trusted_servers }
|
||||
pub fn trusted_servers(&self) -> &[OwnedServerName] { &self.server.config.trusted_servers }
|
||||
|
||||
pub fn turn_password(&self) -> &String { &self.config.turn_password }
|
||||
pub fn turn_password(&self) -> &String { &self.server.config.turn_password }
|
||||
|
||||
pub fn turn_ttl(&self) -> u64 { self.config.turn_ttl }
|
||||
pub fn turn_ttl(&self) -> u64 { self.server.config.turn_ttl }
|
||||
|
||||
pub fn turn_uris(&self) -> &[String] { &self.config.turn_uris }
|
||||
pub fn turn_uris(&self) -> &[String] { &self.server.config.turn_uris }
|
||||
|
||||
pub fn turn_username(&self) -> &String { &self.config.turn_username }
|
||||
pub fn turn_username(&self) -> &String { &self.server.config.turn_username }
|
||||
|
||||
pub fn notification_push_path(&self) -> &String { &self.config.notification_push_path }
|
||||
pub fn notification_push_path(&self) -> &String { &self.server.config.notification_push_path }
|
||||
|
||||
pub fn emergency_password(&self) -> &Option<String> { &self.config.emergency_password }
|
||||
pub fn emergency_password(&self) -> &Option<String> { &self.server.config.emergency_password }
|
||||
|
||||
pub fn url_preview_domain_contains_allowlist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_domain_contains_allowlist
|
||||
&self.server.config.url_preview_domain_contains_allowlist
|
||||
}
|
||||
|
||||
pub fn url_preview_domain_explicit_allowlist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_domain_explicit_allowlist
|
||||
&self.server.config.url_preview_domain_explicit_allowlist
|
||||
}
|
||||
|
||||
pub fn url_preview_domain_explicit_denylist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_domain_explicit_denylist
|
||||
&self.server.config.url_preview_domain_explicit_denylist
|
||||
}
|
||||
|
||||
pub fn url_preview_url_contains_allowlist(&self) -> &Vec<String> {
|
||||
&self.config.url_preview_url_contains_allowlist
|
||||
&self.server.config.url_preview_url_contains_allowlist
|
||||
}
|
||||
|
||||
pub fn url_preview_max_spider_size(&self) -> usize { self.config.url_preview_max_spider_size }
|
||||
pub fn url_preview_max_spider_size(&self) -> usize {
|
||||
self.server.config.url_preview_max_spider_size
|
||||
}
|
||||
|
||||
pub fn url_preview_check_root_domain(&self) -> bool {
|
||||
self.config.url_preview_check_root_domain
|
||||
self.server.config.url_preview_check_root_domain
|
||||
}
|
||||
|
||||
pub fn forbidden_alias_names(&self) -> &RegexSet { &self.config.forbidden_alias_names }
|
||||
pub fn forbidden_alias_names(&self) -> &RegexSet { &self.server.config.forbidden_alias_names }
|
||||
|
||||
pub fn forbidden_usernames(&self) -> &RegexSet { &self.config.forbidden_usernames }
|
||||
pub fn forbidden_usernames(&self) -> &RegexSet { &self.server.config.forbidden_usernames }
|
||||
|
||||
pub fn allow_local_presence(&self) -> bool { self.config.allow_local_presence }
|
||||
pub fn allow_local_presence(&self) -> bool { self.server.config.allow_local_presence }
|
||||
|
||||
pub fn allow_incoming_presence(&self) -> bool { self.config.allow_incoming_presence }
|
||||
pub fn allow_incoming_presence(&self) -> bool { self.server.config.allow_incoming_presence }
|
||||
|
||||
pub fn allow_outgoing_presence(&self) -> bool { self.config.allow_outgoing_presence }
|
||||
pub fn allow_outgoing_presence(&self) -> bool { self.server.config.allow_outgoing_presence }
|
||||
|
||||
pub fn allow_incoming_read_receipts(&self) -> bool {
|
||||
self.config.allow_incoming_read_receipts
|
||||
self.server.config.allow_incoming_read_receipts
|
||||
}
|
||||
|
||||
pub fn allow_outgoing_read_receipts(&self) -> bool {
|
||||
self.config.allow_outgoing_read_receipts
|
||||
self.server.config.allow_outgoing_read_receipts
|
||||
}
|
||||
|
||||
pub fn block_non_admin_invites(&self) -> bool { self.config.block_non_admin_invites }
|
||||
pub fn block_non_admin_invites(&self) -> bool { self.server.config.block_non_admin_invites }
|
||||
|
||||
/// checks if `user_id` is local to us via server_name comparison
|
||||
#[inline]
|
||||
|
@ -205,7 +207,7 @@ impl Service {
|
|||
|
||||
#[inline]
|
||||
pub fn server_is_ours(&self, server_name: &ServerName) -> bool {
|
||||
server_name == self.config.server_name
|
||||
server_name == self.server.config.server_name
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue