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