diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 4fa8c1194..cec3aa6b0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -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, 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( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt index 8b0211636..bf9d40fa6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt @@ -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 = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index c4e634e7f..0949c3190 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -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.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.Loading), nwcFilterAssembler = nwcFilters, + otsVerifCache = VerificationStateCache(), cache = LocalCache, client = EmptyNostrClient, scope = scope, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt index 31e72b622..c9a675509 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/DecryptAndIndexProcessor.kt @@ -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 { override suspend fun add( event: OtsEvent, eventNote: Note, publicNote: Note, ) { - Amethyst.instance.otsVerifCache.cacheVerify(event, account.otsResolverBuilder) + otsVerifCache.cacheVerify(event, otsResolverBuilder) } }