mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-24 08:47:03 +02:00
Adds protections against filters with empty arrays because some relays consider that null as opposed to empty.
This commit is contained in:
@@ -35,15 +35,19 @@ object NostrCommunityDataSource : AmethystNostrDataSource("SingleCommunityFeed")
|
|||||||
|
|
||||||
val community = myCommunityToWatch.event as? CommunityDefinitionEvent ?: return null
|
val community = myCommunityToWatch.event as? CommunityDefinitionEvent ?: return null
|
||||||
|
|
||||||
|
val authors =
|
||||||
|
community
|
||||||
|
.moderators()
|
||||||
|
.map { it.key }
|
||||||
|
.plus(listOfNotNull(myCommunityToWatch.author?.pubkeyHex))
|
||||||
|
|
||||||
|
if (authors.isEmpty()) return null
|
||||||
|
|
||||||
return TypedFilter(
|
return TypedFilter(
|
||||||
types = COMMON_FEED_TYPES,
|
types = COMMON_FEED_TYPES,
|
||||||
filter =
|
filter =
|
||||||
SincePerRelayFilter(
|
SincePerRelayFilter(
|
||||||
authors =
|
authors = authors,
|
||||||
community
|
|
||||||
.moderators()
|
|
||||||
.map { it.key }
|
|
||||||
.plus(listOfNotNull(myCommunityToWatch.author?.pubkeyHex)),
|
|
||||||
tags =
|
tags =
|
||||||
mapOf(
|
mapOf(
|
||||||
"a" to listOf(myCommunityToWatch.address.toTag()),
|
"a" to listOf(myCommunityToWatch.address.toTag()),
|
||||||
|
@@ -67,15 +67,17 @@ object NostrDiscoveryDataSource : AmethystNostrDataSource("DiscoveryFeed") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createMarketplaceFilter(): List<TypedFilter> {
|
fun createMarketplaceFilter(): List<TypedFilter> {
|
||||||
val follows = account.liveDiscoveryListAuthorsPerRelay.value
|
val follows = account.liveDiscoveryListAuthorsPerRelay.value?.ifEmpty { null }
|
||||||
val hashToLoad =
|
val hashToLoad =
|
||||||
account.liveDiscoveryFollowLists.value
|
account.liveDiscoveryFollowLists.value
|
||||||
?.hashtags
|
?.hashtags
|
||||||
?.toList()
|
?.toList()
|
||||||
|
?.ifEmpty { null }
|
||||||
val geohashToLoad =
|
val geohashToLoad =
|
||||||
account.liveDiscoveryFollowLists.value
|
account.liveDiscoveryFollowLists.value
|
||||||
?.geotags
|
?.geotags
|
||||||
?.toList()
|
?.toList()
|
||||||
|
?.ifEmpty { null }
|
||||||
|
|
||||||
return listOfNotNull(
|
return listOfNotNull(
|
||||||
TypedFilter(
|
TypedFilter(
|
||||||
@@ -162,6 +164,7 @@ object NostrDiscoveryDataSource : AmethystNostrDataSource("DiscoveryFeed") {
|
|||||||
account.liveDiscoveryFollowLists.value
|
account.liveDiscoveryFollowLists.value
|
||||||
?.users
|
?.users
|
||||||
?.toList()
|
?.toList()
|
||||||
|
?.ifEmpty { null }
|
||||||
|
|
||||||
val followsRelays = account.liveDiscoveryListAuthorsPerRelay.value
|
val followsRelays = account.liveDiscoveryListAuthorsPerRelay.value
|
||||||
|
|
||||||
@@ -200,7 +203,7 @@ object NostrDiscoveryDataSource : AmethystNostrDataSource("DiscoveryFeed") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createPublicChatFilter(): List<TypedFilter> {
|
fun createPublicChatFilter(): List<TypedFilter> {
|
||||||
val follows = account.liveDiscoveryListAuthorsPerRelay.value
|
val follows = account.liveDiscoveryListAuthorsPerRelay.value?.ifEmpty { null }
|
||||||
val followChats = account.selectedChatsFollowList().toList()
|
val followChats = account.selectedChatsFollowList().toList()
|
||||||
|
|
||||||
return listOfNotNull(
|
return listOfNotNull(
|
||||||
|
@@ -114,7 +114,7 @@ object NostrHomeDataSource : AmethystNostrDataSource("HomeFeed") {
|
|||||||
fun createFollowMetadataAndReleaseFilter(): TypedFilter? {
|
fun createFollowMetadataAndReleaseFilter(): TypedFilter? {
|
||||||
val follows = account.liveHomeListAuthorsPerRelay.value
|
val follows = account.liveHomeListAuthorsPerRelay.value
|
||||||
|
|
||||||
return if (follows != null) {
|
return if (!follows.isNullOrEmpty()) {
|
||||||
TypedFilter(
|
TypedFilter(
|
||||||
types = setOf(FeedType.FOLLOWS),
|
types = setOf(FeedType.FOLLOWS),
|
||||||
filter =
|
filter =
|
||||||
|
@@ -65,26 +65,30 @@ object NostrSingleUserDataSource : AmethystNostrDataSource("SingleUserFeed") {
|
|||||||
val groupIds = group.map { it.pubkeyHex }
|
val groupIds = group.map { it.pubkeyHex }
|
||||||
val minEOSEs = findMinimumEOSEsForUsers(group)
|
val minEOSEs = findMinimumEOSEsForUsers(group)
|
||||||
|
|
||||||
listOf(
|
if (groupIds.isNotEmpty()) {
|
||||||
TypedFilter(
|
listOf(
|
||||||
types = EVENT_FINDER_TYPES,
|
TypedFilter(
|
||||||
filter =
|
types = EVENT_FINDER_TYPES,
|
||||||
SincePerRelayFilter(
|
filter =
|
||||||
kinds = listOf(MetadataEvent.KIND, StatusEvent.KIND, AdvertisedRelayListEvent.KIND, ChatMessageRelayListEvent.KIND),
|
SincePerRelayFilter(
|
||||||
authors = groupIds,
|
kinds = listOf(MetadataEvent.KIND, StatusEvent.KIND, AdvertisedRelayListEvent.KIND, ChatMessageRelayListEvent.KIND),
|
||||||
since = minEOSEs,
|
authors = groupIds,
|
||||||
),
|
since = minEOSEs,
|
||||||
),
|
),
|
||||||
TypedFilter(
|
),
|
||||||
types = EVENT_FINDER_TYPES,
|
TypedFilter(
|
||||||
filter =
|
types = EVENT_FINDER_TYPES,
|
||||||
SincePerRelayFilter(
|
filter =
|
||||||
kinds = listOf(ReportEvent.KIND),
|
SincePerRelayFilter(
|
||||||
tags = mapOf("p" to groupIds),
|
kinds = listOf(ReportEvent.KIND),
|
||||||
since = minEOSEs,
|
tags = mapOf("p" to groupIds),
|
||||||
),
|
since = minEOSEs,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
listOf()
|
||||||
|
}
|
||||||
}.flatten()
|
}.flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user