From bb3d8e0041ef4d5247c8f9de3a63e66927663f7c Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 27 Feb 2023 17:14:37 -0500 Subject: [PATCH] Filtering Notifications to the events that cite the user directly. --- .../amethyst/ui/dal/NotificationFeedFilter.kt | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) 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 f9a7f2933..181b975d8 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 @@ -5,18 +5,64 @@ import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent import com.vitorpamplona.amethyst.service.model.LnZapRequestEvent +import com.vitorpamplona.amethyst.service.model.ReactionEvent +import com.vitorpamplona.amethyst.service.model.RepostEvent +import nostr.postr.events.TextNoteEvent object NotificationFeedFilter: FeedFilter() { lateinit var account: Account override fun feed(): List { return account.userProfile().taggedPosts - .filter { it.author == null || (!account.isHidden(it.author!!) && it.author != account.userProfile()) } + .filter { + it.author == null + || (!account.isHidden(it.author!!) && it.author != account.userProfile()) + } .filter { it.event !is ChannelCreateEvent && it.event !is ChannelMetadataEvent && it.event !is LnZapRequestEvent } + .filter { + it.event !is TextNoteEvent + || + ( + it.event is TextNoteEvent + && + ( + it.replyTo?.lastOrNull()?.author == account.userProfile() + || + account.userProfile() in it.directlyCiteUsers() + ) + ) + } + .filter { + it.event !is ReactionEvent + || + ( + it.event is ReactionEvent + && + ( + it.replyTo?.lastOrNull()?.author == account.userProfile() + || + account.userProfile() in it.directlyCiteUsers() + ) + ) + } + .filter { + it.event !is RepostEvent + || + ( + it.event is RepostEvent + && + ( + it.replyTo?.lastOrNull()?.author == account.userProfile() + || + account.userProfile() in it.directlyCiteUsers() + ) + ) + } + .sortedBy { it.event?.createdAt } .reversed() }