From ee79f04d24dab597c638672a14026e54754dd690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Fri, 2 Aug 2024 18:49:01 -0700 Subject: [PATCH] Improve message formatting fallbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to something more user-friendly Signed-off-by: Daniel D’Aquino --- src/notification_manager/notification_manager.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/notification_manager/notification_manager.rs b/src/notification_manager/notification_manager.rs index 74dcc2b..866f1d4 100644 --- a/src/notification_manager/notification_manager.rs +++ b/src/notification_manager/notification_manager.rs @@ -312,10 +312,17 @@ impl NotificationManager { } fn format_notification_message(&self, event: &Event) -> (String, String, String) { - let title = "New activity".to_string(); - let subtitle = format!("From: {}", event.pubkey); - let body = event.content.clone(); - (title, subtitle, body) + // NOTE: This is simple because the client will handle formatting. These are just fallbacks. + let (title, body) = match event.kind { + nostr_sdk::Kind::TextNote => ("New activity".to_string(), event.content.clone()), + nostr_sdk::Kind::EncryptedDirectMessage => ("New direct message".to_string(), "Contents are encrypted".to_string()), + nostr_sdk::Kind::Repost => ("Someone reposted".to_string(), event.content.clone()), + nostr_sdk::Kind::Reaction => ("New reaction".to_string(), event.content.clone()), + nostr_sdk::Kind::ZapPrivateMessage => ("New zap private message".to_string(), "Contents are encrypted".to_string()), + nostr_sdk::Kind::ZapReceipt => ("Someone zapped you".to_string(), "".to_string()), + _ => ("New activity".to_string(), "".to_string()), + }; + (title, "".to_string(), body) } pub async fn save_user_device_info(