Removes default and bootstrapping lists from the "Trusted Relay set". This should fix the unwanted NOTIFY requests.
This commit is contained in:
+16
-4
@@ -57,10 +57,11 @@ class SearchRelayListState(
|
||||
|
||||
fun getSearchRelayList(): SearchRelayListEvent? = getSearchRelayListNote().event as? SearchRelayListEvent
|
||||
|
||||
suspend fun normalizeSearchRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> {
|
||||
val event = note.event as? SearchRelayListEvent ?: settings.backupSearchRelayList
|
||||
return event?.let { decryptionCache.relays(it) } ?: DefaultSearchRelayList
|
||||
}
|
||||
fun searchListEvent(note: Note) = note.event as? SearchRelayListEvent ?: settings.backupSearchRelayList
|
||||
|
||||
suspend fun normalizeSearchRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> = searchListEvent(note)?.let { decryptionCache.relays(it) }?.ifEmpty { null } ?: DefaultSearchRelayList
|
||||
|
||||
suspend fun normalizeSearchRelayListWithBackupNoDefaults(note: Note): Set<NormalizedRelayUrl> = searchListEvent(note)?.let { decryptionCache.relays(it) } ?: emptySet()
|
||||
|
||||
val flow =
|
||||
getSearchRelayListFlow()
|
||||
@@ -73,6 +74,17 @@ class SearchRelayListState(
|
||||
emptySet(),
|
||||
)
|
||||
|
||||
val flowNoDefaults =
|
||||
getSearchRelayListFlow()
|
||||
.map { normalizeSearchRelayListWithBackupNoDefaults(it.note) }
|
||||
.onStart { emit(normalizeSearchRelayListWithBackupNoDefaults(getSearchRelayListNote())) }
|
||||
.flowOn(Dispatchers.Default)
|
||||
.stateIn(
|
||||
scope,
|
||||
SharingStarted.Companion.Eagerly,
|
||||
emptySet(),
|
||||
)
|
||||
|
||||
suspend fun saveRelayList(searchRelays: List<NormalizedRelayUrl>): SearchRelayListEvent {
|
||||
val relayListForSearch = getSearchRelayList()
|
||||
|
||||
|
||||
+18
-12
@@ -57,20 +57,15 @@ class Nip65RelayListState(
|
||||
|
||||
fun getNIP65RelayList(): AdvertisedRelayListEvent? = getNIP65RelayListNote().event as? AdvertisedRelayListEvent
|
||||
|
||||
fun normalizeNIP65WriteRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> {
|
||||
val event = note.event as? AdvertisedRelayListEvent ?: settings.backupNIP65RelayList
|
||||
return event?.writeRelaysNorm()?.toSet() ?: Constants.eventFinderRelays
|
||||
}
|
||||
fun nip65Event(note: Note) = note.event as? AdvertisedRelayListEvent ?: settings.backupNIP65RelayList
|
||||
|
||||
fun normalizeNIP65ReadRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> {
|
||||
val event = note.event as? AdvertisedRelayListEvent ?: settings.backupNIP65RelayList
|
||||
return event?.readRelaysNorm()?.toSet() ?: Constants.eventFinderRelays
|
||||
}
|
||||
fun normalizeNIP65WriteRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> = nip65Event(note)?.writeRelaysNorm()?.toSet() ?: Constants.eventFinderRelays
|
||||
|
||||
fun normalizeNIP65AllRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> {
|
||||
val event = note.event as? AdvertisedRelayListEvent ?: settings.backupNIP65RelayList
|
||||
return event?.relays()?.map { it.relayUrl }?.toSet() ?: Constants.eventFinderRelays
|
||||
}
|
||||
fun normalizeNIP65ReadRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> = nip65Event(note)?.readRelaysNorm()?.toSet() ?: Constants.eventFinderRelays
|
||||
|
||||
fun normalizeNIP65AllRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> = nip65Event(note)?.relays()?.map { it.relayUrl }?.toSet() ?: Constants.eventFinderRelays
|
||||
|
||||
fun normalizeNIP65AllRelayListWithBackupNoDefaults(note: Note): Set<NormalizedRelayUrl> = nip65Event(note)?.relays()?.map { it.relayUrl }?.toSet() ?: emptySet()
|
||||
|
||||
val outboxFlow =
|
||||
getNIP65RelayListFlow()
|
||||
@@ -105,6 +100,17 @@ class Nip65RelayListState(
|
||||
emptySet(),
|
||||
)
|
||||
|
||||
val allFlowNoDefaults =
|
||||
getNIP65RelayListFlow()
|
||||
.map { normalizeNIP65AllRelayListWithBackupNoDefaults(it.note) }
|
||||
.onStart { emit(normalizeNIP65AllRelayListWithBackupNoDefaults(getNIP65RelayListNote())) }
|
||||
.flowOn(Dispatchers.Default)
|
||||
.stateIn(
|
||||
scope,
|
||||
SharingStarted.Eagerly,
|
||||
emptySet(),
|
||||
)
|
||||
|
||||
suspend fun saveRelayList(relays: List<AdvertisedRelayInfo>): AdvertisedRelayListEvent {
|
||||
val nip65RelayList = getNIP65RelayList()
|
||||
|
||||
|
||||
+2
-2
@@ -52,11 +52,11 @@ class TrustedRelayListsState(
|
||||
val flow: StateFlow<Set<NormalizedRelayUrl>> =
|
||||
combine(
|
||||
listOf(
|
||||
nip65RelayList.allFlow,
|
||||
nip65RelayList.allFlowNoDefaults,
|
||||
privateOutboxRelayList.flow,
|
||||
localRelayList.flow,
|
||||
dmRelayList.flow,
|
||||
searchRelayListState.flow,
|
||||
searchRelayListState.flowNoDefaults,
|
||||
trustedRelayList.flow,
|
||||
broadcastRelayList.flow,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user