mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-05 18:13:21 +02:00
Filtering Notifications to the events that cite the user directly.
This commit is contained in:
@@ -5,18 +5,64 @@ import com.vitorpamplona.amethyst.model.Note
|
|||||||
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.LnZapRequestEvent
|
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<Note>() {
|
object NotificationFeedFilter: FeedFilter<Note>() {
|
||||||
lateinit var account: Account
|
lateinit var account: Account
|
||||||
|
|
||||||
override fun feed(): List<Note> {
|
override fun feed(): List<Note> {
|
||||||
return account.userProfile().taggedPosts
|
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 {
|
.filter {
|
||||||
it.event !is ChannelCreateEvent
|
it.event !is ChannelCreateEvent
|
||||||
&& it.event !is ChannelMetadataEvent
|
&& it.event !is ChannelMetadataEvent
|
||||||
&& it.event !is LnZapRequestEvent
|
&& 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 }
|
.sortedBy { it.event?.createdAt }
|
||||||
.reversed()
|
.reversed()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user