From c896acb7298028e4c182c684f81daba90e25bf94 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sat, 27 Jul 2024 19:09:31 -0400 Subject: [PATCH] dont consider presence status changes apart of presence spam Signed-off-by: strawberry --- src/service/presence/data.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/service/presence/data.rs b/src/service/presence/data.rs index 1a0293de..ec036b3d 100644 --- a/src/service/presence/data.rs +++ b/src/service/presence/data.rs @@ -61,6 +61,22 @@ impl Data { Some(ref presence) => presence.1.content.presence != *presence_state, }; + let status_msg_changed = match last_presence { + None => true, + Some(ref last_presence) => { + let old_msg = last_presence + .1 + .content + .status_msg + .clone() + .unwrap_or_default(); + + let new_msg = status_msg.clone().unwrap_or_default(); + + new_msg != old_msg + }, + }; + let now = utils::millis_since_unix_epoch(); let last_last_active_ts = match last_presence { None => 0, @@ -72,10 +88,10 @@ impl Data { Some(last_active_ago) => now.saturating_sub(last_active_ago.into()), }; - // tighten for state flicker? - if !state_changed && last_active_ts <= last_last_active_ts { + // TODO: tighten for state flicker? + if !status_msg_changed && !state_changed && last_active_ts < last_last_active_ts { debug_warn!( - "presence spam {:?} last_active_ts:{:?} <= {:?}", + "presence spam {:?} last_active_ts:{:?} < {:?}", user_id, last_active_ts, last_last_active_ts