mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-09 23:02:32 +02:00
Includes Trusted Relays in all my relays
This commit is contained in:
@@ -277,7 +277,7 @@ class Account(
|
|||||||
|
|
||||||
// Follows Relays
|
// Follows Relays
|
||||||
val followOutboxes = FollowListOutboxRelays(kind3FollowList, blockedRelayList, cache, scope)
|
val followOutboxes = FollowListOutboxRelays(kind3FollowList, blockedRelayList, cache, scope)
|
||||||
val followPlusAllMine = MergedFollowPlusMineRelayListsState(followOutboxes, nip65RelayList, privateStorageRelayList, localRelayList, scope)
|
val followPlusAllMine = MergedFollowPlusMineRelayListsState(followOutboxes, nip65RelayList, privateStorageRelayList, trustedRelayList, localRelayList, scope)
|
||||||
|
|
||||||
// keeps a cache of the outbox relays for each author
|
// keeps a cache of the outbox relays for each author
|
||||||
val followsPerRelay = FollowsPerOutboxRelay(kind3FollowList, blockedRelayList, cache, scope).flow
|
val followsPerRelay = FollowsPerOutboxRelay(kind3FollowList, blockedRelayList, cache, scope).flow
|
||||||
|
@@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.model.serverList
|
|||||||
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
|
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.localRelays.LocalRelayListState
|
import com.vitorpamplona.amethyst.model.localRelays.LocalRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.nip02FollowLists.FollowListOutboxRelays
|
import com.vitorpamplona.amethyst.model.nip02FollowLists.FollowListOutboxRelays
|
||||||
|
import com.vitorpamplona.amethyst.model.nip51Lists.TrustedRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState
|
import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@@ -39,32 +40,33 @@ class MergedFollowPlusMineRelayListsState(
|
|||||||
val nip65RelayList: Nip65RelayListState,
|
val nip65RelayList: Nip65RelayListState,
|
||||||
val privateOutboxRelayList: PrivateStorageRelayListState,
|
val privateOutboxRelayList: PrivateStorageRelayListState,
|
||||||
val localRelayList: LocalRelayListState,
|
val localRelayList: LocalRelayListState,
|
||||||
|
val trustedRelayList: TrustedRelayListState,
|
||||||
val scope: CoroutineScope,
|
val scope: CoroutineScope,
|
||||||
) {
|
) {
|
||||||
fun mergeLists(
|
fun mergeLists(lists: Array<Set<NormalizedRelayUrl>>): Set<NormalizedRelayUrl> = lists.reduce { acc, set -> acc + set }
|
||||||
kind3: Set<NormalizedRelayUrl>,
|
|
||||||
outbox: Set<NormalizedRelayUrl>,
|
|
||||||
inbox: Set<NormalizedRelayUrl>,
|
|
||||||
private: Set<NormalizedRelayUrl>,
|
|
||||||
local: Set<NormalizedRelayUrl>,
|
|
||||||
): Set<NormalizedRelayUrl> = kind3 + outbox + inbox + private + local
|
|
||||||
|
|
||||||
val flow: StateFlow<Set<NormalizedRelayUrl>> =
|
val flow: StateFlow<Set<NormalizedRelayUrl>> =
|
||||||
combine(
|
combine(
|
||||||
followsOutboxRelayList.flow,
|
listOf(
|
||||||
nip65RelayList.outboxFlow,
|
followsOutboxRelayList.flow,
|
||||||
nip65RelayList.inboxFlow,
|
nip65RelayList.outboxFlow,
|
||||||
privateOutboxRelayList.flow,
|
nip65RelayList.inboxFlow,
|
||||||
localRelayList.flow,
|
privateOutboxRelayList.flow,
|
||||||
|
localRelayList.flow,
|
||||||
|
trustedRelayList.flow,
|
||||||
|
),
|
||||||
::mergeLists,
|
::mergeLists,
|
||||||
).onStart {
|
).onStart {
|
||||||
emit(
|
emit(
|
||||||
mergeLists(
|
mergeLists(
|
||||||
followsOutboxRelayList.flow.value,
|
arrayOf(
|
||||||
nip65RelayList.outboxFlow.value,
|
followsOutboxRelayList.flow.value,
|
||||||
nip65RelayList.inboxFlow.value,
|
nip65RelayList.outboxFlow.value,
|
||||||
privateOutboxRelayList.flow.value,
|
nip65RelayList.inboxFlow.value,
|
||||||
localRelayList.flow.value,
|
privateOutboxRelayList.flow.value,
|
||||||
|
localRelayList.flow.value,
|
||||||
|
trustedRelayList.flow.value,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}.flowOn(Dispatchers.Default)
|
}.flowOn(Dispatchers.Default)
|
||||||
@@ -72,11 +74,14 @@ class MergedFollowPlusMineRelayListsState(
|
|||||||
scope,
|
scope,
|
||||||
SharingStarted.Eagerly,
|
SharingStarted.Eagerly,
|
||||||
mergeLists(
|
mergeLists(
|
||||||
followsOutboxRelayList.flow.value,
|
arrayOf(
|
||||||
nip65RelayList.outboxFlow.value,
|
followsOutboxRelayList.flow.value,
|
||||||
nip65RelayList.inboxFlow.value,
|
nip65RelayList.outboxFlow.value,
|
||||||
privateOutboxRelayList.flow.value,
|
nip65RelayList.inboxFlow.value,
|
||||||
localRelayList.flow.value,
|
privateOutboxRelayList.flow.value,
|
||||||
|
localRelayList.flow.value,
|
||||||
|
trustedRelayList.flow.value,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user