mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-26 21:46:30 +02:00
In case a user does not have an outbox list, defaults to all hints seen for that user.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.amethyst.model.nip02FollowLists
|
||||
|
||||
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||
import com.vitorpamplona.amethyst.model.Constants
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.NoteState
|
||||
import com.vitorpamplona.amethyst.model.nip51Lists.blockedRelays.BlockedRelayListState
|
||||
@@ -45,6 +46,7 @@ import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.transformLatest
|
||||
import kotlin.collections.ifEmpty
|
||||
|
||||
class FollowsPerOutboxRelay(
|
||||
kind3Follows: FollowListState,
|
||||
@@ -68,7 +70,11 @@ class FollowsPerOutboxRelay(
|
||||
mapOfSet {
|
||||
relayListNotes.forEach { noteState ->
|
||||
noteState.note.author?.pubkeyHex?.let { authorHex ->
|
||||
(noteState.note.event as? AdvertisedRelayListEvent)?.writeRelaysNorm()?.forEach { relay ->
|
||||
val outboxRelayList =
|
||||
getNIP65RelayList(authorHex)?.writeRelaysNorm()
|
||||
?: LocalCache.relayHints.hintsForKey(authorHex).ifEmpty { null }
|
||||
?: Constants.eventFinderRelays
|
||||
outboxRelayList.forEach { relay ->
|
||||
add(relay, authorHex)
|
||||
}
|
||||
}
|
||||
@@ -85,7 +91,11 @@ class FollowsPerOutboxRelay(
|
||||
emit(
|
||||
mapOfSet {
|
||||
kind3Follows.flow.value.authors.map { authorHex ->
|
||||
getNIP65RelayList(authorHex)?.writeRelaysNorm()?.forEach { relay ->
|
||||
val outboxRelayList =
|
||||
getNIP65RelayList(authorHex)?.writeRelaysNorm()
|
||||
?: LocalCache.relayHints.hintsForKey(authorHex).ifEmpty { null }
|
||||
?: Constants.eventFinderRelays
|
||||
outboxRelayList.forEach { relay ->
|
||||
add(relay, authorHex)
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
package com.vitorpamplona.amethyst.model.topNavFeeds
|
||||
|
||||
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||
import com.vitorpamplona.amethyst.model.Constants
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.NoteState
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
@@ -50,8 +51,9 @@ class OutboxRelayLoader {
|
||||
|
||||
if (authorHex != null) {
|
||||
val relays =
|
||||
(outboxNote.note.event as? AdvertisedRelayListEvent)?.writeRelaysNorm()?.ifEmpty { null }
|
||||
?: cache.relayHints.hintsForKey(authorHex)
|
||||
(outboxNote.note.event as? AdvertisedRelayListEvent)?.writeRelaysNorm()
|
||||
?: cache.relayHints.hintsForKey(authorHex).ifEmpty { null }
|
||||
?: Constants.eventFinderRelays
|
||||
|
||||
relays.forEach {
|
||||
add(it, authorHex)
|
||||
|
@@ -52,7 +52,7 @@ fun filterFindUserMetadataForKey(
|
||||
mapOfSet {
|
||||
authors.forEach { key ->
|
||||
val relays =
|
||||
key.authorRelayList()?.writeRelaysNorm()?.ifEmpty { null }
|
||||
key.authorRelayList()?.writeRelaysNorm()
|
||||
?: LocalCache.relayHints.hintsForKey(key.pubkeyHex).ifEmpty { null }
|
||||
?: (key.relaysBeingUsed.keys + defaultRelays).toList()
|
||||
|
||||
|
@@ -50,7 +50,7 @@ fun filterUserMetadataForKey(
|
||||
val authorHomeRelayEventAddress = AdvertisedRelayListEvent.createAddressTag(it)
|
||||
val authorHomeRelayEvent = (LocalCache.getAddressableNoteIfExists(authorHomeRelayEventAddress)?.event as? AdvertisedRelayListEvent)
|
||||
|
||||
authorHomeRelayEvent?.writeRelaysNorm()?.ifEmpty { null }
|
||||
authorHomeRelayEvent?.writeRelaysNorm()
|
||||
?: LocalCache.relayHints.hintsForKey(it).ifEmpty { null }
|
||||
?: listOfNotNull(LocalCache.getUserIfExists(it)?.latestMetadataRelay)
|
||||
}.flatten()
|
||||
|
@@ -48,7 +48,7 @@ fun filterNip04DMs(
|
||||
val authorHomeRelayEvent = (LocalCache.getAddressableNoteIfExists(authorHomeRelayEventAddress)?.event as? AdvertisedRelayListEvent)
|
||||
|
||||
val outbox =
|
||||
authorHomeRelayEvent?.writeRelaysNorm()?.ifEmpty { null }
|
||||
authorHomeRelayEvent?.writeRelaysNorm()
|
||||
?: LocalCache.relayHints.hintsForKey(it).ifEmpty { null }
|
||||
?: listOfNotNull(LocalCache.getUserIfExists(it)?.latestMetadataRelay)
|
||||
|
||||
|
Reference in New Issue
Block a user