Limit search to only 1 relay.

This commit is contained in:
Kgothatso Ngako
2026-04-21 23:29:58 +02:00
parent ef4c5a592c
commit 7212cad052
8 changed files with 14 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
import com.vitorpamplona.quartz.nip01Core.tags.events.taggedEvents
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent
import kotlin.math.log
import kotlin.time.Clock
import kotlin.time.Instant
@@ -92,8 +93,12 @@ abstract class NostrDao(
// Add new nostr event
database.nostrEventDao().insert(nostrEvent)
} else if (nostrEvent.createdAt > storedNostrEvent.createdAt) {
// Update nostr event
// Update nostr event`
database.nostrEventDao().upsert(nostrEvent)
} else {
// Nothing else needs to be done
logger.i("We have the latest version for: ${nostrEvent.id}")
return
}
// Index nostrEvent

View File

@@ -34,7 +34,7 @@ object Relays {
val nostr1 = RelayUrlNormalizer.normalize("wss://profiles.nostr1.com")
val bootstrapInboxRelaySet = setOf(damus, primal, mom, nos, bitcoiner, oxtr, yabu)
val eventFinderRelaySet = setOf(wine, damus, primal, mom, nos, bitcoiner, oxtr)
val eventFinderRelaySet = setOf(primal, wine, damus, mom, nos, bitcoiner, oxtr)
val eventPublishRelaySet = setOf(primal, mom, nos, bitcoiner, oxtr)

View File

@@ -73,7 +73,7 @@ class FeedListViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
nostrRepository.queueSynchronizeNostrEvent(
Relays.eventPublishRelaySet.map { normalizedRelay ->
Relays.eventPublishRelaySet.take(1).map { normalizedRelay -> // TODO: Sync from all the publish relays...
SynchronizeNostrEventRequest(
purpose = "feed",
synchronizationFilters = arrayOf(

View File

@@ -207,7 +207,7 @@ class MetadataEventDetailViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
nostrRepository.queueSynchronizeNostrEvent(
Relays.eventFinderRelaySet.map { normalizedRelay ->
Relays.eventFinderRelaySet.take(1).map { normalizedRelay -> // TODO: Sync from all relays instead of 1
SynchronizeNostrEventRequest(
purpose = "search",
synchronizationFilters = arrayOf(

View File

@@ -164,7 +164,7 @@ class NavigationViewModel(
nostrRepository.saveNostrEvent(
nostrEvent = it,
synchronizeNostrEventRequest,
synchronizationRelayURLs = Relays.eventPublishRelaySet.map { normalizedRelayUrl -> normalizedRelayUrl.url } + synchronizeNostrEventRequest.relayURL
synchronizationRelayURLs = listOf(synchronizeNostrEventRequest.relayURL) // TODO: + Relays.eventPublishRelaySet.map { normalizedRelayUrl -> normalizedRelayUrl.url }
)
}
@@ -176,7 +176,7 @@ class NavigationViewModel(
nostrRepository.saveNostrEvent(
nostrEvent = nostrEvent,
synchronizeNostrEventRequest,
synchronizationRelayURLs = Relays.eventPublishRelaySet.map { normalizedRelayUrl -> normalizedRelayUrl.url } + synchronizeNostrEventRequest.relayURL
synchronizationRelayURLs = listOf(synchronizeNostrEventRequest.relayURL) // TODO: + Relays.eventPublishRelaySet.map { normalizedRelayUrl -> normalizedRelayUrl.url }
)
}
}

View File

@@ -42,7 +42,7 @@ class NostrEventDetailViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
nostrRepository.queueSynchronizeNostrEvent(
Relays.eventPublishRelaySet.map { normalizedRelay ->
Relays.eventPublishRelaySet.take(1).map { normalizedRelay -> // TODO: Sync from all relays instead of 1
SynchronizeNostrEventRequest(
purpose = "detail",
synchronizationFilters = arrayOf(

View File

@@ -128,7 +128,7 @@ class SearchResultViewModel(
viewModelScope.launch(Dispatchers.IO) {
// Sync Notifications... might want to also run this in the background
searchRepository.submitSearch(
Relays.eventFinderRelaySet.map { normalizedRelay ->
Relays.eventFinderRelaySet.take(1).map { normalizedRelay -> // TODO: Search all relays instead of the first
SynchronizeNostrEventRequest(
purpose = "search",
synchronizationFilters = arrayOf(

View File

@@ -53,7 +53,7 @@ class UnqueuedProfileSynchronizationViewModel(
delay(2_000)
nostrRepository.queueSynchronizeNostrEvent(
Relays.eventPublishRelaySet.map { normalizedRelayUrl ->
Relays.eventPublishRelaySet.take(1).map { normalizedRelayUrl -> // TODO: Sync from all relays instead of 1
SynchronizeNostrEventRequest(
purpose = "sign-in",
synchronizationFilters = arrayOf(