Checks if the relay list in NIP-28 groups is empty and uses default when needed.

This commit is contained in:
Vitor Pamplona
2025-08-18 19:24:57 -04:00
parent f31fa4a9c6
commit 667c15b3a1
3 changed files with 12 additions and 9 deletions
@@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent
import com.vitorpamplona.quartz.utils.mapOfSet
fun filterFollowingPublicChats(
fun filterFollowingPublicChatsCreationEvent(
followingChannels: Set<HexKey>,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? {
@@ -38,13 +38,16 @@ fun filterFollowingPublicChats(
val relayRoomDTags =
mapOfSet {
followingChannels.forEach { channelId ->
val relays =
LocalCache.getPublicChatChannelIfExists(channelId)?.relays()
?: LocalCache.relayHints.hintsForEvent(channelId).ifEmpty { null }
?: Constants.eventFinderRelays
val channel = LocalCache.getPublicChatChannelIfExists(channelId)
if (channel?.event == null) {
val relays =
channel?.relays()?.ifEmpty { null }
?: LocalCache.relayHints.hintsForEvent(channelId).ifEmpty { null }
?: Constants.eventFinderRelays
relays.forEach { relayUrl ->
add(relayUrl, channelId)
relays.forEach { relayUrl ->
add(relayUrl, channelId)
}
}
}
}
@@ -40,7 +40,7 @@ fun filterLastMessageFollowingPublicChats(
mapOfSet {
followingChannels.forEach { channelId ->
val relays =
LocalCache.getPublicChatChannelIfExists(channelId)?.relays()
LocalCache.getPublicChatChannelIfExists(channelId)?.relays()?.ifEmpty { null }
?: LocalCache.relayHints.hintsForEvent(channelId).ifEmpty { null }
?: Constants.eventFinderRelays
@@ -43,7 +43,7 @@ class FollowingPublicChatSubAssembler(
): List<RelayBasedFilter>? =
listOfNotNull(
filterLastMessageFollowingPublicChats(key.account.publicChatList.flowSet.value, since),
filterFollowingPublicChats(key.account.publicChatList.flowSet.value, since),
filterFollowingPublicChatsCreationEvent(key.account.publicChatList.flowSet.value, since),
).flatten()
override fun user(key: ChatroomListState) = key.account.userProfile()