Checks if the relay list in NIP-28 groups is empty and uses default when needed.
This commit is contained in:
+10
-7
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user