Reviews event-based filters.

This commit is contained in:
Vitor Pamplona
2023-07-30 16:55:09 -04:00
parent 30d31b35ab
commit d5ad6b983a
@@ -12,7 +12,7 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
private var eventsToWatch = setOf<Note>() private var eventsToWatch = setOf<Note>()
private var addressesToWatch = setOf<Note>() private var addressesToWatch = setOf<Note>()
private fun createTagToAddressFilter(): List<TypedFilter>? { private fun createReactionsToWatchInAddressFilter(): List<TypedFilter>? {
val addressesToWatch = eventsToWatch.filter { it.address() != null } + addressesToWatch val addressesToWatch = eventsToWatch.filter { it.address() != null } + addressesToWatch
if (addressesToWatch.isEmpty()) { if (addressesToWatch.isEmpty()) {
@@ -25,12 +25,15 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = JsonFilter( filter = JsonFilter(
kinds = listOf( kinds = listOf(
TextNoteEvent.kind, LongTextNoteEvent.kind, TextNoteEvent.kind,
ReactionEvent.kind, RepostEvent.kind, GenericRepostEvent.kind, ReportEvent.kind, ReactionEvent.kind,
LnZapEvent.kind, LnZapRequestEvent.kind, RepostEvent.kind,
BadgeAwardEvent.kind, BadgeDefinitionEvent.kind, BadgeProfilesEvent.kind, GenericRepostEvent.kind,
PollNoteEvent.kind, AudioTrackEvent.kind, PinListEvent.kind, ReportEvent.kind,
PeopleListEvent.kind, BookmarkListEvent.kind LnZapEvent.kind,
PollNoteEvent.kind,
CommunityPostApprovalEvent.kind,
LiveActivitiesChatMessageEvent.kind
), ),
tags = mapOf("a" to listOf(aTag.toTag())), tags = mapOf("a" to listOf(aTag.toTag())),
since = it.lastReactionsDownloadTime, since = it.lastReactionsDownloadTime,
@@ -55,7 +58,8 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = JsonFilter( filter = JsonFilter(
kinds = listOf(aTag.kind), kinds = listOf(aTag.kind),
authors = listOf(aTag.pubKeyHex) authors = listOf(aTag.pubKeyHex),
limit = 1000 // Max amount of "replies" to download on a specific event.
) )
) )
} else { } else {
@@ -64,7 +68,8 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
filter = JsonFilter( filter = JsonFilter(
kinds = listOf(aTag.kind), kinds = listOf(aTag.kind),
tags = mapOf("d" to listOf(aTag.dTag)), tags = mapOf("d" to listOf(aTag.dTag)),
authors = listOf(aTag.pubKeyHex) authors = listOf(aTag.pubKeyHex),
limit = 1000 // Max amount of "replies" to download on a specific event.
) )
) )
} }
@@ -85,17 +90,12 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
filter = JsonFilter( filter = JsonFilter(
kinds = listOf( kinds = listOf(
TextNoteEvent.kind, TextNoteEvent.kind,
LongTextNoteEvent.kind,
ReactionEvent.kind, ReactionEvent.kind,
RepostEvent.kind, RepostEvent.kind,
GenericRepostEvent.kind, GenericRepostEvent.kind,
ReportEvent.kind, ReportEvent.kind,
LnZapEvent.kind, LnZapEvent.kind,
LnZapRequestEvent.kind, PollNoteEvent.kind
PollNoteEvent.kind,
HighlightEvent.kind,
AudioTrackEvent.kind,
PinListEvent.kind
), ),
tags = mapOf("e" to listOf(it.idHex)), tags = mapOf("e" to listOf(it.idHex)),
since = it.lastReactionsDownloadTime, since = it.lastReactionsDownloadTime,
@@ -154,7 +154,7 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
val reactions = createRepliesAndReactionsFilter() val reactions = createRepliesAndReactionsFilter()
val missing = createLoadEventsIfNotLoadedFilter() val missing = createLoadEventsIfNotLoadedFilter()
val addresses = createAddressFilter() val addresses = createAddressFilter()
val addressReactions = createTagToAddressFilter() val addressReactions = createReactionsToWatchInAddressFilter()
singleEventChannel.typedFilters = listOfNotNull(missing, addresses, reactions, addressReactions).flatten().ifEmpty { null } singleEventChannel.typedFilters = listOfNotNull(missing, addresses, reactions, addressReactions).flatten().ifEmpty { null }
} }