From d9f8f93e83f66cf014b271462a86de9f59978c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Fri, 2 Aug 2024 18:54:59 -0700 Subject: [PATCH] Do not send notifications about unsupported nostr event kinds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel D’Aquino --- .../notification_manager.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/notification_manager/notification_manager.rs b/src/notification_manager/notification_manager.rs index 866f1d4..8583de7 100644 --- a/src/notification_manager/notification_manager.rs +++ b/src/notification_manager/notification_manager.rs @@ -138,6 +138,11 @@ impl NotificationManager { log::debug!("Event is older than a week, 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(()); + } let pubkeys_to_notify = self.pubkeys_to_notify_for_event(event).await?; @@ -166,6 +171,20 @@ impl NotificationManager { } Ok(()) } + + fn is_event_kind_supported(event_kind: nostr::Kind) -> bool { + match event_kind { + nostr_sdk::Kind::TextNote => true, + nostr_sdk::Kind::EncryptedDirectMessage => true, + nostr_sdk::Kind::Repost => true, + nostr_sdk::Kind::GenericRepost => true, + nostr_sdk::Kind::Reaction => true, + nostr_sdk::Kind::ZapPrivateMessage => true, + nostr_sdk::Kind::ZapRequest => false, + nostr_sdk::Kind::ZapReceipt => true, + _ => false, + } + } async fn pubkeys_to_notify_for_event( &self,