diff --git a/src/service/globals/emerg_access.rs b/src/service/globals/emerg_access.rs index bda664d6..fdf803cf 100644 --- a/src/service/globals/emerg_access.rs +++ b/src/service/globals/emerg_access.rs @@ -1,9 +1,6 @@ use conduit::Result; use ruma::{ - events::{ - push_rules::PushRulesEventContent, room::message::RoomMessageEventContent, GlobalAccountDataEvent, - GlobalAccountDataEventType, - }, + events::{push_rules::PushRulesEventContent, GlobalAccountDataEvent, GlobalAccountDataEventType}, push::Ruleset, UserId, }; @@ -11,28 +8,11 @@ use tracing::{error, warn}; use crate::services; -pub(crate) async fn init_emergency_access() { - // Set emergency access for the conduit user - match set_emergency_access() { - Ok(pwd_set) => { - if pwd_set { - warn!( - "The Conduit account emergency password is set! Please unset it as soon as you finish admin \ - account recovery!" - ); - services() - .admin - .send_message(RoomMessageEventContent::text_plain( - "The Conduit account emergency password is set! Please unset it as soon as you finish admin \ - account recovery!", - )) - .await; - } - }, - Err(e) => { - error!("Could not set the configured emergency password for the conduit user: {}", e); - }, - }; +/// Set emergency access for the conduit user +pub(crate) fn init_emergency_access() { + if let Err(e) = set_emergency_access() { + error!("Could not set the configured emergency password for the conduit user: {e}"); + } } /// Sets the emergency password and push rules for the @conduit account in case @@ -45,9 +25,9 @@ fn set_emergency_access() -> Result { .users .set_password(&conduit_user, services().globals.emergency_password().as_deref())?; - let (ruleset, res) = match services().globals.emergency_password() { - Some(_) => (Ruleset::server_default(&conduit_user), Ok(true)), - None => (Ruleset::new(), Ok(false)), + let (ruleset, pwd_set) = match services().globals.emergency_password() { + Some(_) => (Ruleset::server_default(&conduit_user), true), + None => (Ruleset::new(), false), }; services().account_data.update( @@ -62,5 +42,12 @@ fn set_emergency_access() -> Result { .expect("to json value always works"), )?; - res + if pwd_set { + warn!( + "The Conduit account emergency password is set! Please unset it as soon as you finish admin account \ + recovery!" + ); + } + + Ok(pwd_set) } diff --git a/src/service/services.rs b/src/service/services.rs index 05894753..4883d574 100644 --- a/src/service/services.rs +++ b/src/service/services.rs @@ -276,14 +276,12 @@ bad_signature_ratelimiter: {bad_signature_ratelimiter} pub async fn start(&self) -> Result<()> { debug_info!("Starting services"); + globals::migrations::migrations(&self.db, &self.globals.config).await?; + globals::emerg_access::init_emergency_access(); self.admin.start_handler().await; - - globals::emerg_access::init_emergency_access().await; - self.sending.start_handler().await; - if self.globals.config.allow_local_presence { self.presence.start_handler().await; }