mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-25 18:21:20 +02:00
Growing the number of possibilities to download profile information from
This commit is contained in:
@@ -214,6 +214,7 @@ import kotlinx.coroutines.launch
|
||||
import java.math.BigDecimal
|
||||
import java.util.Locale
|
||||
import kotlin.collections.forEach
|
||||
import kotlin.collections.ifEmpty
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@Stable
|
||||
@@ -536,7 +537,7 @@ class Account(
|
||||
val zapRequest =
|
||||
LnZapRequestEvent.create(
|
||||
userHex = user.pubkeyHex,
|
||||
relays = nip65RelayList.inboxFlow.value + user.inboxRelays(),
|
||||
relays = nip65RelayList.inboxFlow.value + (user.inboxRelays() ?: emptyList()),
|
||||
signer = signer,
|
||||
message = message,
|
||||
zapType = zapType,
|
||||
@@ -657,7 +658,8 @@ class Account(
|
||||
if (replyToAuthor == userProfile()) {
|
||||
outboxRelays.flow.value
|
||||
} else {
|
||||
replyToAuthor.outboxRelays().ifEmpty { null }?.toSet()
|
||||
replyToAuthor.inboxRelays()?.ifEmpty { null }?.toSet()
|
||||
?: replyToAuthor.relaysBeingUsed.keys.ifEmpty { null }
|
||||
?: cache.relayHints
|
||||
.hintsForKey(replyToAuthor.pubkeyHex)
|
||||
.ifEmpty { null }
|
||||
@@ -683,7 +685,7 @@ class Account(
|
||||
if (user == userProfile()) {
|
||||
notificationRelays.flow.value
|
||||
} else {
|
||||
user.inboxRelays().ifEmpty { null }?.toSet()
|
||||
user.inboxRelays()?.ifEmpty { null }?.toSet()
|
||||
?: (cache.relayHints.hintsForKey(user.pubkeyHex).toSet() + user.relaysBeingUsed.keys)
|
||||
}
|
||||
|
||||
@@ -736,10 +738,12 @@ class Account(
|
||||
if (author == userProfile()) {
|
||||
relayList.addAll(outboxRelays.flow.value)
|
||||
} else {
|
||||
relayList.addAll(
|
||||
author.outboxRelays().ifEmpty { null }
|
||||
?: cache.relayHints.hintsForKey(author.pubkeyHex),
|
||||
)
|
||||
val relays =
|
||||
author.outboxRelays()?.ifEmpty { null }
|
||||
?: author.relaysBeingUsed.keys.ifEmpty { null }
|
||||
?: cache.relayHints.hintsForKey(author.pubkeyHex)
|
||||
|
||||
relayList.addAll(relays)
|
||||
}
|
||||
} else {
|
||||
relayList.addAll(cache.relayHints.hintsForKey(event.pubKey))
|
||||
@@ -1548,11 +1552,8 @@ class Account(
|
||||
val request = NIP90ContentDiscoveryRequestEvent.create(dvmPublicKey.pubkeyHex, signer.pubKey, relays, signer)
|
||||
|
||||
val relayList =
|
||||
dvmPublicKey
|
||||
.inboxRelays()
|
||||
.ifEmpty {
|
||||
cache.relayHints.hintsForKey(dvmPublicKey.pubkeyHex) + dvmPublicKey.relaysBeingUsed.keys
|
||||
}.toSet()
|
||||
dvmPublicKey.inboxRelays()?.toSet()?.ifEmpty { null }
|
||||
?: (dvmPublicKey.relaysBeingUsed.keys + cache.relayHints.hintsForKey(dvmPublicKey.pubkeyHex))
|
||||
|
||||
cache.justConsumeMyOwnEvent(request)
|
||||
onReady(request)
|
||||
|
@@ -78,11 +78,11 @@ class User(
|
||||
|
||||
fun toNProfile() = NProfile.create(pubkeyHex, relayHints())
|
||||
|
||||
fun outboxRelays() = authorRelayList()?.writeRelaysNorm() ?: listOfNotNull(latestMetadataRelay)
|
||||
fun outboxRelays() = authorRelayList()?.writeRelaysNorm()
|
||||
|
||||
fun relayHints() = authorRelayList()?.writeRelaysNorm()?.take(3) ?: listOfNotNull(latestMetadataRelay)
|
||||
|
||||
fun inboxRelays() = authorRelayList()?.readRelaysNorm() ?: listOfNotNull(latestMetadataRelay)
|
||||
fun inboxRelays() = authorRelayList()?.readRelaysNorm()
|
||||
|
||||
fun dmInboxRelays() = dmInboxRelayList()?.relays()?.ifEmpty { null } ?: inboxRelays()
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource
|
||||
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
||||
@@ -31,8 +32,13 @@ val UserProfileFollowersKinds = listOf(ContactListEvent.KIND)
|
||||
fun filterUserProfileFollowers(
|
||||
user: User,
|
||||
since: SincePerRelayMap?,
|
||||
): List<RelayBasedFilter> =
|
||||
user.inboxRelays().map {
|
||||
): List<RelayBasedFilter> {
|
||||
val relays =
|
||||
user.inboxRelays()?.ifEmpty { null }
|
||||
?: user.relaysBeingUsed.keys.ifEmpty { null }
|
||||
?: LocalCache.relayHints.hintsForKey(user.pubkeyHex)
|
||||
|
||||
return relays.map {
|
||||
RelayBasedFilter(
|
||||
relay = it,
|
||||
filter =
|
||||
@@ -43,3 +49,4 @@ fun filterUserProfileFollowers(
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource
|
||||
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
||||
import com.vitorpamplona.quartz.experimental.profileGallery.ProfileGalleryEntryEvent
|
||||
@@ -40,8 +41,13 @@ val UserProfileMediaKinds =
|
||||
fun filterUserProfileMedia(
|
||||
user: User,
|
||||
since: SincePerRelayMap?,
|
||||
): List<RelayBasedFilter> =
|
||||
user.outboxRelays().map { relay ->
|
||||
): List<RelayBasedFilter> {
|
||||
val relays =
|
||||
user.outboxRelays()?.ifEmpty { null }
|
||||
?: user.relaysBeingUsed.keys.ifEmpty { null }
|
||||
?: LocalCache.relayHints.hintsForKey(user.pubkeyHex)
|
||||
|
||||
return relays.map { relay ->
|
||||
RelayBasedFilter(
|
||||
relay = relay,
|
||||
filter =
|
||||
@@ -53,3 +59,4 @@ fun filterUserProfileMedia(
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource
|
||||
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
||||
import com.vitorpamplona.quartz.experimental.interactiveStories.InteractiveStoryPrologueEvent
|
||||
@@ -66,9 +67,13 @@ val UserProfilePostKinds2 =
|
||||
fun filterUserProfilePosts(
|
||||
user: User,
|
||||
since: SincePerRelayMap?,
|
||||
): List<RelayBasedFilter> =
|
||||
user
|
||||
.outboxRelays()
|
||||
): List<RelayBasedFilter> {
|
||||
val relays =
|
||||
user.outboxRelays()?.ifEmpty { null }
|
||||
?: user.relaysBeingUsed.keys.ifEmpty { null }
|
||||
?: LocalCache.relayHints.hintsForKey(user.pubkeyHex)
|
||||
|
||||
return relays
|
||||
.map { relay ->
|
||||
listOf(
|
||||
RelayBasedFilter(
|
||||
@@ -93,3 +98,4 @@ fun filterUserProfilePosts(
|
||||
),
|
||||
)
|
||||
}.flatten()
|
||||
}
|
||||
|
@@ -20,19 +20,26 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource
|
||||
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
||||
import kotlin.collections.ifEmpty
|
||||
|
||||
val UserProfileZapReceiverKinds = listOf(LnZapEvent.KIND)
|
||||
|
||||
fun filterUserProfileZapsReceived(
|
||||
user: User,
|
||||
since: SincePerRelayMap?,
|
||||
): List<RelayBasedFilter> =
|
||||
user.inboxRelays().map { relay ->
|
||||
): List<RelayBasedFilter> {
|
||||
val relays =
|
||||
user.inboxRelays()?.ifEmpty { null }
|
||||
?: user.relaysBeingUsed.keys.ifEmpty { null }
|
||||
?: LocalCache.relayHints.hintsForKey(user.pubkeyHex)
|
||||
|
||||
return relays.map { relay ->
|
||||
RelayBasedFilter(
|
||||
relay = relay,
|
||||
filter =
|
||||
@@ -44,3 +51,4 @@ fun filterUserProfileZapsReceived(
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@@ -20,11 +20,13 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.datasource
|
||||
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.service.relayClient.eoseManagers.SingleSubEoseManager
|
||||
import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.NostrClient
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter
|
||||
import com.vitorpamplona.quartz.utils.mapOfSet
|
||||
import kotlin.collections.ifEmpty
|
||||
|
||||
class UserProfileMetadataFilterSubAssembler(
|
||||
client: NostrClient,
|
||||
@@ -37,7 +39,12 @@ class UserProfileMetadataFilterSubAssembler(
|
||||
val userPerRelay =
|
||||
mapOfSet {
|
||||
keys.mapTo(mutableSetOf()) { key -> key.user }.forEach { user ->
|
||||
user.outboxRelays().forEach { relay ->
|
||||
val relays =
|
||||
user.outboxRelays()?.ifEmpty { null }
|
||||
?: user.relaysBeingUsed.keys.ifEmpty { null }
|
||||
?: LocalCache.relayHints.hintsForKey(user.pubkeyHex)
|
||||
|
||||
relays.forEach { relay ->
|
||||
add(relay, user.pubkeyHex)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user