From 539433014edcc409e46cf0ef707391e851acb385 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 26 Mar 2024 21:05:24 -0400 Subject: [PATCH] Fixes Notification for Follows now showing Zaps --- .../service/NostrAccountDataSource.kt | 13 ++++++++++ .../amethyst/ui/dal/NotificationFeedFilter.kt | 24 +++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt index 34a51b4c6..5e285cd36 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrAccountDataSource.kt @@ -310,6 +310,19 @@ object NostrAccountDataSource : NostrDataSource("AccountData") { event.cachedGossip(account.signer) { LocalCache.justConsume(it, relay) } } + is LnZapEvent -> { + // Avoid decrypting over and over again if the event already exist. + + val note = LocalCache.getNoteIfExists(event.id) + if (note != null && relay.brief in note.relays) return + + event.zapRequest?.let { + if (it.isPrivateZap()) { + it.decryptPrivateZap(account.signer) {} + } + } + } + else -> { LocalCache.justConsume(event, relay) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/NotificationFeedFilter.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/NotificationFeedFilter.kt index c33dcc3a7..e97dd069d 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/NotificationFeedFilter.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/dal/NotificationFeedFilter.kt @@ -88,7 +88,23 @@ class NotificationFeedFilter(val account: Account) : AdditiveFeedFilter() filterParams: FilterByListParams, ): Boolean { val loggedInUserHex = account.userProfile().pubkeyHex - val loggedInUser = account.userProfile() + + val noteEvent = it.event + val notifAuthor = + if (noteEvent is LnZapEvent) { + val zapRequest = noteEvent.zapRequest + if (zapRequest != null) { + if (noteEvent.zapRequest?.isPrivateZap() == true) { + zapRequest.cachedPrivateZap()?.pubKey ?: zapRequest.pubKey + } else { + zapRequest.pubKey + } + } else { + noteEvent.pubKey + } + } else { + it.author?.pubkeyHex + } return it.event !is ChannelCreateEvent && it.event !is ChannelMetadataEvent && @@ -96,10 +112,10 @@ class NotificationFeedFilter(val account: Account) : AdditiveFeedFilter() it.event !is BadgeDefinitionEvent && it.event !is BadgeProfilesEvent && it.event !is GiftWrapEvent && - (it.event is LnZapEvent || it.author !== loggedInUser) && - (filterParams.isGlobal || filterParams.followLists?.users?.contains(it.author?.pubkeyHex) == true) && + (it.event is LnZapEvent || notifAuthor != loggedInUserHex) && + (filterParams.isGlobal || filterParams.followLists?.users?.contains(notifAuthor) == true) && it.event?.isTaggedUser(loggedInUserHex) ?: false && - (filterParams.isHiddenList || it.author == null || !account.isHidden(it.author!!.pubkeyHex)) && + (filterParams.isHiddenList || notifAuthor == null || !account.isHidden(notifAuthor)) && tagsAnEventByUser(it, loggedInUserHex) }