use single global function for server name local and user local checking

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-28 11:35:25 -04:00 committed by June
parent 8f17d965b2
commit 9931e60050
14 changed files with 77 additions and 41 deletions

View file

@ -13,7 +13,11 @@ use serde::{Deserialize, Serialize};
use tokio::{sync::Mutex, time::sleep};
use tracing::{debug, error};
use crate::{services, utils, Config, Error, Result};
use crate::{
services,
utils::{self, user_id::user_is_local},
Config, Error, Result,
};
/// Represents data required to be kept in order to implement the presence
/// specification.
@ -154,7 +158,7 @@ impl Service {
self.db
.set_presence(user_id, presence_state, currently_active, last_active_ago, status_msg)?;
if self.timeout_remote_users || user_id.server_name() == services().globals.server_name() {
if self.timeout_remote_users || user_is_local(user_id) {
let timeout = match presence_state {
PresenceState::Online => services().globals.config.presence_idle_timeout_s,
_ => services().globals.config.presence_offline_timeout_s,