From e73f5ce70eb0eb6a47b25a18a07cf260ed6ce9ff Mon Sep 17 00:00:00 2001 From: Terry Yiu Date: Fri, 11 Apr 2025 13:55:45 -0400 Subject: [PATCH] Do not send notifications for future notes Changelog-Fixed: Do not send notifications for future notes Closes: https://github.com/damus-io/damus/issues/2949 Signed-off-by: Terry Yiu --- src/notification_manager/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/notification_manager/mod.rs b/src/notification_manager/mod.rs index e5d9600..cda2099 100644 --- a/src/notification_manager/mod.rs +++ b/src/notification_manager/mod.rs @@ -345,6 +345,13 @@ impl NotificationManager { return Ok(()); } + // Allow notes that are created no more than 3 seconds in the future + // to account for natural clock skew between sender and receiver. + if event.created_at > Timestamp::now() + 3 { + log::debug!("Event was scheduled for the future, not sending notifications"); + return Ok(()); + } + if !Self::is_event_kind_supported(event.kind) { log::debug!("Event kind is not supported, not sending notifications"); return Ok(());