From 85364a9c27b950a8de821726bc5406bde04713c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Fri, 1 Jan 2021 10:52:43 +0100 Subject: [PATCH] improvement: change federation_enabled to federation_disabled This enables federation by default --- src/database.rs | 2 +- src/database/globals.rs | 4 ++-- src/server_server.rs | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/database.rs b/src/database.rs index 84be5785..99ea9f5e 100644 --- a/src/database.rs +++ b/src/database.rs @@ -37,7 +37,7 @@ pub struct Config { #[serde(default)] encryption_disabled: bool, #[serde(default)] - federation_enabled: bool, + federation_disabled: bool, } fn default_cache_capacity() -> u64 { diff --git a/src/database/globals.rs b/src/database/globals.rs index 485650f2..5444d6ec 100644 --- a/src/database/globals.rs +++ b/src/database/globals.rs @@ -119,8 +119,8 @@ impl Globals { self.config.encryption_disabled } - pub fn federation_enabled(&self) -> bool { - self.config.federation_enabled + pub fn federation_disabled(&self) -> bool { + self.config.federation_disabled } pub fn dns_resolver(&self) -> &TokioAsyncResolver { diff --git a/src/server_server.rs b/src/server_server.rs index 87e986d5..88b6a01c 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -36,7 +36,7 @@ pub async fn send_request( where T: Debug, { - if !globals.federation_enabled() { + if globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); } @@ -322,7 +322,7 @@ pub async fn request_well_known( pub fn get_server_version_route( db: State<'_, Database>, ) -> ConduitResult { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); } @@ -337,7 +337,7 @@ pub fn get_server_version_route( #[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server"))] pub fn get_server_keys_route(db: State<'_, Database>) -> Json { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { // TODO: Use proper types return Json("Federation is disabled.".to_owned()); } @@ -390,7 +390,7 @@ pub async fn get_public_rooms_filtered_route( db: State<'_, Database>, body: Ruma>, ) -> ConduitResult { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); } @@ -437,7 +437,7 @@ pub async fn get_public_rooms_route( db: State<'_, Database>, body: Ruma>, ) -> ConduitResult { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); } @@ -484,7 +484,7 @@ pub async fn send_transaction_message_route<'a>( db: State<'a, Database>, body: Ruma>, ) -> ConduitResult { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); } @@ -587,7 +587,7 @@ pub fn get_missing_events_route<'a>( db: State<'a, Database>, body: Ruma>, ) -> ConduitResult { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); } @@ -632,7 +632,7 @@ pub fn get_profile_information_route<'a>( db: State<'a, Database>, body: Ruma>, ) -> ConduitResult { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); } @@ -666,7 +666,7 @@ pub fn get_user_devices_route<'a>( db: State<'a, Database>, body: Ruma>, ) -> ConduitResult { - if !db.globals.federation_enabled() { + if db.globals.federation_disabled() { return Err(Error::bad_config("Federation is disabled.")); }