mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 10:00:35 +02:00
Removes dependency on the application class from DecryptAndIndexProcessor
This commit is contained in:
@@ -136,6 +136,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtags
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.hasAnyTaggedUser
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUserIds
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.references.references
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.VerificationStateCache
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.okhttp.OkHttpOtsResolverBuilder
|
||||
import com.vitorpamplona.quartz.nip04Dm.PrivateDMCache
|
||||
import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent
|
||||
@@ -225,6 +226,7 @@ class Account(
|
||||
val signer: NostrSigner,
|
||||
val geolocationFlow: StateFlow<LocationState.LocationResult>,
|
||||
val nwcFilterAssembler: NWCPaymentFilterAssembler,
|
||||
val otsVerifCache: VerificationStateCache,
|
||||
val cache: LocalCache,
|
||||
val client: INostrClient,
|
||||
val scope: CoroutineScope,
|
||||
@@ -335,7 +337,7 @@ class Account(
|
||||
|
||||
val otsState = OtsState(signer, cache, otsResolverBuilder, scope, settings)
|
||||
|
||||
val newNotesPreProcessor = EventProcessor(this, LocalCache)
|
||||
val newNotesPreProcessor = EventProcessor(this, otsVerifCache, cache)
|
||||
|
||||
val feedDecryptionCaches =
|
||||
FeedDecryptionCaches(
|
||||
|
@@ -33,6 +33,7 @@ import com.vitorpamplona.quartz.nip01Core.core.toHexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.VerificationStateCache
|
||||
import com.vitorpamplona.quartz.nip55AndroidSigner.client.NostrSignerExternal
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -94,6 +95,7 @@ class AccountCacheState(
|
||||
signer = signer,
|
||||
geolocationFlow = geolocationFlow,
|
||||
nwcFilterAssembler = nwcFilterAssembler,
|
||||
otsVerifCache = VerificationStateCache(),
|
||||
cache = cache,
|
||||
client = client,
|
||||
scope =
|
||||
|
@@ -106,6 +106,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.SignerExceptions
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PubKeyReferenceTag
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.VerificationStateCache
|
||||
import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation
|
||||
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable
|
||||
import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent
|
||||
@@ -1698,6 +1699,7 @@ fun mockAccountViewModel(): AccountViewModel {
|
||||
signer = NostrSignerInternal(keyPair),
|
||||
geolocationFlow = MutableStateFlow<LocationState.LocationResult>(LocationState.LocationResult.Loading),
|
||||
nwcFilterAssembler = nwcFilters,
|
||||
otsVerifCache = VerificationStateCache(),
|
||||
cache = LocalCache,
|
||||
client = client,
|
||||
scope = scope,
|
||||
@@ -1739,6 +1741,7 @@ fun mockVitorAccountViewModel(): AccountViewModel {
|
||||
signer = NostrSignerInternal(keyPair),
|
||||
geolocationFlow = MutableStateFlow<LocationState.LocationResult>(LocationState.LocationResult.Loading),
|
||||
nwcFilterAssembler = nwcFilters,
|
||||
otsVerifCache = VerificationStateCache(),
|
||||
cache = LocalCache,
|
||||
client = EmptyNostrClient,
|
||||
scope = scope,
|
||||
|
@@ -21,7 +21,6 @@
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn
|
||||
|
||||
import android.util.Log
|
||||
import com.vitorpamplona.amethyst.Amethyst
|
||||
import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
@@ -30,6 +29,8 @@ import com.vitorpamplona.quartz.experimental.ephemChat.chat.EphemeralChatEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.core.IEvent
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.OtsEvent
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.VerificationStateCache
|
||||
import com.vitorpamplona.quartz.nip03Timestamp.ots.okhttp.OkHttpOtsResolverBuilder
|
||||
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable
|
||||
import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
|
||||
import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent
|
||||
@@ -43,10 +44,11 @@ import kotlinx.coroutines.CancellationException
|
||||
|
||||
class EventProcessor(
|
||||
private val account: Account,
|
||||
private val otsVerifCache: VerificationStateCache,
|
||||
private val cache: LocalCache,
|
||||
) {
|
||||
private val chatHandler = ChatHandler(account.chatroomList)
|
||||
private val otsHandler = OtsEventHandler(account)
|
||||
private val otsHandler = OtsEventHandler(account.otsResolverBuilder, otsVerifCache)
|
||||
|
||||
private val draftHandler = DraftEventHandler(account, cache)
|
||||
|
||||
@@ -179,14 +181,15 @@ class ChatHandler(
|
||||
}
|
||||
|
||||
class OtsEventHandler(
|
||||
private val account: Account,
|
||||
private val otsResolverBuilder: OkHttpOtsResolverBuilder,
|
||||
private val otsVerifCache: VerificationStateCache,
|
||||
) : EventHandler<OtsEvent> {
|
||||
override suspend fun add(
|
||||
event: OtsEvent,
|
||||
eventNote: Note,
|
||||
publicNote: Note,
|
||||
) {
|
||||
Amethyst.instance.otsVerifCache.cacheVerify(event, account.otsResolverBuilder)
|
||||
otsVerifCache.cacheVerify(event, otsResolverBuilder)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user