From c10ce4b1ba98e7a802a0a7c8d4f025b6fe25b571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Fri, 1 Dec 2023 21:26:41 +0000 Subject: [PATCH] Do not show notifications from muted users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Muted users + unfollowed users test ------------------------------------ PASS Device: iPhone 15 Pro simulator iOS: 17.0.1 Damus: This commit Setup: - Two phones running Damus on different accounts - Local relay with strfry-push-notify test setup - Apple push notification test tool Steps: 1. Unfollow the user who is the author of the saved notifications 2. Disable notifications for people you don't follow 3. Trigger a push notification (Resend push notification from test tool) 4. Ensure that the notification is not received on the other device 5. Enable notifications for people you don't follow 6. Trigger a push notification (Resend push notification from test tool) 7. Ensure that the notification is received on the other device 8. Mute the user who is the author of the saved notifications 9. Trigger a push notification (Resend push notification from test tool) 10. Ensure that the notification is not received on the other device 11. Unmute the user who is the author of the saved notifications 12. Trigger a push notification (Resend push notification from test tool) 13. Ensure that the notification is received on the other device Result: PASS Closes: https://github.com/damus-io/damus/issues/1705 Signed-off-by: Daniel D’Aquino Signed-off-by: William Casarin --- damus/Models/NotificationsManager.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/damus/Models/NotificationsManager.swift b/damus/Models/NotificationsManager.swift index ba78359c..3618cd3e 100644 --- a/damus/Models/NotificationsManager.swift +++ b/damus/Models/NotificationsManager.swift @@ -40,6 +40,11 @@ func should_display_notification(state: HeadlessDamusState, event ev: NostrEvent return false } + // Don't show notifications from muted users + if state.contacts.is_muted(ev.pubkey) { + return false + } + // Don't show notifications for old events guard ev.age < EVENT_MAX_AGE_FOR_NOTIFICATION else { return false