From 8257d0447a936aa74d04f9f5d5800d609fb9c25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kub=C3=ADk?= Date: Wed, 7 Dec 2022 18:43:27 +0100 Subject: [PATCH] fix(presence): check for allow_presence only after services are available --- src/database/key_value/rooms/edus/presence.rs | 8 ++++++++ src/service/rooms/edus/presence/mod.rs | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/database/key_value/rooms/edus/presence.rs b/src/database/key_value/rooms/edus/presence.rs index 5c49b95a..7732983a 100644 --- a/src/database/key_value/rooms/edus/presence.rs +++ b/src/database/key_value/rooms/edus/presence.rs @@ -210,6 +210,10 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase { // Wait for services to be created sleep(Duration::from_secs(15)).await; + if !services().globals.allow_presence() { + return; + } + let idle_timeout = Duration::from_secs(services().globals.presence_idle_timeout()); let offline_timeout = Duration::from_secs(services().globals.presence_offline_timeout()); @@ -296,6 +300,10 @@ impl service::rooms::edus::presence::Data for KeyValueDatabase { // Wait for services to be created sleep(Duration::from_secs(15)).await; + if !services().globals.allow_presence() { + return; + } + let period = Duration::from_secs(services().globals.presence_cleanup_period()); let age_limit = Duration::from_secs(services().globals.presence_cleanup_limit()); diff --git a/src/service/rooms/edus/presence/mod.rs b/src/service/rooms/edus/presence/mod.rs index 38e0f022..0f3421c9 100644 --- a/src/service/rooms/edus/presence/mod.rs +++ b/src/service/rooms/edus/presence/mod.rs @@ -114,18 +114,10 @@ impl Service { &self, timer_receiver: mpsc::UnboundedReceiver, ) -> Result<()> { - if !services().globals.allow_presence() { - return Ok(()); - } - self.db.presence_maintain(timer_receiver) } fn presence_cleanup(&self) -> Result<()> { - if !services().globals.allow_presence() { - return Ok(()); - } - self.db.presence_cleanup() }