From 6ff9460243aee013d6f946fb154e91b7b65c81c9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 15:28:20 +0000 Subject: [PATCH 01/57] refactor: move the DataStore preference layer into commons (KMP) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 1 of the SharedPreferences -> DataStore migration. androidx.datastore:datastore-preferences 1.2.1 publishes android, jvm, ios, linux and macos variants plus common metadata, so the preference layer does not need a port interface to serve the JVM app — the implementation itself is portable. Moves the dependency from commons' androidMain to commonMain and the storage infrastructure with it, using the okio-based `createWithPath` factory because the `java.io.File` overloads are absent on Apple targets. Placement follows what each piece actually needs: - commonMain: DataStoreExt, AccountPreferenceStores (per-account, non-secret). No platform API — the root directory is injected, so Android passes filesDir, desktop its data dir, tests a temp folder. - jvmAndroid: SecretEncryption (expect), EncryptedDataStore, AccountSecretsEncryptedStores. Android and desktop are the two targets that store secrets today; an Apple actual belongs with the first iOS build that needs one rather than stubbed here where nothing exercises it. - androidMain: the existing AndroidKeyStore implementation, moved verbatim from amethyst so the Marmot stores' data stays readable. - jvmMain: a new desktop actual — same AES-256-GCM, key in a 0600 file this OS user owns. Weaker custody than a TEE, documented as such. Fixes a real defect in EncryptedDataStore while moving it. `decrypt` read `encryption.decrypt(...).contentToString()`, which renders a ByteArray as "[104, 101, 108]" rather than decoding it, so every value round-tripped to the debug rendering of its own bytes. Nothing caught it because the class had no callers: AccountPreferenceStores and AccountSecretsEncryptedStores were dead code, one reference each (their own declaration). Verified by reintroducing the bug against the new tests — saveAndGetRoundTrips reads "second" back as "[115, 101, 99, 111, 110, 100]". Private keys deliberately do NOT move into AccountSecretsEncryptedStores. commons already has SecureKeyStorage, backed by the OS credential manager and already used by desktopApp; a second, weaker identity-key store would win by being convenient. That store keeps only non-identity secrets. 13 new tests cover the encrypt/decrypt round trip, that values are not stored in plaintext, that GCM never reuses an IV, that the key persists across instances, that a different key cannot decrypt, 0600 permissions, and that a malformed key file is refused rather than silently replaced. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../marmot/AndroidKeyPackageBundleStore.kt | 6 +- .../model/marmot/AndroidMarmotMessageStore.kt | 6 +- .../model/marmot/AndroidMlsGroupStateStore.kt | 6 +- .../marmot/AndroidPublishObligationStore.kt | 6 +- .../preferences/AccountPreferenceStores.kt | 83 ---------- commons/build.gradle.kts | 9 +- .../preferences/SecretEncryption.android.kt | 10 +- .../preferences/AccountPreferenceStores.kt | 68 ++++++++ .../model/preferences/DataStoreExt.kt | 41 +++-- .../AccountSecretsEncryptedStores.kt | 56 ++++--- .../model/preferences/EncryptedDataStore.kt | 52 +++---- .../model/preferences/SecretEncryption.kt | 41 +++++ .../model/preferences/SecretEncryption.jvm.kt | 146 ++++++++++++++++++ .../preferences/EncryptedDataStoreTest.kt | 134 ++++++++++++++++ .../model/preferences/SecretEncryptionTest.kt | 118 ++++++++++++++ 15 files changed, 599 insertions(+), 183 deletions(-) delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/KeyStoreEncryption.kt => commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.android.kt (96%) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/model/preferences/DataStoreExt.kt (68%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons}/model/preferences/AccountSecretsEncryptedStores.kt (55%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons}/model/preferences/EncryptedDataStore.kt (64%) create mode 100644 commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.kt create mode 100644 commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt index 7a99f80347..04c0db4493 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.amethyst.model.marmot -import com.vitorpamplona.amethyst.model.preferences.KeyStoreEncryption +import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.marmot.mip00KeyPackages.KeyPackageBundleStore import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.Dispatchers @@ -40,12 +40,12 @@ import java.io.File * The blob contains private key material — init keys, encryption keys, * signature keys — that the MLS engine needs to process Welcome events * received days or weeks after the corresponding KeyPackage was published. - * It is encrypted at rest with [KeyStoreEncryption] (AES/GCM via Android + * It is encrypted at rest with [SecretEncryption] (AES/GCM via Android * KeyStore), the same primitive used by [AndroidMlsGroupStateStore]. */ class AndroidKeyPackageBundleStore( private val rootDir: File, - private val encryption: KeyStoreEncryption = KeyStoreEncryption(), + private val encryption: SecretEncryption = SecretEncryption(), ) : KeyPackageBundleStore { private val mutex = Mutex() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt index e7641cb3bf..e6775aa56a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.amethyst.model.marmot import com.vitorpamplona.amethyst.commons.marmot.EncryptedAppendLog -import com.vitorpamplona.amethyst.model.preferences.KeyStoreEncryption +import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.marmot.mls.group.MarmotMessageStore import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.utils.Log @@ -46,7 +46,7 @@ import java.io.File */ class AndroidMarmotMessageStore( private val rootDir: File, - private val encryption: KeyStoreEncryption = KeyStoreEncryption(), + private val encryption: SecretEncryption = SecretEncryption(), ) : MarmotMessageStore { private val logMutex = Mutex() @@ -324,7 +324,7 @@ class AndroidMarmotMessageStore( EncryptedAppendLog( encrypt = { encryption.encrypt(it) }, // EncryptedAppendLog requires null, not a throw, for a segment it - // cannot open — KeyStoreEncryption.decrypt rethrows. Without this + // cannot open — SecretEncryption.decrypt rethrows. Without this // one bad segment would abort the whole read, and a caller that // then sees an empty log can overwrite a history that was merely // unreadable. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt index 504037d630..8d509ed7fc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.amethyst.model.marmot -import com.vitorpamplona.amethyst.model.preferences.KeyStoreEncryption +import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.marmot.mls.group.MlsGroupStateStore import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.Dispatchers @@ -32,7 +32,7 @@ import java.io.FileOutputStream * Android implementation of [MlsGroupStateStore] using file-based encrypted storage. * * All MLS group state (containing private keys and epoch secrets) is encrypted - * at rest using [KeyStoreEncryption] (AES/GCM backed by Android KeyStore). + * at rest using [SecretEncryption] (AES/GCM backed by Android KeyStore). * * Storage layout: * ``` @@ -43,7 +43,7 @@ import java.io.FileOutputStream */ class AndroidMlsGroupStateStore( private val rootDir: File, - private val encryption: KeyStoreEncryption = KeyStoreEncryption(), + private val encryption: SecretEncryption = SecretEncryption(), ) : MlsGroupStateStore { init { Log.d(TAG) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt index 445e91ee91..64b561935e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.amethyst.model.marmot -import com.vitorpamplona.amethyst.model.preferences.KeyStoreEncryption +import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.marmot.protocolCore.MarmotPublishObligationStore import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.utils.Log @@ -32,7 +32,7 @@ import java.io.File /** * Android implementation of [MarmotPublishObligationStore], encrypted at rest - * with [KeyStoreEncryption] like the group-state and KeyPackage stores. + * with [SecretEncryption] like the group-state and KeyPackage stores. * * ``` * /marmot_obligations/.obligation @@ -51,7 +51,7 @@ import java.io.File */ class AndroidPublishObligationStore( private val rootDir: File, - private val encryption: KeyStoreEncryption = KeyStoreEncryption(), + private val encryption: SecretEncryption = SecretEncryption(), ) : MarmotPublishObligationStore { private val mutex = Mutex() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt deleted file mode 100644 index c7fdad1616..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.model.preferences - -import androidx.datastore.core.DataStore -import androidx.datastore.preferences.core.PreferenceDataStoreFactory -import androidx.datastore.preferences.core.Preferences -import androidx.datastore.preferences.core.stringPreferencesKey -import com.vitorpamplona.quartz.utils.cache.LargeCache -import java.io.File - -class AccountPreferenceStores( - val rootFilesDir: () -> File, -) { - companion object { - val defaultHomeFollowList = stringPreferencesKey("defaultHomeFollowList") - val defaultStoriesFollowList = stringPreferencesKey("defaultStoriesFollowList") - val defaultNotificationFollowList = stringPreferencesKey("defaultNotificationFollowList") - val defaultDiscoveryFollowList = stringPreferencesKey("defaultDiscoveryFollowList") - - val localRelayServers = stringPreferencesKey("localRelayServers") - val defaultFileServer = stringPreferencesKey("defaultFileServer") - - val latestUserMetadata = stringPreferencesKey("latestUserMetadata") - val latestContactList = stringPreferencesKey("latestContactList") - val latestDMRelayList = stringPreferencesKey("latestDMRelayList") - val latestNIP65RelayList = stringPreferencesKey("latestNIP65RelayList") - val latestSearchRelayList = stringPreferencesKey("latestSearchRelayList") - val latestBlockedRelayList = stringPreferencesKey("latestBlockedRelayList") - val latestTrustedRelayList = stringPreferencesKey("latestTrustedRelayList") - val latestMuteList = stringPreferencesKey("latestMuteList") - val latestPrivateHomeRelayList = stringPreferencesKey("latestPrivateHomeRelayList") - val latestAppSpecificData = stringPreferencesKey("latestAppSpecificData") - val latestChannelList = stringPreferencesKey("latestChannelList") - val latestCommunityList = stringPreferencesKey("latestCommunityList") - val latestHashtagList = stringPreferencesKey("latestHashtagList") - val latestGeohashList = stringPreferencesKey("latestGeohashList") - val latestEphemeralChatList = stringPreferencesKey("latestEphemeralChatList") - - val hideDeleteRequestDialog = stringPreferencesKey("hideDeleteRequestDialog") - val hideBlockAlertDialog = stringPreferencesKey("hideBlockAlertDialog") - val hideNip17WarningDialog = stringPreferencesKey("hideNip17WarningDialog") - - val torSettings = stringPreferencesKey("tor_settings") - - val hasDonatedInVersion = stringPreferencesKey("hasDonatedInVersion") - } - - private val storeCache = LargeCache>() - - fun file(npub: String) = File(rootFilesDir(), "datastore/$npub.preferences") - - private fun getDataStore(npub: String): DataStore = - storeCache.getOrCreate(npub) { - PreferenceDataStoreFactory.create( - produceFile = { file(npub) }, - ) - } - - fun removeAccount(npub: String): Boolean { - val deleted = file(npub).delete() - storeCache.remove(npub) - return deleted - } -} diff --git a/commons/build.gradle.kts b/commons/build.gradle.kts index b952fe67af..4d6a78e368 100644 --- a/commons/build.gradle.kts +++ b/commons/build.gradle.kts @@ -90,6 +90,14 @@ kotlin { // OkHttp), so declare the dependency the file actually has. implementation(libs.okio) + // DataStore (KMP, Apache-2.0) — the preference storage layer. + // Publishes android/jvm/ios/linux/macos variants plus common + // metadata, so the stores under model/preferences/ are shared + // rather than duplicated per front end. Uses the okio-based + // `createWithPath` factory in common; the `java.io.File` + // overloads are jvmAndroid-only. + implementation(libs.androidx.datastore.preferences) + // Immutable collections api(libs.kotlinx.collections.immutable) @@ -161,7 +169,6 @@ kotlin { // Secure key storage via Android Keystore implementation(libs.androidx.security.crypto.ktx) - implementation(libs.androidx.datastore.preferences) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/KeyStoreEncryption.kt b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.android.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/KeyStoreEncryption.kt rename to commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.android.kt index 68c4efb75e..6e48a17de5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/KeyStoreEncryption.kt +++ b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.android.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import android.os.Build import android.security.keystore.KeyGenParameterSpec @@ -33,9 +33,9 @@ import javax.crypto.SecretKey import javax.crypto.SecretKeyFactory import javax.crypto.spec.GCMParameterSpec -class KeyStoreEncryption { +actual class SecretEncryption { companion object { - private const val TAG = "KeyStoreEncryption" + private const val TAG = "SecretEncryption" private const val ANDROID_KEY_STORE = "AndroidKeyStore" private const val ALGORITHM = KeyProperties.KEY_ALGORITHM_AES private const val BLOCK_MODE = KeyProperties.BLOCK_MODE_GCM @@ -147,7 +147,7 @@ class KeyStoreEncryption { return createKeyStrongBoxIfAvailable() ?: createKeyRegular() } - fun encrypt(bytes: ByteArray): ByteArray { + actual fun encrypt(bytes: ByteArray): ByteArray { try { // Initializes the cipher in encrypt mode and encrypts data val cipher = ciphers.get() @@ -164,7 +164,7 @@ class KeyStoreEncryption { } } - fun decrypt(bytes: ByteArray): ByteArray? { + actual fun decrypt(bytes: ByteArray): ByteArray? { try { // Extract the 12-byte GCM IV prefix and decrypt the remainder. The // AndroidKeyStore cipher only accepts GCMParameterSpec (not a plain diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt new file mode 100644 index 0000000000..ed544ac080 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import com.vitorpamplona.amethyst.commons.util.platformFileSystem +import com.vitorpamplona.quartz.utils.cache.LargeCache +import okio.Path + +/** + * The per-account, non-secret preference store: one DataStore file per npub, + * at `/datastore/.preferences_pb`. + * + * The root directory is injected rather than discovered so every front end can + * say where its data lives — `filesDir` on Android, the app data directory on + * desktop, a temp folder in tests — and so this class needs no platform API of + * its own. + * + * Built on [PreferenceDataStoreFactory.createWithPath], the okio-based factory, + * because the `java.io.File` overloads are absent on Apple targets. + */ +class AccountPreferenceStores( + val rootFilesDir: () -> Path, +) { + private val storeCache = LargeCache>() + + fun file(npub: String): Path = rootFilesDir() / "datastore" / "$npub.preferences_pb" + + fun getDataStore(npub: String): DataStore = + storeCache.getOrCreate(npub) { + PreferenceDataStoreFactory.createWithPath(produceFile = { file(npub) }) + } + + /** + * Drops the account's stored preferences. + * + * The cached handle goes first: deleting the file under a live DataStore + * would leave that instance writing the account's settings back out on the + * next edit, re-creating what this call is meant to erase. + */ + fun removeAccount(npub: String): Boolean { + storeCache.remove(npub) + val path = file(npub) + if (!platformFileSystem.exists(path)) return false + platformFileSystem.delete(path) + return true + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DataStoreExt.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DataStoreExt.kt similarity index 68% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DataStoreExt.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DataStoreExt.kt index 453dd70212..0358899d51 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DataStoreExt.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DataStoreExt.kt @@ -18,18 +18,28 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.emptyPreferences -import com.vitorpamplona.amethyst.commons.model.preferences.UpdatablePropertyFlow import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.map -import java.io.IOException +import okio.IOException +/** + * Exposes one DataStore key as an [UpdatablePropertyFlow]. + * + * A missing key, a blank serialization and an explicit null all mean the same + * thing here — the property is absent — so each of them removes the key rather + * than storing an empty string that would later parse into a bogus value. + * + * Uses okio's [IOException] rather than `java.io.IOException`: on JVM targets + * okio aliases it to exactly that type, so the read-error branch keeps catching + * what DataStore throws while the file stays compilable for Apple targets. + */ fun DataStore.getProperty( key: Preferences.Key, parser: (String) -> T, @@ -42,29 +52,14 @@ fun DataStore.getProperty( .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e }.map { prefs -> - val value = prefs[key] - if (value != null) { - parser(value) - } else { - null - } + prefs[key]?.let(parser) }, update = { newValue -> - if (newValue != null) { - val serialized = serializer(newValue) - if (serialized.isNotBlank()) { - edit { prefs -> - prefs[key] = serialized - } - } else { - edit { prefs -> - prefs.remove(key) - } - } + val serialized = newValue?.let(serializer) + if (serialized != null && serialized.isNotBlank()) { + edit { prefs -> prefs[key] = serialized } } else { - edit { prefs -> - prefs.remove(key) - } + edit { prefs -> prefs.remove(key) } } }, scope = scope, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountSecretsEncryptedStores.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt similarity index 55% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountSecretsEncryptedStores.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt index b9318a4713..60300c1498 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountSecretsEncryptedStores.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt @@ -18,61 +18,67 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.stringPreferencesKey -import com.vitorpamplona.amethyst.commons.model.preferences.UpdatablePropertyFlow -import com.vitorpamplona.quartz.nip01Core.core.HexKey +import com.vitorpamplona.amethyst.commons.util.platformFileSystem import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.utils.cache.LargeCache import kotlinx.coroutines.CoroutineScope -import java.io.File +import okio.Path +/** + * The per-account secret store: one encrypted DataStore per npub, at + * `/datastore/.secrets_pb`, for secrets that are not the identity + * key — wallet connection strings, NIP-46 bunker material. + * + * **Private keys do not belong here.** They live in + * [com.vitorpamplona.amethyst.commons.keystorage.SecureKeyStorage], which backs + * them with the OS credential manager (Keychain, Credential Manager, Secret + * Service) rather than a file this process can read, and which desktop already + * uses. Two stores for one identity key would be one store too many, and the + * weaker one would win by being convenient. + * + * Separate from [AccountPreferenceStores] so ordinary settings stay cheap to + * read: every value here pays an encrypt/decrypt, which on a StrongBox-backed + * device runs at roughly 68 KB/s. + */ class AccountSecretsEncryptedStores( - val rootFilesDir: () -> File, + val rootFilesDir: () -> Path, val scope: CoroutineScope, + private val encryption: SecretEncryption = SecretEncryption(), ) { - companion object Companion { - val encryption = KeyStoreEncryption() - val key = stringPreferencesKey("privKey") + companion object { val nwc = stringPreferencesKey("nwc") } private val storeCache = LargeCache() - fun file(npub: String) = File(rootFilesDir(), "datastore/$npub.secrets") + fun file(npub: String): Path = rootFilesDir() / "datastore" / "$npub.secrets_pb" - private fun getDataStore(npub: String): EncryptedDataStore = + fun getDataStore(npub: String): EncryptedDataStore = storeCache.getOrCreate(npub) { EncryptedDataStore( - PreferenceDataStoreFactory.create( - produceFile = { file(npub) }, - ), + PreferenceDataStoreFactory.createWithPath(produceFile = { file(npub) }), encryption, scope = scope, ) } - suspend fun getPrivateKey(npub: String): String? = getDataStore(npub).get(key) - - suspend fun savePrivateKey( - npub: String, - value: HexKey, - ) { - getDataStore(npub).save(key, value) - } - - suspend fun nwc(npub: String): UpdatablePropertyFlow = + fun nwc(npub: String): UpdatablePropertyFlow = getDataStore(npub).getProperty( key = nwc, parser = Nip47WalletConnect.Nip47URI::parser, serializer = Nip47WalletConnect.Nip47URI::serializer, ) + /** See [AccountPreferenceStores.removeAccount] — the cached handle goes first. */ fun removeAccount(npub: String): Boolean { - val deleted = file(npub).delete() storeCache.remove(npub) - return deleted + val path = file(npub) + if (!platformFileSystem.exists(path)) return false + platformFileSystem.delete(path) + return true } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/EncryptedDataStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt similarity index 64% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/EncryptedDataStore.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt index 49091d62c7..710102f222 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/EncryptedDataStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt @@ -18,46 +18,44 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.emptyPreferences -import com.vitorpamplona.amethyst.commons.model.preferences.UpdatablePropertyFlow import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map -import java.io.IOException +import okio.IOException import kotlin.io.encoding.Base64 +/** + * A DataStore whose values are encrypted with [SecretEncryption] and stored + * Base64-encoded, for anything that must not sit in plaintext on disk. + * + * Keys stay in the clear — only values are encrypted — so the set of keys an + * account has is visible even though their contents are not. + */ class EncryptedDataStore( private val store: DataStore, - private val encryption: KeyStoreEncryption = KeyStoreEncryption(), + private val encryption: SecretEncryption = SecretEncryption(), private val scope: CoroutineScope, ) { - private fun decode(str: String): ByteArray = Base64.decode(str) + private fun encrypt(value: String): String = Base64.encode(encryption.encrypt(value.encodeToByteArray())) - private fun encode(bytes: ByteArray): String = Base64.encode(bytes) - - private fun encrypt(value: String): String = encode(encryption.encrypt(value.toByteArray())) - - private fun decrypt(value: String): String = encryption.decrypt(decode(value)).contentToString() + private fun decrypt(value: String): String? = encryption.decrypt(Base64.decode(value))?.decodeToString() suspend fun remove(key: Preferences.Key) { - store.edit { prefs -> - prefs.remove(key) - } + store.edit { prefs -> prefs.remove(key) } } suspend fun save( key: Preferences.Key, value: String, ) { - store.edit { prefs -> - prefs[key] = encrypt(value) - } + store.edit { prefs -> prefs[key] = encrypt(value) } } suspend fun get(key: Preferences.Key): String? = @@ -79,26 +77,12 @@ class EncryptedDataStore( .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e }.map { prefs -> - val value = prefs[key] - if (value != null) { - val decrypted = decrypt(value) - if (decrypted.isNotBlank()) { - parser(decrypted) - } else { - null - } - } else { - null - } + prefs[key]?.let { decrypt(it) }?.takeIf { it.isNotBlank() }?.let(parser) }, update = { newValue -> - if (newValue != null) { - val serialized = serializer(newValue) - if (serialized.isNotBlank()) { - save(key, serialized) - } else { - remove(key) - } + val serialized = newValue?.let(serializer) + if (serialized != null && serialized.isNotBlank()) { + save(key, serialized) } else { remove(key) } diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.kt new file mode 100644 index 0000000000..22ad8f450e --- /dev/null +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.kt @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +/** + * Symmetric encryption for data this app stores at rest — account secrets, the + * Marmot group state, message bodies. + * + * Declared for `jvmAndroid` rather than `commonMain` on purpose: Android backs + * it with the hardware-held AndroidKeyStore and desktop with a key file the OS + * user owns, and those are the two targets that store secrets today. An Apple + * actual belongs with the first iOS build that needs one, written against the + * Keychain — not stubbed here, where nothing would exercise it. + * + * Implementations must be safe to call from several coroutines at once. + */ +expect class SecretEncryption() { + /** Returns the ciphertext with whatever nonce/IV the implementation needs prefixed. */ + fun encrypt(bytes: ByteArray): ByteArray + + /** Inverse of [encrypt]. Throws if the input is not what [encrypt] produced. */ + fun decrypt(bytes: ByteArray): ByteArray? +} diff --git a/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt new file mode 100644 index 0000000000..a1c9246919 --- /dev/null +++ b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import com.vitorpamplona.amethyst.commons.util.restrictToOwner +import com.vitorpamplona.quartz.utils.Log +import java.io.File +import java.security.SecureRandom +import javax.crypto.Cipher +import javax.crypto.SecretKey +import javax.crypto.spec.GCMParameterSpec +import javax.crypto.spec.SecretKeySpec + +/** + * Desktop [SecretEncryption]: the same AES-256-GCM as Android, but with the key + * held in a file this OS user owns instead of in hardware. + * + * That difference is real and worth stating plainly. On Android the key lives + * in the AndroidKeyStore and never enters app memory, so a copy of the data + * files is useless without the device. Here the key sits next to the data, + * readable by anything running as this user — encryption at rest that survives + * a stolen disk or a careless backup, not a compromised account. The JVM has no + * portable hardware-backed keystore to do better with; a per-OS keyring binding + * (as `cli`'s SecretStore does for credentials) is the upgrade path. + */ +actual class SecretEncryption internal constructor( + private val keyFile: File, +) { + /** Production entry point: the key file this OS user owns. */ + actual constructor() : this(defaultKeyFile()) + + companion object { + private const val TAG = "SecretEncryption" + private const val TRANSFORMATION = "AES/GCM/NoPadding" + private const val ALGORITHM = "AES" + private const val KEY_SIZE_BYTES = 32 + private const val GCM_IV_LENGTH = 12 + private const val GCM_TAG_LENGTH_BITS = 128 + private const val KEY_FILE_NAME = "secret.key" + + /** Where this OS keeps per-user application data. */ + internal fun defaultKeyFile(): File { + val home = System.getProperty("user.home") ?: "." + val os = System.getProperty("os.name").orEmpty().lowercase() + val dir = + when { + os.contains("mac") || os.contains("darwin") -> + File(home, "Library/Application Support/Amethyst") + os.contains("win") -> + File(System.getenv("APPDATA") ?: "$home\\AppData\\Roaming", "Amethyst") + else -> + File(System.getenv("XDG_DATA_HOME")?.takeIf { it.isNotBlank() } ?: "$home/.local/share", "amethyst") + } + return File(dir, KEY_FILE_NAME) + } + } + + // A Cipher holds the state of the operation in progress, so two coroutines + // encrypting through one instance would corrupt each other's output. One + // per thread, matching the Android actual. + private val ciphers = ThreadLocal.withInitial { Cipher.getInstance(TRANSFORMATION) } + + @Volatile + private var cachedKey: SecretKey? = null + + private fun getKey(): SecretKey = + cachedKey ?: synchronized(this) { + cachedKey ?: loadOrCreateKey().also { cachedKey = it } + } + + private fun loadOrCreateKey(): SecretKey { + if (keyFile.exists()) { + val bytes = keyFile.readBytes() + if (bytes.size == KEY_SIZE_BYTES) return SecretKeySpec(bytes, ALGORITHM) + // A truncated or padded key file cannot decrypt anything already + // written; replacing it silently would strand that data under a key + // nobody holds. Fail loudly instead. + throw IllegalStateException( + "Key file ${keyFile.absolutePath} is ${bytes.size} bytes, expected $KEY_SIZE_BYTES. " + + "Refusing to overwrite it — move it aside to start fresh.", + ) + } + return createKey() + } + + private fun createKey(): SecretKey { + Log.d(TAG) { "Creating a new AES key at ${keyFile.absolutePath}" } + val bytes = ByteArray(KEY_SIZE_BYTES).also { SecureRandom().nextBytes(it) } + + keyFile.parentFile?.let { parent -> + parent.mkdirs() + parent.restrictToOwner(TAG) + } + // Narrow the file before the key goes in: created at the default umask + // and chmodded afterwards, the key would be world-readable in between. + keyFile.createNewFile() + keyFile.restrictToOwner(TAG) + keyFile.writeBytes(bytes) + + return SecretKeySpec(bytes, ALGORITHM) + } + + actual fun encrypt(bytes: ByteArray): ByteArray { + try { + val cipher = ciphers.get() + cipher.init(Cipher.ENCRYPT_MODE, getKey()) + return cipher.iv + cipher.doFinal(bytes) + } catch (e: Exception) { + cachedKey = null + Log.e(TAG, "encrypt() failed: ${e.message}", e) + throw e + } + } + + actual fun decrypt(bytes: ByteArray): ByteArray? { + try { + val iv = bytes.copyOfRange(0, GCM_IV_LENGTH) + val data = bytes.copyOfRange(GCM_IV_LENGTH, bytes.size) + val cipher = ciphers.get() + cipher.init(Cipher.DECRYPT_MODE, getKey(), GCMParameterSpec(GCM_TAG_LENGTH_BITS, iv)) + return cipher.doFinal(data) + } catch (e: Exception) { + cachedKey = null + Log.e(TAG, "decrypt() failed (input ${bytes.size} bytes): ${e.message}", e) + throw e + } + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt new file mode 100644 index 0000000000..68eddfbf94 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * Round-trip coverage for the encrypted store. + * + * The store shipped with `decrypt` reading + * `encryption.decrypt(...).contentToString()`, which renders a ByteArray as + * `"[104, 101, 108]"` instead of decoding it, so every value read back was the + * debug rendering of its own bytes. Nothing caught it because the class had no + * callers. [saveAndGetRoundTrips] is the test that fails against that version. + */ +class EncryptedDataStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private val key = stringPreferencesKey("nwc") + + private var seq = 0 + + /** + * A store over its own pair of fresh paths. + * + * The files are named, never created: DataStore writes them itself, and an + * empty file left behind by `newFile()` is not a valid preferences_pb. The + * path is resolved once and captured, because `produceFile` may be invoked + * more than once and must answer the same file every time. + */ + private fun store(scope: CoroutineScope): EncryptedDataStore { + val n = seq++ + val dataFile = File(folder.root, "secrets_$n.preferences_pb") + val keyFile = File(folder.root, "secret_$n.key") + return EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath(scope = scope, produceFile = { dataFile.toOkioPath() }), + SecretEncryption(keyFile), + scope = scope, + ) + } + + @Test + fun saveAndGetRoundTrips() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val subject = store(scope) + val nsec = "e5e2b1d3f6a94c8d7b0e1f2a3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d" + + subject.save(key, nsec) + + assertEquals(nsec, subject.get(key)) + } + + @Test + fun missingKeyReadsBackAsNull() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + assertNull(store(scope).get(key)) + } + + @Test + fun valuesAreNotStoredInPlaintext() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val file = File(folder.root, "plaintext_check.preferences_pb") + val subject = + EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath(scope = scope, produceFile = { file.toOkioPath() }), + SecretEncryption(File(folder.root, "plaintext_check.key")), + scope = scope, + ) + val secret = "correct-horse-battery-staple" + + subject.save(key, secret) + + val onDisk = file.readBytes().decodeToString() + assertEquals("the secret must not be readable in the store file", false, onDisk.contains(secret)) + } + + @Test + fun overwriteReplacesTheValue() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val subject = store(scope) + + subject.save(key, "first") + subject.save(key, "second") + + assertEquals("second", subject.get(key)) + } + + @Test + fun removeClearsTheValue() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val subject = store(scope) + + subject.save(key, "value") + subject.remove(key) + + assertNull(subject.get(key)) + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt new file mode 100644 index 0000000000..854eef57ab --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotEquals +import org.junit.Assert.assertThrows +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File +import java.nio.file.Files +import java.nio.file.attribute.PosixFilePermission + +class SecretEncryptionTest { + @get:Rule + val folder = TemporaryFolder() + + private fun subject(name: String = "secret.key") = SecretEncryption(File(folder.root, name)) + + @Test + fun roundTripsBytes() { + val encryption = subject() + val plaintext = "an nsec, a wallet string, a group state".encodeToByteArray() + + assertArrayEquals(plaintext, encryption.decrypt(encryption.encrypt(plaintext))) + } + + @Test + fun roundTripsEmptyInput() { + val encryption = subject() + + assertArrayEquals(ByteArray(0), encryption.decrypt(encryption.encrypt(ByteArray(0)))) + } + + @Test + fun ciphertextDiffersFromPlaintext() { + val plaintext = "correct-horse-battery-staple".encodeToByteArray() + + val ciphertext = subject().encrypt(plaintext) + + assertFalse(ciphertext.decodeToString().contains("correct-horse")) + } + + /** GCM must never reuse an IV under the same key, so the same input encrypts differently each time. */ + @Test + fun encryptingTwiceProducesDifferentCiphertext() { + val encryption = subject() + val plaintext = "same input".encodeToByteArray() + + assertNotEquals( + encryption.encrypt(plaintext).toList(), + encryption.encrypt(plaintext).toList(), + ) + } + + /** A second instance over the same key file must read the first one's output. */ + @Test + fun keyPersistsAcrossInstances() { + val plaintext = "survives a restart".encodeToByteArray() + val ciphertext = subject().encrypt(plaintext) + + assertArrayEquals(plaintext, subject().decrypt(ciphertext)) + } + + /** A different key file must not decrypt — otherwise the key is not doing anything. */ + @Test + fun aDifferentKeyCannotDecrypt() { + val ciphertext = subject("first.key").encrypt("secret".encodeToByteArray()) + + assertThrows(Exception::class.java) { subject("second.key").decrypt(ciphertext) } + } + + @Test + fun keyFileIsOwnerOnly() { + subject().encrypt("x".encodeToByteArray()) + + val perms = Files.getPosixFilePermissions(File(folder.root, "secret.key").toPath()) + assertEquals(setOf(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE), perms) + } + + /** + * A wrong-sized key file means data already on disk was written under a key + * we no longer have. Overwriting it would strand that data silently. + */ + @Test + fun refusesToOverwriteAMalformedKeyFile() { + val keyFile = File(folder.root, "truncated.key") + keyFile.writeBytes(ByteArray(7)) + + val error = + assertThrows(IllegalStateException::class.java) { + SecretEncryption(keyFile).encrypt("x".encodeToByteArray()) + } + assertTrue(error.message!!.contains("Refusing to overwrite")) + } +} From 3c8581717d99cd0bffbe34cb20728f1ca4cf1d08 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 15:48:48 +0000 Subject: [PATCH 02/57] refactor: move the 31 top-nav follow-list prefs to DataStore Step 2a of the SharedPreferences -> DataStore migration. The top-nav filter selections were 31 near-identical SharedPreferences reads and 31 writes spread across LocalPreferences. They become a table: FollowListSlot names each feed with the key it has always been stored under and the filter it falls back to, and TopNavFollowListStore (in commons/commonMain, so desktop gets it too) reads and writes the set. LocalPreferences keeps mapping the slots onto the named AccountSettings fields, so AccountSettings itself is unchanged. The slot table was generated from the live loader rather than transcribed, because the defaults are not uniform and the differences matter: products and geocaches open to what is nearby, badges and relay-group discovery to the user's own, most others to Global. Values keep the same JSON encoding, so a migrated store and a legacy one hold byte-identical strings. Existing users are carried over by CopyOnceMigration, which copies the legacy values into the new store the first time it is read. It copies rather than moves, deliberately: SharedPreferencesMigration, the stock implementation, deletes each key it migrates, making the change a one-way door where a rolled-back build finds the settings gone. A marker key in the destination records that the copy ran, so the legacy data stays readable and rollback still works. Deleting it is a later, separate decision. Two traps worth naming, both hit while writing this: - androidx.datastore declares its own `infix to` on Preferences.Key, so `slot.key to value` silently builds a Preferences.Pair rather than the kotlin Pair that toMap() needs. Both sites now construct Pair(...) explicitly. - kotlinx serializes by STATIC type, so JsonMapper.toJson(TopFilter.Global) encodes the concrete object with no polymorphic discriminator and cannot be read back as a TopFilter. Production call sites are safe because they read a StateFlow.value; the tests now go through a helper that widens to TopFilter, which is what caught it. 8 tests cover the per-slot defaults (including that they have not collapsed to a single value), that saved values read back, that an unparseable entry costs only that feed's filter, that the prefKeys are the ones the app has always written, that the migration copies, and that it does not run twice and clobber a later edit. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/LocalPreferences.kt | 180 +++++++++----- .../preferences/AccountPreferenceStores.kt | 11 +- .../model/preferences/CopyOnceMigration.kt | 66 ++++++ .../preferences/TopNavFollowListStore.kt | 141 +++++++++++ .../preferences/TopNavFollowListStoreTest.kt | 223 ++++++++++++++++++ 5 files changed, 555 insertions(+), 66 deletions(-) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index a76ebb2365..467f07eb97 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -34,6 +34,10 @@ import com.vitorpamplona.amethyst.commons.model.mediaServers.ServerName import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupViewMode import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntry import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntryNorm +import com.vitorpamplona.amethyst.commons.model.preferences.AccountPreferenceStores +import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration +import com.vitorpamplona.amethyst.commons.model.preferences.FollowListSlot +import com.vitorpamplona.amethyst.commons.model.preferences.TopNavFollowListStore import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthPolicy import com.vitorpamplona.amethyst.model.AccountSettings @@ -85,6 +89,7 @@ import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable +import okio.Path.Companion.toOkioPath import java.io.File // Release mode (!BuildConfig.DEBUG) always uses encrypted preferences @@ -249,6 +254,40 @@ object LocalPreferences { private val savedAccountsMutex = Mutex() private val cachedAccounts: MutableMap = mutableMapOf() + /** + * The per-account DataStore, and the top-nav filter selections inside it. + * + * Each account's store carries a [CopyOnceMigration] that lifts the filters + * out of that account's legacy encrypted SharedPreferences the first time + * the store is read. The copy leaves the legacy keys in place, so a build + * that reads the old location still works — see [CopyOnceMigration]. + */ + private val accountStores: AccountPreferenceStores by lazy { + AccountPreferenceStores( + rootFilesDir = { + Amethyst.instance.appContext.filesDir + .toOkioPath() + }, + migrations = { npub -> listOf(followListMigration(npub)) }, + ) + } + + private fun followListStore(npub: String) = TopNavFollowListStore(accountStores.getDataStore(npub)) + + private fun followListMigration(npub: String) = + CopyOnceMigration("migrated.followLists") { + withContext(Dispatchers.IO) { + val legacy = encryptedPreferences(npub) + // Pair(...) and not `slot.key to it`: androidx.datastore declares its + // own infix `to` on Preferences.Key, which would build a + // Preferences.Pair instead of the kotlin Pair toMap() needs. + FollowListSlot.entries + .mapNotNull { slot -> + legacy.getString(slot.prefKey, null)?.let { Pair(slot.key, it) } + }.toMap() + } + } + // Global master switch for the always-on notification service ("Background // notification service"). Default ON: existing users keep current behavior, and // per-account participation decides who actually stays active. @@ -526,38 +565,8 @@ object LocalPreferences { putString(PrefKeys.NIP46_TRANSPORT_KEY, settings.nip46TransportKey.value) putStringSet(PrefKeys.NIP46_SEEN_IDS, settings.nip46SeenRequestIds.value) - putString(PrefKeys.DEFAULT_HOME_FOLLOW_LIST, JsonMapper.toJson(settings.defaultHomeFollowList.value)) - putString(PrefKeys.DEFAULT_STORIES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultStoriesFollowList.value)) - putString(PrefKeys.DEFAULT_NOTIFICATION_FOLLOW_LIST, JsonMapper.toJson(settings.defaultNotificationFollowList.value)) - putString(PrefKeys.DEFAULT_DISCOVERY_FOLLOW_LIST, JsonMapper.toJson(settings.defaultDiscoveryFollowList.value)) - - putString(PrefKeys.DEFAULT_POLLS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultPollsFollowList.value)) - putString(PrefKeys.DEFAULT_PICTURES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultPicturesFollowList.value)) - putString(PrefKeys.DEFAULT_RELAY_GROUPS_DISCOVERY_FOLLOW_LIST, JsonMapper.toJson(settings.defaultRelayGroupsDiscoveryFollowList.value)) - putString(PrefKeys.DEFAULT_NAPPLETS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultNappletsFollowList.value)) - putString(PrefKeys.DEFAULT_NSITES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultNsitesFollowList.value)) - putString(PrefKeys.DEFAULT_WORKOUTS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultWorkoutsFollowList.value)) - putString(PrefKeys.DEFAULT_GIT_REPOSITORIES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultGitRepositoriesFollowList.value)) - putString(PrefKeys.DEFAULT_HIGHLIGHTS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultHighlightsFollowList.value)) - putString(PrefKeys.DEFAULT_CALENDARS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultCalendarsFollowList.value)) - putString(PrefKeys.DEFAULT_PRODUCTS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultProductsFollowList.value)) - putString(PrefKeys.DEFAULT_GEOCACHES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultGeocachesFollowList.value)) - putString(PrefKeys.DEFAULT_SHORTS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultShortsFollowList.value)) - putString(PrefKeys.DEFAULT_PUBLIC_CHATS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultPublicChatsFollowList.value)) - putString(PrefKeys.DEFAULT_LIVE_STREAMS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultLiveStreamsFollowList.value)) - putString(PrefKeys.DEFAULT_NESTS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultNestsFollowList.value)) - putString(PrefKeys.DEFAULT_LONGS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultLongsFollowList.value)) - putString(PrefKeys.DEFAULT_ARTICLES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultArticlesFollowList.value)) - putString(PrefKeys.DEFAULT_MUSIC_TRACKS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultMusicTracksFollowList.value)) - putString(PrefKeys.DEFAULT_MUSIC_PLAYLISTS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultMusicPlaylistsFollowList.value)) - putString(PrefKeys.DEFAULT_PODCAST_EPISODES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultPodcastEpisodesFollowList.value)) - putString(PrefKeys.DEFAULT_PODCASTS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultPodcastsFollowList.value)) - putString(PrefKeys.DEFAULT_SOFTWARE_APPS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultSoftwareAppsFollowList.value)) - putString(PrefKeys.DEFAULT_BADGES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultBadgesFollowList.value)) - putString(PrefKeys.DEFAULT_BROWSE_EMOJI_SETS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultBrowseEmojiSetsFollowList.value)) - putString(PrefKeys.DEFAULT_COMMUNITIES_FOLLOW_LIST, JsonMapper.toJson(settings.defaultCommunitiesFollowList.value)) - putString(PrefKeys.DEFAULT_FOLLOW_PACKS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultFollowPacksFollowList.value)) - putString(PrefKeys.DEFAULT_APP_RECOMMENDATIONS_FOLLOW_LIST, JsonMapper.toJson(settings.defaultAppRecommendationsFollowList.value)) + // top-nav filters now live in the account's DataStore; written below, + // outside this edit block, because that write is suspend. val walletEntries = settings.nwcWallets.value.mapNotNull { it.denormalize() } if (walletEntries.isNotEmpty()) { @@ -678,6 +687,41 @@ object LocalPreferences { ) } } + followListStore(settings.keyPair.pubKey.toNpub()).saveAll( + mapOf( + FollowListSlot.HOME to settings.defaultHomeFollowList.value, + FollowListSlot.STORIES to settings.defaultStoriesFollowList.value, + FollowListSlot.NOTIFICATION to settings.defaultNotificationFollowList.value, + FollowListSlot.DISCOVERY to settings.defaultDiscoveryFollowList.value, + FollowListSlot.POLLS to settings.defaultPollsFollowList.value, + FollowListSlot.PICTURES to settings.defaultPicturesFollowList.value, + FollowListSlot.RELAY_GROUPS_DISCOVERY to settings.defaultRelayGroupsDiscoveryFollowList.value, + FollowListSlot.NAPPLETS to settings.defaultNappletsFollowList.value, + FollowListSlot.NSITES to settings.defaultNsitesFollowList.value, + FollowListSlot.WORKOUTS to settings.defaultWorkoutsFollowList.value, + FollowListSlot.GIT_REPOSITORIES to settings.defaultGitRepositoriesFollowList.value, + FollowListSlot.HIGHLIGHTS to settings.defaultHighlightsFollowList.value, + FollowListSlot.CALENDARS to settings.defaultCalendarsFollowList.value, + FollowListSlot.PRODUCTS to settings.defaultProductsFollowList.value, + FollowListSlot.GEOCACHES to settings.defaultGeocachesFollowList.value, + FollowListSlot.SHORTS to settings.defaultShortsFollowList.value, + FollowListSlot.PUBLIC_CHATS to settings.defaultPublicChatsFollowList.value, + FollowListSlot.LIVE_STREAMS to settings.defaultLiveStreamsFollowList.value, + FollowListSlot.NESTS to settings.defaultNestsFollowList.value, + FollowListSlot.LONGS to settings.defaultLongsFollowList.value, + FollowListSlot.ARTICLES to settings.defaultArticlesFollowList.value, + FollowListSlot.MUSIC_TRACKS to settings.defaultMusicTracksFollowList.value, + FollowListSlot.MUSIC_PLAYLISTS to settings.defaultMusicPlaylistsFollowList.value, + FollowListSlot.PODCAST_EPISODES to settings.defaultPodcastEpisodesFollowList.value, + FollowListSlot.PODCASTS to settings.defaultPodcastsFollowList.value, + FollowListSlot.SOFTWARE_APPS to settings.defaultSoftwareAppsFollowList.value, + FollowListSlot.BADGES to settings.defaultBadgesFollowList.value, + FollowListSlot.BROWSE_EMOJI_SETS to settings.defaultBrowseEmojiSetsFollowList.value, + FollowListSlot.COMMUNITIES to settings.defaultCommunitiesFollowList.value, + FollowListSlot.FOLLOW_PACKS to settings.defaultFollowPacksFollowList.value, + FollowListSlot.APP_RECOMMENDATIONS to settings.defaultAppRecommendationsFollowList.value, + ), + ) } Log.d("LocalPreferences", "Saved to encrypted storage") } @@ -810,7 +854,7 @@ object LocalPreferences { val viewedPollResultNoteIdsStr = getString(PrefKeys.VIEWED_POLL_RESULT_NOTE_IDS, null) val localRelayServers = getStringSet(PrefKeys.LOCAL_RELAY_SERVERS, null) ?: setOf() - val followListPrefs = loadFollowListPrefs() + val followListPrefs = toFollowListPrefs(followListStore(keyPair.pubKey.toNpub()).load()) val zapPaymentRequestServerStr = getString(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER, null) val nwcWalletsStr = getString(PrefKeys.NWC_WALLETS, null) @@ -1160,39 +1204,45 @@ object LocalPreferences { return migrated } - private fun SharedPreferences.loadFollowListPrefs(): FollowListPrefs = + /** + * Maps the store's slot table onto the named fields [AccountSettings] + * still expects. `getValue` is intentional: [TopNavFollowListStore.load] + * returns every slot, so a missing one is a bug in this mapping rather + * than a user with no saved filter, and should fail loudly. + */ + private fun SharedPreferences.toFollowListPrefs(filters: Map): FollowListPrefs = FollowListPrefs( - home = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_HOME_FOLLOW_LIST, null), TopFilter.AllFollows), - stories = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_STORIES_FOLLOW_LIST, null), TopFilter.Global), - notification = migrateNotificationFilter(parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_NOTIFICATION_FOLLOW_LIST, null), TopFilter.Selected)), - discovery = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_DISCOVERY_FOLLOW_LIST, null), TopFilter.Global), - polls = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_POLLS_FOLLOW_LIST, null), TopFilter.Global), - pictures = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_PICTURES_FOLLOW_LIST, null), TopFilter.Global), - relayGroupsDiscovery = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_RELAY_GROUPS_DISCOVERY_FOLLOW_LIST, null), TopFilter.Mine), - napplets = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_NAPPLETS_FOLLOW_LIST, null), TopFilter.Global), - nsites = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_NSITES_FOLLOW_LIST, null), TopFilter.Global), - workouts = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_WORKOUTS_FOLLOW_LIST, null), TopFilter.Global), - gitRepositories = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_GIT_REPOSITORIES_FOLLOW_LIST, null), TopFilter.Global), - highlights = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_HIGHLIGHTS_FOLLOW_LIST, null), TopFilter.Global), - calendars = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_CALENDARS_FOLLOW_LIST, null), TopFilter.Global), - products = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_PRODUCTS_FOLLOW_LIST, null), TopFilter.AroundMe), - geocaches = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_GEOCACHES_FOLLOW_LIST, null), TopFilter.AroundMe), - shorts = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_SHORTS_FOLLOW_LIST, null), TopFilter.Global), - publicChats = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_PUBLIC_CHATS_FOLLOW_LIST, null), TopFilter.Global), - liveStreams = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_LIVE_STREAMS_FOLLOW_LIST, null), TopFilter.Global), - nests = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_NESTS_FOLLOW_LIST, null), TopFilter.Global), - longs = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_LONGS_FOLLOW_LIST, null), TopFilter.Global), - articles = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_ARTICLES_FOLLOW_LIST, null), TopFilter.AllFollows), - musicTracks = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_MUSIC_TRACKS_FOLLOW_LIST, null), TopFilter.Global), - musicPlaylists = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_MUSIC_PLAYLISTS_FOLLOW_LIST, null), TopFilter.Global), - podcastEpisodes = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_PODCAST_EPISODES_FOLLOW_LIST, null), TopFilter.Global), - podcasts = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_PODCASTS_FOLLOW_LIST, null), TopFilter.Global), - softwareApps = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_SOFTWARE_APPS_FOLLOW_LIST, null), TopFilter.Global), - badges = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_BADGES_FOLLOW_LIST, null), TopFilter.Mine), - browseEmojiSets = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_BROWSE_EMOJI_SETS_FOLLOW_LIST, null), TopFilter.Global), - communities = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_COMMUNITIES_FOLLOW_LIST, null), TopFilter.AllFollows), - followPacks = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_FOLLOW_PACKS_FOLLOW_LIST, null), TopFilter.Global), - appRecommendations = parseTopFilterOrDefault(getString(PrefKeys.DEFAULT_APP_RECOMMENDATIONS_FOLLOW_LIST, null), TopFilter.Global), + home = filters.getValue(FollowListSlot.HOME), + stories = filters.getValue(FollowListSlot.STORIES), + notification = migrateNotificationFilter(filters.getValue(FollowListSlot.NOTIFICATION)), + discovery = filters.getValue(FollowListSlot.DISCOVERY), + polls = filters.getValue(FollowListSlot.POLLS), + pictures = filters.getValue(FollowListSlot.PICTURES), + relayGroupsDiscovery = filters.getValue(FollowListSlot.RELAY_GROUPS_DISCOVERY), + napplets = filters.getValue(FollowListSlot.NAPPLETS), + nsites = filters.getValue(FollowListSlot.NSITES), + workouts = filters.getValue(FollowListSlot.WORKOUTS), + gitRepositories = filters.getValue(FollowListSlot.GIT_REPOSITORIES), + highlights = filters.getValue(FollowListSlot.HIGHLIGHTS), + calendars = filters.getValue(FollowListSlot.CALENDARS), + products = filters.getValue(FollowListSlot.PRODUCTS), + geocaches = filters.getValue(FollowListSlot.GEOCACHES), + shorts = filters.getValue(FollowListSlot.SHORTS), + publicChats = filters.getValue(FollowListSlot.PUBLIC_CHATS), + liveStreams = filters.getValue(FollowListSlot.LIVE_STREAMS), + nests = filters.getValue(FollowListSlot.NESTS), + longs = filters.getValue(FollowListSlot.LONGS), + articles = filters.getValue(FollowListSlot.ARTICLES), + musicTracks = filters.getValue(FollowListSlot.MUSIC_TRACKS), + musicPlaylists = filters.getValue(FollowListSlot.MUSIC_PLAYLISTS), + podcastEpisodes = filters.getValue(FollowListSlot.PODCAST_EPISODES), + podcasts = filters.getValue(FollowListSlot.PODCASTS), + softwareApps = filters.getValue(FollowListSlot.SOFTWARE_APPS), + badges = filters.getValue(FollowListSlot.BADGES), + browseEmojiSets = filters.getValue(FollowListSlot.BROWSE_EMOJI_SETS), + communities = filters.getValue(FollowListSlot.COMMUNITIES), + followPacks = filters.getValue(FollowListSlot.FOLLOW_PACKS), + appRecommendations = filters.getValue(FollowListSlot.APP_RECOMMENDATIONS), ) private inline fun parseOrNull(value: String?): T? { diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt index ed544ac080..af03d7de4d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.commons.model.preferences +import androidx.datastore.core.DataMigration import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences @@ -38,9 +39,14 @@ import okio.Path * * Built on [PreferenceDataStoreFactory.createWithPath], the okio-based factory, * because the `java.io.File` overloads are absent on Apple targets. + * + * [migrations] runs once per account, before that account's store answers its + * first read. Android supplies one that copies out of the legacy + * SharedPreferences; front ends with no history supply none. */ class AccountPreferenceStores( val rootFilesDir: () -> Path, + private val migrations: (npub: String) -> List> = { emptyList() }, ) { private val storeCache = LargeCache>() @@ -48,7 +54,10 @@ class AccountPreferenceStores( fun getDataStore(npub: String): DataStore = storeCache.getOrCreate(npub) { - PreferenceDataStoreFactory.createWithPath(produceFile = { file(npub) }) + PreferenceDataStoreFactory.createWithPath( + migrations = migrations(npub), + produceFile = { file(npub) }, + ) } /** diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt new file mode 100644 index 0000000000..3ab3ba82b7 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataMigration +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey + +/** + * Copies values from an older store into this one, once, the first time the + * DataStore is read. + * + * Deliberately a copy and not a move. `SharedPreferencesMigration`, the stock + * implementation, deletes each key it migrates — which is how it knows not to + * run twice, and which makes the migration a one-way door: a build that rolls + * back to reading the old store finds the user's settings gone. Here a marker + * key in the *destination* records that the copy happened, so the source is + * left untouched and a rollback still works. Deleting the legacy data is a + * separate decision, taken once the migration has shipped and held. + * + * [read] is only called when the migration actually runs, so the cost of + * opening the legacy store is not paid on every launch. + * + * @param markerName key recording, in this store, that the copy has run. + * Distinct per migration, so several can run against the same store. + * @param read the legacy values, already mapped onto this store's keys. A key + * absent here is left absent rather than written blank, so it keeps reading + * as "unset" and falls back to its default. + */ +class CopyOnceMigration( + markerName: String, + private val read: suspend () -> Map, String>, +) : DataMigration { + private val marker = booleanPreferencesKey(markerName) + + override suspend fun shouldMigrate(currentData: Preferences): Boolean = currentData[marker] != true + + override suspend fun migrate(currentData: Preferences): Preferences { + val updated = currentData.toMutablePreferences() + + read().forEach { (key, value) -> updated[key] = value } + updated[marker] = true + + return updated.toPreferences() + } + + override suspend fun cleanUp() = Unit +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt new file mode 100644 index 0000000000..1e07d3154c --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.quartz.nip01Core.core.JsonMapper +import com.vitorpamplona.quartz.utils.Log +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * Every top-nav feed whose author filter the user can change, with the + * preference key it has always been stored under and the filter it falls back + * to when unset. + * + * The keys are the strings the Android app wrote from its first release, so + * this table is a compatibility surface: renaming an entry silently resets that + * feed for everyone who had customised it. + * + * Defaults are not uniform and the differences are deliberate — [PRODUCTS] and + * [GEOCACHES] open to what is physically nearby, [BADGES] and + * [RELAY_GROUPS_DISCOVERY] to the user's own, most others to Global. + */ +enum class FollowListSlot( + val prefKey: String, + val default: TopFilter, +) { + HOME("defaultHomeFollowList", TopFilter.AllFollows), + STORIES("defaultStoriesFollowList", TopFilter.Global), + NOTIFICATION("defaultNotificationFollowList", TopFilter.Selected), + DISCOVERY("defaultDiscoveryFollowList", TopFilter.Global), + POLLS("defaultPollsFollowList", TopFilter.Global), + PICTURES("defaultPicturesFollowList", TopFilter.Global), + RELAY_GROUPS_DISCOVERY("defaultRelayGroupsDiscoveryFollowList", TopFilter.Mine), + NAPPLETS("defaultNappletsFollowList", TopFilter.Global), + NSITES("defaultNsitesFollowList", TopFilter.Global), + WORKOUTS("defaultWorkoutsFollowList", TopFilter.Global), + GIT_REPOSITORIES("defaultGitRepositoriesFollowList", TopFilter.Global), + HIGHLIGHTS("defaultHighlightsFollowList", TopFilter.Global), + CALENDARS("defaultCalendarsFollowList", TopFilter.Global), + PRODUCTS("defaultProductsFollowList", TopFilter.AroundMe), + GEOCACHES("defaultGeocachesFollowList", TopFilter.AroundMe), + SHORTS("defaultShortsFollowList", TopFilter.Global), + PUBLIC_CHATS("defaultPublicChatsFollowList", TopFilter.Global), + LIVE_STREAMS("defaultLiveStreamsFollowList", TopFilter.Global), + NESTS("defaultNestsFollowList", TopFilter.Global), + LONGS("defaultLongsFollowList", TopFilter.Global), + ARTICLES("defaultArticlesFollowList", TopFilter.AllFollows), + MUSIC_TRACKS("defaultMusicTracksFollowList", TopFilter.Global), + MUSIC_PLAYLISTS("defaultMusicPlaylistsFollowList", TopFilter.Global), + PODCAST_EPISODES("defaultPodcastEpisodesFollowList", TopFilter.Global), + PODCASTS("defaultPodcastsFollowList", TopFilter.Global), + SOFTWARE_APPS("defaultSoftwareAppsFollowList", TopFilter.Global), + BADGES("defaultBadgesFollowList", TopFilter.Mine), + BROWSE_EMOJI_SETS("defaultBrowseEmojiSetsFollowList", TopFilter.Global), + COMMUNITIES("defaultCommunitiesFollowList", TopFilter.AllFollows), + FOLLOW_PACKS("defaultFollowPacksFollowList", TopFilter.Global), + APP_RECOMMENDATIONS("defaultAppRecommendationsFollowList", TopFilter.Global), + ; + + val key: Preferences.Key = stringPreferencesKey(prefKey) +} + +/** + * The per-account top-nav filter selections, stored one key per feed. + * + * Values are [TopFilter] as JSON, the same encoding the SharedPreferences + * implementation used, so a migrated store and a legacy one hold byte-identical + * strings. + */ +class TopNavFollowListStore( + private val store: DataStore, +) { + /** + * Every slot's current filter, falling back to [FollowListSlot.default] + * where the key is unset or unreadable. + * + * A value that fails to parse yields the default rather than propagating: + * one corrupt entry should cost the user that feed's filter, not the whole + * account load. + */ + suspend fun load(): Map { + val prefs = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + return FollowListSlot.entries.associateWith { slot -> parse(prefs[slot.key], slot) } + } + + /** Writes every slot in one edit, so a crash cannot leave a half-applied set. */ + suspend fun saveAll(values: Map) { + store.edit { prefs -> + values.forEach { (slot, filter) -> prefs[slot.key] = JsonMapper.toJson(filter) } + } + } + + suspend fun save( + slot: FollowListSlot, + filter: TopFilter, + ) { + store.edit { prefs -> prefs[slot.key] = JsonMapper.toJson(filter) } + } + + private fun parse( + value: String?, + slot: FollowListSlot, + ): TopFilter { + if (value.isNullOrEmpty() || value == "null") return slot.default + return try { + JsonMapper.fromJson(value) + } catch (e: Exception) { + Log.w("TopNavFollowListStore") { "Could not decode ${slot.prefKey}; falling back to its default: ${e.message}" } + slot.default + } + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt new file mode 100644 index 0000000000..59f8a81d38 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataMigration +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter +import com.vitorpamplona.quartz.nip01Core.core.JsonMapper +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +class TopNavFollowListStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun store( + scope: CoroutineScope, + migrations: List> = emptyList(), + ): TopNavFollowListStore { + val file = File(folder.root, "acct_${seq++}.preferences_pb") + return TopNavFollowListStore( + PreferenceDataStoreFactory.createWithPath( + scope = scope, + migrations = migrations, + produceFile = { file.toOkioPath() }, + ), + ) + } + + private fun scope() = CoroutineScope(Dispatchers.IO + SupervisorJob()) + + /** + * Encodes as the app does. + * + * The parameter type matters: kotlinx serializes by STATIC type, so + * `encode(TopFilter.Global)` sees the concrete object and writes + * `{}` with no polymorphic discriminator, which cannot be read back as a + * TopFilter. Widening to TopFilter here is what the production call sites do + * by reading a `StateFlow.value`. + */ + private fun encode(filter: TopFilter): String = JsonMapper.toJson(filter) + + /** An empty store must hand back each slot's documented default, not null and not a blanket Global. */ + @Test + fun emptyStoreReturnsEachSlotsOwnDefault() = + runTest { + val loaded = store(scope()).load() + + assertEquals(FollowListSlot.entries.size, loaded.size) + FollowListSlot.entries.forEach { slot -> + assertEquals("default for ${slot.prefKey}", slot.default, loaded.getValue(slot)) + } + } + + /** The defaults are not uniform — a regression that collapsed them would pass the test above. */ + @Test + fun defaultsAreNotAllTheSame() { + val defaults = FollowListSlot.entries.map { it.default }.toSet() + + assertTrue("expected several distinct defaults, got $defaults", defaults.size >= 4) + assertEquals(TopFilter.AllFollows, FollowListSlot.HOME.default) + assertEquals(TopFilter.Selected, FollowListSlot.NOTIFICATION.default) + assertEquals(TopFilter.AroundMe, FollowListSlot.GEOCACHES.default) + assertEquals(TopFilter.Mine, FollowListSlot.BADGES.default) + } + + @Test + fun savedValuesReadBack() = + runTest { + val subject = store(scope()) + + subject.save(FollowListSlot.HOME, TopFilter.Global) + + assertEquals(TopFilter.Global, subject.load().getValue(FollowListSlot.HOME)) + assertEquals("other slots keep their defaults", TopFilter.Selected, subject.load().getValue(FollowListSlot.NOTIFICATION)) + } + + @Test + fun saveAllWritesEverySlot() = + runTest { + val subject = store(scope()) + + subject.saveAll(FollowListSlot.entries.associateWith { TopFilter.Mine }) + + assertTrue(subject.load().values.all { it == TopFilter.Mine }) + } + + /** A corrupt entry costs that one feed's filter, not the whole account load. */ + @Test + fun anUnparseableValueFallsBackToThatSlotsDefault() = + runTest { + val scope = scope() + val file = File(folder.root, "corrupt.preferences_pb") + val raw = + PreferenceDataStoreFactory.createWithPath(scope = scope, produceFile = { file.toOkioPath() }) + raw.updateData { prefs -> + prefs.toMutablePreferences().apply { + this[FollowListSlot.HOME.key] = "{ not json" + this[FollowListSlot.STORIES.key] = encode(TopFilter.Mine) + } + } + + val loaded = TopNavFollowListStore(raw).load() + + assertEquals(FollowListSlot.HOME.default, loaded.getValue(FollowListSlot.HOME)) + assertEquals("a sibling slot still loads", TopFilter.Mine, loaded.getValue(FollowListSlot.STORIES)) + } + + /** The prefKeys are a compatibility surface: renaming one silently resets that feed for everyone. */ + @Test + fun prefKeysAreTheOnesTheAndroidAppHasAlwaysWritten() { + assertEquals("defaultHomeFollowList", FollowListSlot.HOME.prefKey) + assertEquals("defaultNotificationFollowList", FollowListSlot.NOTIFICATION.prefKey) + assertEquals("defaultAppRecommendationsFollowList", FollowListSlot.APP_RECOMMENDATIONS.prefKey) + assertEquals(31, FollowListSlot.entries.size) + assertEquals( + "prefKeys must be unique", + 31, + FollowListSlot.entries + .map { it.prefKey } + .toSet() + .size, + ) + } + + // ── migration ────────────────────────────────────────────────────── + + @Test + fun migrationCopiesLegacyValuesOnFirstRead() = + runTest { + val legacy = + mapOf( + Pair(FollowListSlot.HOME.key, encode(TopFilter.Global)), + Pair(FollowListSlot.BADGES.key, encode(TopFilter.AllFollows)), + ) + + val loaded = store(scope(), listOf(CopyOnceMigration("migrated.followLists") { legacy })).load() + + assertEquals(TopFilter.Global, loaded.getValue(FollowListSlot.HOME)) + assertEquals(TopFilter.AllFollows, loaded.getValue(FollowListSlot.BADGES)) + assertEquals("unmigrated slots keep defaults", FollowListSlot.STORIES.default, loaded.getValue(FollowListSlot.STORIES)) + } + + /** + * The migration must not run a second time and overwrite what the user has + * changed since — the marker key in the destination is what prevents it. + * + * Each open gets its own scope, cancelled before the next: DataStore + * refuses two live instances over one file, which is exactly why + * [AccountPreferenceStores] caches one per account. + */ + @Test + fun migrationDoesNotClobberLaterEdits() = + runTest { + val file = File(folder.root, "once.preferences_pb") + var reads = 0 + val legacy = mapOf(Pair(FollowListSlot.HOME.key, encode(TopFilter.Global))) + + suspend fun withStore(block: suspend (TopNavFollowListStore) -> T): T { + val scope = scope() + try { + return block( + TopNavFollowListStore( + PreferenceDataStoreFactory.createWithPath( + scope = scope, + migrations = + listOf( + CopyOnceMigration("migrated.followLists") { + reads++ + legacy + }, + ), + produceFile = { file.toOkioPath() }, + ), + ), + ) + } finally { + scope.cancel() + } + } + + assertEquals(TopFilter.Global, withStore { it.load().getValue(FollowListSlot.HOME) }) + withStore { it.save(FollowListSlot.HOME, TopFilter.Mine) } + + assertEquals( + "the user's later choice survives a reopen", + TopFilter.Mine, + withStore { it.load().getValue(FollowListSlot.HOME) }, + ) + assertEquals("the legacy store is read once", 1, reads) + } +} From 668e84b4ef74bb194a73d778078554c321ae22c7 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 16:15:15 +0000 Subject: [PATCH 03/57] refactor: move the 26 cached account events to DataStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 2b of the SharedPreferences -> DataStore migration, finishing the bulk keys. LatestEventSlot names the account-level events cached for a cold start — the user's own metadata, contact list, relay lists, mute list and the rest — and LatestEventCacheStore reads and writes them, replacing 26 getString calls and 26 putOrRemove calls in LocalPreferences. The store is deliberately untyped, moving strings rather than events. Each slot holds a different event type and the app parses them in parallel with the right parser for each, so encoding stays at the call site. That also keeps the stored bytes identical to what the SharedPreferences implementation wrote (OptimizedJsonMapper, not JsonMapper), which is what lets the migration be a straight copy. A null value removes its key rather than storing a blank, so an event the account no longer has stops being served from cache instead of lingering as a stale copy. Carried over by the same CopyOnceMigration as the follow lists, under its own marker key so the two migrate independently. Losing this cache is not fatal — the events re-fetch from relays — but it costs a blank first screen, so the key names are still treated as a compatibility surface and asserted in tests. 6 tests: an empty store reports no slots rather than empty strings, JSON reads back verbatim, null removes, slots are independent, the keys are the ones the app has always written, and the migration copies only what the legacy store had. Known-flaky test note: :amethyst:testPlayDebugUnitTest intermittently fails Nip46ConsentInfoBuilderTest with UncaughtExceptionsBeforeTest — an exception leaking from an earlier test in the same worker. Reproduced on an unmodified main before this series started; it passes on re-run. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/LocalPreferences.kt | 130 +++++++++-------- .../preferences/LatestEventCacheStore.kt | 112 +++++++++++++++ .../preferences/LatestEventCacheStoreTest.kt | 131 ++++++++++++++++++ 3 files changed, 316 insertions(+), 57 deletions(-) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 467f07eb97..2f990985e8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -37,6 +37,8 @@ import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntr import com.vitorpamplona.amethyst.commons.model.preferences.AccountPreferenceStores import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration import com.vitorpamplona.amethyst.commons.model.preferences.FollowListSlot +import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventCacheStore +import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventSlot import com.vitorpamplona.amethyst.commons.model.preferences.TopNavFollowListStore import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthPolicy @@ -268,12 +270,14 @@ object LocalPreferences { Amethyst.instance.appContext.filesDir .toOkioPath() }, - migrations = { npub -> listOf(followListMigration(npub)) }, + migrations = { npub -> listOf(followListMigration(npub), latestEventMigration(npub)) }, ) } private fun followListStore(npub: String) = TopNavFollowListStore(accountStores.getDataStore(npub)) + private fun latestEventStore(npub: String) = LatestEventCacheStore(accountStores.getDataStore(npub)) + private fun followListMigration(npub: String) = CopyOnceMigration("migrated.followLists") { withContext(Dispatchers.IO) { @@ -288,6 +292,17 @@ object LocalPreferences { } } + private fun latestEventMigration(npub: String) = + CopyOnceMigration("migrated.latestEvents") { + withContext(Dispatchers.IO) { + val legacy = encryptedPreferences(npub) + LatestEventSlot.entries + .mapNotNull { slot -> + legacy.getString(slot.prefKey, null)?.let { Pair(slot.key, it) } + }.toMap() + } + } + // Global master switch for the always-on notification service ("Background // notification service"). Default ON: existing users keep current behavior, and // per-account participation decides who actually stays active. @@ -591,8 +606,6 @@ object LocalPreferences { // Remove legacy key after migration remove(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER) - putOrRemove(PrefKeys.LATEST_CONTACT_LIST, settings.backupContactList) - // The undecided conflicts themselves, not just the backups they hold back. // Without these the card vanishes on the next launch and the user never // answers the question the backup is still waiting on. @@ -603,40 +616,12 @@ object LocalPreferences { putString(PrefKeys.OPEN_BACKUP_CONFLICTS, BackupConflictStorage.encode(openConflicts)) } - putOrRemove(PrefKeys.LATEST_USER_METADATA, settings.backupUserMetadata) - putOrRemove(PrefKeys.LATEST_DM_RELAY_LIST, settings.backupDMRelayList) - putOrRemove(PrefKeys.LATEST_NIP65_RELAY_LIST, settings.backupNIP65RelayList) - putOrRemove(PrefKeys.LATEST_SEARCH_RELAY_LIST, settings.backupSearchRelayList) - putOrRemove(PrefKeys.LATEST_INDEX_RELAY_LIST, settings.backupIndexRelayList) - putOrRemove(PrefKeys.LATEST_RELAY_FEEDS_LIST, settings.backupRelayFeedsList) - putOrRemove(PrefKeys.LATEST_BLOCKED_RELAY_LIST, settings.backupBlockedRelayList) - putOrRemove(PrefKeys.LATEST_TRUSTED_RELAY_LIST, settings.backupTrustedRelayList) - if (settings.localRelayServers.value.isNotEmpty()) { putStringSet(PrefKeys.LOCAL_RELAY_SERVERS, settings.localRelayServers.value) } else { remove(PrefKeys.LOCAL_RELAY_SERVERS) } - putOrRemove(PrefKeys.LATEST_MUTE_LIST, settings.backupMuteList) - putOrRemove(PrefKeys.LATEST_PRIVATE_HOME_RELAY_LIST, settings.backupPrivateHomeRelayList) - putOrRemove(PrefKeys.LATEST_APP_SPECIFIC_DATA, settings.backupAppSpecificData) - - putOrRemove(PrefKeys.LATEST_CHANNEL_LIST, settings.backupChannelList) - putOrRemove(PrefKeys.LATEST_COMMUNITY_LIST, settings.backupCommunityList) - putOrRemove(PrefKeys.LATEST_HASHTAG_LIST, settings.backupHashtagList) - putOrRemove(PrefKeys.LATEST_GEOHASH_LIST, settings.backupGeohashList) - putOrRemove(PrefKeys.LATEST_EPHEMERAL_LIST, settings.backupEphemeralChatList) - putOrRemove(PrefKeys.LATEST_RELAY_GROUP_LIST, settings.backupRelayGroupList) - putOrRemove(PrefKeys.LATEST_CONCORD_LIST, settings.backupConcordList) - putOrRemove(PrefKeys.LATEST_TRUST_PROVIDER_LIST, settings.backupTrustProviderList) - putOrRemove(PrefKeys.LATEST_KEY_PACKAGE_RELAY_LIST, settings.backupKeyPackageRelayList) - putOrRemove(PrefKeys.LATEST_FAVORITE_ALGO_FEEDS_LIST, settings.backupFavoriteAlgoFeedsList) - putOrRemove(PrefKeys.LATEST_PAYMENT_TARGETS, settings.backupNipA3PaymentTargets) - putOrRemove(PrefKeys.LATEST_BOLT12_OFFERS, settings.backupBolt12Offers) - putOrRemove(PrefKeys.LATEST_CASHU_WALLET, settings.backupCashuWallet) - putOrRemove(PrefKeys.LATEST_NUTZAP_INFO, settings.backupNutzapInfo) - putBoolean(PrefKeys.HIDE_DELETE_REQUEST_DIALOG, settings.hideDeleteRequestDialog) putBoolean(PrefKeys.HIDE_NIP_17_WARNING_DIALOG, settings.hideNIP17WarningDialog) putBoolean(PrefKeys.HIDE_BLOCK_ALERT_DIALOG, settings.hideBlockAlertDialog) @@ -687,6 +672,36 @@ object LocalPreferences { ) } } + latestEventStore(settings.keyPair.pubKey.toNpub()).saveAll( + mapOf( + LatestEventSlot.CONTACT_LIST to settings.backupContactList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.USER_METADATA to settings.backupUserMetadata?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.DM_RELAY_LIST to settings.backupDMRelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.NIP65_RELAY_LIST to settings.backupNIP65RelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.SEARCH_RELAY_LIST to settings.backupSearchRelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.INDEX_RELAY_LIST to settings.backupIndexRelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.RELAY_FEEDS_LIST to settings.backupRelayFeedsList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.BLOCKED_RELAY_LIST to settings.backupBlockedRelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.TRUSTED_RELAY_LIST to settings.backupTrustedRelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.MUTE_LIST to settings.backupMuteList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.PRIVATE_HOME_RELAY_LIST to settings.backupPrivateHomeRelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.APP_SPECIFIC_DATA to settings.backupAppSpecificData?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.CHANNEL_LIST to settings.backupChannelList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.COMMUNITY_LIST to settings.backupCommunityList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.HASHTAG_LIST to settings.backupHashtagList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.GEOHASH_LIST to settings.backupGeohashList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.EPHEMERAL_LIST to settings.backupEphemeralChatList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.RELAY_GROUP_LIST to settings.backupRelayGroupList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.CONCORD_LIST to settings.backupConcordList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.TRUST_PROVIDER_LIST to settings.backupTrustProviderList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.KEY_PACKAGE_RELAY_LIST to settings.backupKeyPackageRelayList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.FAVORITE_ALGO_FEEDS_LIST to settings.backupFavoriteAlgoFeedsList?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.PAYMENT_TARGETS to settings.backupNipA3PaymentTargets?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.BOLT12_OFFERS to settings.backupBolt12Offers?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.CASHU_WALLET to settings.backupCashuWallet?.let { OptimizedJsonMapper.toJson(it) }, + LatestEventSlot.NUTZAP_INFO to settings.backupNutzapInfo?.let { OptimizedJsonMapper.toJson(it) }, + ), + ) followListStore(settings.keyPair.pubKey.toNpub()).saveAll( mapOf( FollowListSlot.HOME to settings.defaultHomeFollowList.value, @@ -865,32 +880,33 @@ object LocalPreferences { val pendingAttestationsStr = getString(PrefKeys.PENDING_ATTESTATIONS, null) val openBackupConflictsStr = getString(PrefKeys.OPEN_BACKUP_CONFLICTS, null) - val latestUserMetadataStr = getString(PrefKeys.LATEST_USER_METADATA, null) - val latestContactListStr = getString(PrefKeys.LATEST_CONTACT_LIST, null) - val latestDmRelayListStr = getString(PrefKeys.LATEST_DM_RELAY_LIST, null) - val latestNip65RelayListStr = getString(PrefKeys.LATEST_NIP65_RELAY_LIST, null) - val latestSearchRelayListStr = getString(PrefKeys.LATEST_SEARCH_RELAY_LIST, null) - val latestIndexRelayListStr = getString(PrefKeys.LATEST_INDEX_RELAY_LIST, null) - val latestRelayFeedsListStr = getString(PrefKeys.LATEST_RELAY_FEEDS_LIST, null) - val latestBlockedRelayListStr = getString(PrefKeys.LATEST_BLOCKED_RELAY_LIST, null) - val latestTrustedRelayListStr = getString(PrefKeys.LATEST_TRUSTED_RELAY_LIST, null) - val latestMuteListStr = getString(PrefKeys.LATEST_MUTE_LIST, null) - val latestPrivateHomeRelayListStr = getString(PrefKeys.LATEST_PRIVATE_HOME_RELAY_LIST, null) - val latestAppSpecificDataStr = getString(PrefKeys.LATEST_APP_SPECIFIC_DATA, null) - val latestChannelListStr = getString(PrefKeys.LATEST_CHANNEL_LIST, null) - val latestCommunityListStr = getString(PrefKeys.LATEST_COMMUNITY_LIST, null) - val latestHashtagListStr = getString(PrefKeys.LATEST_HASHTAG_LIST, null) - val latestGeohashListStr = getString(PrefKeys.LATEST_GEOHASH_LIST, null) - val latestEphemeralListStr = getString(PrefKeys.LATEST_EPHEMERAL_LIST, null) - val latestRelayGroupListStr = getString(PrefKeys.LATEST_RELAY_GROUP_LIST, null) - val latestConcordListStr = getString(PrefKeys.LATEST_CONCORD_LIST, null) - val latestTrustProviderListStr = getString(PrefKeys.LATEST_TRUST_PROVIDER_LIST, null) - val latestKeyPackageRelayListStr = getString(PrefKeys.LATEST_KEY_PACKAGE_RELAY_LIST, null) - val latestFavoriteAlgoFeedsListStr = getString(PrefKeys.LATEST_FAVORITE_ALGO_FEEDS_LIST, null) - val latestPaymentTargetsStr = getString(PrefKeys.LATEST_PAYMENT_TARGETS, null) - val latestBolt12OffersStr = getString(PrefKeys.LATEST_BOLT12_OFFERS, null) - val latestCashuWalletStr = getString(PrefKeys.LATEST_CASHU_WALLET, null) - val latestNutzapInfoStr = getString(PrefKeys.LATEST_NUTZAP_INFO, null) + val latestEvents = latestEventStore(keyPair.pubKey.toNpub()).load() + val latestUserMetadataStr = latestEvents[LatestEventSlot.USER_METADATA] + val latestContactListStr = latestEvents[LatestEventSlot.CONTACT_LIST] + val latestDmRelayListStr = latestEvents[LatestEventSlot.DM_RELAY_LIST] + val latestNip65RelayListStr = latestEvents[LatestEventSlot.NIP65_RELAY_LIST] + val latestSearchRelayListStr = latestEvents[LatestEventSlot.SEARCH_RELAY_LIST] + val latestIndexRelayListStr = latestEvents[LatestEventSlot.INDEX_RELAY_LIST] + val latestRelayFeedsListStr = latestEvents[LatestEventSlot.RELAY_FEEDS_LIST] + val latestBlockedRelayListStr = latestEvents[LatestEventSlot.BLOCKED_RELAY_LIST] + val latestTrustedRelayListStr = latestEvents[LatestEventSlot.TRUSTED_RELAY_LIST] + val latestMuteListStr = latestEvents[LatestEventSlot.MUTE_LIST] + val latestPrivateHomeRelayListStr = latestEvents[LatestEventSlot.PRIVATE_HOME_RELAY_LIST] + val latestAppSpecificDataStr = latestEvents[LatestEventSlot.APP_SPECIFIC_DATA] + val latestChannelListStr = latestEvents[LatestEventSlot.CHANNEL_LIST] + val latestCommunityListStr = latestEvents[LatestEventSlot.COMMUNITY_LIST] + val latestHashtagListStr = latestEvents[LatestEventSlot.HASHTAG_LIST] + val latestGeohashListStr = latestEvents[LatestEventSlot.GEOHASH_LIST] + val latestEphemeralListStr = latestEvents[LatestEventSlot.EPHEMERAL_LIST] + val latestRelayGroupListStr = latestEvents[LatestEventSlot.RELAY_GROUP_LIST] + val latestConcordListStr = latestEvents[LatestEventSlot.CONCORD_LIST] + val latestTrustProviderListStr = latestEvents[LatestEventSlot.TRUST_PROVIDER_LIST] + val latestKeyPackageRelayListStr = latestEvents[LatestEventSlot.KEY_PACKAGE_RELAY_LIST] + val latestFavoriteAlgoFeedsListStr = latestEvents[LatestEventSlot.FAVORITE_ALGO_FEEDS_LIST] + val latestPaymentTargetsStr = latestEvents[LatestEventSlot.PAYMENT_TARGETS] + val latestBolt12OffersStr = latestEvents[LatestEventSlot.BOLT12_OFFERS] + val latestCashuWalletStr = latestEvents[LatestEventSlot.CASHU_WALLET] + val latestNutzapInfoStr = latestEvents[LatestEventSlot.NUTZAP_INFO] val lastReadPerRouteStr = getString(PrefKeys.LAST_READ_PER_ROUTE, null) Log.d("LocalPreferences") { "Load account from file $npub - before parsing events" } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt new file mode 100644 index 0000000000..b86f434ee0 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * The account-level events cached on disk so a cold start can show something + * before any relay answers — the user's own metadata, contact list, relay + * lists, mute list and the rest. + * + * As with [FollowListSlot], the key strings are the ones the Android app has + * always written, so renaming one throws away that cache for existing users. + * Losing it is not fatal — the event is re-fetched from relays — but it costs a + * blank first screen, so the names are still a compatibility surface. + */ +enum class LatestEventSlot( + val prefKey: String, +) { + CONTACT_LIST("latestContactList"), + USER_METADATA("latestUserMetadata"), + DM_RELAY_LIST("latestDMRelayList"), + NIP65_RELAY_LIST("latestNIP65RelayList"), + SEARCH_RELAY_LIST("latestSearchRelayList"), + INDEX_RELAY_LIST("latestIndexRelayList"), + RELAY_FEEDS_LIST("latestRelayFeedsList"), + BLOCKED_RELAY_LIST("latestBlockedRelayList"), + TRUSTED_RELAY_LIST("latestTrustedRelayList"), + MUTE_LIST("latestMuteList"), + PRIVATE_HOME_RELAY_LIST("latestPrivateHomeRelayList"), + APP_SPECIFIC_DATA("latestAppSpecificData"), + CHANNEL_LIST("latestChannelList"), + COMMUNITY_LIST("latestCommunityList"), + HASHTAG_LIST("latestHashtagList"), + GEOHASH_LIST("latestGeohashList"), + EPHEMERAL_LIST("latestEphemeralChatList"), + RELAY_GROUP_LIST("latestRelayGroupList"), + CONCORD_LIST("latestConcordList"), + TRUST_PROVIDER_LIST("latestTrustProviderList"), + KEY_PACKAGE_RELAY_LIST("latestKeyPackageRelayList"), + FAVORITE_ALGO_FEEDS_LIST("latestFavoriteAlgoFeedsList"), + PAYMENT_TARGETS("latestPaymentTargets"), + BOLT12_OFFERS("latestBolt12Offers"), + CASHU_WALLET("latestCashuWallet"), + NUTZAP_INFO("latestNutzapInfo"), + ; + + val key: Preferences.Key = stringPreferencesKey(prefKey) +} + +/** + * Raw storage for [LatestEventSlot], deliberately untyped. + * + * Each slot holds a different event type and the app parses them in parallel + * with the right parser for each, so this store moves strings and leaves + * encoding to the caller. That also keeps the bytes identical to what the + * SharedPreferences implementation wrote, which the migration relies on. + */ +class LatestEventCacheStore( + private val store: DataStore, +) { + /** Only the slots actually present; an absent slot means nothing was cached. */ + suspend fun load(): Map { + val prefs = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + return LatestEventSlot.entries + .mapNotNull { slot -> + prefs[slot.key]?.let { Pair(slot, it) } + }.toMap() + } + + /** + * Writes every slot in one edit. A null value removes the key, so an event + * the account no longer has stops being served from cache instead of + * lingering as a stale copy. + */ + suspend fun saveAll(values: Map) { + store.edit { prefs -> + values.forEach { (slot, json) -> + if (json != null) prefs[slot.key] = json else prefs.remove(slot.key) + } + } + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt new file mode 100644 index 0000000000..66bc5122ab --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataMigration +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +class LatestEventCacheStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun store(migrations: List> = emptyList()): LatestEventCacheStore { + val file = File(folder.root, "cache_${seq++}.preferences_pb") + return LatestEventCacheStore( + PreferenceDataStoreFactory.createWithPath( + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + migrations = migrations, + produceFile = { file.toOkioPath() }, + ), + ) + } + + /** An absent slot means nothing was cached — not an empty string that would fail to parse. */ + @Test + fun anEmptyStoreReturnsNoSlots() = + runTest { + assertTrue(store().load().isEmpty()) + } + + @Test + fun savedJsonReadsBackVerbatim() = + runTest { + val subject = store() + val json = """{"id":"abc","kind":0,"content":"{}"}""" + + subject.saveAll(mapOf(LatestEventSlot.USER_METADATA to json)) + + assertEquals(json, subject.load()[LatestEventSlot.USER_METADATA]) + } + + /** + * A null must remove the key. Leaving the previous value behind would keep + * serving an event the account no longer has. + */ + @Test + fun aNullValueRemovesTheSlot() = + runTest { + val subject = store() + subject.saveAll(mapOf(LatestEventSlot.MUTE_LIST to """{"kind":10000}""")) + + subject.saveAll(mapOf(LatestEventSlot.MUTE_LIST to null)) + + assertFalse(subject.load().containsKey(LatestEventSlot.MUTE_LIST)) + } + + @Test + fun slotsAreIndependent() = + runTest { + val subject = store() + + subject.saveAll( + mapOf( + LatestEventSlot.CONTACT_LIST to """{"kind":3}""", + LatestEventSlot.MUTE_LIST to null, + ), + ) + + assertEquals("""{"kind":3}""", subject.load()[LatestEventSlot.CONTACT_LIST]) + assertFalse(subject.load().containsKey(LatestEventSlot.MUTE_LIST)) + } + + @Test + fun prefKeysMatchWhatTheAppHasAlwaysWritten() { + assertEquals("latestUserMetadata", LatestEventSlot.USER_METADATA.prefKey) + assertEquals("latestContactList", LatestEventSlot.CONTACT_LIST.prefKey) + assertEquals("latestNIP65RelayList", LatestEventSlot.NIP65_RELAY_LIST.prefKey) + assertEquals(26, LatestEventSlot.entries.size) + assertEquals( + "prefKeys must be unique", + 26, + LatestEventSlot.entries + .map { it.prefKey } + .toSet() + .size, + ) + } + + @Test + fun migrationCopiesTheLegacyCache() = + runTest { + val legacy = mapOf(Pair(LatestEventSlot.USER_METADATA.key, """{"kind":0}""")) + + val loaded = store(listOf(CopyOnceMigration("migrated.latestEvents") { legacy })).load() + + assertEquals("""{"kind":0}""", loaded[LatestEventSlot.USER_METADATA]) + assertFalse("slots absent from the legacy store stay absent", loaded.containsKey(LatestEventSlot.MUTE_LIST)) + } +} From f6a34e1f5f3d601795bb9ecd2041938a7ceb6829 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 16:42:12 +0000 Subject: [PATCH 04/57] refactor: move the per-account setting groups to DataStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 3 of the SharedPreferences -> DataStore migration: the 28 remaining per-account settings, as five domain stores in commons/commonMain rather than one file. UploadSettingsStore 6 what is stripped, mirrored, cached, uploaded DialogDismissalStore 9 what the account has dismissed for good RelayAuthStore 5 when to answer a NIP-42 AUTH challenge FeedVisibilityStore 5 which feeds show and how they are laid out NotificationPrefsStore 5 this account's share of notification settings Each group loads and saves in one edit, so a crash cannot half-apply it. Defaults are the risky part and are asserted per group: they must match what SharedPreferences returned for a missing key, because an account that never touched a setting has no stored value and takes the default forever after. Several are `true` (strip location, mirror uploads, local blossom cache, three of the four AUTH trust flags, show messages in notifications, calls enabled), so a group that defaulted everything to false would quietly turn features off for every existing user. Two keys are kept out of NotificationPrefs and its bulk save, with their own accessors instead: - notif_global_to_curated_migrated is a one-shot migration marker, not a user setting. A bulk save carrying a stale copy could re-run the migration or wrongly suppress it. - last_read_per_route is written on its own path as the user reads things, at a different cadence from the settings around it. Caught while verifying rather than by the compiler: readInboxPrefs() was left reading DEFAULT_RELAY_AUTH_POLICY, the four AUTH trust flags and the view-mode keys from the legacy store, while their writes had already moved to DataStore. Compiles clean, and silently loses every change to those nine settings. It now takes RelayAuth and FeedVisibility. The check that found it — every migrated key must have exactly one remaining reference, the migration's own read — now passes for all 28. innerLoadCurrentAccountFromEncryptedStorage hit the JVM's 64KB method limit: it was already 341 lines and each suspend call adds a state to the generated coroutine state machine, so seven separate store loads pushed it over. They are now one call returning AccountStoreData. That function wants decomposing on its own merits; this is the minimum to get under the limit. 12 tests covering defaults, round trips including string sets, that a null string field clears its key rather than leaving the old value, that the two special-cased keys survive a bulk save, and that the key strings are the ones the app has always written. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/LocalPreferences.kt | 357 ++++++++++++------ .../model/preferences/CopyOnceMigration.kt | 15 +- .../model/preferences/DialogDismissalStore.kt | 106 ++++++ .../model/preferences/FeedVisibilityStore.kt | 89 +++++ .../preferences/NotificationPrefsStore.kt | 111 ++++++ .../model/preferences/RelayAuthStore.kt | 89 +++++ .../model/preferences/UploadSettingsStore.kt | 90 +++++ .../preferences/AccountSettingStoresTest.kt | 221 +++++++++++ .../preferences/LatestEventCacheStoreTest.kt | 2 +- .../preferences/TopNavFollowListStoreTest.kt | 6 +- 10 files changed, 960 insertions(+), 126 deletions(-) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 2f990985e8..ce40ff0157 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -36,10 +36,20 @@ import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntr import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntryNorm import com.vitorpamplona.amethyst.commons.model.preferences.AccountPreferenceStores import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration +import com.vitorpamplona.amethyst.commons.model.preferences.DialogDismissal +import com.vitorpamplona.amethyst.commons.model.preferences.DialogDismissalStore +import com.vitorpamplona.amethyst.commons.model.preferences.FeedVisibility +import com.vitorpamplona.amethyst.commons.model.preferences.FeedVisibilityStore import com.vitorpamplona.amethyst.commons.model.preferences.FollowListSlot import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventCacheStore import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventSlot +import com.vitorpamplona.amethyst.commons.model.preferences.NotificationPrefs +import com.vitorpamplona.amethyst.commons.model.preferences.NotificationPrefsStore +import com.vitorpamplona.amethyst.commons.model.preferences.RelayAuth +import com.vitorpamplona.amethyst.commons.model.preferences.RelayAuthStore import com.vitorpamplona.amethyst.commons.model.preferences.TopNavFollowListStore +import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettings +import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettingsStore import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthPolicy import com.vitorpamplona.amethyst.model.AccountSettings @@ -270,7 +280,10 @@ object LocalPreferences { Amethyst.instance.appContext.filesDir .toOkioPath() }, - migrations = { npub -> listOf(followListMigration(npub), latestEventMigration(npub)) }, + migrations = { npub -> + listOf(followListMigration(npub), latestEventMigration(npub)) + + listOf(uploadSettingsMigration(npub), dialogDismissalMigration(npub), relayAuthMigration(npub), feedVisibilityMigration(npub), notificationPrefsMigration(npub)) + }, ) } @@ -278,28 +291,126 @@ object LocalPreferences { private fun latestEventStore(npub: String) = LatestEventCacheStore(accountStores.getDataStore(npub)) - private fun followListMigration(npub: String) = - CopyOnceMigration("migrated.followLists") { + private fun uploadSettingsStore(npub: String) = UploadSettingsStore(accountStores.getDataStore(npub)) + + private fun dialogDismissalStore(npub: String) = DialogDismissalStore(accountStores.getDataStore(npub)) + + private fun relayAuthStore(npub: String) = RelayAuthStore(accountStores.getDataStore(npub)) + + private fun feedVisibilityStore(npub: String) = FeedVisibilityStore(accountStores.getDataStore(npub)) + + private fun notificationPrefsStore(npub: String) = NotificationPrefsStore(accountStores.getDataStore(npub)) + + private fun uploadSettingsMigration(npub: String) = + CopyOnceMigration("migrated.uploadSettings") { out -> withContext(Dispatchers.IO) { val legacy = encryptedPreferences(npub) - // Pair(...) and not `slot.key to it`: androidx.datastore declares its - // own infix `to` on Preferences.Key, which would build a - // Preferences.Pair instead of the kotlin Pair toMap() needs. - FollowListSlot.entries - .mapNotNull { slot -> - legacy.getString(slot.prefKey, null)?.let { Pair(slot.key, it) } - }.toMap() + if (legacy.contains(PrefKeys.STRIP_LOCATION_ON_UPLOAD)) out[UploadSettingsStore.stripLocationOnUpload] = legacy.getBoolean(PrefKeys.STRIP_LOCATION_ON_UPLOAD, false) + if (legacy.contains(PrefKeys.OPTIMIZE_MEDIA_ON_UPLOAD)) out[UploadSettingsStore.optimizeMediaOnUpload] = legacy.getBoolean(PrefKeys.OPTIMIZE_MEDIA_ON_UPLOAD, false) + if (legacy.contains(PrefKeys.MIRROR_UPLOADS_TO_ALL_SERVERS)) out[UploadSettingsStore.mirrorUploadsToAllServers] = legacy.getBoolean(PrefKeys.MIRROR_UPLOADS_TO_ALL_SERVERS, false) + if (legacy.contains(PrefKeys.USE_LOCAL_BLOSSOM_CACHE)) out[UploadSettingsStore.useLocalBlossomCache] = legacy.getBoolean(PrefKeys.USE_LOCAL_BLOSSOM_CACHE, false) + if (legacy.contains(PrefKeys.LOCAL_BLOSSOM_CACHE_PROFILE_PICTURES_ONLY)) out[UploadSettingsStore.localBlossomCacheProfilePicturesOnly] = legacy.getBoolean(PrefKeys.LOCAL_BLOSSOM_CACHE_PROFILE_PICTURES_ONLY, false) + legacy.getString(PrefKeys.DEFAULT_FILE_SERVER, null)?.let { out[UploadSettingsStore.defaultFileServerJson] = it } + } + } + + private fun dialogDismissalMigration(npub: String) = + CopyOnceMigration("migrated.dialogDismissal") { out -> + withContext(Dispatchers.IO) { + val legacy = encryptedPreferences(npub) + if (legacy.contains(PrefKeys.HIDE_DELETE_REQUEST_DIALOG)) out[DialogDismissalStore.hideDeleteRequestDialog] = legacy.getBoolean(PrefKeys.HIDE_DELETE_REQUEST_DIALOG, false) + if (legacy.contains(PrefKeys.HIDE_BLOCK_ALERT_DIALOG)) out[DialogDismissalStore.hideBlockAlertDialog] = legacy.getBoolean(PrefKeys.HIDE_BLOCK_ALERT_DIALOG, false) + if (legacy.contains(PrefKeys.HIDE_NIP_17_WARNING_DIALOG)) out[DialogDismissalStore.hideNip17WarningDialog] = legacy.getBoolean(PrefKeys.HIDE_NIP_17_WARNING_DIALOG, false) + if (legacy.contains(PrefKeys.HIDE_COMMUNITY_RULES_VIOLATIONS)) out[DialogDismissalStore.hideCommunityRulesViolations] = legacy.getBoolean(PrefKeys.HIDE_COMMUNITY_RULES_VIOLATIONS, false) + legacy.getStringSet(PrefKeys.DISMISSED_POLL_NOTE_IDS, null)?.let { out[DialogDismissalStore.dismissedPollNoteIds] = it } + legacy.getStringSet(PrefKeys.DISMISSED_CHANNEL_INVITES, null)?.let { out[DialogDismissalStore.dismissedChannelInvites] = it } + legacy.getStringSet(PrefKeys.MUTED_PUBLIC_CHATS, null)?.let { out[DialogDismissalStore.mutedPublicChats] = it } + legacy.getStringSet(PrefKeys.HAS_DONATED_IN_VERSION, null)?.let { out[DialogDismissalStore.hasDonatedInVersion] = it } + legacy.getString(PrefKeys.VIEWED_POLL_RESULT_NOTE_IDS, null)?.let { out[DialogDismissalStore.viewedPollResultNoteIdsJson] = it } + } + } + + private fun relayAuthMigration(npub: String) = + CopyOnceMigration("migrated.relayAuth") { out -> + withContext(Dispatchers.IO) { + val legacy = encryptedPreferences(npub) + legacy.getString(PrefKeys.DEFAULT_RELAY_AUTH_POLICY, null)?.let { out[RelayAuthStore.policyName] = it } + if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_MY_RELAYS)) out[RelayAuthStore.trustMyRelays] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_MY_RELAYS, false) + if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_READ_FOLLOWS)) out[RelayAuthStore.trustReadFollows] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_READ_FOLLOWS, false) + if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_FOLLOWS)) out[RelayAuthStore.trustMessageFollows] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_FOLLOWS, false) + if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_STRANGERS)) out[RelayAuthStore.trustMessageStrangers] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_STRANGERS, false) + } + } + + private fun feedVisibilityMigration(npub: String) = + CopyOnceMigration("migrated.feedVisibility") { out -> + withContext(Dispatchers.IO) { + val legacy = encryptedPreferences(npub) + legacy.getString(PrefKeys.DISABLED_CHAT_FEEDS, null)?.let { out[FeedVisibilityStore.disabledChatFeeds] = it } + legacy.getString(PrefKeys.DISABLED_HOME_FEED_TYPES, null)?.let { out[FeedVisibilityStore.disabledHomeFeedTypes] = it } + legacy.getString(PrefKeys.RELAY_GROUP_VIEW_MODE, null)?.let { out[FeedVisibilityStore.relayGroupViewMode] = it } + legacy.getString(PrefKeys.CONCORD_VIEW_MODE, null)?.let { out[FeedVisibilityStore.concordViewMode] = it } + if (legacy.contains(PrefKeys.CALLS_ENABLED)) out[FeedVisibilityStore.callsEnabled] = legacy.getBoolean(PrefKeys.CALLS_ENABLED, false) + } + } + + private fun notificationPrefsMigration(npub: String) = + CopyOnceMigration("migrated.notificationPrefs") { out -> + withContext(Dispatchers.IO) { + val legacy = encryptedPreferences(npub) + if (legacy.contains(PrefKeys.ALWAYS_ON_NOTIFICATION_SERVICE)) out[NotificationPrefsStore.alwaysOnService] = legacy.getBoolean(PrefKeys.ALWAYS_ON_NOTIFICATION_SERVICE, false) + if (legacy.contains(PrefKeys.SHOW_MESSAGES_IN_NOTIFICATIONS)) out[NotificationPrefsStore.showMessagesInNotifications] = legacy.getBoolean(PrefKeys.SHOW_MESSAGES_IN_NOTIFICATIONS, false) + if (legacy.contains(PrefKeys.SPLIT_NOTIFICATIONS_ENABLED)) out[NotificationPrefsStore.splitNotificationsEnabled] = legacy.getBoolean(PrefKeys.SPLIT_NOTIFICATIONS_ENABLED, false) + } + } + + /** + * Everything the account's DataStore holds, read in one hop. + * + * Loaded as a group rather than store by store because + * [innerLoadCurrentAccountFromEncryptedStorage] is already near the JVM's + * 64KB method limit: every suspend call inside it adds a state to the + * generated coroutine state machine, and seven separate loads pushed it + * over. One call, one state. + */ + private class AccountStoreData( + val followLists: Map, + val latestEvents: Map, + val uploadSettings: UploadSettings, + val dialogDismissal: DialogDismissal, + val relayAuth: RelayAuth, + val feedVisibility: FeedVisibility, + val notificationPrefs: NotificationPrefs, + ) + + private suspend fun loadAccountStores(npub: String) = + AccountStoreData( + followLists = followListStore(npub).load(), + latestEvents = latestEventStore(npub).load(), + uploadSettings = uploadSettingsStore(npub).load(), + dialogDismissal = dialogDismissalStore(npub).load(), + relayAuth = relayAuthStore(npub).load(), + feedVisibility = feedVisibilityStore(npub).load(), + notificationPrefs = notificationPrefsStore(npub).load(), + ) + + private fun followListMigration(npub: String) = + CopyOnceMigration("migrated.followLists") { out -> + withContext(Dispatchers.IO) { + val legacy = encryptedPreferences(npub) + FollowListSlot.entries.forEach { slot -> + legacy.getString(slot.prefKey, null)?.let { out[slot.key] = it } + } } } private fun latestEventMigration(npub: String) = - CopyOnceMigration("migrated.latestEvents") { + CopyOnceMigration("migrated.latestEvents") { out -> withContext(Dispatchers.IO) { val legacy = encryptedPreferences(npub) - LatestEventSlot.entries - .mapNotNull { slot -> - legacy.getString(slot.prefKey, null)?.let { Pair(slot.key, it) } - }.toMap() + LatestEventSlot.entries.forEach { slot -> + legacy.getString(slot.prefKey, null)?.let { out[slot.key] = it } + } } } @@ -564,17 +675,6 @@ object LocalPreferences { } settings.keyPair.pubKey.let { putString(PrefKeys.NOSTR_PUBKEY, it.toHexKey()) } - putString( - PrefKeys.DEFAULT_FILE_SERVER, - JsonMapper.toJson(settings.defaultFileServer), - ) - - putBoolean(PrefKeys.STRIP_LOCATION_ON_UPLOAD, settings.stripLocationOnUpload) - putBoolean(PrefKeys.USE_LOCAL_BLOSSOM_CACHE, settings.useLocalBlossomCache.value) - putBoolean(PrefKeys.LOCAL_BLOSSOM_CACHE_PROFILE_PICTURES_ONLY, settings.localBlossomCacheProfilePicturesOnly.value) - putBoolean(PrefKeys.MIRROR_UPLOADS_TO_ALL_SERVERS, settings.mirrorUploadsToAllServers.value) - putBoolean(PrefKeys.OPTIMIZE_MEDIA_ON_UPLOAD, settings.optimizeMediaOnUpload.value) - putBoolean(PrefKeys.HIDE_COMMUNITY_RULES_VIOLATIONS, settings.hideCommunityRulesViolations.value) putBoolean(PrefKeys.NIP46_SIGNER_ENABLED, settings.nip46SignerEnabled.value) putString(PrefKeys.NIP46_BUNKER_SECRET, settings.nip46BunkerSecret.value) putString(PrefKeys.NIP46_TRANSPORT_KEY, settings.nip46TransportKey.value) @@ -622,22 +722,6 @@ object LocalPreferences { remove(PrefKeys.LOCAL_RELAY_SERVERS) } - putBoolean(PrefKeys.HIDE_DELETE_REQUEST_DIALOG, settings.hideDeleteRequestDialog) - putBoolean(PrefKeys.HIDE_NIP_17_WARNING_DIALOG, settings.hideNIP17WarningDialog) - putBoolean(PrefKeys.HIDE_BLOCK_ALERT_DIALOG, settings.hideBlockAlertDialog) - putBoolean(PrefKeys.CALLS_ENABLED, settings.callsEnabled.value) - putBoolean(PrefKeys.ALWAYS_ON_NOTIFICATION_SERVICE, settings.alwaysOnNotificationService.value) - putString(PrefKeys.DEFAULT_RELAY_AUTH_POLICY, settings.defaultRelayAuthPolicy.value.name) - putString(PrefKeys.RELAY_GROUP_VIEW_MODE, settings.relayGroupViewMode.value.name) - putString(PrefKeys.CONCORD_VIEW_MODE, settings.concordViewMode.value.name) - putString(PrefKeys.DISABLED_CHAT_FEEDS, ChatFeedType.encode(ChatFeedType.ALL - settings.enabledChatFeeds.value)) - putString(PrefKeys.DISABLED_HOME_FEED_TYPES, HomeFeedType.encode(HomeFeedType.ALL - settings.enabledHomeFeedTypes.value)) - putBoolean(PrefKeys.RELAY_AUTH_TRUST_MY_RELAYS, settings.relayAuthTrustMyRelaysAndVenues.value) - putBoolean(PrefKeys.RELAY_AUTH_TRUST_READ_FOLLOWS, settings.relayAuthTrustReadFollows.value) - putBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_FOLLOWS, settings.relayAuthTrustMessageFollows.value) - putBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_STRANGERS, settings.relayAuthTrustMessageStrangers.value) - putBoolean(PrefKeys.SPLIT_NOTIFICATIONS_ENABLED, settings.splitNotificationsEnabled.value) - putBoolean(PrefKeys.SHOW_MESSAGES_IN_NOTIFICATIONS, settings.showMessagesInNotifications.value) // Any account that reaches a save has its notification filter in its // post-split meaning, so stamp it as migrated. This keeps the one-shot // Global -> Selected rewrite from ever touching it again and preserves a @@ -657,14 +741,6 @@ object LocalPreferences { PrefKeys.LAST_READ_PER_ROUTE, JsonMapper.toJson(regularMap), ) - putStringSet(PrefKeys.HAS_DONATED_IN_VERSION, settings.hasDonatedInVersion.value) - putStringSet(PrefKeys.DISMISSED_POLL_NOTE_IDS, settings.dismissedPollNoteIds.value) - putStringSet(PrefKeys.DISMISSED_CHANNEL_INVITES, settings.dismissedChannelInvites.value) - putStringSet(PrefKeys.MUTED_PUBLIC_CHATS, settings.mutedPublicChats.value) - putString( - PrefKeys.VIEWED_POLL_RESULT_NOTE_IDS, - JsonMapper.toJson(settings.viewedPollResultNoteIds.value), - ) putString( PrefKeys.PENDING_ATTESTATIONS, @@ -672,6 +748,54 @@ object LocalPreferences { ) } } + uploadSettingsStore(settings.keyPair.pubKey.toNpub()).save( + UploadSettings( + stripLocationOnUpload = settings.stripLocationOnUpload, + optimizeMediaOnUpload = settings.optimizeMediaOnUpload.value, + mirrorUploadsToAllServers = settings.mirrorUploadsToAllServers.value, + useLocalBlossomCache = settings.useLocalBlossomCache.value, + localBlossomCacheProfilePicturesOnly = settings.localBlossomCacheProfilePicturesOnly.value, + defaultFileServerJson = JsonMapper.toJson(settings.defaultFileServer), + ), + ) + dialogDismissalStore(settings.keyPair.pubKey.toNpub()).save( + DialogDismissal( + hideDeleteRequestDialog = settings.hideDeleteRequestDialog, + hideBlockAlertDialog = settings.hideBlockAlertDialog, + hideNip17WarningDialog = settings.hideNIP17WarningDialog, + hideCommunityRulesViolations = settings.hideCommunityRulesViolations.value, + dismissedPollNoteIds = settings.dismissedPollNoteIds.value, + dismissedChannelInvites = settings.dismissedChannelInvites.value, + mutedPublicChats = settings.mutedPublicChats.value, + hasDonatedInVersion = settings.hasDonatedInVersion.value, + viewedPollResultNoteIdsJson = JsonMapper.toJson(settings.viewedPollResultNoteIds.value), + ), + ) + relayAuthStore(settings.keyPair.pubKey.toNpub()).save( + RelayAuth( + policyName = settings.defaultRelayAuthPolicy.value.name, + trustMyRelays = settings.relayAuthTrustMyRelaysAndVenues.value, + trustReadFollows = settings.relayAuthTrustReadFollows.value, + trustMessageFollows = settings.relayAuthTrustMessageFollows.value, + trustMessageStrangers = settings.relayAuthTrustMessageStrangers.value, + ), + ) + feedVisibilityStore(settings.keyPair.pubKey.toNpub()).save( + FeedVisibility( + disabledChatFeeds = ChatFeedType.encode(ChatFeedType.ALL - settings.enabledChatFeeds.value), + disabledHomeFeedTypes = HomeFeedType.encode(HomeFeedType.ALL - settings.enabledHomeFeedTypes.value), + relayGroupViewMode = settings.relayGroupViewMode.value.name, + concordViewMode = settings.concordViewMode.value.name, + callsEnabled = settings.callsEnabled.value, + ), + ) + notificationPrefsStore(settings.keyPair.pubKey.toNpub()).save( + NotificationPrefs( + alwaysOnService = settings.alwaysOnNotificationService.value, + showMessagesInNotifications = settings.showMessagesInNotifications.value, + splitNotificationsEnabled = settings.splitNotificationsEnabled.value, + ), + ) latestEventStore(settings.keyPair.pubKey.toNpub()).saveAll( mapOf( LatestEventSlot.CONTACT_LIST to settings.backupContactList?.let { OptimizedJsonMapper.toJson(it) }, @@ -839,74 +963,75 @@ object LocalPreferences { val keyPair = KeyPair(privKey = privKey?.hexToByteArray(), pubKey = pubKey.hexToByteArray()) + val stores = loadAccountStores(keyPair.pubKey.toNpub()) + Log.d("LocalPreferences") { "Load account from file $npub - keys ready" } - val stripLocationOnUpload = getBoolean(PrefKeys.STRIP_LOCATION_ON_UPLOAD, true) - val useLocalBlossomCache = getBoolean(PrefKeys.USE_LOCAL_BLOSSOM_CACHE, true) - val localBlossomCacheProfilePicturesOnly = getBoolean(PrefKeys.LOCAL_BLOSSOM_CACHE_PROFILE_PICTURES_ONLY, false) - val mirrorUploadsToAllServers = getBoolean(PrefKeys.MIRROR_UPLOADS_TO_ALL_SERVERS, true) - val optimizeMediaOnUpload = getBoolean(PrefKeys.OPTIMIZE_MEDIA_ON_UPLOAD, false) - val hideCommunityRulesViolations = getBoolean(PrefKeys.HIDE_COMMUNITY_RULES_VIOLATIONS, false) + val stripLocationOnUpload = stores.uploadSettings.stripLocationOnUpload + val useLocalBlossomCache = stores.uploadSettings.useLocalBlossomCache + val localBlossomCacheProfilePicturesOnly = stores.uploadSettings.localBlossomCacheProfilePicturesOnly + val mirrorUploadsToAllServers = stores.uploadSettings.mirrorUploadsToAllServers + val optimizeMediaOnUpload = stores.uploadSettings.optimizeMediaOnUpload + val hideCommunityRulesViolations = stores.dialogDismissal.hideCommunityRulesViolations val nip46SignerEnabled = getBoolean(PrefKeys.NIP46_SIGNER_ENABLED, false) val nip46BunkerSecret = getString(PrefKeys.NIP46_BUNKER_SECRET, "") ?: "" val nip46TransportKey = getString(PrefKeys.NIP46_TRANSPORT_KEY, "") ?: "" val nip46SeenRequestIds = getStringSet(PrefKeys.NIP46_SEEN_IDS, null) ?: setOf() - val hideDeleteRequestDialog = getBoolean(PrefKeys.HIDE_DELETE_REQUEST_DIALOG, false) - val hideBlockAlertDialog = getBoolean(PrefKeys.HIDE_BLOCK_ALERT_DIALOG, false) - val hideNIP17WarningDialog = getBoolean(PrefKeys.HIDE_NIP_17_WARNING_DIALOG, false) - val callsEnabled = getBoolean(PrefKeys.CALLS_ENABLED, true) - val alwaysOnNotificationService = getBoolean(PrefKeys.ALWAYS_ON_NOTIFICATION_SERVICE, false) + val hideDeleteRequestDialog = stores.dialogDismissal.hideDeleteRequestDialog + val hideBlockAlertDialog = stores.dialogDismissal.hideBlockAlertDialog + val hideNIP17WarningDialog = stores.dialogDismissal.hideNip17WarningDialog + val callsEnabled = stores.feedVisibility.callsEnabled + val alwaysOnNotificationService = stores.notificationPrefs.alwaysOnService // Read as a group via a helper: this load lambda sits right at the JVM's // per-method bytecode limit (see the note above the awaits below), so keeping // these heavy string/enum decodes out of it preserves headroom. - val inboxPrefs = readInboxPrefs() - val splitNotificationsEnabled = getBoolean(PrefKeys.SPLIT_NOTIFICATIONS_ENABLED, false) - val showMessagesInNotifications = getBoolean(PrefKeys.SHOW_MESSAGES_IN_NOTIFICATIONS, true) - val hasDonatedInVersion = getStringSet(PrefKeys.HAS_DONATED_IN_VERSION, null) ?: setOf() - val dismissedPollNoteIds = getStringSet(PrefKeys.DISMISSED_POLL_NOTE_IDS, null) ?: setOf() - val dismissedChannelInvites = getStringSet(PrefKeys.DISMISSED_CHANNEL_INVITES, null) ?: setOf() - val mutedPublicChats = getStringSet(PrefKeys.MUTED_PUBLIC_CHATS, null) ?: setOf() - val viewedPollResultNoteIdsStr = getString(PrefKeys.VIEWED_POLL_RESULT_NOTE_IDS, null) + val inboxPrefs = readInboxPrefs(stores.relayAuth, stores.feedVisibility) + val splitNotificationsEnabled = stores.notificationPrefs.splitNotificationsEnabled + val showMessagesInNotifications = stores.notificationPrefs.showMessagesInNotifications + val hasDonatedInVersion = stores.dialogDismissal.hasDonatedInVersion + val dismissedPollNoteIds = stores.dialogDismissal.dismissedPollNoteIds + val dismissedChannelInvites = stores.dialogDismissal.dismissedChannelInvites + val mutedPublicChats = stores.dialogDismissal.mutedPublicChats + val viewedPollResultNoteIdsStr = stores.dialogDismissal.viewedPollResultNoteIdsJson val localRelayServers = getStringSet(PrefKeys.LOCAL_RELAY_SERVERS, null) ?: setOf() - val followListPrefs = toFollowListPrefs(followListStore(keyPair.pubKey.toNpub()).load()) + val followListPrefs = toFollowListPrefs(stores.followLists) val zapPaymentRequestServerStr = getString(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER, null) val nwcWalletsStr = getString(PrefKeys.NWC_WALLETS, null) val defaultNwcWalletIdStr = getString(PrefKeys.DEFAULT_NWC_WALLET_ID, null) val clinkDebitWalletsStr = getString(PrefKeys.CLINK_DEBIT_WALLETS, null) val defaultPaymentSourceIdStr = getString(PrefKeys.DEFAULT_PAYMENT_SOURCE_ID, null) - val defaultFileServerStr = getString(PrefKeys.DEFAULT_FILE_SERVER, null) + val defaultFileServerStr = stores.uploadSettings.defaultFileServerJson val pendingAttestationsStr = getString(PrefKeys.PENDING_ATTESTATIONS, null) val openBackupConflictsStr = getString(PrefKeys.OPEN_BACKUP_CONFLICTS, null) - val latestEvents = latestEventStore(keyPair.pubKey.toNpub()).load() - val latestUserMetadataStr = latestEvents[LatestEventSlot.USER_METADATA] - val latestContactListStr = latestEvents[LatestEventSlot.CONTACT_LIST] - val latestDmRelayListStr = latestEvents[LatestEventSlot.DM_RELAY_LIST] - val latestNip65RelayListStr = latestEvents[LatestEventSlot.NIP65_RELAY_LIST] - val latestSearchRelayListStr = latestEvents[LatestEventSlot.SEARCH_RELAY_LIST] - val latestIndexRelayListStr = latestEvents[LatestEventSlot.INDEX_RELAY_LIST] - val latestRelayFeedsListStr = latestEvents[LatestEventSlot.RELAY_FEEDS_LIST] - val latestBlockedRelayListStr = latestEvents[LatestEventSlot.BLOCKED_RELAY_LIST] - val latestTrustedRelayListStr = latestEvents[LatestEventSlot.TRUSTED_RELAY_LIST] - val latestMuteListStr = latestEvents[LatestEventSlot.MUTE_LIST] - val latestPrivateHomeRelayListStr = latestEvents[LatestEventSlot.PRIVATE_HOME_RELAY_LIST] - val latestAppSpecificDataStr = latestEvents[LatestEventSlot.APP_SPECIFIC_DATA] - val latestChannelListStr = latestEvents[LatestEventSlot.CHANNEL_LIST] - val latestCommunityListStr = latestEvents[LatestEventSlot.COMMUNITY_LIST] - val latestHashtagListStr = latestEvents[LatestEventSlot.HASHTAG_LIST] - val latestGeohashListStr = latestEvents[LatestEventSlot.GEOHASH_LIST] - val latestEphemeralListStr = latestEvents[LatestEventSlot.EPHEMERAL_LIST] - val latestRelayGroupListStr = latestEvents[LatestEventSlot.RELAY_GROUP_LIST] - val latestConcordListStr = latestEvents[LatestEventSlot.CONCORD_LIST] - val latestTrustProviderListStr = latestEvents[LatestEventSlot.TRUST_PROVIDER_LIST] - val latestKeyPackageRelayListStr = latestEvents[LatestEventSlot.KEY_PACKAGE_RELAY_LIST] - val latestFavoriteAlgoFeedsListStr = latestEvents[LatestEventSlot.FAVORITE_ALGO_FEEDS_LIST] - val latestPaymentTargetsStr = latestEvents[LatestEventSlot.PAYMENT_TARGETS] - val latestBolt12OffersStr = latestEvents[LatestEventSlot.BOLT12_OFFERS] - val latestCashuWalletStr = latestEvents[LatestEventSlot.CASHU_WALLET] - val latestNutzapInfoStr = latestEvents[LatestEventSlot.NUTZAP_INFO] + val latestUserMetadataStr = stores.latestEvents[LatestEventSlot.USER_METADATA] + val latestContactListStr = stores.latestEvents[LatestEventSlot.CONTACT_LIST] + val latestDmRelayListStr = stores.latestEvents[LatestEventSlot.DM_RELAY_LIST] + val latestNip65RelayListStr = stores.latestEvents[LatestEventSlot.NIP65_RELAY_LIST] + val latestSearchRelayListStr = stores.latestEvents[LatestEventSlot.SEARCH_RELAY_LIST] + val latestIndexRelayListStr = stores.latestEvents[LatestEventSlot.INDEX_RELAY_LIST] + val latestRelayFeedsListStr = stores.latestEvents[LatestEventSlot.RELAY_FEEDS_LIST] + val latestBlockedRelayListStr = stores.latestEvents[LatestEventSlot.BLOCKED_RELAY_LIST] + val latestTrustedRelayListStr = stores.latestEvents[LatestEventSlot.TRUSTED_RELAY_LIST] + val latestMuteListStr = stores.latestEvents[LatestEventSlot.MUTE_LIST] + val latestPrivateHomeRelayListStr = stores.latestEvents[LatestEventSlot.PRIVATE_HOME_RELAY_LIST] + val latestAppSpecificDataStr = stores.latestEvents[LatestEventSlot.APP_SPECIFIC_DATA] + val latestChannelListStr = stores.latestEvents[LatestEventSlot.CHANNEL_LIST] + val latestCommunityListStr = stores.latestEvents[LatestEventSlot.COMMUNITY_LIST] + val latestHashtagListStr = stores.latestEvents[LatestEventSlot.HASHTAG_LIST] + val latestGeohashListStr = stores.latestEvents[LatestEventSlot.GEOHASH_LIST] + val latestEphemeralListStr = stores.latestEvents[LatestEventSlot.EPHEMERAL_LIST] + val latestRelayGroupListStr = stores.latestEvents[LatestEventSlot.RELAY_GROUP_LIST] + val latestConcordListStr = stores.latestEvents[LatestEventSlot.CONCORD_LIST] + val latestTrustProviderListStr = stores.latestEvents[LatestEventSlot.TRUST_PROVIDER_LIST] + val latestKeyPackageRelayListStr = stores.latestEvents[LatestEventSlot.KEY_PACKAGE_RELAY_LIST] + val latestFavoriteAlgoFeedsListStr = stores.latestEvents[LatestEventSlot.FAVORITE_ALGO_FEEDS_LIST] + val latestPaymentTargetsStr = stores.latestEvents[LatestEventSlot.PAYMENT_TARGETS] + val latestBolt12OffersStr = stores.latestEvents[LatestEventSlot.BOLT12_OFFERS] + val latestCashuWalletStr = stores.latestEvents[LatestEventSlot.CASHU_WALLET] + val latestNutzapInfoStr = stores.latestEvents[LatestEventSlot.NUTZAP_INFO] val lastReadPerRouteStr = getString(PrefKeys.LAST_READ_PER_ROUTE, null) Log.d("LocalPreferences") { "Load account from file $npub - before parsing events" } @@ -1342,20 +1467,22 @@ private class InboxPrefs( val relayAuthTrustMessageStrangers: Boolean, ) -private fun SharedPreferences.readInboxPrefs() = - InboxPrefs( - // Missing key = an account saved before this setting existed. Those keep CUSTOM; only - // brand-new logins get the ALWAYS default from AccountSettings' constructor. - defaultRelayAuthPolicy = - getString(PrefKeys.DEFAULT_RELAY_AUTH_POLICY, null) - ?.let { runCatching { RelayAuthPolicy.valueOf(it) }.getOrNull() } - ?: RelayAuthPolicy.CUSTOM, - relayGroupViewMode = RelayGroupViewMode.fromName(getString(PrefKeys.RELAY_GROUP_VIEW_MODE, null)), - concordViewMode = ConcordViewMode.fromName(getString(PrefKeys.CONCORD_VIEW_MODE, null)), - enabledChatFeeds = ChatFeedType.ALL - ChatFeedType.decode(getString(PrefKeys.DISABLED_CHAT_FEEDS, null)), - enabledHomeFeedTypes = HomeFeedType.ALL - HomeFeedType.decode(getString(PrefKeys.DISABLED_HOME_FEED_TYPES, null)), - relayAuthTrustMyRelays = getBoolean(PrefKeys.RELAY_AUTH_TRUST_MY_RELAYS, true), - relayAuthTrustReadFollows = getBoolean(PrefKeys.RELAY_AUTH_TRUST_READ_FOLLOWS, true), - relayAuthTrustMessageFollows = getBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_FOLLOWS, true), - relayAuthTrustMessageStrangers = getBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_STRANGERS, false), - ) +private fun readInboxPrefs( + relayAuth: RelayAuth, + feedVisibility: FeedVisibility, +) = InboxPrefs( + // Missing key = an account saved before this setting existed. Those keep CUSTOM; only + // brand-new logins get the ALWAYS default from AccountSettings' constructor. + defaultRelayAuthPolicy = + relayAuth.policyName + ?.let { runCatching { RelayAuthPolicy.valueOf(it) }.getOrNull() } + ?: RelayAuthPolicy.CUSTOM, + relayGroupViewMode = RelayGroupViewMode.fromName(feedVisibility.relayGroupViewMode), + concordViewMode = ConcordViewMode.fromName(feedVisibility.concordViewMode), + enabledChatFeeds = ChatFeedType.ALL - ChatFeedType.decode(feedVisibility.disabledChatFeeds), + enabledHomeFeedTypes = HomeFeedType.ALL - HomeFeedType.decode(feedVisibility.disabledHomeFeedTypes), + relayAuthTrustMyRelays = relayAuth.trustMyRelays, + relayAuthTrustReadFollows = relayAuth.trustReadFollows, + relayAuthTrustMessageFollows = relayAuth.trustMessageFollows, + relayAuthTrustMessageStrangers = relayAuth.trustMessageStrangers, +) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt index 3ab3ba82b7..d1a3be3e89 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.commons.model.preferences import androidx.datastore.core.DataMigration +import androidx.datastore.preferences.core.MutablePreferences import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey @@ -36,18 +37,18 @@ import androidx.datastore.preferences.core.booleanPreferencesKey * left untouched and a rollback still works. Deleting the legacy data is a * separate decision, taken once the migration has shipped and held. * - * [read] is only called when the migration actually runs, so the cost of - * opening the legacy store is not paid on every launch. + * [copy] receives the destination and writes whatever it has, so a migration + * can carry strings, booleans, int and string sets alike. It is only called + * when the migration actually runs, so opening the legacy store is not a cost + * paid on every launch. A key it does not write is left absent rather than + * written blank, so it keeps reading as "unset" and falls back to its default. * * @param markerName key recording, in this store, that the copy has run. * Distinct per migration, so several can run against the same store. - * @param read the legacy values, already mapped onto this store's keys. A key - * absent here is left absent rather than written blank, so it keeps reading - * as "unset" and falls back to its default. */ class CopyOnceMigration( markerName: String, - private val read: suspend () -> Map, String>, + private val copy: suspend (MutablePreferences) -> Unit, ) : DataMigration { private val marker = booleanPreferencesKey(markerName) @@ -56,7 +57,7 @@ class CopyOnceMigration( override suspend fun migrate(currentData: Preferences): Preferences { val updated = currentData.toMutablePreferences() - read().forEach { (key, value) -> updated[key] = value } + copy(updated) updated[marker] = true return updated.toPreferences() diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt new file mode 100644 index 0000000000..870a2bc2c1 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import androidx.datastore.preferences.core.stringSetPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * What this account has dismissed and does not want shown again — + * confirmation dialogs, individual polls and invites, the donation card. + * + * Everything here defaults to "not dismissed", so a lost value costs the user + * one more prompt rather than hiding something they never dismissed. + * + * Defaults match what the SharedPreferences implementation returned for a + * missing key, so an account that never touched a setting behaves identically + * before and after the migration. + */ +data class DialogDismissal( + val hideDeleteRequestDialog: Boolean = false, + val hideBlockAlertDialog: Boolean = false, + val hideNip17WarningDialog: Boolean = false, + val hideCommunityRulesViolations: Boolean = false, + val dismissedPollNoteIds: Set = emptySet(), + val dismissedChannelInvites: Set = emptySet(), + val mutedPublicChats: Set = emptySet(), + val hasDonatedInVersion: Set = emptySet(), + val viewedPollResultNoteIdsJson: String? = null, +) + +/** Reads and writes [DialogDismissal] in the account's DataStore. */ +class DialogDismissalStore( + private val store: DataStore, +) { + companion object { + val hideDeleteRequestDialog = booleanPreferencesKey("hide_delete_request_dialog") + val hideBlockAlertDialog = booleanPreferencesKey("hide_block_alert_dialog") + val hideNip17WarningDialog = booleanPreferencesKey("hide_nip24_warning_dialog") + val hideCommunityRulesViolations = booleanPreferencesKey("hideCommunityRulesViolations") + val dismissedPollNoteIds = stringSetPreferencesKey("dismissedPollNoteIds") + val dismissedChannelInvites = stringSetPreferencesKey("dismissedChannelInvites") + val mutedPublicChats = stringSetPreferencesKey("mutedPublicChats") + val hasDonatedInVersion = stringSetPreferencesKey("hasDonatedInVersion") + val viewedPollResultNoteIdsJson = stringPreferencesKey("viewedPollResultNoteIds") + } + + suspend fun load(): DialogDismissal { + val prefs = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + return DialogDismissal( + hideDeleteRequestDialog = prefs[hideDeleteRequestDialog] ?: false, + hideBlockAlertDialog = prefs[hideBlockAlertDialog] ?: false, + hideNip17WarningDialog = prefs[hideNip17WarningDialog] ?: false, + hideCommunityRulesViolations = prefs[hideCommunityRulesViolations] ?: false, + dismissedPollNoteIds = prefs[dismissedPollNoteIds] ?: emptySet(), + dismissedChannelInvites = prefs[dismissedChannelInvites] ?: emptySet(), + mutedPublicChats = prefs[mutedPublicChats] ?: emptySet(), + hasDonatedInVersion = prefs[hasDonatedInVersion] ?: emptySet(), + viewedPollResultNoteIdsJson = prefs[viewedPollResultNoteIdsJson], + ) + } + + /** Writes the whole group in one edit, so a crash cannot half-apply it. */ + suspend fun save(value: DialogDismissal) { + store.edit { prefs -> + prefs[hideDeleteRequestDialog] = value.hideDeleteRequestDialog + prefs[hideBlockAlertDialog] = value.hideBlockAlertDialog + prefs[hideNip17WarningDialog] = value.hideNip17WarningDialog + prefs[hideCommunityRulesViolations] = value.hideCommunityRulesViolations + prefs[dismissedPollNoteIds] = value.dismissedPollNoteIds + prefs[dismissedChannelInvites] = value.dismissedChannelInvites + prefs[mutedPublicChats] = value.mutedPublicChats + prefs[hasDonatedInVersion] = value.hasDonatedInVersion + value.viewedPollResultNoteIdsJson.let { if (it != null) prefs[viewedPollResultNoteIdsJson] = it else prefs.remove(viewedPollResultNoteIdsJson) } + } + } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt new file mode 100644 index 0000000000..f99321a914 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * Which feeds this account shows and how they are laid out. + + * The two "disabled" keys store what is switched OFF, not what is on, so an + * absent value means everything is enabled and a feed type added later defaults + * to on for accounts that customised before it existed. + * + * Defaults match what the SharedPreferences implementation returned for a + * missing key, so an account that never touched a setting behaves identically + * before and after the migration. + */ +data class FeedVisibility( + val disabledChatFeeds: String? = null, + val disabledHomeFeedTypes: String? = null, + val relayGroupViewMode: String? = null, + val concordViewMode: String? = null, + val callsEnabled: Boolean = true, +) + +/** Reads and writes [FeedVisibility] in the account's DataStore. */ +class FeedVisibilityStore( + private val store: DataStore, +) { + companion object { + val disabledChatFeeds = stringPreferencesKey("disabled_chat_feeds") + val disabledHomeFeedTypes = stringPreferencesKey("disabled_home_feed_types") + val relayGroupViewMode = stringPreferencesKey("relay_group_view_mode") + val concordViewMode = stringPreferencesKey("concord_view_mode") + val callsEnabled = booleanPreferencesKey("calls_enabled") + } + + suspend fun load(): FeedVisibility { + val prefs = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + return FeedVisibility( + disabledChatFeeds = prefs[disabledChatFeeds], + disabledHomeFeedTypes = prefs[disabledHomeFeedTypes], + relayGroupViewMode = prefs[relayGroupViewMode], + concordViewMode = prefs[concordViewMode], + callsEnabled = prefs[callsEnabled] ?: true, + ) + } + + /** Writes the whole group in one edit, so a crash cannot half-apply it. */ + suspend fun save(value: FeedVisibility) { + store.edit { prefs -> + value.disabledChatFeeds.let { if (it != null) prefs[disabledChatFeeds] = it else prefs.remove(disabledChatFeeds) } + value.disabledHomeFeedTypes.let { if (it != null) prefs[disabledHomeFeedTypes] = it else prefs.remove(disabledHomeFeedTypes) } + value.relayGroupViewMode.let { if (it != null) prefs[relayGroupViewMode] = it else prefs.remove(relayGroupViewMode) } + value.concordViewMode.let { if (it != null) prefs[concordViewMode] = it else prefs.remove(concordViewMode) } + prefs[callsEnabled] = value.callsEnabled + } + } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt new file mode 100644 index 0000000000..e6de5d5c83 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * This account's share of the notification settings. + + * The global on/off switch is not here — it lives in plain, non-encrypted + * storage because the restart layer must read it synchronously from a fresh + * process (boot receiver, WorkManager) before any account is loaded. + * + * Defaults match what the SharedPreferences implementation returned for a + * missing key, so an account that never touched a setting behaves identically + * before and after the migration. + */ +data class NotificationPrefs( + val alwaysOnService: Boolean = false, + val showMessagesInNotifications: Boolean = true, + val splitNotificationsEnabled: Boolean = false, +) + +/** Reads and writes [NotificationPrefs] in the account's DataStore. */ +class NotificationPrefsStore( + private val store: DataStore, +) { + companion object { + val alwaysOnService = booleanPreferencesKey("always_on_notification_service") + val showMessagesInNotifications = booleanPreferencesKey("show_messages_in_notifications") + val splitNotificationsEnabled = booleanPreferencesKey("split_notifications_enabled") + val globalToCuratedMigrated = booleanPreferencesKey("notif_global_to_curated_migrated") + val lastReadPerRouteJson = stringPreferencesKey("last_read_per_route") + } + + private suspend fun read(): Preferences = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + suspend fun load(): NotificationPrefs { + val prefs = read() + + return NotificationPrefs( + alwaysOnService = prefs[alwaysOnService] ?: false, + showMessagesInNotifications = prefs[showMessagesInNotifications] ?: true, + splitNotificationsEnabled = prefs[splitNotificationsEnabled] ?: false, + ) + } + + /** + * Whether the one-shot global-to-curated notification filter migration has + * already run for this account. + * + * Kept out of [NotificationPrefs] and its bulk save because it is not a + * user setting: it is written once, by that migration, and a bulk save that + * carried a stale copy could re-run the migration or wrongly suppress it. + */ + suspend fun hasRunGlobalToCuratedMigration(): Boolean = read()[globalToCuratedMigrated] ?: false + + suspend fun markGlobalToCuratedMigrated() { + store.edit { prefs -> prefs[globalToCuratedMigrated] = true } + } + + /** + * The per-route read markers, as JSON. + * + * Written on its own path as the user reads things, at a different cadence + * from the settings above, so it is not part of [save]. + */ + suspend fun lastReadPerRoute(): String? = read()[lastReadPerRouteJson] + + suspend fun saveLastReadPerRoute(json: String) { + store.edit { prefs -> prefs[lastReadPerRouteJson] = json } + } + + /** Writes the whole group in one edit, so a crash cannot half-apply it. */ + suspend fun save(value: NotificationPrefs) { + store.edit { prefs -> + prefs[alwaysOnService] = value.alwaysOnService + prefs[showMessagesInNotifications] = value.showMessagesInNotifications + prefs[splitNotificationsEnabled] = value.splitNotificationsEnabled + } + } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt new file mode 100644 index 0000000000..1f18ed793b --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * When this account answers a relay's NIP-42 AUTH challenge. + + * The policy key is absent for accounts saved before the setting existed; the + * caller maps that absence to CUSTOM rather than to the constructor default, so + * an existing user's behaviour does not change under them. + * + * Defaults match what the SharedPreferences implementation returned for a + * missing key, so an account that never touched a setting behaves identically + * before and after the migration. + */ +data class RelayAuth( + val policyName: String? = null, + val trustMyRelays: Boolean = true, + val trustReadFollows: Boolean = true, + val trustMessageFollows: Boolean = true, + val trustMessageStrangers: Boolean = false, +) + +/** Reads and writes [RelayAuth] in the account's DataStore. */ +class RelayAuthStore( + private val store: DataStore, +) { + companion object { + val policyName = stringPreferencesKey("default_relay_auth_policy") + val trustMyRelays = booleanPreferencesKey("relay_auth_trust_my_relays") + val trustReadFollows = booleanPreferencesKey("relay_auth_trust_read_follows") + val trustMessageFollows = booleanPreferencesKey("relay_auth_trust_message_follows") + val trustMessageStrangers = booleanPreferencesKey("relay_auth_trust_message_strangers") + } + + suspend fun load(): RelayAuth { + val prefs = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + return RelayAuth( + policyName = prefs[policyName], + trustMyRelays = prefs[trustMyRelays] ?: true, + trustReadFollows = prefs[trustReadFollows] ?: true, + trustMessageFollows = prefs[trustMessageFollows] ?: true, + trustMessageStrangers = prefs[trustMessageStrangers] ?: false, + ) + } + + /** Writes the whole group in one edit, so a crash cannot half-apply it. */ + suspend fun save(value: RelayAuth) { + store.edit { prefs -> + value.policyName.let { if (it != null) prefs[policyName] = it else prefs.remove(policyName) } + prefs[trustMyRelays] = value.trustMyRelays + prefs[trustReadFollows] = value.trustReadFollows + prefs[trustMessageFollows] = value.trustMessageFollows + prefs[trustMessageStrangers] = value.trustMessageStrangers + } + } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt new file mode 100644 index 0000000000..c63769dae7 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * How this account uploads media: which server, what is stripped, what is + * mirrored and what is cached locally. + * + * Defaults match what the SharedPreferences implementation returned for a + * missing key, so an account that never touched a setting behaves identically + * before and after the migration. + */ +data class UploadSettings( + val stripLocationOnUpload: Boolean = true, + val optimizeMediaOnUpload: Boolean = false, + val mirrorUploadsToAllServers: Boolean = true, + val useLocalBlossomCache: Boolean = true, + val localBlossomCacheProfilePicturesOnly: Boolean = false, + val defaultFileServerJson: String? = null, +) + +/** Reads and writes [UploadSettings] in the account's DataStore. */ +class UploadSettingsStore( + private val store: DataStore, +) { + companion object { + val stripLocationOnUpload = booleanPreferencesKey("stripLocationOnUpload") + val optimizeMediaOnUpload = booleanPreferencesKey("optimizeMediaOnUpload") + val mirrorUploadsToAllServers = booleanPreferencesKey("mirrorUploadsToAllServers") + val useLocalBlossomCache = booleanPreferencesKey("useLocalBlossomCache") + val localBlossomCacheProfilePicturesOnly = booleanPreferencesKey("localBlossomCacheProfilePicturesOnly") + val defaultFileServerJson = stringPreferencesKey("defaultFileServer") + } + + suspend fun load(): UploadSettings { + val prefs = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + return UploadSettings( + stripLocationOnUpload = prefs[stripLocationOnUpload] ?: true, + optimizeMediaOnUpload = prefs[optimizeMediaOnUpload] ?: false, + mirrorUploadsToAllServers = prefs[mirrorUploadsToAllServers] ?: true, + useLocalBlossomCache = prefs[useLocalBlossomCache] ?: true, + localBlossomCacheProfilePicturesOnly = prefs[localBlossomCacheProfilePicturesOnly] ?: false, + defaultFileServerJson = prefs[defaultFileServerJson], + ) + } + + /** Writes the whole group in one edit, so a crash cannot half-apply it. */ + suspend fun save(value: UploadSettings) { + store.edit { prefs -> + prefs[stripLocationOnUpload] = value.stripLocationOnUpload + prefs[optimizeMediaOnUpload] = value.optimizeMediaOnUpload + prefs[mirrorUploadsToAllServers] = value.mirrorUploadsToAllServers + prefs[useLocalBlossomCache] = value.useLocalBlossomCache + prefs[localBlossomCacheProfilePicturesOnly] = value.localBlossomCacheProfilePicturesOnly + value.defaultFileServerJson.let { if (it != null) prefs[defaultFileServerJson] = it else prefs.remove(defaultFileServerJson) } + } + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt new file mode 100644 index 0000000000..e15c451da8 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * The five per-account setting groups. + * + * The defaults are the point: they must match what the SharedPreferences + * implementation returned for a missing key, because an account that never + * touched a setting has no stored value and gets the default forever after. + * Several are `true`, so a group that defaulted everything to `false` would + * silently turn features off for every existing user. + */ +class AccountSettingStoresTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun raw(): DataStore { + val file = File(folder.root, "group_${seq++}.preferences_pb") + return PreferenceDataStoreFactory.createWithPath( + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + produceFile = { file.toOkioPath() }, + ) + } + + @Test + fun uploadSettingsDefaultsMatchTheLegacyOnes() = + runTest { + val loaded = UploadSettingsStore(raw()).load() + + assertEquals(true, loaded.stripLocationOnUpload) + assertEquals(false, loaded.optimizeMediaOnUpload) + assertEquals(true, loaded.mirrorUploadsToAllServers) + assertEquals(true, loaded.useLocalBlossomCache) + assertEquals(false, loaded.localBlossomCacheProfilePicturesOnly) + assertNull(loaded.defaultFileServerJson) + } + + @Test + fun uploadSettingsRoundTrip() = + runTest { + val store = UploadSettingsStore(raw()) + val value = + UploadSettings( + stripLocationOnUpload = false, + optimizeMediaOnUpload = true, + mirrorUploadsToAllServers = false, + useLocalBlossomCache = false, + localBlossomCacheProfilePicturesOnly = true, + defaultFileServerJson = """{"name":"x"}""", + ) + + store.save(value) + + assertEquals(value, store.load()) + } + + @Test + fun dialogDismissalDefaultsToNothingDismissed() = + runTest { + val loaded = DialogDismissalStore(raw()).load() + + assertEquals(false, loaded.hideDeleteRequestDialog) + assertEquals(false, loaded.hideBlockAlertDialog) + assertEquals(false, loaded.hideNip17WarningDialog) + assertEquals(false, loaded.hideCommunityRulesViolations) + assertTrue(loaded.dismissedPollNoteIds.isEmpty()) + assertTrue(loaded.dismissedChannelInvites.isEmpty()) + assertTrue(loaded.mutedPublicChats.isEmpty()) + assertTrue(loaded.hasDonatedInVersion.isEmpty()) + } + + @Test + fun dialogDismissalRoundTripsSets() = + runTest { + val store = DialogDismissalStore(raw()) + val value = + DialogDismissal( + hideDeleteRequestDialog = true, + dismissedPollNoteIds = setOf("a", "b"), + mutedPublicChats = setOf("chat1"), + hasDonatedInVersion = setOf("1.2.3"), + ) + + store.save(value) + + assertEquals(value, store.load()) + } + + /** Three of these default to true — trusting by default — so a wrong default weakens AUTH behaviour. */ + @Test + fun relayAuthDefaults() = + runTest { + val loaded = RelayAuthStore(raw()).load() + + assertNull("absent means CUSTOM, decided by the caller", loaded.policyName) + assertEquals(true, loaded.trustMyRelays) + assertEquals(true, loaded.trustReadFollows) + assertEquals(true, loaded.trustMessageFollows) + assertEquals(false, loaded.trustMessageStrangers) + } + + @Test + fun relayAuthRoundTrip() = + runTest { + val store = RelayAuthStore(raw()) + val value = RelayAuth("ALWAYS", trustMyRelays = false, trustMessageStrangers = true) + + store.save(value) + + assertEquals(value, store.load()) + } + + /** The disabled-feed keys store what is OFF, so absent must mean everything on. */ + @Test + fun feedVisibilityDefaultsToEverythingEnabled() = + runTest { + val loaded = FeedVisibilityStore(raw()).load() + + assertNull(loaded.disabledChatFeeds) + assertNull(loaded.disabledHomeFeedTypes) + assertEquals(true, loaded.callsEnabled) + } + + @Test + fun notificationPrefsDefaults() = + runTest { + val loaded = NotificationPrefsStore(raw()).load() + + assertEquals(false, loaded.alwaysOnService) + assertEquals(true, loaded.showMessagesInNotifications) + assertEquals(false, loaded.splitNotificationsEnabled) + } + + /** + * The one-shot migration marker is not a user setting, so it must not ride + * along in the bulk save where a stale copy could re-run or suppress it. + */ + @Test + fun theGlobalToCuratedMarkerIsIndependentOfTheBulkSave() = + runTest { + val store = NotificationPrefsStore(raw()) + + assertEquals(false, store.hasRunGlobalToCuratedMigration()) + store.markGlobalToCuratedMigrated() + store.save(NotificationPrefs(alwaysOnService = true)) + + assertEquals("a later bulk save must not clear it", true, store.hasRunGlobalToCuratedMigration()) + assertEquals(true, store.load().alwaysOnService) + } + + @Test + fun lastReadPerRouteIsIndependentOfTheBulkSave() = + runTest { + val store = NotificationPrefsStore(raw()) + + store.saveLastReadPerRoute("""{"home":1}""") + store.save(NotificationPrefs(splitNotificationsEnabled = true)) + + assertEquals("""{"home":1}""", store.lastReadPerRoute()) + } + + /** A null string field must clear its key rather than leave the old value behind. */ + @Test + fun aNullStringFieldClearsTheKey() = + runTest { + val store = FeedVisibilityStore(raw()) + + store.save(FeedVisibility(disabledChatFeeds = "a,b")) + store.save(FeedVisibility(disabledChatFeeds = null)) + + assertNull(store.load().disabledChatFeeds) + } + + /** Key strings are a compatibility surface — renaming one resets that setting for everyone. */ + @Test + fun keyNamesMatchTheLegacyOnes() { + assertEquals("stripLocationOnUpload", UploadSettingsStore.stripLocationOnUpload.name) + assertEquals("hide_delete_request_dialog", DialogDismissalStore.hideDeleteRequestDialog.name) + assertEquals("hide_nip24_warning_dialog", DialogDismissalStore.hideNip17WarningDialog.name) + assertEquals("default_relay_auth_policy", RelayAuthStore.policyName.name) + assertEquals("disabled_chat_feeds", FeedVisibilityStore.disabledChatFeeds.name) + assertEquals("always_on_notification_service", NotificationPrefsStore.alwaysOnService.name) + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt index 66bc5122ab..32d0003c47 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStoreTest.kt @@ -123,7 +123,7 @@ class LatestEventCacheStoreTest { runTest { val legacy = mapOf(Pair(LatestEventSlot.USER_METADATA.key, """{"kind":0}""")) - val loaded = store(listOf(CopyOnceMigration("migrated.latestEvents") { legacy })).load() + val loaded = store(listOf(CopyOnceMigration("migrated.latestEvents") { out -> legacy.forEach { (k, v) -> out[k] = v } })).load() assertEquals("""{"kind":0}""", loaded[LatestEventSlot.USER_METADATA]) assertFalse("slots absent from the legacy store stay absent", loaded.containsKey(LatestEventSlot.MUTE_LIST)) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt index 59f8a81d38..1a08dc1eb7 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt @@ -165,7 +165,7 @@ class TopNavFollowListStoreTest { Pair(FollowListSlot.BADGES.key, encode(TopFilter.AllFollows)), ) - val loaded = store(scope(), listOf(CopyOnceMigration("migrated.followLists") { legacy })).load() + val loaded = store(scope(), listOf(CopyOnceMigration("migrated.followLists") { out -> legacy.forEach { (k, v) -> out[k] = v } })).load() assertEquals(TopFilter.Global, loaded.getValue(FollowListSlot.HOME)) assertEquals(TopFilter.AllFollows, loaded.getValue(FollowListSlot.BADGES)) @@ -196,9 +196,9 @@ class TopNavFollowListStoreTest { scope = scope, migrations = listOf( - CopyOnceMigration("migrated.followLists") { + CopyOnceMigration("migrated.followLists") { out -> reads++ - legacy + legacy.forEach { (k, v) -> out[k] = v } }, ), produceFile = { file.toOkioPath() }, From 9a6be77841ae13f5869e77473b638eb359a2a8e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 17:38:53 +0000 Subject: [PATCH 05/57] refactor: move the calendar reminder stores to DataStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 4 of the SharedPreferences -> DataStore migration. CalendarReminderPrefs and CalendarReminderStore become CalendarReminderSettingsStore and CalendarReminderLogStore in commons/commonMain, carried over by CopyOnceMigration as before. The log keeps storing the event-start time a reminder fired for rather than a bare flag, which is what makes a moved meeting work: if the author changes the start, the stored value no longer matches and a fresh reminder fires instead of the new time being silently skipped. forgetBefore now also checks the key prefix, so a future setting sharing that store cannot be pruned away by a stale cutoff. The settings screen was the only synchronous reader. It now collects the store's flow instead of reading once in a remember{}, so the first frame shows defaults and the stored values arrive right after — and the screen stays correct if the worker path changes a value while it is open. The other two call sites (CoroutineWorker.doWork, an applicationIOScope launch) were already suspending. Two things in this step were NOT migrated, and the reasons are now in the code rather than in a commit message nobody reads again: - NOTIFICATION_SERVICE_ENABLED cannot move. DataStore is suspend-only, while NotificationRelayService.isEnabled(context) is a synchronous Boolean read from Service and BroadcastReceiver entry points in freshly started processes (boot, watchdog, WorkManager). Making it suspend would leave the restart layers unable to consult it, so a saved OFF would be missed on cold boot and the service would resurrect itself. Plain SharedPreferences is the only store here that answers synchronously on any thread. - ChessDismissedGamesStorage stays too. ChessLobbyLogic reads it in a property initializer and writes it from two non-suspending functions, so migrating means seeding the dismissed set asynchronously — and until that load lands, a game the user already dismissed reappears. That is a visible regression bought with consistency alone: this store is already an expect/actual with a working iOS implementation, so unlike the rest of the preference layer it blocks no target. The account roster (CURRENT_ACCOUNT, SAVED_ACCOUNTS, ALL_ACCOUNT_INFO) is deferred to the secrets step rather than moved here. It currently lives in the encrypted global file; moving it to a plain store would put the list of an installation's npubs in cleartext, so it belongs with the encrypted-store work, not with device settings. 8 tests, porting what the deleted Android CalendarReminderPrefsTest covered plus the two behaviours above. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 4 +- .../amethyst/LocalPreferences.kt | 9 + .../service/calendar/CalendarReminderPrefs.kt | 66 ----- .../service/calendar/CalendarReminderStore.kt | 84 ------- .../calendar/CalendarReminderStores.kt | 76 ++++++ .../calendar/CalendarReminderWorker.kt | 10 +- .../CalendarReminderSettingsScreen.kt | 29 ++- .../calendar/CalendarReminderPrefsTest.kt | 237 ------------------ .../nip64Chess/ChessDismissedGamesStorage.kt | 15 ++ .../preferences/CalendarReminderLogStore.kt | 88 +++++++ .../CalendarReminderSettingsStore.kt | 89 +++++++ .../preferences/CalendarReminderStoresTest.kt | 144 +++++++++++ 12 files changed, 446 insertions(+), 405 deletions(-) delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderPrefs.kt delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStore.kt create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt delete mode 100644 amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarReminderPrefsTest.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderLogStore.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderSettingsStore.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderStoresTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 84f2e38472..00e18e0019 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -75,8 +75,8 @@ import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilde import com.vitorpamplona.amethyst.model.torState.AccountsTorStateConnector import com.vitorpamplona.amethyst.model.torState.TorRelayState import com.vitorpamplona.amethyst.napplet.DataStoreNappletPermissionStore -import com.vitorpamplona.amethyst.service.calendar.CalendarReminderPrefs import com.vitorpamplona.amethyst.service.calendar.CalendarReminderWorker +import com.vitorpamplona.amethyst.service.calendar.calendarReminderSettings import com.vitorpamplona.amethyst.service.cast.CastRegistry import com.vitorpamplona.amethyst.service.connectivity.ConnectivityManager import com.vitorpamplona.amethyst.service.crashreports.CrashReportCache @@ -1297,7 +1297,7 @@ class AppModules( Filter(kinds = listOf(CalendarDateSlotEvent.KIND, CalendarTimeSlotEvent.KIND)), ).conflate() .collect { - if (CalendarReminderPrefs(appContext).isEnabled() && + if (appContext.calendarReminderSettings().load().enabled && CalendarReminderWorker.couldStillFire(CalendarReminderWorker.acceptedRsvpsInCache(), TimeUtils.now()) ) { CalendarReminderWorker.schedule(appContext) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index ce40ff0157..dabf6b10e0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -414,6 +414,15 @@ object LocalPreferences { } } + // NOT migrated to DataStore, and cannot be: DataStore is suspend-only, while + // NotificationRelayService.isEnabled(context) is a synchronous Boolean read + // from Service and BroadcastReceiver entry points in freshly started + // processes (boot, watchdog, WorkManager). Making it suspend would mean the + // restart layers could not consult it at all, and a saved OFF would be + // missed on cold boot — the service would resurrect itself. Plain + // SharedPreferences is the only store here that answers synchronously on + // any thread, so this key stays on it deliberately. + // // Global master switch for the always-on notification service ("Background // notification service"). Default ON: existing users keep current behavior, and // per-account participation decides who actually stays active. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderPrefs.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderPrefs.kt deleted file mode 100644 index 737cffdadb..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderPrefs.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.service.calendar - -import android.content.Context -import android.content.SharedPreferences -import androidx.core.content.edit - -/** - * Device-wide preferences for the calendar reminder worker. - * - * Stored at device scope (rather than per-account) because the worker that consults them runs - * globally — multiplexing per-account preferences would require account-context plumbing into - * WorkManager that the rest of the app doesn't have. A user who flips between two accounts on - * the same device shares the same lead-time and enabled-state. Per-account preferences could be - * a follow-up if anyone asks. - */ -class CalendarReminderPrefs( - context: Context, -) { - private val prefs: SharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE) - - fun isEnabled(): Boolean = prefs.getBoolean(KEY_ENABLED, DEFAULT_ENABLED) - - fun setEnabled(enabled: Boolean) { - prefs.edit { putBoolean(KEY_ENABLED, enabled) } - } - - fun leadMinutes(): Int = prefs.getInt(KEY_LEAD_MINUTES, DEFAULT_LEAD_MINUTES) - - fun setLeadMinutes(minutes: Int) { - prefs.edit { putInt(KEY_LEAD_MINUTES, minutes) } - } - - companion object { - const val DEFAULT_LEAD_MINUTES = 15 - const val DEFAULT_ENABLED = true - - // Choices presented in the settings UI. Anchored to the worker cadence — lead times - // smaller than the cadence (15 min) can't be honoured reliably; 60 is the largest the - // UX shape supports without an extra "hours" picker. - val LEAD_TIME_CHOICES = listOf(5, 15, 30, 60) - - private const val PREF_NAME = "amethyst_calendar_reminder_prefs" - private const val KEY_ENABLED = "enabled" - private const val KEY_LEAD_MINUTES = "lead_minutes" - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStore.kt deleted file mode 100644 index 81c3ad882f..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStore.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.service.calendar - -import android.content.Context -import android.content.SharedPreferences -import androidx.core.content.edit - -/** - * Persistent "I've already notified for this event" set. Backed by [SharedPreferences] because - * the worker that consults it runs in the app process and the dataset is tiny (≤ a few hundred - * IDs at most). Without persistence, every worker run after a restart would re-notify for the - * same upcoming event until it started, since LocalCache has no memory of past reminders. - * - * Keys are event ids (the 32-byte hex from a 31922/31923 appointment). Values aren't used; only - * presence in the set matters. Entries are pruned by [forgetBefore] when the worker has just - * fired so the store doesn't grow unbounded over time. - */ -class CalendarReminderStore( - context: Context, -) { - private val prefs: SharedPreferences = - context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE) - - /** - * Returns true when we've previously notified for this exact event-start pairing. If the - * author updates the appointment to a new start time, the stored value won't match and - * we'll fire a fresh reminder for the new time — that's the desired behaviour: a moved - * meeting shouldn't be silently skipped. - */ - fun wasNotified( - eventId: String, - eventStartSeconds: Long, - ): Boolean = prefs.getLong(keyFor(eventId), Long.MIN_VALUE) == eventStartSeconds - - fun markNotified( - eventId: String, - eventStartSeconds: Long, - ) { - prefs.edit { putLong(keyFor(eventId), eventStartSeconds) } - } - - /** - * Drops any entry whose recorded event-start time is older than [cutoffSeconds]. Called - * after each worker run so the store stays bounded — events that have long since ended - * can't fire a second reminder, so their entries are dead weight. - */ - fun forgetBefore(cutoffSeconds: Long) { - val editor = prefs.edit() - var changed = false - prefs.all.forEach { (key, value) -> - if (value is Long && value < cutoffSeconds) { - editor.remove(key) - changed = true - } - } - if (changed) editor.apply() - } - - companion object { - private const val PREF_NAME = "amethyst_calendar_reminders" - private const val KEY_PREFIX = "notified:" - - private fun keyFor(eventId: String) = KEY_PREFIX + eventId - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt new file mode 100644 index 0000000000..e7105b31b8 --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.service.calendar + +import android.content.Context +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.intPreferencesKey +import androidx.datastore.preferences.preferencesDataStore +import com.vitorpamplona.amethyst.commons.model.preferences.CalendarReminderLogStore +import com.vitorpamplona.amethyst.commons.model.preferences.CalendarReminderSettings +import com.vitorpamplona.amethyst.commons.model.preferences.CalendarReminderSettingsStore +import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration + +/** + * Android wiring for the two calendar-reminder stores. + * + * The store classes live in commons; only the file location and the one-off + * lift out of the legacy SharedPreferences are Android's business. + */ +private const val LEGACY_SETTINGS_FILE = "amethyst_calendar_reminder_prefs" +private const val LEGACY_LOG_FILE = "amethyst_calendar_reminders" + +private val Context.calendarReminderSettingsData by preferencesDataStore( + name = "calendar_reminder_settings", + produceMigrations = { context -> + listOf( + CopyOnceMigration("migrated.calendarReminderSettings") { out -> + val legacy = context.getSharedPreferences(LEGACY_SETTINGS_FILE, Context.MODE_PRIVATE) + if (legacy.contains("enabled")) { + out[booleanPreferencesKey("enabled")] = legacy.getBoolean("enabled", CalendarReminderSettings.DEFAULT_ENABLED) + } + if (legacy.contains("lead_minutes")) { + out[intPreferencesKey("lead_minutes")] = legacy.getInt("lead_minutes", CalendarReminderSettings.DEFAULT_LEAD_MINUTES) + } + }, + ) + }, +) + +private val Context.calendarReminderLogData by preferencesDataStore( + name = "calendar_reminder_log", + produceMigrations = { context -> + listOf( + CopyOnceMigration("migrated.calendarReminderLog") { out -> + val legacy = context.getSharedPreferences(LEGACY_LOG_FILE, Context.MODE_PRIVATE) + // Values are the event-start times the reminders fired for; anything + // else in the file is not ours and is left behind. + legacy.all.forEach { (key, value) -> + if (value is Long) out[CalendarReminderLogStore.keyFor(key.removePrefix("notified:"))] = value + } + }, + ) + }, +) + +fun Context.calendarReminderSettings() = CalendarReminderSettingsStore(calendarReminderSettingsData) + +fun Context.calendarReminderLog() = CalendarReminderLogStore(calendarReminderLogData) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt index 0ec27f7e71..4916a4f8ed 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt @@ -65,8 +65,8 @@ class CalendarReminderWorker( ) : CoroutineWorker(appContext, params) { override suspend fun doWork(): Result { runCatching { Amethyst.instance.resourceUsage.add(UsageKeys.workerRuns("calendarReminder"), 1) } - val prefs = CalendarReminderPrefs(applicationContext) - if (!prefs.isEnabled()) { + val settings = applicationContext.calendarReminderSettings().load() + if (!settings.enabled) { Log.d(TAG) { "Reminders disabled; ending periodic chain." } // The settings toggle re-schedules on enable; no reason to keep // waking the process while the feature is off. @@ -74,8 +74,8 @@ class CalendarReminderWorker( return Result.success() } val now = TimeUtils.now() - val windowEnd = now + prefs.leadMinutes() * 60L - val store = CalendarReminderStore(applicationContext) + val windowEnd = now + settings.leadMinutes * 60L + val store = applicationContext.calendarReminderLog() // Walk every kind-31925 RSVP authored by an account on this device. We don't have a // multi-account "all logged-in pubkeys" view here, so we accept any RSVP that's @@ -83,7 +83,7 @@ class CalendarReminderWorker( // silently break notifications for account switching during the lead window. val acceptedRsvps = acceptedRsvpsInCache() - Log.d(TAG) { "Worker scanning ${acceptedRsvps.size} accepted RSVPs (now=$now, lead=${prefs.leadMinutes()}m)" } + Log.d(TAG) { "Worker scanning ${acceptedRsvps.size} accepted RSVPs (now=$now, lead=${settings.leadMinutes}m)" } acceptedRsvps.forEach { rsvp -> val targetAddress = rsvp.calendarEventAddress() ?: return@forEach diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt index ebae9478f0..14b8917612 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt @@ -34,14 +34,15 @@ import androidx.compose.material3.SingleChoiceSegmentedButtonRow import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.preferences.CalendarReminderSettings import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.calendar_reminder_settings_enabled_subtitle import com.vitorpamplona.amethyst.commons.resources.calendar_reminder_settings_enabled_title @@ -50,8 +51,8 @@ import com.vitorpamplona.amethyst.commons.resources.calendar_reminder_settings_l import com.vitorpamplona.amethyst.commons.resources.calendar_reminder_settings_lead_title import com.vitorpamplona.amethyst.commons.resources.calendar_reminder_settings_title import com.vitorpamplona.amethyst.commons.resources.settings_section_reminders -import com.vitorpamplona.amethyst.service.calendar.CalendarReminderPrefs import com.vitorpamplona.amethyst.service.calendar.CalendarReminderWorker +import com.vitorpamplona.amethyst.service.calendar.calendarReminderSettings import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.navigation.topbars.TopBarWithBackButton import com.vitorpamplona.amethyst.ui.pluralStringRes @@ -60,14 +61,22 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsDivider import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsSection import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsSwitchTile import com.vitorpamplona.amethyst.ui.stringRes +import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) @Composable fun CalendarReminderSettingsScreen(nav: INav) { val context = LocalContext.current - val prefs = remember { CalendarReminderPrefs(context) } - var enabled by remember { mutableStateOf(prefs.isEnabled()) } - var leadMinutes by remember { mutableIntStateOf(prefs.leadMinutes()) } + val scope = rememberCoroutineScope() + val store = remember(context) { context.calendarReminderSettings() } + + // DataStore reads are suspend, so the first frame renders the defaults and + // the stored values arrive right after. Collecting the flow rather than + // reading once also keeps the screen correct if the worker path or another + // screen changes a value while this one is open. + val settings by store.flow.collectAsStateWithLifecycle(CalendarReminderSettings()) + val enabled = settings.enabled + val leadMinutes = settings.leadMinutes Scaffold( topBar = { @@ -92,8 +101,7 @@ fun CalendarReminderSettingsScreen(nav: INav) { description = Res.string.calendar_reminder_settings_enabled_subtitle, checked = enabled, onCheckedChange = { - enabled = it - prefs.setEnabled(it) + scope.launch { store.setEnabled(it) } // Cancel eagerly on disable so the periodic worker stops waking the // process; re-enabling re-schedules immediately, and the ACCEPTED-RSVP // observer in AppModules re-schedules on the next relevant RSVP too. @@ -110,15 +118,14 @@ fun CalendarReminderSettingsScreen(nav: INav) { title = stringRes(Res.string.calendar_reminder_settings_lead_title), description = stringRes(Res.string.calendar_reminder_settings_lead_subtitle), ) { - val choices = CalendarReminderPrefs.LEAD_TIME_CHOICES + val choices = CalendarReminderSettings.LEAD_TIME_CHOICES SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) { choices.forEachIndexed { index, choice -> SegmentedButton( selected = choice == leadMinutes, enabled = enabled, onClick = { - leadMinutes = choice - prefs.setLeadMinutes(choice) + scope.launch { store.setLeadMinutes(choice) } }, shape = SegmentedButtonDefaults.itemShape(index = index, count = choices.size), icon = {}, diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarReminderPrefsTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarReminderPrefsTest.kt deleted file mode 100644 index 56006280bd..0000000000 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarReminderPrefsTest.kt +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.calendar - -import android.content.Context -import android.content.SharedPreferences -import com.vitorpamplona.amethyst.service.calendar.CalendarReminderPrefs -import com.vitorpamplona.amethyst.service.calendar.CalendarReminderStore -import io.mockk.every -import io.mockk.mockk -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Before -import org.junit.Test - -/** - * Unit tests for the device-level reminder preferences and the per-event "already notified" - * store. Backed by an in-memory fake [SharedPreferences] so the test runs on the JVM without - * needing Robolectric. - */ -class CalendarReminderPrefsTest { - private lateinit var fakePrefs: FakeSharedPreferences - private lateinit var ctx: Context - - @Before - fun setUp() { - fakePrefs = FakeSharedPreferences() - ctx = mockk() - every { ctx.getSharedPreferences(any(), any()) } returns fakePrefs - } - - @Test - fun prefs_defaultsMatchPublicConstants() { - val prefs = CalendarReminderPrefs(ctx) - // Defaults are the contract callers in AppModules rely on — flipping these without an - // explicit migration would silently re-enable reminders for users who had turned them - // off (or vice versa). - assertEquals(CalendarReminderPrefs.DEFAULT_ENABLED, prefs.isEnabled()) - assertEquals(CalendarReminderPrefs.DEFAULT_LEAD_MINUTES, prefs.leadMinutes()) - } - - @Test - fun prefs_setEnabled_roundTrips() { - val prefs = CalendarReminderPrefs(ctx) - prefs.setEnabled(false) - assertFalse(prefs.isEnabled()) - prefs.setEnabled(true) - assertTrue(prefs.isEnabled()) - } - - @Test - fun prefs_setLeadMinutes_roundTrips() { - val prefs = CalendarReminderPrefs(ctx) - prefs.setLeadMinutes(30) - assertEquals(30, prefs.leadMinutes()) - } - - @Test - fun store_wasNotified_isFalseByDefault() { - val store = CalendarReminderStore(ctx) - assertFalse(store.wasNotified("event-a", 1_000_000L)) - } - - @Test - fun store_markNotified_makesWasNotifiedTrueForSameStart() { - val store = CalendarReminderStore(ctx) - store.markNotified("event-a", 1_000_000L) - assertTrue(store.wasNotified("event-a", 1_000_000L)) - } - - @Test - fun store_wasNotified_isFalseWhenStartChanges() { - // Regression test for the "moved meeting" case: if the author updates the appointment - // with a new start, the store should not silently swallow the new reminder. - val store = CalendarReminderStore(ctx) - store.markNotified("event-a", 1_000_000L) - assertFalse(store.wasNotified("event-a", 2_000_000L)) - } - - @Test - fun store_forgetBefore_dropsOldEntries() { - val store = CalendarReminderStore(ctx) - store.markNotified("old", 1_000_000L) - store.markNotified("recent", 5_000_000L) - store.forgetBefore(3_000_000L) - assertFalse(store.wasNotified("old", 1_000_000L)) - assertTrue(store.wasNotified("recent", 5_000_000L)) - } -} - -/** - * Bare-bones in-memory implementation of [SharedPreferences] sufficient for the prefs/store - * round-trip tests. apply() is synchronous here — fine because the production code never relies - * on apply()'s async semantics. - */ -private class FakeSharedPreferences : SharedPreferences { - private val data = mutableMapOf() - - override fun getAll(): MutableMap = data - - override fun getString( - key: String, - defValue: String?, - ): String? = data[key] as? String ?: defValue - - override fun getStringSet( - key: String, - defValues: MutableSet?, - ): MutableSet? { - @Suppress("UNCHECKED_CAST") - return data[key] as? MutableSet ?: defValues - } - - override fun getInt( - key: String, - defValue: Int, - ): Int = (data[key] as? Int) ?: defValue - - override fun getLong( - key: String, - defValue: Long, - ): Long = (data[key] as? Long) ?: defValue - - override fun getFloat( - key: String, - defValue: Float, - ): Float = (data[key] as? Float) ?: defValue - - override fun getBoolean( - key: String, - defValue: Boolean, - ): Boolean = (data[key] as? Boolean) ?: defValue - - override fun contains(key: String): Boolean = data.containsKey(key) - - override fun edit(): SharedPreferences.Editor = FakeEditor(data) - - override fun registerOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener?) = Unit - - override fun unregisterOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener?) = Unit -} - -private class FakeEditor( - private val data: MutableMap, -) : SharedPreferences.Editor { - private val pending = mutableMapOf() - private val removed = mutableSetOf() - private var clearAll = false - - override fun putString( - key: String, - value: String?, - ): SharedPreferences.Editor { - pending[key] = value - return this - } - - override fun putStringSet( - key: String, - values: MutableSet?, - ): SharedPreferences.Editor { - pending[key] = values - return this - } - - override fun putInt( - key: String, - value: Int, - ): SharedPreferences.Editor { - pending[key] = value - return this - } - - override fun putLong( - key: String, - value: Long, - ): SharedPreferences.Editor { - pending[key] = value - return this - } - - override fun putFloat( - key: String, - value: Float, - ): SharedPreferences.Editor { - pending[key] = value - return this - } - - override fun putBoolean( - key: String, - value: Boolean, - ): SharedPreferences.Editor { - pending[key] = value - return this - } - - override fun remove(key: String): SharedPreferences.Editor { - removed.add(key) - return this - } - - override fun clear(): SharedPreferences.Editor { - clearAll = true - return this - } - - override fun commit(): Boolean { - apply() - return true - } - - override fun apply() { - if (clearAll) data.clear() - removed.forEach { data.remove(it) } - data.putAll(pending) - } -} diff --git a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt index 53e63f7e8e..db5078390e 100644 --- a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt +++ b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt @@ -24,6 +24,21 @@ import android.content.Context import android.content.SharedPreferences import androidx.core.content.edit +/** + * Still on SharedPreferences, deliberately, while the rest of the app moved to + * DataStore. + * + * ChessLobbyLogic reads this in a property initializer and writes it from two + * non-suspending functions. DataStore is suspend-only, so migrating would mean + * seeding the dismissed set asynchronously — and until that load lands, a game + * the user already dismissed reappears in the list. That is a visible + * regression in exchange for consistency alone: this store is already an + * expect/actual with a working iOS implementation, so unlike the rest of the + * preference layer it is not blocking any target. + * + * Worth revisiting if ChessLobbyLogic ever gains a suspending initialisation + * path of its own. + */ actual class ChessDismissedGamesStorage private actual constructor() { private var prefs: SharedPreferences? = null diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderLogStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderLogStore.kt new file mode 100644 index 0000000000..0cf1590083 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderLogStore.kt @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.longPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * The "already reminded about this" log for calendar appointments. + * + * Without it, every worker run after a restart would re-notify for the same + * upcoming event until it started, since LocalCache has no memory of past + * reminders. + * + * Each key stores the event-start time the reminder fired for, not a bare flag. + * That is what makes a moved meeting work: if the author changes the start, the + * stored value no longer matches and a fresh reminder fires, rather than the + * new time being silently skipped. + */ +class CalendarReminderLogStore( + private val store: DataStore, +) { + companion object { + private const val KEY_PREFIX = "notified:" + + fun keyFor(eventId: String) = longPreferencesKey(KEY_PREFIX + eventId) + + internal fun isLogKey(key: Preferences.Key<*>) = key.name.startsWith(KEY_PREFIX) + } + + private suspend fun read(): Preferences = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + suspend fun wasNotified( + eventId: String, + eventStartSeconds: Long, + ): Boolean = read()[keyFor(eventId)] == eventStartSeconds + + suspend fun markNotified( + eventId: String, + eventStartSeconds: Long, + ) { + store.edit { it[keyFor(eventId)] = eventStartSeconds } + } + + /** + * Drops entries whose recorded event-start is older than [cutoffSeconds], + * keeping the log bounded — an event that has long since ended cannot fire + * a second reminder, so its entry is dead weight. + * + * Only keys carrying the log's own prefix are considered, so a future + * setting sharing this store cannot be pruned away by a stale cutoff. + */ + suspend fun forgetBefore(cutoffSeconds: Long) { + store.edit { prefs -> + prefs + .asMap() + .filter { (key, value) -> isLogKey(key) && value is Long && value < cutoffSeconds } + .forEach { (key, _) -> prefs.remove(key) } + } + } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderSettingsStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderSettingsStore.kt new file mode 100644 index 0000000000..adcb7b17f6 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderSettingsStore.kt @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.intPreferencesKey +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.map +import okio.IOException + +/** + * Device-wide settings for the calendar reminder worker. + * + * Device scope rather than per-account, as before: the worker that consults + * them runs globally, and multiplexing per-account settings would need + * account-context plumbing into WorkManager that the rest of the app does not + * have. A user who flips between accounts on one device shares one lead time. + */ +data class CalendarReminderSettings( + val enabled: Boolean = DEFAULT_ENABLED, + val leadMinutes: Int = DEFAULT_LEAD_MINUTES, +) { + companion object { + const val DEFAULT_LEAD_MINUTES = 15 + const val DEFAULT_ENABLED = true + + /** + * Choices presented in the settings UI. Anchored to the worker cadence — + * lead times smaller than the cadence (15 min) cannot be honoured + * reliably; 60 is the largest the UX shape supports without an extra + * "hours" picker. + */ + val LEAD_TIME_CHOICES = listOf(5, 15, 30, 60) + } +} + +class CalendarReminderSettingsStore( + private val store: DataStore, +) { + companion object { + val enabled = booleanPreferencesKey("enabled") + val leadMinutes = intPreferencesKey("lead_minutes") + } + + private fun Flow.guarded() = catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + + /** Observes the settings, so a screen can react to a change made elsewhere. */ + val flow: Flow = + store.data.guarded().map { prefs -> + CalendarReminderSettings( + enabled = prefs[enabled] ?: CalendarReminderSettings.DEFAULT_ENABLED, + leadMinutes = prefs[leadMinutes] ?: CalendarReminderSettings.DEFAULT_LEAD_MINUTES, + ) + } + + suspend fun load(): CalendarReminderSettings = flow.first() + + suspend fun setEnabled(value: Boolean) { + store.edit { it[enabled] = value } + } + + suspend fun setLeadMinutes(value: Int) { + store.edit { it[leadMinutes] = value } + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderStoresTest.kt new file mode 100644 index 0000000000..06a9219e4d --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CalendarReminderStoresTest.kt @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.longPreferencesKey +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** Ports the coverage the Android CalendarReminderPrefsTest had, onto the DataStore stores. */ +class CalendarReminderStoresTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun raw(): DataStore { + val file = File(folder.root, "cal_${seq++}.preferences_pb") + return PreferenceDataStoreFactory.createWithPath( + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + produceFile = { file.toOkioPath() }, + ) + } + + // ── settings ────────────────────────────────────────────────────── + + /** Reminders are ON out of the box; a wrong default here silently stops everyone's reminders. */ + @Test + fun defaultsAreEnabledAtFifteenMinutes() = + runTest { + val loaded = CalendarReminderSettingsStore(raw()).load() + + assertEquals(true, loaded.enabled) + assertEquals(15, loaded.leadMinutes) + } + + @Test + fun settingsRoundTrip() = + runTest { + val store = CalendarReminderSettingsStore(raw()) + + store.setEnabled(false) + store.setLeadMinutes(60) + + assertEquals(CalendarReminderSettings(enabled = false, leadMinutes = 60), store.load()) + } + + /** The choices are anchored to the worker cadence — below 15 min cannot be honoured. */ + @Test + fun leadTimeChoicesAreUnchanged() { + assertEquals(listOf(5, 15, 30, 60), CalendarReminderSettings.LEAD_TIME_CHOICES) + assertTrue(CalendarReminderSettings.DEFAULT_LEAD_MINUTES in CalendarReminderSettings.LEAD_TIME_CHOICES) + } + + // ── log ─────────────────────────────────────────────────────────── + + @Test + fun anUnknownEventWasNotNotified() = + runTest { + assertFalse(CalendarReminderLogStore(raw()).wasNotified("abc", 1_000L)) + } + + @Test + fun markingMakesItNotified() = + runTest { + val store = CalendarReminderLogStore(raw()) + + store.markNotified("abc", 1_000L) + + assertTrue(store.wasNotified("abc", 1_000L)) + } + + /** + * The stored value is the event-start the reminder fired for, not a flag: + * a moved meeting must fire again rather than be silently skipped. + */ + @Test + fun aMovedEventIsNotifiedAgain() = + runTest { + val store = CalendarReminderLogStore(raw()) + store.markNotified("abc", 1_000L) + + assertFalse("the new start time has not been notified", store.wasNotified("abc", 2_000L)) + } + + @Test + fun forgetBeforeDropsOnlyOlderEntries() = + runTest { + val store = CalendarReminderLogStore(raw()) + store.markNotified("old", 100L) + store.markNotified("new", 900L) + + store.forgetBefore(500L) + + assertFalse(store.wasNotified("old", 100L)) + assertTrue(store.wasNotified("new", 900L)) + } + + /** forgetBefore must only prune its own keys, not anything else sharing the store. */ + @Test + fun forgetBeforeLeavesForeignKeysAlone() = + runTest { + val foreignKey = longPreferencesKey("someone_elses_counter") + val raw = raw() + val log = CalendarReminderLogStore(raw) + log.markNotified("old", 100L) + raw.updateData { prefs -> prefs.toMutablePreferences().apply { this[foreignKey] = 1L } } + + log.forgetBefore(500L) + + assertEquals(1L, raw.data.first()[foreignKey]) + } +} From e4ebb0c728117b0a7bbf8bb6b7440191b4a7c83a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 18:47:31 +0000 Subject: [PATCH 06/57] refactor: move chess dismissed games to DataStore, dropping the old data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverses the decision made one commit earlier to leave this on SharedPreferences. That call was made to avoid a visible regression — seeding asynchronously means a dismissed game can reappear for a frame or two — but chess has few enough users that the regression does not matter, which also removes the reason to carry the old data over. Replaces the whole expect/actual trio (commonMain expect, androidMain SharedPreferences, jvmMain java.util.prefs, iosMain in-memory) with one commonMain ChessDismissedGamesStore over DataStore. That is the payoff from making the preference layer multiplatform in the first commit of this series: the platform now supplies a file location rather than an implementation. iOS gains real persistence as a side effect. Its actual had been an in-memory map, commented as standing in until an iosApp module existed, so dismissals there were lost on every launch. No migration, deliberately. The old stores keep their data and nothing reads it; a user who had dismissed a game sees it once more and dismisses it again. Android writes to a new file (chess_dismissed_games_v2) rather than reusing the old name, so the two cannot be confused. ChessLobbyLogic now seeds the dismissed set in an init launch rather than a property initializer. The seed unions rather than replaces, so a dismissal the user makes before the read lands is not overwritten by it. The two writes are fire-and-forget on the logic's own scope. Desktop gets its store from commons rather than building one itself, so a front end does not need DataStore on its own classpath. The per-OS data directory that SecretEncryption had inlined is now a single commons/jvmMain definition both use, so the key file and the stores land in the same place. 5 tests: unknown user, round trip, per-user isolation, that an empty set removes the key rather than storing an empty one, and that a later save replaces rather than merges. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../loggedIn/chess/ChessDismissedGamesData.kt | 26 ++--- .../loggedIn/chess/ChessViewModelNew.kt | 4 +- .../nip64Chess/ChessDismissedGamesStorage.kt | 69 ----------- .../nip64Chess/ChessDismissedGamesStore.kt | 66 +++++++++++ .../commons/nip64Chess/ChessLobbyLogic.kt | 30 ++++- .../model/preferences/SecretEncryption.jvm.kt | 17 +-- .../ChessDismissedGamesStoreJvm.kt} | 36 +++--- .../AppDataDir.kt} | 46 ++++---- .../ChessDismissedGamesStoreTest.kt | 107 ++++++++++++++++++ .../desktop/chess/DesktopChessViewModelNew.kt | 4 +- 10 files changed, 250 insertions(+), 155 deletions(-) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt => amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt (65%) delete mode 100644 commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStore.kt rename commons/src/{iosMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.ios.kt => jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt} (58%) rename commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/{nip64Chess/ChessDismissedGamesStorage.kt => util/AppDataDir.kt} (53%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt similarity index 65% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt index 3c950e3509..dc63800518 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt @@ -18,21 +18,17 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.nip64Chess +package com.vitorpamplona.amethyst.ui.screen.loggedIn.chess + +import android.content.Context +import androidx.datastore.preferences.preferencesDataStore /** - * Persists dismissed chess game IDs locally per user. - * Uses expect/actual for platform-specific storage. + * Where Android keeps the dismissed-chess-games store. + * + * A new file rather than a migration of `chess_dismissed_games`: the dismissed + * list is a convenience, and chess has few enough users that carrying the old + * data over is not worth the code. Anyone who had dismissed a game sees it once + * more and dismisses it again. */ -expect class ChessDismissedGamesStorage private constructor() { - companion object { - fun create(context: Any? = null): ChessDismissedGamesStorage - } - - fun load(userPubkey: String): Set - - fun save( - userPubkey: String, - ids: Set, - ) -} +internal val Context.chessDismissedGamesData by preferencesDataStore(name = "chess_dismissed_games_v2") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt index 893c23fb17..ae46d80463 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt @@ -25,7 +25,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.commons.nip64Chess.ChessBroadcastStatus import com.vitorpamplona.amethyst.commons.nip64Chess.ChessChallenge -import com.vitorpamplona.amethyst.commons.nip64Chess.ChessDismissedGamesStorage +import com.vitorpamplona.amethyst.commons.nip64Chess.ChessDismissedGamesStore import com.vitorpamplona.amethyst.commons.nip64Chess.ChessLobbyLogic import com.vitorpamplona.amethyst.commons.nip64Chess.ChessPollingDefaults import com.vitorpamplona.amethyst.commons.nip64Chess.ChessSyncStatus @@ -61,7 +61,7 @@ class ChessViewModelNew( private val publisher = AndroidChessPublisher(account) private val fetcher = AndroidRelayFetcher(account) private val metadataProvider = AndroidMetadataProvider() - private val dismissedStorage = ChessDismissedGamesStorage.create(application) + private val dismissedStorage = ChessDismissedGamesStore(application.chessDismissedGamesData) // Shared business logic (creates its own ChessLobbyState internally) private val logic = diff --git a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt deleted file mode 100644 index db5078390e..0000000000 --- a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.commons.nip64Chess - -import android.content.Context -import android.content.SharedPreferences -import androidx.core.content.edit - -/** - * Still on SharedPreferences, deliberately, while the rest of the app moved to - * DataStore. - * - * ChessLobbyLogic reads this in a property initializer and writes it from two - * non-suspending functions. DataStore is suspend-only, so migrating would mean - * seeding the dismissed set asynchronously — and until that load lands, a game - * the user already dismissed reappears in the list. That is a visible - * regression in exchange for consistency alone: this store is already an - * expect/actual with a working iOS implementation, so unlike the rest of the - * preference layer it is not blocking any target. - * - * Worth revisiting if ChessLobbyLogic ever gains a suspending initialisation - * path of its own. - */ -actual class ChessDismissedGamesStorage private actual constructor() { - private var prefs: SharedPreferences? = null - - actual companion object { - private const val PREFS_NAME = "chess_dismissed_games" - - private fun prefsKey(userPubkey: String) = "dismissed_$userPubkey" - - actual fun create(context: Any?): ChessDismissedGamesStorage { - val storage = ChessDismissedGamesStorage() - val ctx = - context as? Context - ?: throw IllegalArgumentException("Android context required") - storage.prefs = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) - return storage - } - } - - // getStringSet returns a live reference to the internal set — must copy defensively - actual fun load(userPubkey: String): Set = prefs?.getStringSet(prefsKey(userPubkey), null)?.toHashSet() ?: emptySet() - - actual fun save( - userPubkey: String, - ids: Set, - ) { - prefs?.edit { putStringSet(prefsKey(userPubkey), ids) } - } -} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStore.kt new file mode 100644 index 0000000000..1adbf9ab06 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStore.kt @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.nip64Chess + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringSetPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * The chess games a user has dismissed from their completed list, per pubkey. + * + * Replaces the previous expect/actual trio. DataStore is multiplatform, so one + * implementation now serves every target — and iOS gains real persistence, + * where its actual had been an in-memory map standing in until an iosApp + * module existed. + * + * Nothing is carried over from the old per-platform stores: the dismissed list + * is a convenience, losing it costs a user one re-dismissal, and chess has few + * enough users that a migration is not worth the code that would carry it. + */ +class ChessDismissedGamesStore( + private val store: DataStore, +) { + companion object { + internal fun keyFor(userPubkey: String) = stringSetPreferencesKey("dismissed_$userPubkey") + } + + suspend fun load(userPubkey: String): Set = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first()[keyFor(userPubkey)] + ?: emptySet() + + /** An empty set removes the key rather than storing an empty one. */ + suspend fun save( + userPubkey: String, + ids: Set, + ) { + store.edit { prefs -> + if (ids.isEmpty()) prefs.remove(keyFor(userPubkey)) else prefs[keyFor(userPubkey)] = ids + } + } +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt index ee6e5604bd..d799e48997 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt @@ -128,13 +128,33 @@ class ChessLobbyLogic( private val metadataProvider: IUserMetadataProvider, private val scope: CoroutineScope, pollingConfig: ChessPollingConfig = ChessPollingDefaults.android, - private val dismissedStorage: ChessDismissedGamesStorage? = null, + private val dismissedStorage: ChessDismissedGamesStore? = null, ) { val state = ChessLobbyState(userPubkey, scope) private val dismissedGameIdsLock = KmpLock() - private val dismissedGameIds: MutableSet = - (dismissedStorage?.load(userPubkey)?.toMutableSet() ?: mutableSetOf()) + + /** + * Seeded asynchronously: the store is DataStore-backed and reads suspend, + * so this starts empty and fills shortly after construction. Until it does, + * a previously dismissed game can appear in the completed list for a frame + * or two. + * + * The seed unions rather than replaces, so a dismissal the user makes + * before the read lands is not overwritten by it. + */ + private val dismissedGameIds: MutableSet = mutableSetOf() + + init { + dismissedStorage?.let { storage -> + scope.launch { + val stored = storage.load(userPubkey) + if (stored.isNotEmpty()) { + dismissedGameIdsLock.withLock { dismissedGameIds.addAll(stored) } + } + } + } + } // Track when games were last loaded to prevent duplicate fetches // (e.g., discoverUserGames loads a game, then polling immediately re-fetches it). @@ -969,7 +989,7 @@ class ChessLobbyLogic( dismissedGameIds.add(gameId) dismissedGameIds.toSet() } - dismissedStorage?.save(userPubkey, snapshot) + dismissedStorage?.let { storage -> scope.launch { storage.save(userPubkey, snapshot) } } } fun dismissAllCompletedGames() { @@ -980,7 +1000,7 @@ class ChessLobbyLogic( dismissedGameIds.addAll(allIds) dismissedGameIds.toSet() } - dismissedStorage?.save(userPubkey, snapshot) + dismissedStorage?.let { storage -> scope.launch { storage.save(userPubkey, snapshot) } } } /** diff --git a/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt index a1c9246919..c11b1505da 100644 --- a/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt +++ b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryption.jvm.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.commons.model.preferences +import com.vitorpamplona.amethyst.commons.util.appDataDir import com.vitorpamplona.amethyst.commons.util.restrictToOwner import com.vitorpamplona.quartz.utils.Log import java.io.File @@ -56,21 +57,7 @@ actual class SecretEncryption internal constructor( private const val GCM_TAG_LENGTH_BITS = 128 private const val KEY_FILE_NAME = "secret.key" - /** Where this OS keeps per-user application data. */ - internal fun defaultKeyFile(): File { - val home = System.getProperty("user.home") ?: "." - val os = System.getProperty("os.name").orEmpty().lowercase() - val dir = - when { - os.contains("mac") || os.contains("darwin") -> - File(home, "Library/Application Support/Amethyst") - os.contains("win") -> - File(System.getenv("APPDATA") ?: "$home\\AppData\\Roaming", "Amethyst") - else -> - File(System.getenv("XDG_DATA_HOME")?.takeIf { it.isNotBlank() } ?: "$home/.local/share", "amethyst") - } - return File(dir, KEY_FILE_NAME) - } + internal fun defaultKeyFile(): File = File(appDataDir, KEY_FILE_NAME) } // A Cipher holds the state of the operation in progress, so two coroutines diff --git a/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.ios.kt b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt similarity index 58% rename from commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.ios.kt rename to commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt index 9148daed9e..5d0153c51d 100644 --- a/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.ios.kt +++ b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt @@ -20,25 +20,21 @@ */ package com.vitorpamplona.amethyst.commons.nip64Chess -// Phase 2 compile-only iOS actual. In-memory only; persistence via -// NSUserDefaults arrives with the iosApp module in Phase 3. -actual class ChessDismissedGamesStorage private actual constructor() { - private val dismissed = mutableMapOf>() +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import com.vitorpamplona.amethyst.commons.util.appDataDir +import okio.Path.Companion.toOkioPath +import java.io.File - actual companion object { - actual fun create(context: Any?): ChessDismissedGamesStorage = ChessDismissedGamesStorage() - } - - actual fun load(userPubkey: String): Set = dismissed[userPubkey] ?: emptySet() - - actual fun save( - userPubkey: String, - ids: Set, - ) { - if (ids.isEmpty()) { - dismissed.remove(userPubkey) - } else { - dismissed[userPubkey] = ids - } - } +/** + * The desktop dismissed-games store, in the shared app data directory. + * + * Built here rather than in desktopApp so a front end does not need DataStore + * on its own classpath to get one. Replaces a `java.util.prefs` node without + * carrying it over — the dismissed list is a convenience, and chess has few + * enough users that a migration is not worth the code. + */ +fun desktopChessDismissedGamesStore(): ChessDismissedGamesStore { + val file = File(appDataDir, "chess_dismissed_games.preferences_pb") + file.parentFile?.mkdirs() + return ChessDismissedGamesStore(PreferenceDataStoreFactory.createWithPath(produceFile = { file.toOkioPath() })) } diff --git a/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/util/AppDataDir.kt similarity index 53% rename from commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt rename to commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/util/AppDataDir.kt index 7ea69cdd61..c589ceb54c 100644 --- a/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStorage.kt +++ b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/util/AppDataDir.kt @@ -18,34 +18,26 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.nip64Chess +package com.vitorpamplona.amethyst.commons.util -import java.util.prefs.Preferences +import java.io.File -actual class ChessDismissedGamesStorage private actual constructor() { - private val prefs: Preferences = Preferences.userNodeForPackage(ChessDismissedGamesStorage::class.java) - - actual companion object { - private const val NODE_PREFIX = "chess_dismissed_" - private const val DELIMITER = "," - - actual fun create(context: Any?): ChessDismissedGamesStorage = ChessDismissedGamesStorage() - } - - actual fun load(userPubkey: String): Set { - val raw = prefs.get("$NODE_PREFIX$userPubkey", "") - if (raw.isEmpty()) return emptySet() - return raw.split(DELIMITER).toSet() - } - - actual fun save( - userPubkey: String, - ids: Set, - ) { - if (ids.isEmpty()) { - prefs.remove("$NODE_PREFIX$userPubkey") - } else { - prefs.put("$NODE_PREFIX$userPubkey", ids.joinToString(DELIMITER)) +/** + * Where this desktop OS keeps per-user application data. + * + * One definition, so the key file, the preference stores and anything else + * persistent land together rather than each picking their own convention. + */ +val appDataDir: File + get() { + val home = System.getProperty("user.home") ?: "." + val os = System.getProperty("os.name").orEmpty().lowercase() + return when { + os.contains("mac") || os.contains("darwin") -> + File(home, "Library/Application Support/Amethyst") + os.contains("win") -> + File(System.getenv("APPDATA") ?: "$home\\AppData\\Roaming", "Amethyst") + else -> + File(System.getenv("XDG_DATA_HOME")?.takeIf { it.isNotBlank() } ?: "$home/.local/share", "amethyst") } } -} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt new file mode 100644 index 0000000000..0d4efd334f --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.nip64Chess + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +class ChessDismissedGamesStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun raw(): DataStore { + val file = File(folder.root, "chess_${seq++}.preferences_pb") + return PreferenceDataStoreFactory.createWithPath( + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + produceFile = { file.toOkioPath() }, + ) + } + + @Test + fun anUnknownUserHasDismissedNothing() = + runTest { + assertTrue(ChessDismissedGamesStore(raw()).load("npub1").isEmpty()) + } + + @Test + fun savedIdsReadBack() = + runTest { + val store = ChessDismissedGamesStore(raw()) + + store.save("npub1", setOf("game1", "game2")) + + assertEquals(setOf("game1", "game2"), store.load("npub1")) + } + + /** Two accounts on one device must not see each other's dismissals. */ + @Test + fun usersAreIsolated() = + runTest { + val store = ChessDismissedGamesStore(raw()) + + store.save("npub1", setOf("game1")) + store.save("npub2", setOf("game2")) + + assertEquals(setOf("game1"), store.load("npub1")) + assertEquals(setOf("game2"), store.load("npub2")) + } + + /** An empty set removes the key rather than storing an empty one. */ + @Test + fun savingAnEmptySetClearsTheEntry() = + runTest { + val raw = raw() + val store = ChessDismissedGamesStore(raw) + store.save("npub1", setOf("game1")) + + store.save("npub1", emptySet()) + + assertTrue(store.load("npub1").isEmpty()) + assertFalse(raw.data.first().contains(ChessDismissedGamesStore.keyFor("npub1"))) + } + + @Test + fun aLaterSaveReplacesTheSet() = + runTest { + val store = ChessDismissedGamesStore(raw()) + + store.save("npub1", setOf("a", "b")) + store.save("npub1", setOf("c")) + + assertEquals(setOf("c"), store.load("npub1")) + } +} diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/chess/DesktopChessViewModelNew.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/chess/DesktopChessViewModelNew.kt index d120a24714..3a5123f8b7 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/chess/DesktopChessViewModelNew.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/chess/DesktopChessViewModelNew.kt @@ -23,12 +23,12 @@ package com.vitorpamplona.amethyst.desktop.chess import com.vitorpamplona.amethyst.commons.model.cache.UserMetadataCache import com.vitorpamplona.amethyst.commons.nip64Chess.ChessBroadcastStatus import com.vitorpamplona.amethyst.commons.nip64Chess.ChessChallenge -import com.vitorpamplona.amethyst.commons.nip64Chess.ChessDismissedGamesStorage import com.vitorpamplona.amethyst.commons.nip64Chess.ChessLobbyLogic import com.vitorpamplona.amethyst.commons.nip64Chess.ChessPollingDefaults import com.vitorpamplona.amethyst.commons.nip64Chess.ChessSyncStatus import com.vitorpamplona.amethyst.commons.nip64Chess.CompletedGame import com.vitorpamplona.amethyst.commons.nip64Chess.PublicGame +import com.vitorpamplona.amethyst.commons.nip64Chess.desktopChessDismissedGamesStore import com.vitorpamplona.amethyst.desktop.account.AccountState import com.vitorpamplona.amethyst.desktop.network.DesktopRelayConnectionManager import com.vitorpamplona.quartz.nip01Core.core.Event @@ -60,7 +60,7 @@ class DesktopChessViewModelNew( private val publisher = DesktopChessPublisher(account, relayManager) private val fetcher = DesktopRelayFetcher(relayManager, account.pubKeyHex) private val metadataProvider = DesktopMetadataProvider(userMetadataCache) - private val dismissedStorage = ChessDismissedGamesStorage.create() + private val dismissedStorage = desktopChessDismissedGamesStore() // Shared business logic (creates its own ChessLobbyState internally) private val logic = From 1397bc6f819f165cafe184093372f353d19b89ae Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 19:50:58 +0000 Subject: [PATCH 07/57] refactor: move NUT-13 counters to DataStore, hoisting the reservation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 6, built as option 2: the counter reservation moves up to the suspend layer so secret derivation stays pure, rather than making SecretFactory.nextSecrets suspend and dragging RandomSecretFactory — a function that does nothing but generate randomness — along with it. SecretFactory splits in two: suspend fun reserve(keysetId, count): SecretReservation fun derive(reservation, count): List reserve() is the durability boundary and the only part that touches storage. derive() is pure: same reservation, same secrets, no suspension. nextSecrets() remains as the convenience that does both. CashuMintOperations.secretOutputsFor now calls them separately, so the write that stands between a crash and a reused counter is visible at the layer that can await it, instead of hidden inside derivation. RandomSecretFactory reserves nothing. DeterministicSecretFactory reserves nothing either when it has no seed yet, since it will fall back to random and burning counters for secrets never derived from them is waste. If the seed disappears between reserving and deriving, that batch falls back to random and the reserved range goes unused — harmless, because counters only ever move forward and an unused one is never replayed. Storage: CashuKeysetCounterStore becomes suspend, and the Android implementation moves to DataStore as DataStoreCashuCounterStore in commons, so desktop gets one too rather than having none. Read and write sit inside a single `edit`, which is what the previous @Synchronized was for: two concurrent mints cannot observe the same starting index. DataStore's edit suspends until its write lands and swaps the file atomically — the same guarantee SharedPreferences.edit(commit = true) gave, paid at a suspension rather than a blocked thread. Both older layers still feed in and neither can move a counter backwards: the per-account SharedPreferences file is copied in full on first read, inside the same atomic write that records the copy happened, so a crash cannot leave the marker set with the counters missing; and the older AccountSettings.cashuKeysetCounters map is still applied per keyset through seedIfMissing. 21 tests where there were none. This path decides whether ecash is spendable and had no coverage at all while it was on SharedPreferences. The ones that matter most: 25 concurrent reservations carve strictly disjoint ranges, a reservation survives a reopen, seedIfMissing never moves a counter backwards, the legacy migration carries every counter and does not rewind reservations made after it ran, and a host with no store wired fails loudly instead of answering 0. Not verified here: no mint was contacted. The durability and concurrency properties are covered by tests, but an end-to-end mint/melt against a real mint is still worth doing before release. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/model/AccountSettings.kt | 9 +- .../model/nip60Cashu/CashuPreferences.kt | 136 ++++------ .../cli/stores/FileCashuKeysetCounterStore.kt | 4 +- .../commons/cashu/CashuKeysetCounterStore.kt | 13 +- .../cashu/DataStoreCashuCounterStore.kt | 101 +++++++ .../commons/cashu/ops/CashuWalletOps.kt | 4 +- .../cashu/DataStoreCashuCounterStoreTest.kt | 254 ++++++++++++++++++ .../nip60Cashu/mintApi/SecretFactory.kt | 101 +++++-- .../nip60Cashu/mintApi/SecretFactoryTest.kt | 150 +++++++++++ .../nip60Cashu/mintApi/CashuMintOperations.kt | 11 +- 10 files changed, 658 insertions(+), 125 deletions(-) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStore.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStoreTest.kt create mode 100644 quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactoryTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt index e2613fbe36..0ae9158a53 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt @@ -1221,7 +1221,8 @@ class AccountSettings( * Reserve [count] consecutive NUT-13 counters for [keysetId], * returning the first one. Caller derives `(secret, r)` from * `(seed, keysetId, i)` for `i in [returned .. returned+count-1]`. - * Persisted synchronously before returning — see [CashuKeysetCounterStore]. + * Persisted before returning — see [CashuKeysetCounterStore]. Suspends + * because that write is what stands between a crash and a reused counter. * * One-time migration: when this keyset has a non-zero value in the * legacy [cashuKeysetCounters] map (from a build that persisted @@ -1229,7 +1230,7 @@ class AccountSettings( * still at zero, the legacy value is copied over before we reserve * so an upgrade doesn't reset the counter. */ - fun reserveCashuCounters( + suspend fun reserveCashuCounters( keysetId: String, count: Int, ): Long { @@ -1238,12 +1239,12 @@ class AccountSettings( } /** Inspect the next counter for [keysetId] without consuming any. */ - fun peekCashuCounter(keysetId: String): Long { + suspend fun peekCashuCounter(keysetId: String): Long { migrateLegacyCashuCounter(keysetId) return cashuCounters.peek(keysetId) } - private fun migrateLegacyCashuCounter(keysetId: String) { + private suspend fun migrateLegacyCashuCounter(keysetId: String) { val legacy = cashuKeysetCounters[keysetId] ?: return cashuCounters.seedIfMissing(keysetId, legacy) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt index 02ce5266ac..08f3b96ada 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt @@ -20,110 +20,64 @@ */ package com.vitorpamplona.amethyst.model.nip60Cashu -import android.annotation.SuppressLint import android.content.Context -import android.content.SharedPreferences -import androidx.core.content.edit +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.longPreferencesKey import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.cashu.CashuKeysetCounterStore +import com.vitorpamplona.amethyst.commons.cashu.DataStoreCashuCounterStore +import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration +import com.vitorpamplona.quartz.utils.cache.LargeCache +import okio.Path.Companion.toOkioPath +import java.io.File /** - * Per-account Cashu state that needs durable, synchronous persistence — - * separate from [com.vitorpamplona.amethyst.model.AccountSettings] which - * batches writes through a 1-second debounced StateFlow. + * Android's per-account NUT-13 counter store: the shared + * [DataStoreCashuCounterStore] over a file in the app's data directory. * - * # Why a separate store + * Two older layers feed into it, and neither may move a counter backwards: * - * The NUT-13 keyset counter is the critical bit. Every mint / swap / - * melt reserves counter slots, derives deterministic blinded outputs at - * those slots, sends them to the mint, and the mint signs them. The - * mint persists which (keyset, blind_message) pairs it has ever signed; - * a second request to sign the same blind_message returns HTTP 400 - * "outputs already signed". So once the wallet hands a counter to the - * mint, the local counter advance MUST survive a crash — otherwise the - * next reservation pulls the same slot and the mint rejects it. + * - `cashu_prefs_` SharedPreferences, copied in full on first read by + * [CopyOnceMigration]. The copy happens inside the same atomic DataStore + * write that records it happened, so a crash cannot leave the marker set + * with the counters missing. It is a copy, not a move: the old file stays + * intact, so a rolled-back build still finds its counters. + * - `AccountSettings.cashuKeysetCounters`, an older in-settings map, still + * applied per keyset through `seedIfMissing` on every read. * - * The default settings save path debounces writes by 1000 ms, which is - * exactly the race window between "we asked the mint to sign" and "the - * mint replied". A crash inside that window (OOM, signer dialog dismiss, - * unexpected process death) loses the counter advance and makes the - * wallet unusable. This store writes via `commit = true` so each - * reservation is durable before the function returns. - * - * # Layout - * - * One SharedPreferences file per account, named - * `cashu_prefs_.xml`. Keys are flat: - * - `counter_` → Long, the next free NUT-13 counter - * - * Plain (non-encrypted) prefs because keyset counters aren't secret — - * they're not the seed, they don't carry value, and a leak would only - * tell an attacker how many proofs the wallet has minted at each - * keyset (a privacy signal at most). - * - * # Migration - * - * Older builds stored counters inside `AccountSettings.cashuKeysetCounters`. - * On first read of a given keyset, callers should pre-seed the store - * from the legacy map (one-time copy) so an upgrade doesn't reset the - * counter to zero. See `AccountSettings.migrateCashuCountersTo` for - * the helper. + * Losing a counter here means restarting a keyset at zero and reusing + * indices, which costs real ecash — so nothing on this path is best-effort. */ -class CashuPreferences( - private val prefs: SharedPreferences, -) : CashuKeysetCounterStore { - /** Inspect the next free counter for [keysetId] without advancing it. */ - @Synchronized - override fun peek(keysetId: String): Long = prefs.getLong(counterKey(keysetId), 0L) +object CashuPreferences { + private const val LEGACY_FILE_PREFIX = "cashu_prefs_" + + private val stores = LargeCache() /** - * Atomically reserve [count] consecutive NUT-13 counters for - * [keysetId] and return the first reserved index. The write is - * forced to disk with `commit = true` BEFORE returning — see the - * class header for why this isn't optional. + * Per-account instance, cached: DataStore refuses two live instances over + * one file, and a second instance would defeat the single-writer + * serialisation that `reserve` depends on. */ - @Synchronized - @SuppressLint("ApplySharedPref") - override fun reserve( - keysetId: String, - count: Int, - ): Long { - require(count > 0) { "Counter reservation must be positive" } - val current = peek(keysetId) - val next = current + count.toLong() - prefs.edit(commit = true) { putLong(counterKey(keysetId), next) } - return current - } - - /** - * Seed [keysetId]'s counter from a legacy value found in - * [AccountSettings.cashuKeysetCounters]. No-op when the store - * already has a value at or above [legacyValue] — never moves the - * counter backwards. Called once at wallet load to carry forward - * pre-migration state. - */ - @Synchronized - @SuppressLint("ApplySharedPref") - override fun seedIfMissing( - keysetId: String, - legacyValue: Long, - ) { - if (legacyValue <= 0L) return - val current = peek(keysetId) - if (current >= legacyValue) return - prefs.edit(commit = true) { putLong(counterKey(keysetId), legacyValue) } - } - - companion object { - private const val FILE_PREFIX = "cashu_prefs_" - - private fun counterKey(keysetId: String) = "counter_$keysetId" - - /** Per-account instance. [npub] keys the on-disk file so each account is isolated. */ - fun forAccount(npub: String): CashuPreferences { + fun forAccount(npub: String): CashuKeysetCounterStore = + stores.getOrCreate(npub) { val context = Amethyst.instance.appContext - val prefs = context.getSharedPreferences("$FILE_PREFIX$npub", Context.MODE_PRIVATE) - return CashuPreferences(prefs) + DataStoreCashuCounterStore( + PreferenceDataStoreFactory.createWithPath( + migrations = listOf(legacyMigration(context, npub)), + produceFile = { File(context.filesDir, "datastore/cashu_$npub.preferences_pb").toOkioPath() }, + ), + ) + } + + private fun legacyMigration( + context: Context, + npub: String, + ) = CopyOnceMigration("migrated.cashuCounters") { out -> + val legacy = context.getSharedPreferences("$LEGACY_FILE_PREFIX$npub", Context.MODE_PRIVATE) + legacy.all.forEach { (key, value) -> + if (key.startsWith(DataStoreCashuCounterStore.COUNTER_PREFIX) && value is Long) { + out[longPreferencesKey(key)] = value + } } } } diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/stores/FileCashuKeysetCounterStore.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/stores/FileCashuKeysetCounterStore.kt index c561cf2b10..02b3317824 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/stores/FileCashuKeysetCounterStore.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/stores/FileCashuKeysetCounterStore.kt @@ -54,9 +54,9 @@ class FileCashuKeysetCounterStore( Persisted() } - override fun peek(keysetId: String): Long = synchronized(lock) { load().keyset_counters[keysetId] ?: 0L } + override suspend fun peek(keysetId: String): Long = synchronized(lock) { load().keyset_counters[keysetId] ?: 0L } - override fun reserve( + override suspend fun reserve( keysetId: String, count: Int, ): Long = diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/CashuKeysetCounterStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/CashuKeysetCounterStore.kt index 3974287c4d..64349e0b3f 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/CashuKeysetCounterStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/CashuKeysetCounterStore.kt @@ -27,7 +27,8 @@ package com.vitorpamplona.amethyst.commons.cashu * monotonically increasing counter. Reusing a counter makes the mint reply * `outputs already signed`, so every reservation MUST be persisted **before** * the blinded outputs hit the mint. Implementations therefore make - * [reserve] atomic and durable. + * [reserve] atomic and durable. They suspend because durable storage on + * every target this runs on is a suspending API. * * - Android backs this with `AccountSettings` / `CashuPreferences`. * - `amy` backs this with `~/.amy//cashu.json`. @@ -37,13 +38,13 @@ package com.vitorpamplona.amethyst.commons.cashu */ interface CashuKeysetCounterStore { /** The next counter for [keysetId] without advancing it (0 if unseen). */ - fun peek(keysetId: String): Long + suspend fun peek(keysetId: String): Long /** * Atomically reserve [count] consecutive counters for [keysetId] and * return the first reserved index. Persists before returning. */ - fun reserve( + suspend fun reserve( keysetId: String, count: Int, ): Long @@ -55,7 +56,7 @@ interface CashuKeysetCounterStore { * kept whatever the backing store; a host whose store can write the value in * one atomic op should override it. */ - fun seedIfMissing( + suspend fun seedIfMissing( keysetId: String, legacyValue: Long, ) { @@ -76,9 +77,9 @@ interface CashuKeysetCounterStore { object UnavailableCashuKeysetCounterStore : CashuKeysetCounterStore { private fun fail(): Nothing = error("No durable NUT-13 counter store is wired for this account; refusing to reuse counters.") - override fun peek(keysetId: String): Long = fail() + override suspend fun peek(keysetId: String): Long = fail() - override fun reserve( + override suspend fun reserve( keysetId: String, count: Int, ): Long = fail() diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStore.kt new file mode 100644 index 0000000000..3795cd3a7a --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStore.kt @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.cashu + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.longPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * DataStore-backed NUT-13 counter store, shared by every front end that has one. + * + * # Why the counters are not secret + * + * They are indices, not key material: they derive nothing without the wallet + * seed, carry no value, and a leak would at most reveal how many proofs the + * wallet has minted at each keyset. + * + * # Why every write is awaited + * + * Reusing a counter makes the mint reply `outputs already signed` and strands + * the proofs, so [reserve] must reach disk before the secrets derived from it + * reach the mint. DataStore's `edit` suspends until its write completes and + * swaps the file atomically — the same guarantee + * `SharedPreferences.edit(commit = true)` gave, paid at a suspension rather + * than a blocked thread. + * + * Read and write live inside one `edit`, so two concurrent mints cannot + * observe the same starting index; that is what the previous implementation's + * `@Synchronized` was for. + */ +class DataStoreCashuCounterStore( + private val store: DataStore, +) : CashuKeysetCounterStore { + companion object { + const val COUNTER_PREFIX = "counter_" + + fun counterKey(keysetId: String) = longPreferencesKey(COUNTER_PREFIX + keysetId) + } + + private suspend fun read(): Preferences = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + override suspend fun peek(keysetId: String): Long = read()[counterKey(keysetId)] ?: 0L + + override suspend fun reserve( + keysetId: String, + count: Int, + ): Long { + require(count > 0) { "Counter reservation must be positive" } + var first = 0L + store.edit { prefs -> + val key = counterKey(keysetId) + first = prefs[key] ?: 0L + prefs[key] = first + count.toLong() + } + return first + } + + /** + * Carry a counter forward from an older store, never backwards. + * + * Writes the value directly in one atomic edit rather than advancing + * through [reserve], and compares inside that edit so a concurrent + * reservation cannot be undone by a stale read. + */ + override suspend fun seedIfMissing( + keysetId: String, + legacyValue: Long, + ) { + if (legacyValue <= 0L) return + store.edit { prefs -> + val key = counterKey(keysetId) + if ((prefs[key] ?: 0L) < legacyValue) prefs[key] = legacyValue + } + } +} diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt index 99def91987..d7e7dd65bc 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt @@ -119,14 +119,14 @@ class CashuWalletOps( * it. Used to rewind the restore window in [completeMintFromLightning] * recovery. Default is 0 (no persistent counter store). */ - private val peekCashuCounter: (keysetId: String) -> Long = { 0L }, + private val peekCashuCounter: suspend (keysetId: String) -> Long = { 0L }, /** * Atomically reserve [count] consecutive NUT-13 counters and * return the first reserved index. Used by the recovery path to * advance past slots the mint confirmed in use. Default is a * no-op for tests / random-only callers. */ - private val reserveCashuCounters: (keysetId: String, count: Int) -> Long = { _, _ -> 0L }, + private val reserveCashuCounters: suspend (keysetId: String, count: Int) -> Long = { _, _ -> 0L }, ) { private val opsCache = ConcurrentHashMap() diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStoreTest.kt new file mode 100644 index 0000000000..e1485b0698 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/cashu/DataStoreCashuCounterStoreTest.kt @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.cashu + +import androidx.datastore.core.DataMigration +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.longPreferencesKey +import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.cancelAndJoin +import kotlinx.coroutines.job +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * NUT-13 counters decide whether ecash is spendable. + * + * A counter handed out twice under the same (seed, keyset) derives the same + * blinded secret twice; the mint answers `outputs already signed` and the + * proofs are stranded. These tests exist because that path had no coverage at + * all while it was backed by SharedPreferences. + */ +class DataStoreCashuCounterStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + /** + * Closes a store's scope and waits for it. + * + * DataStore refuses two live instances over one file and only releases it + * once the owning job has actually finished, so a bare cancel() races the + * next open. + */ + private suspend fun CoroutineScope.release() { + coroutineContext.job.cancelAndJoin() + } + + private fun raw( + file: File = File(folder.root, "cashu_${seq++}.preferences_pb"), + scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + migrations: List> = emptyList(), + ): DataStore = + PreferenceDataStoreFactory.createWithPath( + scope = scope, + migrations = migrations, + produceFile = { file.toOkioPath() }, + ) + + @Test + fun anUnseenKeysetStartsAtZero() = + runTest { + assertEquals(0L, DataStoreCashuCounterStore(raw()).peek("keyset1")) + } + + @Test + fun peekDoesNotAdvance() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + + store.peek("keyset1") + store.peek("keyset1") + + assertEquals(0L, store.reserve("keyset1", 1)) + } + + @Test + fun reserveReturnsTheFirstIndexAndAdvancesByCount() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + + assertEquals(0L, store.reserve("keyset1", 3)) + assertEquals(3L, store.peek("keyset1")) + assertEquals(3L, store.reserve("keyset1", 2)) + assertEquals(5L, store.peek("keyset1")) + } + + @Test + fun keysetsAdvanceIndependently() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + + store.reserve("keyset1", 5) + + assertEquals(0L, store.reserve("keyset2", 1)) + } + + @Test + fun aNonPositiveReservationIsRejected() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + + // Not assertThrows: a nested runTest would wrap the failure. + val thrown = runCatching { store.reserve("keyset1", 0) }.exceptionOrNull() + + assertTrue("expected IllegalArgumentException, got $thrown", thrown is IllegalArgumentException) + } + + /** + * The property everything else rests on: no index is ever handed out twice. + * Concurrent reservations must carve up disjoint ranges. + */ + @Test + fun concurrentReservationsNeverOverlap() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + val batch = 4 + val workers = 25 + + val firsts = + (1..workers) + .map { async(Dispatchers.IO) { store.reserve("keyset1", batch) } } + .awaitAll() + + val handedOut = firsts.flatMap { first -> (0 until batch).map { first + it } } + assertEquals("every index handed out exactly once", handedOut.size, handedOut.toSet().size) + assertEquals("the counter accounts for all of them", (workers * batch).toLong(), store.peek("keyset1")) + } + + /** A reserved counter must survive the process that reserved it. */ + @Test + fun reservationsSurviveAReopen() = + runTest { + val file = File(folder.root, "persist.preferences_pb") + + val firstScope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + DataStoreCashuCounterStore(raw(file, firstScope)).reserve("keyset1", 7) + firstScope.release() + + val secondScope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + assertEquals(7L, DataStoreCashuCounterStore(raw(file, secondScope)).peek("keyset1")) + secondScope.release() + } + + // ── seeding from older stores ───────────────────────────────────── + + @Test + fun seedIfMissingCarriesALegacyValueForward() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + + store.seedIfMissing("keyset1", 42L) + + assertEquals(42L, store.peek("keyset1")) + } + + /** Never backwards: a legacy value below the current one must be ignored. */ + @Test + fun seedIfMissingNeverMovesACounterBackwards() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + store.reserve("keyset1", 100) + + store.seedIfMissing("keyset1", 5L) + + assertEquals(100L, store.peek("keyset1")) + } + + @Test + fun seedIfMissingIgnoresNonPositiveValues() = + runTest { + val store = DataStoreCashuCounterStore(raw()) + store.reserve("keyset1", 3) + + store.seedIfMissing("keyset1", 0L) + store.seedIfMissing("keyset1", -1L) + + assertEquals(3L, store.peek("keyset1")) + } + + /** + * The SharedPreferences -> DataStore migration. A counter lost here + * restarts a keyset at zero and reuses every index it already spent. + */ + @Test + fun theLegacyMigrationCarriesEveryCounter() = + runTest { + val legacy = + mapOf( + "counter_keysetA" to 17L, + "counter_keysetB" to 4L, + ) + val migration = + CopyOnceMigration("migrated.cashuCounters") { out -> + legacy.forEach { (key, value) -> out[longPreferencesKey(key)] = value } + } + + val store = DataStoreCashuCounterStore(raw(migrations = listOf(migration))) + + assertEquals(17L, store.peek("keysetA")) + assertEquals(4L, store.peek("keysetB")) + assertEquals("the next reservation continues, never replays", 17L, store.reserve("keysetA", 1)) + } + + /** The migration must not re-run and rewind counters spent since it ran. */ + @Test + fun theLegacyMigrationDoesNotRewindLaterReservations() = + runTest { + val file = File(folder.root, "once.preferences_pb") + val migration = { CopyOnceMigration("migrated.cashuCounters") { out -> out[longPreferencesKey("counter_keysetA")] = 10L } } + + val firstScope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + DataStoreCashuCounterStore(raw(file, firstScope, listOf(migration()))).reserve("keysetA", 5) + firstScope.release() + + val secondScope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val reopened = DataStoreCashuCounterStore(raw(file, secondScope, listOf(migration()))) + assertEquals(15L, reopened.peek("keysetA")) + assertTrue("a later reservation is past everything spent", reopened.reserve("keysetA", 1) >= 15L) + secondScope.release() + } + + /** A host that wired no store must fail loudly rather than answer 0. */ + @Test + fun theUnavailableStoreRefusesToAnswer() = + runTest { + val onPeek = runCatching { UnavailableCashuKeysetCounterStore.peek("keyset1") }.exceptionOrNull() + val onReserve = runCatching { UnavailableCashuKeysetCounterStore.reserve("keyset1", 1) }.exceptionOrNull() + + assertTrue("peek must refuse, got $onPeek", onPeek is IllegalStateException) + assertTrue("reserve must refuse, got $onReserve", onReserve is IllegalStateException) + } +} diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactory.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactory.kt index 51d662f82f..2da95e82fc 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactory.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactory.kt @@ -44,6 +44,18 @@ data class DerivedSecret( override fun hashCode(): Int = 31 * secretHex.hashCode() + blindingFactor.contentHashCode() } +/** + * Where a batch of deterministic secrets starts. + * + * [firstCounter] is null when the secrets will be random — either because the + * factory is [RandomSecretFactory], or because a [DeterministicSecretFactory] + * had no seed available when it reserved. + */ +data class SecretReservation( + val keysetId: String, + val firstCounter: Long?, +) + /** * Strategy for producing the (secret, r) pairs that go into BDHKE blind * messages. Two impls today: @@ -61,21 +73,48 @@ data class DerivedSecret( */ interface SecretFactory { /** - * Mint [count] (secret, r) pairs for use on the specified keyset. + * Reserve whatever durable state the next [count] secrets need, and return + * where they start. * - * Batched on purpose: the deterministic implementation reserves a - * contiguous counter range via a single atomic critical section on - * `AccountSettings.reserveCashuCounters`. Calling one-at-a-time - * inside `splitAmounts(amount).map { ... }` would take the lock N - * times per mint — wasteful for both contention and disk writes. + * Suspends because that is the durability boundary: a NUT-13 counter MUST + * reach disk before any secret derived from it reaches a mint, or a crash + * mid-mint replays the counter on the next launch and the mint answers + * `outputs already signed`. + * + * Separate from [derive] so that derivation stays pure and synchronous. + * Reserving is the only part that touches storage, and only a + * deterministic factory does so at all. */ - fun nextSecrets( + suspend fun reserve( keysetId: String, count: Int, + ): SecretReservation + + /** + * Derive [count] (secret, r) pairs from an already-reserved position. + * + * Pure: no storage, no suspension, same output for the same reservation. + */ + fun derive( + reservation: SecretReservation, + count: Int, ): List + /** + * Reserve and derive in one step. + * + * Batched on purpose: the deterministic implementation reserves a + * contiguous counter range in a single atomic write. Calling one-at-a-time + * inside `splitAmounts(amount).map { ... }` would take the lock N times per + * mint — wasteful for both contention and disk writes. + */ + suspend fun nextSecrets( + keysetId: String, + count: Int, + ): List = derive(reserve(keysetId, count), count) + /** Convenience for ops that need a single output. */ - fun nextSecret(keysetId: String): DerivedSecret = nextSecrets(keysetId, 1).first() + suspend fun nextSecret(keysetId: String): DerivedSecret = nextSecrets(keysetId, 1).first() } /** @@ -85,9 +124,15 @@ interface SecretFactory { * pre-dates the NUT-13 wiring). */ object RandomSecretFactory : SecretFactory { - override fun nextSecrets( + /** Nothing to reserve: random secrets keep no durable state. */ + override suspend fun reserve( keysetId: String, count: Int, + ): SecretReservation = SecretReservation(keysetId, null) + + override fun derive( + reservation: SecretReservation, + count: Int, ): List { require(count > 0) { "Must request at least one secret" } return List(count) { @@ -126,29 +171,51 @@ class DeterministicSecretFactory( private val seedProvider: () -> ByteArray?, /** * Atomically reserves [count] consecutive counters for a keyset and - * returns the FIRST one — the factory then derives at indices + * returns the FIRST one — derivation then runs at indices * `[returned .. returned+count)`. Persisting in one shot avoids the - * lock-N-times-per-mint waste of the old per-secret API. + * lock-N-times-per-mint waste of a per-secret API. * + * Suspends: it must reach disk before the secrets are used. * `AccountSettings.reserveCashuCounters(keysetId, count)` is the * canonical implementation. */ - private val reserveCounters: (keysetId: String, count: Int) -> Long, + private val reserveCounters: suspend (keysetId: String, count: Int) -> Long, private val fallback: SecretFactory = RandomSecretFactory, ) : SecretFactory { - override fun nextSecrets( + /** + * With no seed yet — the wallet has not decrypted its kind:17375 — this + * reserves nothing and reports a random batch, so counters are not burned + * for secrets that will not be derived from them. + */ + override suspend fun reserve( keysetId: String, count: Int, + ): SecretReservation { + require(count > 0) { "Must request at least one secret" } + seedProvider() ?: return SecretReservation(keysetId, null) + return SecretReservation(keysetId, reserveCounters(keysetId, count)) + } + + override fun derive( + reservation: SecretReservation, + count: Int, ): List { require(count > 0) { "Must request at least one secret" } - val seed = seedProvider() ?: return fallback.nextSecrets(keysetId, count) - val first = reserveCounters(keysetId, count) + val first = reservation.firstCounter ?: return fallback.derive(reservation, count) + + // Re-read rather than capturing the seed in the reservation, which + // would carry it through a public data class. If the seed vanished + // between reserving and deriving, this batch falls back to random and + // the reserved counters go unused — harmless, because counters only + // ever move forward and an unused one is never replayed. + val seed = seedProvider() ?: return fallback.derive(SecretReservation(reservation.keysetId, null), count) + return List(count) { offset -> val counter = first + offset // CashuDeterministic.secretBytes returns the raw 32 bytes; // the hex form is what BDHKE/proof storage actually use. - val secretHex = CashuDeterministic.secretBytes(seed, keysetId, counter).toHexKey() - val r = CashuDeterministic.blindingFactor(seed, keysetId, counter) + val secretHex = CashuDeterministic.secretBytes(seed, reservation.keysetId, counter).toHexKey() + val r = CashuDeterministic.blindingFactor(seed, reservation.keysetId, counter) DerivedSecret(secretHex, r) } } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactoryTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactoryTest.kt new file mode 100644 index 0000000000..1d6d88c318 --- /dev/null +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/SecretFactoryTest.kt @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.quartz.nip60Cashu.mintApi + +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNotEquals +import kotlin.test.assertNull +import kotlin.test.assertTrue + +/** + * The reserve/derive split. + * + * Reserving is the durability boundary — it suspends and must persist a NUT-13 + * counter before any secret derived from it reaches a mint. Deriving is pure. + * Keeping them apart is what lets [RandomSecretFactory] stay free of storage + * and lets the mint layer see where the write happens. + */ +class SecretFactoryTest { + private val seed = ByteArray(64) { it.toByte() } + + // Keyset ids are hex by NUT-02, and NUT-13 derivation decodes them, so a + // placeholder like "keyset1" is rejected before any secret is produced. + private val keysetA = "009a1f293253e41e" + private val keysetB = "00ad268c4d1f5826" + + @Test + fun randomFactoryReservesNothing() = + runTest { + val reservation = RandomSecretFactory.reserve(keysetA, 3) + + assertNull(reservation.firstCounter, "random secrets keep no durable state") + assertEquals(keysetA, reservation.keysetId) + } + + @Test + fun randomFactoryDerivesDistinctSecrets() = + runTest { + val secrets = RandomSecretFactory.nextSecrets(keysetA, 4) + + assertEquals(4, secrets.size) + assertEquals(4, secrets.map { it.secretHex }.toSet().size, "random secrets must not repeat") + } + + @Test + fun deterministicFactoryReservesTheWholeBatchOnce() = + runTest { + val calls = mutableListOf>() + val factory = + DeterministicSecretFactory( + seedProvider = { seed }, + reserveCounters = { keysetId, count -> + calls.add(keysetId to count) + 10L + }, + ) + + val reservation = factory.reserve(keysetA, 5) + + assertEquals(listOf(keysetA to 5), calls, "one reservation for the batch, not one per secret") + assertEquals(10L, reservation.firstCounter) + } + + /** + * With no seed the factory falls back to random, so reserving would burn + * counters for secrets that are never derived from them. + */ + @Test + fun noSeedMeansNoCountersBurned() = + runTest { + var reserved = false + val factory = + DeterministicSecretFactory( + seedProvider = { null }, + reserveCounters = { _, _ -> + reserved = true + 0L + }, + ) + + val reservation = factory.reserve(keysetA, 3) + + assertTrue(!reserved, "the counter store must not be touched") + assertNull(reservation.firstCounter) + } + + /** Derivation is pure: the same reservation yields the same secrets. */ + @Test + fun deriveIsDeterministicForAReservation() = + runTest { + val factory = DeterministicSecretFactory(seedProvider = { seed }, reserveCounters = { _, _ -> 7L }) + val reservation = SecretReservation(keysetA, 7L) + + assertEquals(factory.derive(reservation, 3), factory.derive(reservation, 3)) + } + + /** Consecutive counters must give different secrets, or a reused index would be harmless — it is not. */ + @Test + fun eachCounterInABatchDerivesADifferentSecret() = + runTest { + val factory = DeterministicSecretFactory(seedProvider = { seed }, reserveCounters = { _, _ -> 0L }) + + val secrets = factory.derive(SecretReservation(keysetA, 0L), 4) + + assertEquals(4, secrets.map { it.secretHex }.toSet().size) + } + + /** NUT-13 derivation is keyset-aware: the same counter on another keyset is a different secret. */ + @Test + fun theSameCounterOnAnotherKeysetDerivesADifferentSecret() = + runTest { + val factory = DeterministicSecretFactory(seedProvider = { seed }, reserveCounters = { _, _ -> 0L }) + + val onA = factory.derive(SecretReservation(keysetA, 0L), 1).first() + val onB = factory.derive(SecretReservation(keysetB, 0L), 1).first() + + assertNotEquals(onA.secretHex, onB.secretHex) + } + + /** A reservation carrying no counter derives random secrets, whatever the factory. */ + @Test + fun aCounterlessReservationFallsBackToRandom() = + runTest { + val factory = DeterministicSecretFactory(seedProvider = { seed }, reserveCounters = { _, _ -> 0L }) + + val first = factory.derive(SecretReservation(keysetA, null), 2) + val second = factory.derive(SecretReservation(keysetA, null), 2) + + assertNotEquals(first.map { it.secretHex }, second.map { it.secretHex }, "random, so not reproducible") + } +} diff --git a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt index bedae4d049..024413a720 100644 --- a/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt +++ b/quartz/src/jvmAndroid/kotlin/com/vitorpamplona/quartz/nip60Cashu/mintApi/CashuMintOperations.kt @@ -723,7 +723,7 @@ class CashuMintOperations( */ private suspend fun fetchInputFeePpkByKeyset(): Map = client.keysets().keysets.associate { it.id to (it.inputFeePpk ?: 0L) } - private fun createBlindedOutputs( + private suspend fun createBlindedOutputs( amount: Long, keyset: KeysetDto, ): List = secretOutputsFor(splitAmounts(amount), keyset) @@ -735,7 +735,7 @@ class CashuMintOperations( * [SecretFactory.nextSecret] per amount instead would take the * @Synchronized lock + dirty `AccountSettings.saveable` N times. */ - private fun secretOutputsFor( + private suspend fun secretOutputsFor( amounts: List, keyset: KeysetDto, ): List { @@ -744,7 +744,12 @@ class CashuMintOperations( // [secretFactory] decides whether those bytes are pure-random or // NUT-13-derived from a wallet seed; either way the on-wire shape // is identical so the mint can't tell which scheme we're using. - val derived = secretFactory.nextSecrets(keyset.id, amounts.size) + // Two steps on purpose. reserve() suspends and persists the NUT-13 + // counter; derive() is pure. Keeping them apart means the durability + // boundary is visible here, at the only layer that can await it, rather + // than hidden inside secret derivation. + val reservation = secretFactory.reserve(keyset.id, amounts.size) + val derived = secretFactory.derive(reservation, amounts.size) return amounts.mapIndexed { i, amount -> val pair = derived[i] val bTick = Bdhke.blind(pair.secretHex.encodeToByteArray(), pair.blindingFactor) From d2d1d813d1c5ab1e97ceb1b623565b5dafc5c09a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 20:14:04 +0000 Subject: [PATCH 08/57] refactor: drop androidx.security from commons' key storage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 5a. SecureKeyStorage's Android actual was EncryptedSharedPreferences from androidx.security.crypto — the same deprecated library, and the same MasterKey.DEFAULT_MASTER_KEY_ALIAS, that EncryptedStorage uses. It now runs on EncryptedDataStore sealed with SecretEncryption, which talks to the AndroidKeyStore directly, so the key still never enters app memory and the library leaves this module. Verified: androidx.security no longer appears on commons' androidCompileClasspath. Worth recording, because it corrects the plan this series was working to: migrating the Android app's private keys *into* SecureKeyStorage would have gained nothing. Both sides were the same deprecated implementation under different filenames. The OS-keychain backing its KDoc describes is the JVM actual, which desktop uses; Android never had it. No migration, and none needed: SecureKeyStorage has 42 references in desktopApp and none in amethyst, so `amethyst_secure_keys` has never been written on an Android install. Were that to change, a migration would have to land first — the class says so. Also fixes a hazard this move would otherwise have introduced. EncryptedDataStore.get() flattens a read failure into null, which is fine for settings but wrong for getPrivateKeyOrThrow — the probe whose whole purpose is telling "no key" apart from "backend failed", used before creating a replacement key. Reading a merely unreadable store as absent there overwrites a live key. getOrThrow() now propagates instead, and a test truncates a store to prove the two reads diverge on it. Not verified here: the Android actual itself. It needs an instrumented test for the real AndroidKeyStore, and this environment has no device or emulator (commons has no Robolectric either). The contract underneath it — EncryptedDataStore over SecretEncryption — is covered by 14 jvmTest cases against the JVM actual. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- commons/build.gradle.kts | 4 +- .../commons/keystorage/SecureKeyStorage.kt | 146 ++++++++---------- .../model/preferences/EncryptedDataStore.kt | 18 +++ .../preferences/EncryptedDataStoreTest.kt | 45 ++++++ 4 files changed, 129 insertions(+), 84 deletions(-) diff --git a/commons/build.gradle.kts b/commons/build.gradle.kts index 4d6a78e368..86c5c10c33 100644 --- a/commons/build.gradle.kts +++ b/commons/build.gradle.kts @@ -167,8 +167,8 @@ kotlin { // Compose UI artifacts before the :commonsUI split. implementation(libs.androidx.core.ktx) - // Secure key storage via Android Keystore - implementation(libs.androidx.security.crypto.ktx) + // Secure key storage talks to the AndroidKeyStore directly through + // SecretEncryption; androidx.security.crypto is gone from this module. } } diff --git a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt index dbb4efb401..f3b08ae257 100644 --- a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt +++ b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt @@ -21,42 +21,48 @@ package com.vitorpamplona.amethyst.commons.keystorage import android.content.Context -import androidx.core.content.edit -import androidx.security.crypto.EncryptedSharedPreferences -import androidx.security.crypto.MasterKey +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.stringPreferencesKey +import com.vitorpamplona.amethyst.commons.model.preferences.EncryptedDataStore +import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext +import kotlinx.coroutines.SupervisorJob +import okio.Path.Companion.toOkioPath +import java.io.File /** - * Android implementation of SecureKeyStorage using EncryptedSharedPreferences - * backed by Android Keystore (AES-256-GCM, hardware-backed when available). + * Android implementation of [SecureKeyStorage]: an encrypted DataStore whose + * values are sealed with a key held in the AndroidKeyStore. * - * ## Security Features + * ## Why not EncryptedSharedPreferences * - * - **Hardware Security:** Uses Android Keystore (hardware-backed on supported devices with StrongBox) - * - **Encryption:** AES-256-GCM for both keys and values - * - **Key Derivation:** AES-256-SIV for preference keys, AES-256-GCM for values - * - **Application Context:** Uses applicationContext to prevent memory leaks - * - **Auto-backup Disabled:** EncryptedSharedPreferences automatically excluded from cloud backups + * This used to be `androidx.security.crypto`, which Google deprecated with no + * drop-in successor. [SecretEncryption] talks to the AndroidKeyStore directly — + * AES-256-GCM, StrongBox-backed where the device offers it — so the key still + * never enters app memory, and the library goes away. * - * **Note:** While the encryption keys are protected by hardware security modules (when available), - * the decrypted private keys returned by [getPrivateKey] are still subject to the String memory - * limitation described in [SecureKeyStorage]. + * Nothing is migrated from the old `amethyst_secure_keys` file because nothing + * ever wrote to it: this class is used by the desktop app, and the Android app + * has its own key storage in LocalPreferences. Were that to change, a migration + * would have to come first. + * + * ## Security note + * + * Only values are encrypted; the key names are not. That reveals which npubs + * this installation holds keys for, but not the keys themselves — the same + * trade-off the rest of the encrypted stores make. + * + * The String memory limitation described on [SecureKeyStorage] still applies: + * a decrypted private key cannot be zeroed from a JVM String. */ actual class SecureKeyStorage private actual constructor() { actual companion object { - private const val PREFS_NAME = "amethyst_secure_keys" + private const val STORE_FILE = "datastore/secure_keys.preferences_pb" private const val KEY_PREFIX = "privkey_" private lateinit var appContext: Context - /** - * Creates a SecureKeyStorage instance for Android. - * - * @param context Android Context (will use applicationContext to avoid leaks) - * @return SecureKeyStorage instance - * @throws IllegalArgumentException if context is null or not a valid Context - */ actual fun create(context: Any?): SecureKeyStorage { require(context is Context) { "Android requires a valid Context" } appContext = context.applicationContext @@ -64,85 +70,61 @@ actual class SecureKeyStorage private actual constructor() { } } - // androidx.security.crypto is deprecated with no drop-in successor; migrating the - // on-disk key store is a separate, security-sensitive effort. - @Suppress("DEPRECATION") - private val masterKey: MasterKey by lazy { - MasterKey - .Builder(appContext, MasterKey.DEFAULT_MASTER_KEY_ALIAS) - .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) - .build() - } + private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) - @Suppress("DEPRECATION") - private val encryptedPrefs by lazy { - EncryptedSharedPreferences.create( - appContext, - PREFS_NAME, - masterKey, - EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, + private val store by lazy { + EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath( + scope = scope, + produceFile = { File(appContext.filesDir, STORE_FILE).toOkioPath() }, + ), + SecretEncryption(), + scope = scope, ) } + private fun keyFor(npub: String) = stringPreferencesKey(KEY_PREFIX + npub) + actual suspend fun savePrivateKey( npub: String, privKeyHex: String, ) { - withContext(Dispatchers.IO) { - try { - encryptedPrefs.edit { putString(KEY_PREFIX + npub, privKeyHex) } - } catch (e: Exception) { - throw SecureStorageException("Failed to save private key", e) - } + try { + store.save(keyFor(npub), privKeyHex) + } catch (e: Exception) { + throw SecureStorageException("Failed to save private key", e) } } actual suspend fun getPrivateKey(npub: String): String? = - withContext(Dispatchers.IO) { - try { - encryptedPrefs.getString(KEY_PREFIX + npub, null) - } catch (e: Exception) { - throw SecureStorageException("Failed to retrieve private key", e) - } + try { + store.get(keyFor(npub)) + } catch (e: Exception) { + throw SecureStorageException("Failed to retrieve private key", e) } /** - * Android backend: EncryptedSharedPreferences.contains + getString has no - * ambiguous-error state comparable to macOS Keychain user-cancel/deny, so - * "key not present" and "key present" are the only two null outcomes. - * Any thrown exception is a genuine failure and propagates. + * Unlike [getPrivateKey], this reads through [EncryptedDataStore.getOrThrow] + * so a store that cannot be read raises instead of reporting the key as + * absent. That distinction is the whole point of this method: callers use + * it to decide whether a key needs creating, and treating a transient read + * failure as "no key here" would overwrite a live one. */ actual suspend fun getPrivateKeyOrThrow(npub: String): String? = - withContext(Dispatchers.IO) { - try { - val key = KEY_PREFIX + npub - if (!encryptedPrefs.contains(key)) { - null - } else { - encryptedPrefs.getString(key, null) - } - } catch (e: Exception) { - throw SecureStorageException("Failed to retrieve private key", e) - } + try { + store.getOrThrow(keyFor(npub)) + } catch (e: Exception) { + throw SecureStorageException("Failed to retrieve private key", e) } actual suspend fun deletePrivateKey(npub: String): Boolean = - withContext(Dispatchers.IO) { - try { - val key = KEY_PREFIX + npub - val existed = encryptedPrefs.contains(key) - if (existed) { - encryptedPrefs.edit { remove(key) } - } - existed - } catch (e: Exception) { - throw SecureStorageException("Failed to delete private key", e) - } + try { + val existed = store.get(keyFor(npub)) != null + if (existed) store.remove(keyFor(npub)) + existed + } catch (e: Exception) { + throw SecureStorageException("Failed to delete private key", e) } - actual suspend fun hasPrivateKey(npub: String): Boolean = - withContext(Dispatchers.IO) { - encryptedPrefs.contains(KEY_PREFIX + npub) - } + actual suspend fun hasPrivateKey(npub: String): Boolean = getPrivateKey(npub) != null } diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt index 710102f222..01b26082bb 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt @@ -26,6 +26,7 @@ import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.emptyPreferences import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map import okio.IOException @@ -58,6 +59,13 @@ class EncryptedDataStore( store.edit { prefs -> prefs[key] = encrypt(value) } } + /** + * The value, or null when the key is absent **or unreadable**. + * + * A read error is reported as absence, which is what most callers want. + * Anything that must not mistake a failure for an empty store — a probe + * deciding whether to create a replacement key, say — needs [getOrThrow]. + */ suspend fun get(key: Preferences.Key): String? = store.data .catch { e -> @@ -66,6 +74,16 @@ class EncryptedDataStore( ?.get(key) ?.let { decrypt(it) } + /** + * The value, or null only when the key is genuinely absent. + * + * Unlike [get], a failure to read propagates rather than being flattened + * into null. The difference matters wherever null means "nothing was ever + * stored" and the caller acts on that — overwriting a key that is present + * but temporarily unreadable is not recoverable. + */ + suspend fun getOrThrow(key: Preferences.Key): String? = store.data.first()[key]?.let { decrypt(it) } + fun getProperty( key: Preferences.Key, parser: (String) -> T, diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt index 68eddfbf94..05f9e231e1 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt @@ -25,10 +25,12 @@ import androidx.datastore.preferences.core.stringPreferencesKey import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel import kotlinx.coroutines.test.runTest import okio.Path.Companion.toOkioPath import org.junit.Assert.assertEquals import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder @@ -131,4 +133,47 @@ class EncryptedDataStoreTest { assertNull(subject.get(key)) } + + /** + * [EncryptedDataStore.get] flattens a read failure into null; + * [EncryptedDataStore.getOrThrow] does not. + * + * The difference guards a live key: a probe that decides whether to create + * one must not read "absent" from a store it merely failed to open, or it + * overwrites what is already there. + */ + @Test + fun getSwallowsAReadFailureButGetOrThrowDoesNot() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val n = seq++ + val dataFile = File(folder.root, "corrupt_$n.preferences_pb") + val keyFile = File(folder.root, "corrupt_$n.key") + val subject = + EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath(scope = scope, produceFile = { dataFile.toOkioPath() }), + SecretEncryption(keyFile), + scope = scope, + ) + subject.save(key, "a real value") + scope.cancel() + + // Truncate the store so opening it fails rather than reading empty. + dataFile.writeBytes(byteArrayOf(0x01, 0x02, 0x03)) + + val readScope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val reopened = + EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath(scope = readScope, produceFile = { dataFile.toOkioPath() }), + SecretEncryption(keyFile), + scope = readScope, + ) + + assertNull("get() reports the unreadable store as absent", reopened.get(key)) + assertTrue( + "getOrThrow() must not call it absent", + runCatching { reopened.getOrThrow(key) }.isFailure, + ) + readScope.cancel() + } } From 9514548cfeefb9f558dc2b281e01f2fbdd0f59a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 20:33:28 +0000 Subject: [PATCH 09/57] feat: dual-store account private keys, migrating off androidx.security MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 5b. Account private keys now live in SecureKeyStorage — an encrypted DataStore sealed by the AndroidKeyStore since 5a — while the legacy `secret_keeper_` EncryptedSharedPreferences file keeps its copy. Both stores are written on every save and reads prefer the new one with the old as fallback, so: - an install that has never run this build finds its key and is migrated the first time the account loads; - a build rolled back to reading only the legacy store finds every key, including ones added after the upgrade; - a new store that cannot be read — a wiped AndroidKeyStore after a device credential reset — falls back instead of presenting the account as having no key, which would silently demote a signing account to read-only. Nothing is deleted. Dropping the legacy file is a later release's job, once this has shipped and held; doing both at once leaves no way back. That means androidx.security.crypto stays declared in :amethyst for now — 5b alone cannot remove it. Three details that decide whether this is safe: - The mirror matches the legacy write exactly, including the case that is easy to miss: with no external signer and no private key in hand, the legacy store leaves the stored key alone rather than clearing it. Deleting there would drop the key on every save from a session that never decrypted it. - Reads go through getPrivateKeyOrThrow, so an unreadable store raises instead of reporting absence, and a failed read never triggers a migration into the store that just failed. - An npub is derived from its private key, so the two stores cannot legitimately disagree. A mismatch means corruption and resolves in favour of the older, proven store. The logic is behind a PrivateKeyVault interface rather than calling SecureKeyStorage directly, because no unit test can reach an AndroidKeyStore. 13 tests cover each branch: legacy-only migrates, already-migrated is not rewritten, an unreadable store falls back and is not written to, a mismatch prefers legacy, a failed migration still returns the key, and a save with no key in hand leaves the stored one alone. Not verified here: the AndroidKeyStore path itself, which needs a device. The decision logic is tested against a fake vault; the store underneath it is not. A real sign-in, restart and account-switch on a device should confirm the migration before the legacy file is dropped. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../vitorpamplona/amethyst/AccountKeyStore.kt | 181 +++++++++++++++ .../amethyst/LocalPreferences.kt | 18 +- .../amethyst/AccountKeyStoreTest.kt | 216 ++++++++++++++++++ 3 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt create mode 100644 amethyst/src/test/java/com/vitorpamplona/amethyst/AccountKeyStoreTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt new file mode 100644 index 0000000000..67dabc7e34 --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import com.vitorpamplona.amethyst.commons.keystorage.SecureKeyStorage +import com.vitorpamplona.quartz.utils.Log + +/** + * The narrow slice of a key store this needs. + * + * An interface rather than [SecureKeyStorage] directly so the decision logic + * below — which store wins, what happens when one fails — is testable without + * an AndroidKeyStore, which no unit test can reach. + */ +interface PrivateKeyVault { + /** The stored key, or null only when genuinely absent. Throws when the store cannot be read. */ + suspend fun get(npub: String): String? + + suspend fun save( + npub: String, + privKeyHex: String, + ) + + suspend fun delete(npub: String) +} + +/** [PrivateKeyVault] over the real [SecureKeyStorage]. */ +class SecureKeyStorageVault( + private val storage: SecureKeyStorage, +) : PrivateKeyVault { + override suspend fun get(npub: String): String? = storage.getPrivateKeyOrThrow(npub) + + override suspend fun save( + npub: String, + privKeyHex: String, + ) = storage.savePrivateKey(npub, privKeyHex) + + override suspend fun delete(npub: String) { + storage.deletePrivateKey(npub) + } +} + +/** + * Moves account private keys off `androidx.security.crypto` without ever + * leaving one only in a place the running build cannot read. + * + * The old home is `secret_keeper_`, an EncryptedSharedPreferences file. + * The new one is [SecureKeyStorage], which on Android is now an encrypted + * DataStore sealed by the AndroidKeyStore directly. Both are written on every + * save, and reads prefer the new store but fall back to the old one, so: + * + * - an install that has never run this build still finds its key, and is + * migrated the first time the account loads; + * - a build rolled back to reading only the old store still finds every key, + * including ones added after the upgrade; + * - a new store that cannot be read — a wiped AndroidKeyStore after a device + * credential reset, say — falls back rather than presenting the account as + * having no key, which would silently demote it to read-only. + * + * Nothing is deleted here. Dropping the legacy file is a later release's job, + * once this path has shipped and held; doing both at once leaves no way back. + * + * The two stores cannot legitimately disagree: an npub is derived from its + * private key, so the key for a given npub never changes. A mismatch means + * corruption, and is resolved in favour of the older, proven store. + */ +class AccountKeyStore( + private val vault: PrivateKeyVault, +) { + companion object { + private const val TAG = "AccountKeyStore" + } + + /** + * The account's private key, or null when it genuinely has none — an + * external-signer account, or a watch-only npub. + * + * @param legacyValue what the legacy store holds, read by the caller that + * already has the file open. + */ + suspend fun read( + npub: String, + legacyValue: String?, + ): String? { + val fromSecure = + try { + vault.get(npub) + } catch (e: Exception) { + // Unreadable, not absent. Fall back, and do not migrate into a + // store that just failed. + Log.w(TAG, "Could not read the key store for $npub; using the legacy store", e) + return legacyValue + } + + if (fromSecure != null) { + if (legacyValue != null && legacyValue != fromSecure) { + Log.e(TAG, "Key mismatch for $npub between the legacy and current stores; keeping the legacy value", null) + return legacyValue + } + return fromSecure + } + + // Absent from the new store: first load since the upgrade. + if (legacyValue != null) migrate(npub, legacyValue) + return legacyValue + } + + private suspend fun migrate( + npub: String, + privKeyHex: String, + ) { + try { + vault.save(npub, privKeyHex) + Log.i(TAG) { "Migrated the private key for $npub into the current store" } + } catch (e: Exception) { + // The legacy store still has it and is still read, so this is + // recoverable — the next load tries again. + Log.w(TAG, "Could not migrate the private key for $npub; it stays in the legacy store", e) + } + } + + /** + * Mirrors a save into the new store. The legacy write stays where it is, + * inside the caller's existing edit block, so a rollback keeps working. + * + * The three cases match the legacy write exactly, including the one that is + * easy to get wrong: with no external signer and no private key in hand, + * the legacy store *leaves the stored key alone* rather than clearing it, + * so this must not clear it either. Deleting here would drop the key on + * every save from a session that never decrypted it. + */ + suspend fun mirrorSave( + npub: String, + usesExternalSigner: Boolean, + privKeyHex: String?, + ) { + try { + when { + usesExternalSigner -> vault.delete(npub) + privKeyHex != null -> vault.save(npub, privKeyHex) + else -> Unit + } + } catch (e: Exception) { + // Never fatal: the legacy store still loads the account, and the + // next save or load repairs this one. + Log.w(TAG, "Could not write the private key for $npub to the current store", e) + } + } + + /** Drops the key from the new store; the caller clears the legacy file itself. */ + suspend fun delete(npub: String) { + try { + vault.delete(npub) + } catch (e: Exception) { + Log.w(TAG, "Could not delete the private key for $npub from the current store", e) + } + } +} + +/** The production instance, over the app's [SecureKeyStorage]. */ +val accountKeyStore: AccountKeyStore by lazy { + AccountKeyStore(SecureKeyStorageVault(SecureKeyStorage.create(Amethyst.instance.appContext))) +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index dabf6b10e0..f61513aa47 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -622,6 +622,7 @@ object LocalPreferences { // would resurrect the deleted settings from this cache. mutex.withLock { cachedAccounts.remove(accountInfo.npub) } encryptedPreferences(accountInfo.npub).edit(commit = true) { clear() } + accountKeyStore.delete(accountInfo.npub) removeAccount(accountInfo) deleteUserPreferenceFile(accountInfo.npub) @@ -756,6 +757,15 @@ object LocalPreferences { JsonMapper.toJson(settings.pendingAttestations.value), ) } + + // Mirrored into the key store after the legacy write, not + // instead of it: both stores carry the key during the + // transition so a rollback still loads the account. + accountKeyStore.mirrorSave( + npub = settings.keyPair.pubKey.toNpub(), + usesExternalSigner = settings.externalSignerPackageName != null, + privKeyHex = settings.keyPair.privKey?.toHexKey(), + ) } uploadSettingsStore(settings.keyPair.pubKey.toNpub()).save( UploadSettings( @@ -966,8 +976,14 @@ object LocalPreferences { withContext(Dispatchers.IO) { return@withContext with(encryptedPreferences(npub)) { Log.d("LocalPreferences") { "Load account from file $npub - opened file" } - val privKey = getString(PrefKeys.NOSTR_PRIVKEY, null) + // pubKey first: the key store is keyed by npub, which is derived + // from it, and this is the same npub the save side writes under. val pubKey = getString(PrefKeys.NOSTR_PUBKEY, null) ?: return@with null + val privKey = + accountKeyStore.read( + npub = pubKey.hexToByteArray().toNpub(), + legacyValue = getString(PrefKeys.NOSTR_PRIVKEY, null), + ) val externalSignerPackageName = getString(PrefKeys.SIGNER_PACKAGE_NAME, null) ?: if (getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false)) "com.greenart7c3.nostrsigner" else null val keyPair = KeyPair(privKey = privKey?.hexToByteArray(), pubKey = pubKey.hexToByteArray()) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/AccountKeyStoreTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/AccountKeyStoreTest.kt new file mode 100644 index 0000000000..00ccff8987 --- /dev/null +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/AccountKeyStoreTest.kt @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * The read/write decisions that move account keys off the deprecated store. + * + * Every branch here can cost someone their account: reading a working store as + * empty demotes a signing account to read-only, and clearing a key that was + * only temporarily unreadable destroys it. The AndroidKeyStore itself cannot be + * reached from a unit test, so [PrivateKeyVault] is faked and the logic above + * it is what gets exercised. + */ +class AccountKeyStoreTest { + private val npub = "npub1xxxx" + private val key = "e5e2b1d3f6a94c8d7b0e1f2a3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d" + + private class FakeVault( + var stored: MutableMap = mutableMapOf(), + var failReads: Boolean = false, + var failWrites: Boolean = false, + ) : PrivateKeyVault { + var saves = 0 + var deletes = 0 + + override suspend fun get(npub: String): String? { + if (failReads) throw IllegalStateException("store unreadable") + return stored[npub] + } + + override suspend fun save( + npub: String, + privKeyHex: String, + ) { + saves++ + if (failWrites) throw IllegalStateException("store unwritable") + stored[npub] = privKeyHex + } + + override suspend fun delete(npub: String) { + deletes++ + if (failWrites) throw IllegalStateException("store unwritable") + stored.remove(npub) + } + } + + // ── reads ───────────────────────────────────────────────────────── + + /** First load after the upgrade: the key is only in the legacy store, and moves across. */ + @Test + fun aLegacyOnlyKeyIsReturnedAndMigrated() = + runTest { + val vault = FakeVault() + + val read = AccountKeyStore(vault).read(npub, legacyValue = key) + + assertEquals(key, read) + assertEquals("migrated into the new store", key, vault.stored[npub]) + } + + @Test + fun anAlreadyMigratedKeyIsReadFromTheNewStore() = + runTest { + val vault = FakeVault(mutableMapOf(npub to key)) + + assertEquals(key, AccountKeyStore(vault).read(npub, legacyValue = key)) + assertEquals("already there, so not rewritten", 0, vault.saves) + } + + /** + * The dangerous one. A store that cannot be read must not look like an + * account with no key — that would silently turn a signing account into a + * read-only one. + */ + @Test + fun anUnreadableStoreFallsBackToLegacyRatherThanReportingNoKey() = + runTest { + val vault = FakeVault(failReads = true) + + assertEquals(key, AccountKeyStore(vault).read(npub, legacyValue = key)) + } + + /** And it must not try to migrate into a store that just failed. */ + @Test + fun anUnreadableStoreIsNotWrittenTo() = + runTest { + val vault = FakeVault(failReads = true) + + AccountKeyStore(vault).read(npub, legacyValue = key) + + assertEquals(0, vault.saves) + } + + /** An account genuinely without a key — external signer, or watch-only. */ + @Test + fun noKeyAnywhereReadsAsNull() = + runTest { + val vault = FakeVault() + + assertNull(AccountKeyStore(vault).read(npub, legacyValue = null)) + assertEquals("nothing to migrate", 0, vault.saves) + } + + /** A key added after the upgrade exists only in the new store. */ + @Test + fun aNewStoreOnlyKeyIsReturned() = + runTest { + val vault = FakeVault(mutableMapOf(npub to key)) + + assertEquals(key, AccountKeyStore(vault).read(npub, legacyValue = null)) + } + + /** + * An npub is derived from its key, so the two stores disagreeing means + * corruption. The older, proven store wins. + */ + @Test + fun aMismatchPrefersTheLegacyValue() = + runTest { + val vault = FakeVault(mutableMapOf(npub to "deadbeef")) + + assertEquals(key, AccountKeyStore(vault).read(npub, legacyValue = key)) + } + + /** A failed migration must not fail the account load; the legacy store still has it. */ + @Test + fun aFailedMigrationStillReturnsTheKey() = + runTest { + val vault = FakeVault(failWrites = true) + + assertEquals(key, AccountKeyStore(vault).read(npub, legacyValue = key)) + } + + // ── writes ──────────────────────────────────────────────────────── + + @Test + fun aSaveMirrorsTheKey() = + runTest { + val vault = FakeVault() + + AccountKeyStore(vault).mirrorSave(npub, usesExternalSigner = false, privKeyHex = key) + + assertEquals(key, vault.stored[npub]) + } + + @Test + fun anExternalSignerAccountClearsTheKey() = + runTest { + val vault = FakeVault(mutableMapOf(npub to key)) + + AccountKeyStore(vault).mirrorSave(npub, usesExternalSigner = true, privKeyHex = null) + + assertTrue(vault.stored.isEmpty()) + } + + /** + * The case that is easy to get wrong. With no external signer and no key in + * hand, the legacy store leaves the stored key alone — so this must too. + * Deleting here would drop the key on every save from a session that never + * decrypted it. + */ + @Test + fun aSaveWithoutAKeyInHandLeavesTheStoredKeyAlone() = + runTest { + val vault = FakeVault(mutableMapOf(npub to key)) + + AccountKeyStore(vault).mirrorSave(npub, usesExternalSigner = false, privKeyHex = null) + + assertEquals(key, vault.stored[npub]) + assertEquals(0, vault.deletes) + assertEquals(0, vault.saves) + } + + /** A write failure must never fail the save: the legacy store is still written. */ + @Test + fun aWriteFailureIsSwallowed() = + runTest { + val vault = FakeVault(failWrites = true) + + AccountKeyStore(vault).mirrorSave(npub, usesExternalSigner = false, privKeyHex = key) + } + + @Test + fun deleteRemovesFromTheNewStore() = + runTest { + val vault = FakeVault(mutableMapOf(npub to key)) + + AccountKeyStore(vault).delete(npub) + + assertTrue(vault.stored.isEmpty()) + } +} From 61a16fc74c36d04e184ffbf9305750fe42f74ca3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 21:04:58 +0000 Subject: [PATCH 10/57] feat: dual-store per-account secrets (NIP-46, wallets) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 5c. The NIP-46 bunker material and wallet connection strings move out of `secret_keeper_` into an encrypted DataStore, on the same terms as the private key in 5b: both stores written, new store preferred on read, nothing deleted. Everything stays encrypted, including the parts that are not obviously secret. defaultPaymentSourceId is only an identifier and nip46SeenRequestIds only request ids, but both were encrypted before and both say something about what the account does; moving them to a plain store would be a quiet downgrade. The copy is lazy, through the store's own save(), rather than a DataMigration — and that is not a style choice. A DataMigration writes values as-is while this store decrypts on read, so plaintext placed there cannot be read back: the attempt raises "Invalid symbol". A test now pins that, because the failure mode is an account whose wallet strings are unreadable rather than obviously missing. Three bugs found by wiring this up, all in code written earlier in this series while it had no callers: - AccountSecretsEncryptedStores named its file `.secrets_pb`, but DataStore's Preferences factory rejects any extension other than `.preferences_pb`. The class could never open a store at all. Now `.secrets.preferences_pb`. - Neither per-account store could be re-created after removeAccount. DataStore keeps a process-wide registry keyed by file path and releases an entry only when its scope ends, so dropping the cache entry left the path claimed and deleting an account then adding it again in the same session threw. Both stores now own a cancellable scope per account. Fixed in AccountPreferenceStores too, which had it since step 1. - The mirror serialized clinkDebitWallets raw where the legacy write stores `.map { it.denormalize() }`. That would have written JSON the loader cannot parse. Caught by reading the legacy block rather than trusting the field name. 22 tests: 9 for the secrets group (round trip, the boolean and set surviving a string encoding, an empty set not becoming a set holding an empty string, clearing a wallet removing it rather than leaving stale JSON, per-account isolation, and that the bunker secret and wallet string are not readable in the store file), 4 for the plain store including delete-then-re-add, plus the encrypted-migration pin. Not verified here: the AndroidKeyStore path, same as 5b. A device should confirm a NIP-46 signer still pairs and a wallet still pays after upgrade before the legacy file is dropped. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/AccountSecretsStore.kt | 109 ++++++++++ .../amethyst/LocalPreferences.kt | 63 +++++- .../preferences/AccountPreferenceStores.kt | 47 ++++- .../model/preferences/AccountSecrets.kt | 80 ++++++++ .../AccountSecretsEncryptedStores.kt | 120 ++++++++++- .../AccountPreferenceStoresTest.kt | 104 ++++++++++ .../preferences/AccountSecretsStoreTest.kt | 187 ++++++++++++++++++ .../preferences/EncryptedDataStoreTest.kt | 35 ++++ 8 files changed, 716 insertions(+), 29 deletions(-) create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt create mode 100644 commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStoresTest.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt new file mode 100644 index 0000000000..f7c071219e --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets +import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecretsEncryptedStores +import com.vitorpamplona.quartz.utils.Log +import okio.Path.Companion.toOkioPath + +/** + * Moves the per-account secrets — NIP-46 bunker material, wallet connection + * strings — out of the `secret_keeper_` EncryptedSharedPreferences file + * and into an encrypted DataStore, on the same terms as the private key: both + * stores written, new store preferred on read, nothing deleted. + * + * The copy is lazy rather than a DataMigration, and that is not a style + * choice. A DataMigration writes values as-is, while this store decrypts on + * read, so plaintext placed there by one cannot be read back — the attempt + * raises. `EncryptedDataStoreTest` pins that behaviour. Copying through the + * store's own `save` is what keeps the values readable. + * + * Losing these is recoverable — the user re-pairs a signer or re-adds a wallet + * — but it is not something to spend, so a read that fails falls back to the + * legacy values rather than reporting the account as having none. + */ +class AccountSecretsStore( + private val stores: AccountSecretsEncryptedStores, +) { + companion object { + private const val TAG = "AccountSecretsStore" + } + + /** + * The account's secrets, migrating out of the legacy file on first use. + * + * @param legacy what the legacy encrypted file holds, read by the caller + * that already has it open. + */ + suspend fun read( + npub: String, + legacy: AccountSecrets, + ): AccountSecrets { + val stored = + try { + stores.loadSecrets(npub) + } catch (e: Exception) { + Log.w(TAG, "Could not read the secrets store for $npub; using the legacy file", e) + return legacy + } + + if (stored != null) return stored + + // Not migrated yet: copy the legacy values across and use them. + mirror(npub, legacy) + return legacy + } + + /** Mirrors a save into the new store. The legacy write stays where it is. */ + suspend fun mirror( + npub: String, + value: AccountSecrets, + ) { + try { + stores.saveSecrets(npub, value) + } catch (e: Exception) { + // Never fatal: the legacy file still has them, and the next save or + // load tries again. + Log.w(TAG, "Could not write the secrets for $npub to the current store", e) + } + } + + suspend fun delete(npub: String) { + try { + stores.removeAccount(npub) + } catch (e: Exception) { + Log.w(TAG, "Could not drop the secrets store for $npub", e) + } + } +} + +val accountSecretsStore: AccountSecretsStore by lazy { + AccountSecretsStore( + AccountSecretsEncryptedStores( + rootFilesDir = { + Amethyst.instance.appContext.filesDir + .toOkioPath() + }, + scope = Amethyst.instance.applicationIOScope, + ), + ) +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index f61513aa47..726297aa1a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -35,6 +35,7 @@ import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupViewM import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntry import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntryNorm import com.vitorpamplona.amethyst.commons.model.preferences.AccountPreferenceStores +import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration import com.vitorpamplona.amethyst.commons.model.preferences.DialogDismissal import com.vitorpamplona.amethyst.commons.model.preferences.DialogDismissalStore @@ -623,6 +624,7 @@ object LocalPreferences { mutex.withLock { cachedAccounts.remove(accountInfo.npub) } encryptedPreferences(accountInfo.npub).edit(commit = true) { clear() } accountKeyStore.delete(accountInfo.npub) + accountSecretsStore.delete(accountInfo.npub) removeAccount(accountInfo) deleteUserPreferenceFile(accountInfo.npub) @@ -761,6 +763,31 @@ object LocalPreferences { // Mirrored into the key store after the legacy write, not // instead of it: both stores carry the key during the // transition so a rollback still loads the account. + accountSecretsStore.mirror( + npub = settings.keyPair.pubKey.toNpub(), + value = + AccountSecrets( + nip46SignerEnabled = settings.nip46SignerEnabled.value, + nip46BunkerSecret = settings.nip46BunkerSecret.value, + nip46TransportKey = settings.nip46TransportKey.value, + nip46SeenRequestIds = settings.nip46SeenRequestIds.value, + nwcWalletsJson = + settings.nwcWallets.value + .mapNotNull { it.denormalize() } + .takeIf { it.isNotEmpty() } + ?.let { JsonMapper.toJson(it) }, + // .map { denormalize() } and not the raw wallets: the legacy + // write stores the denormalized shape, and the read path parses + // that shape. Serializing the raw value here would write JSON + // the loader cannot understand. + clinkDebitWalletsJson = + settings.clinkDebitWallets.value + .map { it.denormalize() } + .takeIf { it.isNotEmpty() } + ?.let { JsonMapper.toJson(it) }, + defaultPaymentSourceId = settings.defaultPaymentSourceId.value, + ), + ) accountKeyStore.mirrorSave( npub = settings.keyPair.pubKey.toNpub(), usesExternalSigner = settings.externalSignerPackageName != null, @@ -998,10 +1025,6 @@ object LocalPreferences { val mirrorUploadsToAllServers = stores.uploadSettings.mirrorUploadsToAllServers val optimizeMediaOnUpload = stores.uploadSettings.optimizeMediaOnUpload val hideCommunityRulesViolations = stores.dialogDismissal.hideCommunityRulesViolations - val nip46SignerEnabled = getBoolean(PrefKeys.NIP46_SIGNER_ENABLED, false) - val nip46BunkerSecret = getString(PrefKeys.NIP46_BUNKER_SECRET, "") ?: "" - val nip46TransportKey = getString(PrefKeys.NIP46_TRANSPORT_KEY, "") ?: "" - val nip46SeenRequestIds = getStringSet(PrefKeys.NIP46_SEEN_IDS, null) ?: setOf() val hideDeleteRequestDialog = stores.dialogDismissal.hideDeleteRequestDialog val hideBlockAlertDialog = stores.dialogDismissal.hideBlockAlertDialog val hideNIP17WarningDialog = stores.dialogDismissal.hideNip17WarningDialog @@ -1022,11 +1045,33 @@ object LocalPreferences { val followListPrefs = toFollowListPrefs(stores.followLists) - val zapPaymentRequestServerStr = getString(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER, null) - val nwcWalletsStr = getString(PrefKeys.NWC_WALLETS, null) - val defaultNwcWalletIdStr = getString(PrefKeys.DEFAULT_NWC_WALLET_ID, null) - val clinkDebitWalletsStr = getString(PrefKeys.CLINK_DEBIT_WALLETS, null) - val defaultPaymentSourceIdStr = getString(PrefKeys.DEFAULT_PAYMENT_SOURCE_ID, null) + // The secrets that used to live in this file now come from the + // encrypted DataStore, falling back to what is still here. + val secrets = + accountSecretsStore.read( + npub = keyPair.pubKey.toNpub(), + legacy = + AccountSecrets( + nip46SignerEnabled = getBoolean(PrefKeys.NIP46_SIGNER_ENABLED, false), + nip46BunkerSecret = getString(PrefKeys.NIP46_BUNKER_SECRET, "") ?: "", + nip46TransportKey = getString(PrefKeys.NIP46_TRANSPORT_KEY, "") ?: "", + nip46SeenRequestIds = getStringSet(PrefKeys.NIP46_SEEN_IDS, null) ?: setOf(), + nwcWalletsJson = getString(PrefKeys.NWC_WALLETS, null), + clinkDebitWalletsJson = getString(PrefKeys.CLINK_DEBIT_WALLETS, null), + defaultPaymentSourceId = getString(PrefKeys.DEFAULT_PAYMENT_SOURCE_ID, null), + legacyDefaultNwcWalletId = getString(PrefKeys.DEFAULT_NWC_WALLET_ID, null), + legacyZapPaymentRequestServer = getString(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER, null), + ), + ) + val nip46SignerEnabled = secrets.nip46SignerEnabled + val nip46BunkerSecret = secrets.nip46BunkerSecret + val nip46TransportKey = secrets.nip46TransportKey + val nip46SeenRequestIds = secrets.nip46SeenRequestIds + val zapPaymentRequestServerStr = secrets.legacyZapPaymentRequestServer + val nwcWalletsStr = secrets.nwcWalletsJson + val defaultNwcWalletIdStr = secrets.legacyDefaultNwcWalletId + val clinkDebitWalletsStr = secrets.clinkDebitWalletsJson + val defaultPaymentSourceIdStr = secrets.defaultPaymentSourceId val defaultFileServerStr = stores.uploadSettings.defaultFileServerJson val pendingAttestationsStr = getString(PrefKeys.PENDING_ATTESTATIONS, null) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt index af03d7de4d..9695fe17a5 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt @@ -26,6 +26,11 @@ import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences import com.vitorpamplona.amethyst.commons.util.platformFileSystem import com.vitorpamplona.quartz.utils.cache.LargeCache +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel import okio.Path /** @@ -48,26 +53,48 @@ class AccountPreferenceStores( val rootFilesDir: () -> Path, private val migrations: (npub: String) -> List> = { emptyList() }, ) { - private val storeCache = LargeCache>() + /** + * One store per account, each on a scope this class can cancel. + * + * DataStore keeps a process-wide registry keyed by file path and only + * releases an entry when the owning scope ends. Left to create its own + * internal scope, a store is never released, and deleting an account then + * adding it again in the same session throws "multiple DataStores active + * for the same file". + */ + private class Entry( + val scope: CoroutineScope, + val store: DataStore, + ) + + private val storeCache = LargeCache() fun file(npub: String): Path = rootFilesDir() / "datastore" / "$npub.preferences_pb" fun getDataStore(npub: String): DataStore = - storeCache.getOrCreate(npub) { - PreferenceDataStoreFactory.createWithPath( - migrations = migrations(npub), - produceFile = { file(npub) }, - ) - } + storeCache + .getOrCreate(npub) { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + Entry( + scope, + PreferenceDataStoreFactory.createWithPath( + scope = scope, + migrations = migrations(npub), + produceFile = { file(npub) }, + ), + ) + }.store /** * Drops the account's stored preferences. * - * The cached handle goes first: deleting the file under a live DataStore - * would leave that instance writing the account's settings back out on the - * next edit, re-creating what this call is meant to erase. + * The live store is shut down first: deleting the file underneath one + * would leave it writing the account's settings back out on the next edit, + * re-creating what this call is meant to erase — and would keep the path + * registered, so the same account could not be added again. */ fun removeAccount(npub: String): Boolean { + storeCache.get(npub)?.scope?.cancel() storeCache.remove(npub) val path = file(npub) if (!platformFileSystem.exists(path)) return false diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt new file mode 100644 index 0000000000..220d73546c --- /dev/null +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.preferences.core.stringPreferencesKey + +/** + * The per-account values that used to live in the encrypted + * `secret_keeper_` file, other than the private key itself. + * + * Everything here stays encrypted, including the parts that are not obviously + * secret. `defaultPaymentSourceId` is only an identifier and + * `nip46SeenRequestIds` only request ids, but both were encrypted before and + * both say something about what the account does — moving them to a plain + * store would be a quiet downgrade, so they keep the protection they had. + * + * The two `legacy` fields are read-only leftovers the app still migrates from; + * they are carried across so an upgrade does not strand a wallet that only + * exists in the old shape. + */ +data class AccountSecrets( + val nip46SignerEnabled: Boolean = false, + val nip46BunkerSecret: String = "", + val nip46TransportKey: String = "", + val nip46SeenRequestIds: Set = emptySet(), + val nwcWalletsJson: String? = null, + val clinkDebitWalletsJson: String? = null, + val defaultPaymentSourceId: String? = null, + val legacyDefaultNwcWalletId: String? = null, + val legacyZapPaymentRequestServer: String? = null, +) + +/** + * Keys for [AccountSecrets] inside an [EncryptedDataStore]. + * + * All of them are string keys: the store encrypts strings, so a boolean and a + * set are encoded here rather than stored in typed keys that would sit in + * cleartext beside the encrypted values. + */ +internal object AccountSecretKeys { + val nip46SignerEnabled = stringPreferencesKey("nip46SignerEnabled") + val nip46BunkerSecret = stringPreferencesKey("nip46BunkerSecret") + val nip46TransportKey = stringPreferencesKey("nip46TransportKey") + val nip46SeenRequestIds = stringPreferencesKey("nip46SeenRequestIds") + val nwcWallets = stringPreferencesKey("nwcWallets") + val clinkDebitWallets = stringPreferencesKey("clinkDebitWallets") + val defaultPaymentSourceId = stringPreferencesKey("defaultPaymentSourceId") + val legacyDefaultNwcWalletId = stringPreferencesKey("defaultNwcWalletId") + val legacyZapPaymentRequestServer = stringPreferencesKey("zapPaymentServer") + + /** Records that the one-off copy out of the legacy file has run for this account. */ + val migrated = stringPreferencesKey("migrated.accountSecrets") + + /** + * Sets are stored newline-joined rather than as JSON. + * + * The members are nostr event ids — hex, so they cannot contain a newline — + * which makes the round trip exact without pulling a serializer into the + * encryption path. + */ + const val SET_SEPARATOR = "\n" +} diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt index 60300c1498..c56bf6b9bd 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt @@ -26,6 +26,9 @@ import com.vitorpamplona.amethyst.commons.util.platformFileSystem import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.utils.cache.LargeCache import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel import okio.Path /** @@ -53,18 +56,42 @@ class AccountSecretsEncryptedStores( val nwc = stringPreferencesKey("nwc") } - private val storeCache = LargeCache() + /** + * One store per account, each on its own child scope. + * + * The scope matters: DataStore keeps a process-wide registry keyed by file + * path and only releases an entry when the owning scope is cancelled. On a + * shared scope, deleting an account and re-adding it in the same session + * would throw "multiple DataStores active for the same file". + */ + private class Entry( + val scope: CoroutineScope, + val store: EncryptedDataStore, + ) - fun file(npub: String): Path = rootFilesDir() / "datastore" / "$npub.secrets_pb" + private val storeCache = LargeCache() + + /** + * The `.preferences_pb` suffix is required, not decorative: DataStore's + * Preferences factory rejects any other extension at open time. The + * `.secrets` part is what keeps this file distinct from the account's + * plain preference store. + */ + fun file(npub: String): Path = rootFilesDir() / "datastore" / "$npub.secrets.preferences_pb" fun getDataStore(npub: String): EncryptedDataStore = - storeCache.getOrCreate(npub) { - EncryptedDataStore( - PreferenceDataStoreFactory.createWithPath(produceFile = { file(npub) }), - encryption, - scope = scope, - ) - } + storeCache + .getOrCreate(npub) { + val child = CoroutineScope(scope.coroutineContext + SupervisorJob(scope.coroutineContext[Job])) + Entry( + child, + EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath(scope = child, produceFile = { file(npub) }), + encryption, + scope = child, + ), + ) + }.store fun nwc(npub: String): UpdatablePropertyFlow = getDataStore(npub).getProperty( @@ -73,12 +100,85 @@ class AccountSecretsEncryptedStores( serializer = Nip47WalletConnect.Nip47URI::serializer, ) - /** See [AccountPreferenceStores.removeAccount] — the cached handle goes first. */ + /** + * Drops the account's secrets. + * + * Cancels the store's scope before deleting, so DataStore releases the + * path and the same account can be added again in this session. + */ fun removeAccount(npub: String): Boolean { + storeCache.get(npub)?.scope?.cancel() storeCache.remove(npub) val path = file(npub) if (!platformFileSystem.exists(path)) return false platformFileSystem.delete(path) return true } + + // ── the per-account secret group ────────────────────────────────── + + /** + * Reads [AccountSecrets], or null when this account has not been migrated + * out of the legacy encrypted file yet. + * + * Null and "all defaults" are deliberately different answers: the caller + * uses null to decide whether to run the one-off copy, and an account that + * genuinely holds no secrets must not trigger it forever. + */ + suspend fun loadSecrets(npub: String): AccountSecrets? { + val store = getDataStore(npub) + if (store.get(AccountSecretKeys.migrated) == null) return null + + return AccountSecrets( + nip46SignerEnabled = store.get(AccountSecretKeys.nip46SignerEnabled).toBoolean(), + nip46BunkerSecret = store.get(AccountSecretKeys.nip46BunkerSecret) ?: "", + nip46TransportKey = store.get(AccountSecretKeys.nip46TransportKey) ?: "", + nip46SeenRequestIds = decodeSet(store.get(AccountSecretKeys.nip46SeenRequestIds)), + nwcWalletsJson = store.get(AccountSecretKeys.nwcWallets), + clinkDebitWalletsJson = store.get(AccountSecretKeys.clinkDebitWallets), + defaultPaymentSourceId = store.get(AccountSecretKeys.defaultPaymentSourceId), + legacyDefaultNwcWalletId = store.get(AccountSecretKeys.legacyDefaultNwcWalletId), + legacyZapPaymentRequestServer = store.get(AccountSecretKeys.legacyZapPaymentRequestServer), + ) + } + + /** + * Writes the group, then the marker. + * + * Marker last on purpose: a crash midway leaves the account looking + * unmigrated, so the next load copies from the legacy file again rather + * than reading a half-written set of secrets as complete. + */ + suspend fun saveSecrets( + npub: String, + value: AccountSecrets, + ) { + val store = getDataStore(npub) + + store.save(AccountSecretKeys.nip46SignerEnabled, value.nip46SignerEnabled.toString()) + store.save(AccountSecretKeys.nip46BunkerSecret, value.nip46BunkerSecret) + store.save(AccountSecretKeys.nip46TransportKey, value.nip46TransportKey) + store.save(AccountSecretKeys.nip46SeenRequestIds, value.nip46SeenRequestIds.joinToString(AccountSecretKeys.SET_SEPARATOR)) + store.putOrRemove(AccountSecretKeys.nwcWallets, value.nwcWalletsJson) + store.putOrRemove(AccountSecretKeys.clinkDebitWallets, value.clinkDebitWalletsJson) + store.putOrRemove(AccountSecretKeys.defaultPaymentSourceId, value.defaultPaymentSourceId) + store.putOrRemove(AccountSecretKeys.legacyDefaultNwcWalletId, value.legacyDefaultNwcWalletId) + store.putOrRemove(AccountSecretKeys.legacyZapPaymentRequestServer, value.legacyZapPaymentRequestServer) + + store.save(AccountSecretKeys.migrated, "true") + } + + private suspend fun EncryptedDataStore.putOrRemove( + key: androidx.datastore.preferences.core.Preferences.Key, + value: String?, + ) { + if (value != null) save(key, value) else remove(key) + } + + private fun decodeSet(raw: String?): Set = + raw + ?.split(AccountSecretKeys.SET_SEPARATOR) + ?.filter { it.isNotEmpty() } + ?.toSet() + ?: emptySet() } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStoresTest.kt new file mode 100644 index 0000000000..34ba75fabd --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStoresTest.kt @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +class AccountPreferenceStoresTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + /** + * The root is resolved once, outside the lambda: [AccountPreferenceStores] + * calls `rootFilesDir()` on every file() and a lambda that allocated a new + * directory each time would hand out a different path per call. + */ + private fun stores(): AccountPreferenceStores { + val root = File(folder.root, "r${seq++}").apply { mkdirs() } + return AccountPreferenceStores(rootFilesDir = { root.toOkioPath() }) + } + + private val key = stringPreferencesKey("k") + + @Test + fun valuesRoundTripPerAccount() = + runTest { + val subject = stores() + + subject.getDataStore("npub1a").edit { it[key] = "a" } + subject.getDataStore("npub1b").edit { it[key] = "b" } + + assertEquals("a", subject.getDataStore("npub1a").data.first()[key]) + assertEquals("b", subject.getDataStore("npub1b").data.first()[key]) + } + + @Test + fun removingAnAccountDeletesItsFile() = + runTest { + val subject = stores() + subject.getDataStore("npub1a").edit { it[key] = "a" } + + assertTrue(subject.removeAccount("npub1a")) + assertFalse(subject.file("npub1a").toFile().exists()) + } + + /** + * Deleting an account and adding it again in the same session. + * + * DataStore keeps a process-wide registry keyed by file path and only + * releases an entry when its scope ends, so a store that is merely dropped + * from the cache keeps the path claimed — and this throws "multiple + * DataStores active for the same file". + */ + @Test + fun anAccountCanBeAddedAgainAfterRemoval() = + runTest { + val subject = stores() + subject.getDataStore("npub1a").edit { it[key] = "before" } + subject.removeAccount("npub1a") + + val reopened = subject.getDataStore("npub1a") + + assertNull("the old value is gone", reopened.data.first()[key]) + reopened.edit { it[key] = "after" } + assertEquals("after", subject.getDataStore("npub1a").data.first()[key]) + } + + @Test + fun removingAnUnknownAccountReportsNothingDeleted() = + runTest { + assertFalse(stores().removeAccount("npub1missing")) + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt new file mode 100644 index 0000000000..d560d48709 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * The per-account secrets group: NIP-46 bunker material and wallet strings. + * + * These are encrypted at rest and reached through string keys, so a booleans + * and a set have to survive an encode/decode they did not before — that is + * what most of this covers. + */ +class AccountSecretsStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun stores(): AccountSecretsEncryptedStores { + val root = File(folder.root, "acct_${seq++}").apply { mkdirs() } + return AccountSecretsEncryptedStores( + rootFilesDir = { root.toOkioPath() }, + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + encryption = SecretEncryption(File(root, "secret.key")), + ) + } + + private val npub = "npub1abc" + + private val filled = + AccountSecrets( + nip46SignerEnabled = true, + nip46BunkerSecret = "bunker-secret", + nip46TransportKey = "transport-key", + nip46SeenRequestIds = setOf("aa11", "bb22", "cc33"), + nwcWalletsJson = """[{"uri":"nostr+walletconnect://x"}]""", + clinkDebitWalletsJson = """[{"id":"debit1"}]""", + defaultPaymentSourceId = "source-1", + ) + + /** + * Absent must read as null, not as a default-filled group: the caller uses + * null to decide whether to run the one-off copy out of the legacy file. + */ + @Test + fun anUnmigratedAccountReadsAsNull() = + runTest { + assertNull(stores().loadSecrets(npub)) + } + + @Test + fun theGroupRoundTrips() = + runTest { + val subject = stores() + + subject.saveSecrets(npub, filled) + + assertEquals(filled, subject.loadSecrets(npub)) + } + + /** An account that genuinely holds nothing must still read as migrated, not as null forever. */ + @Test + fun anEmptyGroupStillCountsAsMigrated() = + runTest { + val subject = stores() + + subject.saveSecrets(npub, AccountSecrets()) + + assertEquals(AccountSecrets(), subject.loadSecrets(npub)) + } + + /** The boolean and the set go through a string encoding that did not exist before. */ + @Test + fun theBooleanAndSetSurviveEncoding() = + runTest { + val subject = stores() + + subject.saveSecrets(npub, AccountSecrets(nip46SignerEnabled = true, nip46SeenRequestIds = setOf("a", "b"))) + val loaded = subject.loadSecrets(npub)!! + + assertTrue(loaded.nip46SignerEnabled) + assertEquals(setOf("a", "b"), loaded.nip46SeenRequestIds) + } + + @Test + fun anEmptySetDoesNotBecomeASetHoldingAnEmptyString() = + runTest { + val subject = stores() + + subject.saveSecrets(npub, AccountSecrets(nip46SeenRequestIds = emptySet())) + + assertTrue(subject.loadSecrets(npub)!!.nip46SeenRequestIds.isEmpty()) + } + + /** Clearing a wallet must remove it, not leave the previous JSON behind. */ + @Test + fun aClearedWalletIsRemoved() = + runTest { + val subject = stores() + subject.saveSecrets(npub, filled) + + subject.saveSecrets(npub, filled.copy(nwcWalletsJson = null, defaultPaymentSourceId = null)) + val loaded = subject.loadSecrets(npub)!! + + assertNull(loaded.nwcWalletsJson) + assertNull(loaded.defaultPaymentSourceId) + assertEquals("siblings untouched", filled.clinkDebitWalletsJson, loaded.clinkDebitWalletsJson) + } + + @Test + fun accountsAreIsolated() = + runTest { + val subject = stores() + + subject.saveSecrets("npub1aaa", filled) + + assertNull(subject.loadSecrets("npub1bbb")) + } + + /** The values must not be sitting in the store file in the clear. */ + @Test + fun secretsAreNotStoredInPlaintext() = + runTest { + val root = File(folder.root, "plain").apply { mkdirs() } + val subject = + AccountSecretsEncryptedStores( + rootFilesDir = { root.toOkioPath() }, + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + encryption = SecretEncryption(File(root, "secret.key")), + ) + + subject.saveSecrets(npub, filled) + + val onDisk = + subject + .file(npub) + .toFile() + .readBytes() + .decodeToString() + assertFalse("the bunker secret must not be readable", onDisk.contains("bunker-secret")) + assertFalse("the wallet string must not be readable", onDisk.contains("nostr+walletconnect")) + } + + @Test + fun removingAnAccountDropsItsSecrets() = + runTest { + val subject = stores() + subject.saveSecrets(npub, filled) + assertNotNull(subject.loadSecrets(npub)) + + subject.removeAccount(npub) + + assertNull(subject.loadSecrets(npub)) + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt index 05f9e231e1..6354f5e924 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt @@ -176,4 +176,39 @@ class EncryptedDataStoreTest { ) readScope.cancel() } + + /** + * A stock DataMigration writes values as-is, but this store decrypts on + * read — so plaintext put there by one cannot survive the trip, and the + * read raises rather than returning something wrong. + * + * This is why secrets migrate lazily, through [save], instead of through a + * DataMigration the way the plain preference stores do. Getting it wrong + * would leave an account's wallet strings unreadable rather than obviously + * missing. + */ + @Test + fun aRawMigrationIntoAnEncryptedStoreIsNotReadable() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val n = seq++ + val dataFile = File(folder.root, "rawmig_$n.preferences_pb") + val keyFile = File(folder.root, "rawmig_$n.key") + val subject = + EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath( + scope = scope, + migrations = listOf(CopyOnceMigration("probe") { out -> out[key] = "plaintext-secret" }), + produceFile = { dataFile.toOkioPath() }, + ), + SecretEncryption(keyFile), + scope = scope, + ) + + assertTrue( + "a raw-migrated value must not read back as if it were valid", + runCatching { subject.get(key) }.isFailure, + ) + scope.cancel() + } } From 7d9720b3ce75518aa7675739d99dcf4efdfa7e6f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 21:14:45 +0000 Subject: [PATCH 11/57] feat: dual-store the account roster MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finishes 5c. The account index — which accounts exist, which one is in front — moves out of the global `secret_keeper` EncryptedSharedPreferences file into an encrypted DataStore, on the same terms as the keys and secrets before it: both stores written, new store preferred on read, nothing deleted. This is the most consequential piece of the preference layer to get wrong. Every private key can be perfectly intact and, if the roster reads empty, the app still opens as a fresh install with no route back to the accounts sitting on disk. So the legacy file wins every tie: - an unreadable store falls back rather than reporting no accounts; - a migration that could not be written falls back; - a migrated-but-empty list falls back, because "[]" and "never populated" are indistinguishable here and only one is safe to act on. Only a genuinely empty legacy file reads as no accounts. Accessors are per-field rather than one group: the app writes the current account and the account list on separate paths, and a group save would make each clobber the other's value. Encrypted because it was encrypted before. The contents are npubs and two booleans rather than key material, but they are the list of identities on this device. clear() still matches the legacy behaviour when the last account is removed, including dropping the migrated marker — with the legacy file cleared too there is nothing left to copy, and a marker left set would claim a migration whose source no longer exists. 10 tests against a fake store, one per branch above, plus the fresh install that must not invent an account. androidx.security.crypto is still declared in :amethyst. Every reader of the legacy files now prefers a DataStore, but the legacy writes remain so a rollback works, and dropping them is the next release's job. Not verified here, and this is the one to hold: no device. Before the legacy files are deleted, a real device should confirm that an upgraded install still lists its accounts, opens the right one, survives a force-stop, and that adding and removing an account still behaves. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../vitorpamplona/amethyst/AccountRoster.kt | 182 +++++++++++++++ .../amethyst/LocalPreferences.kt | 20 +- .../amethyst/AccountRosterTest.kt | 209 ++++++++++++++++++ .../model/preferences/AccountRosterStore.kt | 89 ++++++++ 4 files changed, 491 insertions(+), 9 deletions(-) create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt create mode 100644 amethyst/src/test/java/com/vitorpamplona/amethyst/AccountRosterTest.kt create mode 100644 commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountRosterStore.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt new file mode 100644 index 0000000000..666e508b11 --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import com.vitorpamplona.amethyst.commons.model.preferences.AccountRosterStore +import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption +import com.vitorpamplona.quartz.utils.Log +import okio.Path.Companion.toOkioPath +import java.io.File + +/** + * The slice of the roster store this needs. + * + * An interface so the fallback decisions below are testable without an + * AndroidKeyStore, which no unit test can reach. + */ +interface RosterStorage { + suspend fun hasMigrated(): Boolean + + suspend fun markMigrated() + + suspend fun currentAccount(): String? + + suspend fun setCurrentAccount(npub: String?) + + suspend fun allAccountInfoJson(): String? + + suspend fun setAllAccountInfoJson(json: String?) + + suspend fun clear() +} + +/** [RosterStorage] over the real encrypted store. */ +class EncryptedRosterStorage( + private val store: AccountRosterStore, +) : RosterStorage { + override suspend fun hasMigrated() = store.hasMigrated() + + override suspend fun markMigrated() = store.markMigrated() + + override suspend fun currentAccount() = store.currentAccount() + + override suspend fun setCurrentAccount(npub: String?) = store.setCurrentAccount(npub) + + override suspend fun allAccountInfoJson() = store.allAccountInfoJson() + + override suspend fun setAllAccountInfoJson(json: String?) = store.setAllAccountInfoJson(json) + + override suspend fun clear() = store.clear() +} + +/** + * Moves the account index — which accounts exist, which one is in front — out + * of the global `secret_keeper` EncryptedSharedPreferences file, on the same + * terms as the keys and secrets before it: both stores written, new store + * preferred on read, nothing deleted. + * + * This one is the most consequential to get wrong. Every private key can be + * perfectly intact and, if the roster reads empty, the app still opens as a + * fresh install with no way back to the accounts that are sitting on disk. + * So a read that fails or comes back empty falls through to the legacy file + * rather than being taken at face value. + */ +class AccountRoster( + private val store: RosterStorage, +) { + companion object { + private const val TAG = "AccountRoster" + } + + /** + * Runs the one-off copy if it has not run, and reports whether the new + * store can be trusted for this read. + * + * Returns false when anything goes wrong, which sends the caller to the + * legacy file. + */ + private suspend fun ready( + legacyCurrent: () -> String?, + legacyAll: () -> String?, + ): Boolean = + try { + if (!store.hasMigrated()) { + store.setCurrentAccount(legacyCurrent()) + store.setAllAccountInfoJson(legacyAll()) + // Marker last: a crash midway leaves this unmigrated, so the + // next read copies again rather than trusting a half-written + // roster. + store.markMigrated() + } + true + } catch (e: Exception) { + Log.w(TAG, "Could not prepare the roster store; using the legacy file", e) + false + } + + suspend fun currentAccount( + legacyCurrent: () -> String?, + legacyAll: () -> String?, + ): String? { + if (!ready(legacyCurrent, legacyAll)) return legacyCurrent() + + return try { + store.currentAccount() ?: legacyCurrent() + } catch (e: Exception) { + Log.w(TAG, "Could not read the current account; using the legacy file", e) + legacyCurrent() + } + } + + /** + * The saved-account list as JSON. + * + * An empty or absent value falls through to the legacy file rather than + * being reported as "no accounts": the two are indistinguishable here, and + * only one of them is safe to act on. + */ + suspend fun allAccountInfoJson( + legacyCurrent: () -> String?, + legacyAll: () -> String?, + ): String? { + if (!ready(legacyCurrent, legacyAll)) return legacyAll() + + return try { + store.allAccountInfoJson()?.takeIf { it.isNotBlank() && it != "[]" } ?: legacyAll() + } catch (e: Exception) { + Log.w(TAG, "Could not read the saved accounts; using the legacy file", e) + legacyAll() + } + } + + suspend fun mirrorCurrentAccount(npub: String?) = guard { store.setCurrentAccount(npub) } + + suspend fun mirrorAllAccountInfoJson(json: String?) = guard { store.setAllAccountInfoJson(json) } + + /** Matches the legacy `clear()` on the global file when the last account goes. */ + suspend fun clear() = guard { store.clear() } + + private suspend fun guard(block: suspend () -> Unit) { + try { + block() + } catch (e: Exception) { + // Never fatal: the legacy file is still written and still read. + Log.w(TAG, "Could not write the roster store", e) + } + } +} + +val accountRoster: AccountRoster by lazy { + val context = Amethyst.instance.appContext + AccountRoster( + EncryptedRosterStorage( + AccountRosterStore( + PreferenceDataStoreFactory.createWithPath( + scope = Amethyst.instance.applicationIOScope, + produceFile = { File(context.filesDir, "datastore/roster.preferences_pb").toOkioPath() }, + ), + SecretEncryption(), + Amethyst.instance.applicationIOScope, + ), + ), + ) +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 726297aa1a..37e72033e3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -467,11 +467,15 @@ object LocalPreferences { globalSettingsPrefs().edit { putBoolean(PrefKeys.NOTIFICATION_SERVICE_ENABLED, enabled) } } + private fun legacyCurrentAccount(): String? = encryptedPreferences().getString(PrefKeys.CURRENT_ACCOUNT, null) + + private fun legacyAllAccountInfo(): String? = encryptedPreferences().getString(PrefKeys.ALL_ACCOUNT_INFO, null) + suspend fun currentAccount(): String? { if (currentAccount == null) { currentAccount = withContext(Dispatchers.IO) { - encryptedPreferences().getString(PrefKeys.CURRENT_ACCOUNT, null) + accountRoster.currentAccount(::legacyCurrentAccount, ::legacyAllAccountInfo) } } return currentAccount @@ -482,12 +486,14 @@ object LocalPreferences { currentAccount = null withContext(Dispatchers.IO) { encryptedPreferences().edit { clear() } + accountRoster.clear() } } else if (currentAccount != info.npub) { currentAccount = info.npub if (!info.isTransient) { withContext(Dispatchers.IO) { encryptedPreferences().edit { putString(PrefKeys.CURRENT_ACCOUNT, info.npub) } + accountRoster.mirrorCurrentAccount(info.npub) } } } @@ -507,7 +513,7 @@ object LocalPreferences { withContext(Dispatchers.IO) { with(encryptedPreferences()) { val newSystemOfAccounts = - getString(PrefKeys.ALL_ACCOUNT_INFO, "[]")?.let { + (accountRoster.allAccountInfoJson(::legacyCurrentAccount, ::legacyAllAccountInfo) ?: "[]").let { JsonMapper.fromJson>(it) } @@ -545,13 +551,9 @@ object LocalPreferences { if (savedAccounts != accounts) { savedAccounts.emit(accounts) - encryptedPreferences() - .edit { - putString( - PrefKeys.ALL_ACCOUNT_INFO, - JsonMapper.toJson(accounts.filter { !it.isTransient }), - ) - } + val json = JsonMapper.toJson(accounts.filter { !it.isTransient }) + encryptedPreferences().edit { putString(PrefKeys.ALL_ACCOUNT_INFO, json) } + accountRoster.mirrorAllAccountInfoJson(json) } } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/AccountRosterTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/AccountRosterTest.kt new file mode 100644 index 0000000000..94f5cb65b5 --- /dev/null +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/AccountRosterTest.kt @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * The account index. + * + * Every branch here decides whether the app opens to the user's accounts or to + * an empty screen. A read that comes back empty is indistinguishable from a + * store that has not been populated, and only one of those is safe to act on — + * so the legacy file wins every tie. + */ +class AccountRosterTest { + private val accountsJson = """[{"npub":"npub1a","hasPrivKey":true}]""" + + private class FakeStorage( + var migrated: Boolean = false, + var current: String? = null, + var allJson: String? = null, + var failReads: Boolean = false, + var failWrites: Boolean = false, + ) : RosterStorage { + var cleared = 0 + + override suspend fun hasMigrated(): Boolean { + if (failReads) throw IllegalStateException("unreadable") + return migrated + } + + override suspend fun markMigrated() { + if (failWrites) throw IllegalStateException("unwritable") + migrated = true + } + + override suspend fun currentAccount(): String? { + if (failReads) throw IllegalStateException("unreadable") + return current + } + + override suspend fun setCurrentAccount(npub: String?) { + if (failWrites) throw IllegalStateException("unwritable") + current = npub + } + + override suspend fun allAccountInfoJson(): String? { + if (failReads) throw IllegalStateException("unreadable") + return allJson + } + + override suspend fun setAllAccountInfoJson(json: String?) { + if (failWrites) throw IllegalStateException("unwritable") + allJson = json + } + + override suspend fun clear() { + cleared++ + migrated = false + current = null + allJson = null + } + } + + private fun legacy( + current: String? = "npub1a", + all: String? = accountsJson, + ) = Pair<() -> String?, () -> String?>({ current }, { all }) + + // ── first run after the upgrade ─────────────────────────────────── + + @Test + fun theLegacyRosterIsCopiedOnFirstRead() = + runTest { + val store = FakeStorage() + val (c, a) = legacy() + + assertEquals("npub1a", AccountRoster(store).currentAccount(c, a)) + + assertTrue(store.migrated) + assertEquals("npub1a", store.current) + assertEquals(accountsJson, store.allJson) + } + + @Test + fun anAlreadyMigratedRosterIsReadFromTheNewStore() = + runTest { + val store = FakeStorage(migrated = true, current = "npub1z", allJson = """[{"npub":"npub1z"}]""") + val (c, a) = legacy() + + assertEquals("npub1z", AccountRoster(store).currentAccount(c, a)) + assertEquals("""[{"npub":"npub1z"}]""", AccountRoster(store).allAccountInfoJson(c, a)) + } + + // ── the failure modes that empty the account list ───────────────── + + /** An unreadable store must never present as "no accounts". */ + @Test + fun anUnreadableStoreFallsBackToLegacy() = + runTest { + val store = FakeStorage(failReads = true) + val (c, a) = legacy() + + assertEquals("npub1a", AccountRoster(store).currentAccount(c, a)) + assertEquals(accountsJson, AccountRoster(store).allAccountInfoJson(c, a)) + } + + /** Nor must a migration that could not be written. */ + @Test + fun aFailedMigrationFallsBackToLegacy() = + runTest { + val store = FakeStorage(failWrites = true) + val (c, a) = legacy() + + assertEquals("npub1a", AccountRoster(store).currentAccount(c, a)) + assertEquals(accountsJson, AccountRoster(store).allAccountInfoJson(c, a)) + } + + /** + * A migrated-but-empty list is indistinguishable from one that was never + * populated, so it falls through rather than being taken as truth. + */ + @Test + fun anEmptyAccountListFallsBackToLegacy() = + runTest { + val (c, a) = legacy() + + assertEquals(accountsJson, AccountRoster(FakeStorage(migrated = true, allJson = "[]")).allAccountInfoJson(c, a)) + assertEquals(accountsJson, AccountRoster(FakeStorage(migrated = true, allJson = "")).allAccountInfoJson(c, a)) + assertEquals(accountsJson, AccountRoster(FakeStorage(migrated = true, allJson = null)).allAccountInfoJson(c, a)) + } + + @Test + fun anAbsentCurrentAccountFallsBackToLegacy() = + runTest { + val (c, a) = legacy() + + assertEquals("npub1a", AccountRoster(FakeStorage(migrated = true, current = null)).currentAccount(c, a)) + } + + /** A genuinely fresh install has nothing anywhere, and must not invent an account. */ + @Test + fun aFreshInstallReadsAsNothing() = + runTest { + val (c, a) = legacy(current = null, all = null) + + assertNull(AccountRoster(FakeStorage()).currentAccount(c, a)) + assertNull(AccountRoster(FakeStorage()).allAccountInfoJson(c, a)) + } + + // ── writes ──────────────────────────────────────────────────────── + + @Test + fun mirroredWritesReachTheStore() = + runTest { + val store = FakeStorage() + val subject = AccountRoster(store) + + subject.mirrorCurrentAccount("npub1b") + subject.mirrorAllAccountInfoJson(accountsJson) + + assertEquals("npub1b", store.current) + assertEquals(accountsJson, store.allJson) + } + + @Test + fun clearingWipesTheRoster() = + runTest { + val store = FakeStorage(migrated = true, current = "npub1a", allJson = accountsJson) + + AccountRoster(store).clear() + + assertEquals(1, store.cleared) + assertNull(store.current) + assertNull(store.allJson) + } + + /** A write failure must never fail the save: the legacy file is still written. */ + @Test + fun aWriteFailureIsSwallowed() = + runTest { + val subject = AccountRoster(FakeStorage(failWrites = true)) + + subject.mirrorCurrentAccount("npub1b") + subject.mirrorAllAccountInfoJson(accountsJson) + } +} diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountRosterStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountRosterStore.kt new file mode 100644 index 0000000000..2090fa600f --- /dev/null +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountRosterStore.kt @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.CoroutineScope + +/** + * Which accounts this installation holds, and which one is in front. + * + * Not per-account — this is the index that has to be read before any account + * can be. Losing it is the worst failure in the preference layer: every key + * survives untouched, and the app still opens as if freshly installed. + * + * Encrypted because it was encrypted before. The contents are npubs and two + * booleans rather than key material, but they are the list of identities on + * this device, and moving them to a plain store would be a quiet downgrade. + * + * Accessors are per-field rather than one group: the app writes the current + * account and the account list on separate paths, and a group save would make + * each one clobber the other's value. + */ +class AccountRosterStore( + store: DataStore, + encryption: SecretEncryption, + scope: CoroutineScope, +) { + companion object { + private val currentAccountKey = stringPreferencesKey("currently_logged_in_account") + private val allAccountInfoKey = stringPreferencesKey("all_saved_accounts_info") + private val migratedKey = stringPreferencesKey("migrated.roster") + } + + private val encrypted = EncryptedDataStore(store, encryption, scope) + + /** True once the one-off copy out of the legacy encrypted file has run. */ + suspend fun hasMigrated(): Boolean = encrypted.get(migratedKey) != null + + suspend fun markMigrated() { + encrypted.save(migratedKey, "true") + } + + suspend fun currentAccount(): String? = encrypted.get(currentAccountKey) + + suspend fun setCurrentAccount(npub: String?) { + if (npub != null) encrypted.save(currentAccountKey, npub) else encrypted.remove(currentAccountKey) + } + + /** The account list as the JSON the app already stores; parsing stays at the call site. */ + suspend fun allAccountInfoJson(): String? = encrypted.get(allAccountInfoKey) + + suspend fun setAllAccountInfoJson(json: String?) { + if (json != null) encrypted.save(allAccountInfoKey, json) else encrypted.remove(allAccountInfoKey) + } + + /** + * Wipes the roster, matching the legacy `clear()` on the global file when + * the last account is removed. + * + * The migrated marker goes too: with the legacy file cleared as well, there + * is nothing left to copy, and leaving the marker set would be a claim + * about a migration whose source no longer exists. + */ + suspend fun clear() { + encrypted.remove(currentAccountKey) + encrypted.remove(allAccountInfoKey) + encrypted.remove(migratedKey) + } +} From 37664390021b375fa1b4bcb9a36814df41e9807b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 21:28:22 +0000 Subject: [PATCH 12/57] docs: record why EncryptedStorage cannot be deleted, and what is left MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrects a claim this series repeated and never checked. Several commit messages and comments said the legacy files could be dropped "once this path has shipped and held". That is wrong, and the mistake matters. Every migration in the preference layer is lazy: it reads the legacy store when it runs, not when the app is installed. Nine come through EncryptedStorage — the seven CopyOnceMigrations plus the key, secret and roster stores. Only the Cashu counters and calendar reminders read a plain source and would survive its removal. So deleting EncryptedStorage does not only affect installs that have yet to upgrade. It strands anyone who SKIPS the release introducing the new stores: a pre-migration build upgrading straight to a post-deletion build runs its migration against a reader that no longer exists, and every key, account, wallet and setting stays encrypted on disk with nothing able to read it. The app opens as a fresh install. Auto-update off, the F-Droid cadence and restoring from a backup all skip releases. The reader is therefore permanent, and androidx.security.crypto stays with it — an unmaintained-library risk rather than an active vulnerability, and far cheaper than stranding users. What a later release can retire is the legacy *write*. An audit of what is actually migrated also found the files are not ready to be deleted even for users who do upgrade in order. Seven keys are still read only from the legacy files, and one is fatal: without NOSTR_PUBKEY, loadAccountConfigFromEncryptedStorage returns null and the account disappears even though its private key migrated fine. The rest — the two external-signer keys, HAS_BACKED_UP_KEYS, LOCAL_RELAY_SERVERS, OPEN_BACKUP_CONFLICTS and the global SHARED_SETTINGS — lose settings rather than accounts. PENDING_ATTESTATIONS, NOTIF_GLOBAL_TO_CURATED_MIGRATED and LAST_READ_PER_ROUTE are accepted losses and stay unmigrated. That makes four accessors added to NotificationPrefsStore in the settings-group commit permanently dead — they were written, documented as deliberately special-cased, and never called. Removed, with their tests, rather than left looking like a feature. amethyst/plans/2026-09-23-encrypted-storage-retirement.md carries the constraint, the outstanding keys, the accepted losses, and the device checks none of this has had. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- ...2026-09-23-encrypted-storage-retirement.md | 78 +++++++++++++++++++ .../vitorpamplona/amethyst/AccountKeyStore.kt | 7 +- .../vitorpamplona/amethyst/AccountRoster.kt | 3 + .../amethyst/AccountSecretsStore.kt | 3 + .../amethyst/EncryptedStorage.kt | 33 ++++++++ .../model/preferences/CopyOnceMigration.kt | 10 ++- .../preferences/NotificationPrefsStore.kt | 34 ++------ .../preferences/AccountSettingStoresTest.kt | 28 ------- 8 files changed, 135 insertions(+), 61 deletions(-) create mode 100644 amethyst/plans/2026-09-23-encrypted-storage-retirement.md diff --git a/amethyst/plans/2026-09-23-encrypted-storage-retirement.md b/amethyst/plans/2026-09-23-encrypted-storage-retirement.md new file mode 100644 index 0000000000..4a6ff1ab2f --- /dev/null +++ b/amethyst/plans/2026-09-23-encrypted-storage-retirement.md @@ -0,0 +1,78 @@ +# Retiring EncryptedStorage + +Status: **blocked** — the legacy files cannot be deleted yet, and the reader +can never be. + +## The constraint + +Every migration in the preference layer is *lazy*: it reads the legacy store +when it runs, not when the app is installed. Nine come through +`EncryptedStorage` — the seven `CopyOnceMigration`s in `LocalPreferences` plus +the key, secret and roster stores. Only the Cashu counters and calendar +reminders read a plain (non-encrypted) source and would survive its removal. + +So deleting `EncryptedStorage` does not merely affect installs that have not +upgraded yet. It strands anyone who **skips** the release introducing the new +stores: a pre-migration build upgrading straight to a post-deletion build runs +its migration against a reader that no longer exists. Keys, accounts, wallets +and settings stay encrypted on disk with nothing able to read them, and the app +opens as a fresh install. Auto-update off, the F-Droid cadence and restoring +from a backup all skip releases. + +**The reader is permanent.** What a later release can retire is the legacy +*write*, which stops new data landing there while old data stays readable. +`androidx.security.crypto` has to stay for as long as the reader does. That is +an unmaintained-library risk, not an active vulnerability, and a much smaller +cost than stranding users. + +## Outstanding before any legacy file is deleted + +Deletion is only safe for an account whose every key has a new home. These do +not yet, and are still read from the legacy files: + +| key | scope | if deleted today | +|---|---|---| +| `NOSTR_PUBKEY` | per-account | **fatal** — `loadAccountConfigFromEncryptedStorage` returns null without it, so the account disappears even though its private key migrated | +| `LOGIN_WITH_EXTERNAL_SIGNER` | per-account | external-signer accounts stop resolving their signer | +| `SIGNER_PACKAGE_NAME` | per-account | as above | +| `HAS_BACKED_UP_KEYS` | per-account | the key-backup nag returns for everyone | +| `LOCAL_RELAY_SERVERS` | per-account | silently lost | +| `OPEN_BACKUP_CONFLICTS` | per-account | silently lost | +| `SHARED_SETTINGS` | global | UI settings reset | + +## Deliberately not migrated + +Three keys are accepted losses rather than outstanding work — the cost of +losing them is one-off and small, and carrying them is not worth the code: + +| key | what is lost | +|---|---| +| `PENDING_ATTESTATIONS` | queued OTS attestations are not published | +| `NOTIF_GLOBAL_TO_CURATED_MIGRATED` | the one-shot notification filter migration runs once more | +| `LAST_READ_PER_ROUTE` | every feed reads as unread once | + +`NotificationPrefsStore` was given `hasRunGlobalToCuratedMigration`, +`markGlobalToCuratedMigrated`, `lastReadPerRoute` and `saveLastReadPerRoute` +for the last two of these. Nothing ever called them, and now nothing will; +they have been removed rather than left looking like a feature. + +`USE_PROXY` and `PROXY_PORT` need nothing either: they are only ever `remove`d, +being cleaned up rather than read. + +## Order of work + +1. Migrate the seven keys above, on the same dual-store terms as the rest. +2. Add a per-account completeness check — every key present in the new stores — + and only then delete that account's legacy file, after reading back what was + written. +3. Retire the legacy writes once (2) holds for every account on a device. +4. Keep the reader, and the dependency, indefinitely. + +## Verification this needs and has not had + +None of the AndroidKeyStore paths have executed: this environment has no device +or emulator, and `commons` has no Robolectric. What is tested is the decision +logic against fakes. On a real device, before any deletion ships: upgrade an +install holding accounts and confirm they all list; open one and sign; +force-stop and relaunch; add and remove an account; pair a NIP-46 signer; pay +from a wallet. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt index 67dabc7e34..71ac28878d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt @@ -75,8 +75,11 @@ class SecureKeyStorageVault( * credential reset, say — falls back rather than presenting the account as * having no key, which would silently demote it to read-only. * - * Nothing is deleted here. Dropping the legacy file is a later release's job, - * once this path has shipped and held; doing both at once leaves no way back. + * Nothing is deleted here, and the legacy *reader* is permanent — see + * [EncryptedStorage]. The migration is lazy, so an install that skips the + * release introducing this store still needs the old file readable when it + * finally arrives. What a later release can drop is the legacy **write**, once + * every key in that file has a new home; several still do not. * * The two stores cannot legitimately disagree: an npub is derived from its * private key, so the key for a given npub never changes. A mismatch means diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt index 666e508b11..e0a79dcd66 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt @@ -79,6 +79,9 @@ class EncryptedRosterStorage( * fresh install with no way back to the accounts that are sitting on disk. * So a read that fails or comes back empty falls through to the legacy file * rather than being taken at face value. + * + * The legacy reader stays for good; see [EncryptedStorage] for why a lazy + * migration cannot have its source deleted. */ class AccountRoster( private val store: RosterStorage, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt index f7c071219e..6e3c3bcf12 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt @@ -40,6 +40,9 @@ import okio.Path.Companion.toOkioPath * Losing these is recoverable — the user re-pairs a signer or re-adds a wallet * — but it is not something to spend, so a read that fails falls back to the * legacy values rather than reporting the account as having none. + * + * The legacy reader stays for good; see [EncryptedStorage] for why a lazy + * migration cannot have its source deleted. */ class AccountSecretsStore( private val stores: AccountSecretsEncryptedStores, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/EncryptedStorage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/EncryptedStorage.kt index 324abea1e1..2802812ca9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/EncryptedStorage.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/EncryptedStorage.kt @@ -24,6 +24,39 @@ import android.content.Context import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKey +/** + * The legacy encrypted preference files, and a permanent read-only migration + * source. + * + * # This class cannot be deleted + * + * Every migration in the preference layer is *lazy*: it reads the legacy store + * at the moment it runs, not when the app is installed. Nine of them come + * through here — the seven CopyOnceMigrations under LocalPreferences plus the + * key, secret and roster stores. + * + * So deleting this class does not only affect installs that have not upgraded + * yet. It strands anyone who **skips** the release that introduced the new + * stores: they move from a pre-migration build straight to a post-deletion one, + * the migration runs against a reader that no longer exists, and their keys, + * accounts, wallets and settings sit encrypted on disk with nothing able to + * read them. The app opens as a fresh install. That is not rare — auto-update + * off, the F-Droid cadence, or a restore from backup all skip releases. + * + * What *can* go, once the new path has shipped and held, is the legacy + * **writes**. Dropping those stops new data landing here while this stays able + * to read what is already here. The `androidx.security.crypto` dependency has + * to stay for as long as this does; it is an unmaintained-library risk rather + * than an active vulnerability, and a far smaller cost than stranding users. + * + * # Before any legacy file is deleted + * + * Deletion is only safe for an account whose every key has been migrated, and + * that is not yet true — see `amethyst/plans/2026-09-23-encrypted-storage-retirement.md` + * for what is still outstanding. NOSTR_PUBKEY is the one to watch: without it + * `loadAccountConfigFromEncryptedStorage` returns null and the account + * disappears whether or not its private key survived. + */ class EncryptedStorage { companion object { private const val PREFERENCES_NAME = "secret_keeper" diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt index d1a3be3e89..671684e847 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/CopyOnceMigration.kt @@ -34,8 +34,14 @@ import androidx.datastore.preferences.core.booleanPreferencesKey * run twice, and which makes the migration a one-way door: a build that rolls * back to reading the old store finds the user's settings gone. Here a marker * key in the *destination* records that the copy happened, so the source is - * left untouched and a rollback still works. Deleting the legacy data is a - * separate decision, taken once the migration has shipped and held. + * left untouched and a rollback still works. + * + * Deleting the legacy data is a separate and later decision, and a narrower one + * than it looks: because this runs lazily — on the first read of the + * destination, not at install time — the source has to stay *readable* + * indefinitely for installs that skip the release which introduced the + * destination. What can be retired is writing to the source, once nothing + * still reads a key only it holds. * * [copy] receives the destination and writes whatever it has, so a migration * can carry strings, booleans, int and string sets alike. It is only called diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt index e6de5d5c83..6925a61289 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt @@ -25,13 +25,17 @@ import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.emptyPreferences -import androidx.datastore.preferences.core.stringPreferencesKey import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.first import okio.IOException /** * This account's share of the notification settings. + * + * Two keys from the legacy file are deliberately absent: + * `notif_global_to_curated_migrated` and `last_read_per_route` are accepted + * losses rather than migrations — re-running a one-shot filter migration, or + * marking feeds unread once, costs less than the code to carry them. * The global on/off switch is not here — it lives in plain, non-encrypted * storage because the restart layer must read it synchronously from a fresh @@ -55,8 +59,6 @@ class NotificationPrefsStore( val alwaysOnService = booleanPreferencesKey("always_on_notification_service") val showMessagesInNotifications = booleanPreferencesKey("show_messages_in_notifications") val splitNotificationsEnabled = booleanPreferencesKey("split_notifications_enabled") - val globalToCuratedMigrated = booleanPreferencesKey("notif_global_to_curated_migrated") - val lastReadPerRouteJson = stringPreferencesKey("last_read_per_route") } private suspend fun read(): Preferences = @@ -74,32 +76,6 @@ class NotificationPrefsStore( ) } - /** - * Whether the one-shot global-to-curated notification filter migration has - * already run for this account. - * - * Kept out of [NotificationPrefs] and its bulk save because it is not a - * user setting: it is written once, by that migration, and a bulk save that - * carried a stale copy could re-run the migration or wrongly suppress it. - */ - suspend fun hasRunGlobalToCuratedMigration(): Boolean = read()[globalToCuratedMigrated] ?: false - - suspend fun markGlobalToCuratedMigrated() { - store.edit { prefs -> prefs[globalToCuratedMigrated] = true } - } - - /** - * The per-route read markers, as JSON. - * - * Written on its own path as the user reads things, at a different cadence - * from the settings above, so it is not part of [save]. - */ - suspend fun lastReadPerRoute(): String? = read()[lastReadPerRouteJson] - - suspend fun saveLastReadPerRoute(json: String) { - store.edit { prefs -> prefs[lastReadPerRouteJson] = json } - } - /** Writes the whole group in one edit, so a crash cannot half-apply it. */ suspend fun save(value: NotificationPrefs) { store.edit { prefs -> diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt index e15c451da8..e6530895a7 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSettingStoresTest.kt @@ -168,34 +168,6 @@ class AccountSettingStoresTest { assertEquals(false, loaded.splitNotificationsEnabled) } - /** - * The one-shot migration marker is not a user setting, so it must not ride - * along in the bulk save where a stale copy could re-run or suppress it. - */ - @Test - fun theGlobalToCuratedMarkerIsIndependentOfTheBulkSave() = - runTest { - val store = NotificationPrefsStore(raw()) - - assertEquals(false, store.hasRunGlobalToCuratedMigration()) - store.markGlobalToCuratedMigrated() - store.save(NotificationPrefs(alwaysOnService = true)) - - assertEquals("a later bulk save must not clear it", true, store.hasRunGlobalToCuratedMigration()) - assertEquals(true, store.load().alwaysOnService) - } - - @Test - fun lastReadPerRouteIsIndependentOfTheBulkSave() = - runTest { - val store = NotificationPrefsStore(raw()) - - store.saveLastReadPerRoute("""{"home":1}""") - store.save(NotificationPrefs(splitNotificationsEnabled = true)) - - assertEquals("""{"home":1}""", store.lastReadPerRoute()) - } - /** A null string field must clear its key rather than leave the old value behind. */ @Test fun aNullStringFieldClearsTheKey() = From 5e9b6b6f6aa2005a365c0707a6dc7211a18ea504 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 22:13:23 +0000 Subject: [PATCH 13/57] feat: migrate the last legacy preference keys, table-driven MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seven keys still read only from `secret_keeper` now have a home in the new stores. `nostr_pubkey` is the one that mattered: without it `loadAccountConfigFromEncryptedStorage` returns null and the account disappears from the app with its private key sitting safe and unreachable in the key store. Six are per-account and go into a new AccountIdentityStore in the account's plain DataStore — pubkey, external-signer flag and package, local relay servers, open backup conflicts, and the key-backup flag. All of it is public, and the store file is already named after the npub, so nothing is revealed that the file name does not reveal. Unlike the earlier plain-store groups, the legacy writes stay: a rollback that loses a setting is an annoyance, one that loses the pubkey is an empty app. `has_backed_up_keys` is carried but deliberately kept out of the group's save. The nudge writes it on its own, so a group save would carry a value its caller never knew about and put the nudge back in front of everyone. The seventh, `shared_settings`, is global and had already been superseded by UiSharedPreferences' own DataStore — except nothing ever moved the old blob across, and the fallback only fires when the new store *throws*, not when it is merely empty. It now carries a guarded copy: the destination has to be unsaved (no `ui.theme`) before the old blob is written into it, so an install that has been using the new store keeps everything it has. `saveSharedSettings` went with it, having had no callers since that store landed. Migrations are now tables of (legacy name -> Preferences.Key) owned by each store, rather than blocks of hand-written copy lines. The point is not brevity: a block cannot be asked what it covers, so the check that gates deleting the legacy file would have to restate the list, and a key added to one and not the other is exactly the silent hole that makes deletion unsafe. The rename pairs are worth having in one place too — five of DialogDismissalStore's nine keys changed name on the way in, and `relay_auth_trust_my_relays_and_venues` lost its suffix. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/LegacySharedPreferences.kt | 45 ++++ .../model/preferences/UISharedPreferences.kt | 107 +++++--- .../model/preferences/AccountIdentityStore.kt | 153 ++++++++++++ .../model/preferences/DialogDismissalStore.kt | 22 ++ .../model/preferences/FeedVisibilityStore.kt | 13 + .../preferences/LatestEventCacheStore.kt | 14 ++ .../model/preferences/LegacyKeyTable.kt | 150 +++++++++++ .../preferences/NotificationPrefsStore.kt | 11 + .../model/preferences/RelayAuthStore.kt | 18 ++ .../preferences/TopNavFollowListStore.kt | 14 ++ .../model/preferences/UploadSettingsStore.kt | 14 ++ .../model/preferences/AccountSecrets.kt | 57 +++++ .../preferences/AccountIdentityStoreTest.kt | 200 +++++++++++++++ .../model/preferences/LegacyKeyTableTest.kt | 232 ++++++++++++++++++ 14 files changed, 1017 insertions(+), 33 deletions(-) create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/LegacySharedPreferences.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStore.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTable.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStoreTest.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTableTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacySharedPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacySharedPreferences.kt new file mode 100644 index 0000000000..a49c151e9e --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacySharedPreferences.kt @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import android.content.SharedPreferences +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyPreferenceSource + +/** + * [LegacyPreferenceSource] over the `secret_keeper` files. + * + * Every getter reports absence as null rather than as a default, which + * `SharedPreferences` itself cannot do — that distinction is what keeps a + * migration from writing "false" over a key the user never set. + */ +class LegacySharedPreferences( + private val prefs: SharedPreferences, +) : LegacyPreferenceSource { + override fun keys(): Set = prefs.all.keys + + override fun getBoolean(name: String): Boolean? = if (prefs.contains(name)) prefs.getBoolean(name, false) else null + + override fun getString(name: String): String? = prefs.getString(name, null) + + // SharedPreferences hands back the live set and documents that mutating it + // corrupts the file, so this copies before anything downstream can hold it. + override fun getStringSet(name: String): Set? = prefs.getStringSet(name, null)?.toSet() +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt index 5909a5a3a7..4148227f82 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt @@ -27,13 +27,16 @@ import androidx.appcompat.app.AppCompatDelegate import androidx.compose.runtime.Stable import androidx.core.content.getSystemService import androidx.core.os.LocaleListCompat +import androidx.datastore.core.DataMigration import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.MutablePreferences import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import com.vitorpamplona.amethyst.LocalPreferences +import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration import com.vitorpamplona.amethyst.model.AccentColorType import com.vitorpamplona.amethyst.model.BooleanType import com.vitorpamplona.amethyst.model.ConnectivityType @@ -58,7 +61,11 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withContext import kotlin.coroutines.cancellation.CancellationException -val Context.sharedPreferencesDataStore: DataStore by preferencesDataStore(name = "shared_settings") +/** The UI settings store. See [UiSharedPreferences.migrations] for the copy it carries. */ +val Context.sharedPreferencesDataStore: DataStore by preferencesDataStore( + name = "shared_settings", + produceMigrations = { UiSharedPreferences.migrations() }, +) @Stable class UiSharedPreferences( @@ -275,43 +282,77 @@ class UiSharedPreferences( } } + /** + * Writes every UI setting into [preferences]. + * + * Shared by [save] and by the one-shot copy out of the old + * `shared_settings` blob, so the two cannot come to disagree about + * which keys a complete set of UI settings has. + */ + internal fun MutablePreferences.write(sharedSettings: UiSettings) { + val preferences = this + preferences[UI_THEME] = sharedSettings.theme.name + preferences[UI_LANGUAGE] = sharedSettings.preferredLanguage ?: "" + preferences[UI_SHOW_IMAGES] = sharedSettings.automaticallyShowImages.name + preferences[UI_START_PLAYBACK] = sharedSettings.automaticallyStartPlayback.name + preferences[UI_PLAY_VIDEOS] = sharedSettings.automaticallyPlayVideos.name + preferences[UI_SHOW_URL_PREVIEW] = sharedSettings.automaticallyShowUrlPreview.name + preferences[UI_HIDE_NAVIGATION_BARS] = sharedSettings.automaticallyHideNavigationBars.name + preferences[UI_SHOW_PROFILE_PICTURES] = sharedSettings.automaticallyShowProfilePictures.name + preferences[UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR] = sharedSettings.dontShowPushNotificationSelector + preferences[UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS] = sharedSettings.dontAskForNotificationPermissions + preferences[UI_FEATURE_SET] = sharedSettings.featureSet.name + preferences[UI_GALLERY_SET] = sharedSettings.gallerySet.name + preferences[UI_PROPOSE_AI_IMPROVEMENTS] = sharedSettings.automaticallyProposeAiImprovements.name + preferences[UI_USE_TRACKED_BROADCASTS] = sharedSettings.useTrackedBroadcasts.name + preferences[UI_AUTOMATICALLY_CREATE_DRAFTS] = sharedSettings.automaticallyCreateDrafts.name + preferences[UI_SHOW_HOME_NEW_THREADS_TAB] = sharedSettings.showHomeNewThreadsTab + preferences[UI_SHOW_HOME_CONVERSATIONS_TAB] = sharedSettings.showHomeConversationsTab + preferences[UI_SHOW_HOME_EVERYTHING_TAB] = sharedSettings.showHomeEverythingTab + preferences[UI_SHOW_PROFILE_BADGES] = sharedSettings.showProfileBadges + preferences[UI_SHOW_PROFILE_APP_RECOMMENDATIONS] = sharedSettings.showProfileAppRecommendations + preferences[UI_SHOW_PROFILE_ZAP_RECEIVED_FEED] = sharedSettings.showProfileZapReceivedFeed + preferences[UI_SHOW_PROFILE_FOLLOWERS_FEED] = sharedSettings.showProfileFollowersFeed + preferences[UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING] = sharedSettings.dontShowOnchainPublicWarning + preferences[UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT] = sharedSettings.suggestWorkoutsFromHealthConnect.name + preferences[UI_ACCENT_COLOR] = sharedSettings.accentColor.name + preferences[UI_FONT_FAMILY] = sharedSettings.fontFamily.name + preferences[UI_FONT_SIZE] = sharedSettings.fontSize.name + preferences[UI_COMPOSE_SIGNATURE] = sharedSettings.composeSignature + preferences[UI_SHOW_ONCHAIN_WALLET] = sharedSettings.showOnchainWallet + preferences[UI_SHOW_PAYTO_ZAP_CHIP] = sharedSettings.showPayToZapChip + } + + /** + * The one-shot copy out of the single `shared_settings` JSON blob these + * settings used to be kept as, in the global encrypted file. + * + * Guarded, and it has to be. Unlike the per-account migrations, this + * store has been the real home of these settings for a while, so most + * installs already have a populated one — and copying an old blob over + * it would undo every UI change the user has made since. [UI_THEME] is + * the test: [save] writes every key unconditionally and is the only + * writer, so its absence means this store has never been saved, which + * is exactly the install whose settings are still only in the legacy + * file. + */ + internal fun migrations(): List> = + listOf( + CopyOnceMigration("migrated.sharedSettings") { out -> + if (out[UI_THEME] == null) { + withContext(Dispatchers.IO) { + LocalPreferences.loadSharedSettings()?.let { out.write(it) } + } + } + }, + ) + suspend fun save( sharedSettings: UiSettings, context: Context, ) { try { - context.sharedPreferencesDataStore.edit { preferences -> - preferences[UI_THEME] = sharedSettings.theme.name - preferences[UI_LANGUAGE] = sharedSettings.preferredLanguage ?: "" - preferences[UI_SHOW_IMAGES] = sharedSettings.automaticallyShowImages.name - preferences[UI_START_PLAYBACK] = sharedSettings.automaticallyStartPlayback.name - preferences[UI_PLAY_VIDEOS] = sharedSettings.automaticallyPlayVideos.name - preferences[UI_SHOW_URL_PREVIEW] = sharedSettings.automaticallyShowUrlPreview.name - preferences[UI_HIDE_NAVIGATION_BARS] = sharedSettings.automaticallyHideNavigationBars.name - preferences[UI_SHOW_PROFILE_PICTURES] = sharedSettings.automaticallyShowProfilePictures.name - preferences[UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR] = sharedSettings.dontShowPushNotificationSelector - preferences[UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS] = sharedSettings.dontAskForNotificationPermissions - preferences[UI_FEATURE_SET] = sharedSettings.featureSet.name - preferences[UI_GALLERY_SET] = sharedSettings.gallerySet.name - preferences[UI_PROPOSE_AI_IMPROVEMENTS] = sharedSettings.automaticallyProposeAiImprovements.name - preferences[UI_USE_TRACKED_BROADCASTS] = sharedSettings.useTrackedBroadcasts.name - preferences[UI_AUTOMATICALLY_CREATE_DRAFTS] = sharedSettings.automaticallyCreateDrafts.name - preferences[UI_SHOW_HOME_NEW_THREADS_TAB] = sharedSettings.showHomeNewThreadsTab - preferences[UI_SHOW_HOME_CONVERSATIONS_TAB] = sharedSettings.showHomeConversationsTab - preferences[UI_SHOW_HOME_EVERYTHING_TAB] = sharedSettings.showHomeEverythingTab - preferences[UI_SHOW_PROFILE_BADGES] = sharedSettings.showProfileBadges - preferences[UI_SHOW_PROFILE_APP_RECOMMENDATIONS] = sharedSettings.showProfileAppRecommendations - preferences[UI_SHOW_PROFILE_ZAP_RECEIVED_FEED] = sharedSettings.showProfileZapReceivedFeed - preferences[UI_SHOW_PROFILE_FOLLOWERS_FEED] = sharedSettings.showProfileFollowersFeed - preferences[UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING] = sharedSettings.dontShowOnchainPublicWarning - preferences[UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT] = sharedSettings.suggestWorkoutsFromHealthConnect.name - preferences[UI_ACCENT_COLOR] = sharedSettings.accentColor.name - preferences[UI_FONT_FAMILY] = sharedSettings.fontFamily.name - preferences[UI_FONT_SIZE] = sharedSettings.fontSize.name - preferences[UI_COMPOSE_SIGNATURE] = sharedSettings.composeSignature - preferences[UI_SHOW_ONCHAIN_WALLET] = sharedSettings.showOnchainWallet - preferences[UI_SHOW_PAYTO_ZAP_CHIP] = sharedSettings.showPayToZapChip - } + context.sharedPreferencesDataStore.edit { preferences -> preferences.write(sharedSettings) } } catch (e: Exception) { if (e is CancellationException) throw e // Log any errors that occur while reading the DataStore. diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStore.kt new file mode 100644 index 0000000000..f562540913 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStore.kt @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import androidx.datastore.preferences.core.stringSetPreferencesKey +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first +import okio.IOException + +/** + * Who this account is, and the handful of per-account settings that sat beside + * that in the legacy file. + * + * [pubKeyHex] is the one value in the whole preference layer that the account + * cannot be loaded without: the loader returns null the moment it is missing, + * and the account disappears from the app even with its private key safe in the + * key store. Everything here is public — a pubkey, a signer's package name, the + * relay URLs the user typed — and the store file is already named after the + * account's npub, so keeping it in the plain per-account store reveals nothing + * the file name does not. + * + * `hasBackedUpKeys` is deliberately *not* a field here. It is written on its + * own, by the key-backup nudge, at moments unrelated to any of these; folding + * it into the group would mean every [AccountIdentityStore.save] carried a + * value its caller never knew about and would flip the nudge back on. It gets + * its own accessors below. + */ +data class AccountIdentity( + val pubKeyHex: String? = null, + val loginWithExternalSigner: Boolean = false, + val externalSignerPackageName: String? = null, + val localRelayServers: Set = emptySet(), + val openBackupConflictsJson: String? = null, +) + +/** Reads and writes [AccountIdentity] in the account's DataStore. */ +class AccountIdentityStore( + private val store: DataStore, +) { + companion object { + val pubKeyHex = stringPreferencesKey("nostr_pubkey") + val loginWithExternalSigner = booleanPreferencesKey("login_with_external_signer") + val externalSignerPackageName = stringPreferencesKey("signer_package_name") + val localRelayServers = stringSetPreferencesKey("localRelayServers") + val openBackupConflictsJson = stringPreferencesKey("openBackupConflicts") + val hasBackedUpKeys = booleanPreferencesKey("has_backed_up_keys") + + /** + * What the `secret_keeper_` file called these, for the one-shot copy. + * + * `has_backed_up_keys` is carried here even though it is not part of + * [AccountIdentity]: the copy is per *key*, not per group, and losing + * it would put the "back up your key" nudge back in front of every + * user who had already dismissed it. + */ + val legacyTable = + LegacyKeyTable( + "migrated.identity", + listOf( + LegacyStringKey("nostr_pubkey", pubKeyHex), + LegacyBooleanKey("login_with_external_signer", loginWithExternalSigner), + LegacyStringKey("signer_package_name", externalSignerPackageName), + LegacyStringSetKey("localRelayServers", localRelayServers), + LegacyStringKey("openBackupConflicts", openBackupConflictsJson), + LegacyBooleanKey("has_backed_up_keys", hasBackedUpKeys), + ), + ) + } + + private suspend fun read(): Preferences = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .first() + + suspend fun load(): AccountIdentity { + val prefs = read() + + return AccountIdentity( + pubKeyHex = prefs[pubKeyHex], + loginWithExternalSigner = prefs[loginWithExternalSigner] ?: false, + externalSignerPackageName = prefs[externalSignerPackageName], + localRelayServers = prefs[localRelayServers] ?: emptySet(), + openBackupConflictsJson = prefs[openBackupConflictsJson], + ) + } + + /** + * Writes the whole group in one edit, so a crash cannot half-apply it. + * + * The removes matter as much as the puts and mirror the legacy block + * exactly: an account that drops its external signer, clears its local + * relays or answers its last backup conflict has to end up with those keys + * *absent*, not holding yesterday's value. + */ + suspend fun save(value: AccountIdentity) { + store.edit { prefs -> + value.pubKeyHex.let { if (it != null) prefs[pubKeyHex] = it else prefs.remove(pubKeyHex) } + prefs[loginWithExternalSigner] = value.loginWithExternalSigner + value.externalSignerPackageName.let { if (it != null) prefs[externalSignerPackageName] = it else prefs.remove(externalSignerPackageName) } + value.localRelayServers.let { if (it.isNotEmpty()) prefs[localRelayServers] = it else prefs.remove(localRelayServers) } + value.openBackupConflictsJson.let { if (it != null) prefs[openBackupConflictsJson] = it else prefs.remove(openBackupConflictsJson) } + } + } + + /** + * True unless a freshly generated account still has its key only in the + * app. Absent means true: every account logged in from an existing nsec, + * bunker or external signer already holds its key elsewhere and must not + * be nudged. + */ + suspend fun hasBackedUpKeys(): Boolean = read()[hasBackedUpKeys] ?: true + + suspend fun setHasBackedUpKeys(value: Boolean) { + store.edit { prefs -> prefs[hasBackedUpKeys] = value } + } +} + +/** + * Falls back to [legacy] as a whole when this identity cannot be used. + * + * The test is [AccountIdentity.pubKeyHex], and the fallback is all-or-nothing + * on purpose. A missing pubkey means the store answered from + * `emptyPreferences()` — its file is unreadable, or the one-shot copy never + * ran — and in that state the other fields are equally untrustworthy: an + * absent boolean and a `false` one are the same value here, so merging field + * by field would quietly report an external-signer account as a local one. + * A pubkey present means the store is live and authoritative. + */ +fun AccountIdentity.orIfUnusable(legacy: () -> AccountIdentity): AccountIdentity = if (pubKeyHex != null) this else legacy() diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt index 870a2bc2c1..5a53bfdacd 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DialogDismissalStore.kt @@ -68,6 +68,28 @@ class DialogDismissalStore( val mutedPublicChats = stringSetPreferencesKey("mutedPublicChats") val hasDonatedInVersion = stringSetPreferencesKey("hasDonatedInVersion") val viewedPollResultNoteIdsJson = stringPreferencesKey("viewedPollResultNoteIds") + + /** + * What the `secret_keeper_` file called these, for the one-shot copy. + * + * Five of the nine were renamed on the way in, so the pairs below are + * not derivable from either side alone. + */ + val legacyTable = + LegacyKeyTable( + "migrated.dialogDismissal", + listOf( + LegacyBooleanKey("hide_delete_request_dialog", hideDeleteRequestDialog), + LegacyBooleanKey("hide_block_alert_dialog", hideBlockAlertDialog), + LegacyBooleanKey("hide_nip24_warning_dialog", hideNip17WarningDialog), + LegacyBooleanKey("hideCommunityRulesViolations", hideCommunityRulesViolations), + LegacyStringSetKey("dismissed_poll_note_ids", dismissedPollNoteIds), + LegacyStringSetKey("dismissed_channel_invites", dismissedChannelInvites), + LegacyStringSetKey("muted_public_chats", mutedPublicChats), + LegacyStringSetKey("has_donated_in_version", hasDonatedInVersion), + LegacyStringKey("viewed_poll_result_note_ids", viewedPollResultNoteIdsJson), + ), + ) } suspend fun load(): DialogDismissal { diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt index f99321a914..a72a628c97 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/FeedVisibilityStore.kt @@ -59,6 +59,19 @@ class FeedVisibilityStore( val relayGroupViewMode = stringPreferencesKey("relay_group_view_mode") val concordViewMode = stringPreferencesKey("concord_view_mode") val callsEnabled = booleanPreferencesKey("calls_enabled") + + /** What the `secret_keeper_` file called these, for the one-shot copy. */ + val legacyTable = + LegacyKeyTable( + "migrated.feedVisibility", + listOf( + LegacyStringKey("disabled_chat_feeds", disabledChatFeeds), + LegacyStringKey("disabled_home_feed_types", disabledHomeFeedTypes), + LegacyStringKey("relay_group_view_mode", relayGroupViewMode), + LegacyStringKey("concord_view_mode", concordViewMode), + LegacyBooleanKey("calls_enabled", callsEnabled), + ), + ) } suspend fun load(): FeedVisibility { diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt index b86f434ee0..f743239662 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LatestEventCacheStore.kt @@ -84,6 +84,20 @@ enum class LatestEventSlot( class LatestEventCacheStore( private val store: DataStore, ) { + companion object { + /** + * The one-shot copy out of `secret_keeper_`. + * + * Both names come off the same enum entry, so this table cannot drift + * from the slots the store actually reads. + */ + val legacyTable = + LegacyKeyTable( + "migrated.latestEvents", + LatestEventSlot.entries.map { LegacyStringKey(it.prefKey, it.key) }, + ) + } + /** Only the slots actually present; an absent slot means nothing was cached. */ suspend fun load(): Map { val prefs = diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTable.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTable.kt new file mode 100644 index 0000000000..6d4e275996 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTable.kt @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataMigration +import androidx.datastore.preferences.core.MutablePreferences +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO +import kotlinx.coroutines.withContext + +/** + * The older preference file a migration reads from, reduced to the four calls + * a migration makes. + * + * An interface because the legacy store is an Android + * `EncryptedSharedPreferences`, which commonMain cannot name — and because a + * test wants to hand a migration a map rather than a file. + * + * Every getter returns null for an absent key rather than a default, so a + * migration can tell "the user turned this off" from "the user never touched + * it" — the distinction the whole copy depends on, since a key left absent + * keeps reading as unset and falls back to its own default. + */ +interface LegacyPreferenceSource { + /** Every key the file holds, used to spot ones no migration claims. */ + fun keys(): Set + + fun getBoolean(name: String): Boolean? + + fun getString(name: String): String? + + fun getStringSet(name: String): Set? +} + +/** + * One legacy key, and the [Preferences.Key] it lands on. + * + * The legacy name is a compatibility surface: it is the string the Android app + * has written since its first release, and it is frequently *not* the new key's + * name (`has_donated_in_version` became `hasDonatedInVersion`, and five of + * [DialogDismissalStore]'s nine keys were renamed like that). So both names are + * spelled out here rather than derived from one another. + */ +sealed class LegacyKey( + val legacyName: String, + val key: Preferences.Key, +) { + abstract fun read(source: LegacyPreferenceSource): T? + + /** Absent stays absent — see [LegacyPreferenceSource]. */ + fun copyInto( + source: LegacyPreferenceSource, + out: MutablePreferences, + ) { + read(source)?.let { out[key] = it } + } +} + +class LegacyBooleanKey( + legacyName: String, + key: Preferences.Key, +) : LegacyKey(legacyName, key) { + override fun read(source: LegacyPreferenceSource) = source.getBoolean(legacyName) +} + +class LegacyStringKey( + legacyName: String, + key: Preferences.Key, +) : LegacyKey(legacyName, key) { + override fun read(source: LegacyPreferenceSource) = source.getString(legacyName) +} + +class LegacyStringSetKey( + legacyName: String, + key: Preferences.Key>, +) : LegacyKey>(legacyName, key) { + override fun read(source: LegacyPreferenceSource) = source.getStringSet(legacyName) +} + +/** + * The keys one migration carries, as data. + * + * The point of the table is that the copy and the later *check* that the copy + * happened read from the same list. A migration written as a block of + * `if (legacy.contains(k)) out[key] = legacy.getBoolean(k)` lines cannot be + * asked what it covers, so anything verifying it has to restate the list — and + * a key added to one copy and not the other is exactly the silent hole that + * makes deleting the legacy file unsafe. + * + * @param markerName the key recording, in the destination, that this copy has + * run. Distinct per table, so several can run against one store. + */ +class LegacyKeyTable( + val markerName: String, + val keys: List>, +) { + private val marker = booleanPreferencesKey(markerName) + + val legacyNames: Set = keys.mapTo(mutableSetOf()) { it.legacyName } + + /** + * Builds the one-shot copy. + * + * [openSource] is called only when the migration actually runs, so opening + * the legacy file is not a cost paid on every launch — decrypting an + * `EncryptedSharedPreferences` is not free. + */ + fun migration(openSource: () -> LegacyPreferenceSource): DataMigration = + CopyOnceMigration(markerName) { out -> + withContext(Dispatchers.IO) { + val source = openSource() + keys.forEach { it.copyInto(source, out) } + } + } + + /** + * Whether the copy has run against [destination]. + * + * This, and not a value-by-value comparison, is what says the legacy keys + * made it across. [CopyOnceMigration] writes the values and this marker as + * one `Preferences`, which DataStore commits atomically, so the marker + * being set means every value the copy read was written with it. + * + * A comparison would be the wrong question anyway: once migrated, these + * groups are written *only* to the new store, so the legacy file is a + * frozen snapshot and the two are expected to diverge the moment the user + * changes a setting. + */ + fun hasRun(destination: Preferences): Boolean = destination[marker] == true +} diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt index 6925a61289..fba9ded945 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NotificationPrefsStore.kt @@ -59,6 +59,17 @@ class NotificationPrefsStore( val alwaysOnService = booleanPreferencesKey("always_on_notification_service") val showMessagesInNotifications = booleanPreferencesKey("show_messages_in_notifications") val splitNotificationsEnabled = booleanPreferencesKey("split_notifications_enabled") + + /** What the `secret_keeper_` file called these, for the one-shot copy. */ + val legacyTable = + LegacyKeyTable( + "migrated.notificationPrefs", + listOf( + LegacyBooleanKey("always_on_notification_service", alwaysOnService), + LegacyBooleanKey("show_messages_in_notifications", showMessagesInNotifications), + LegacyBooleanKey("split_notifications_enabled", splitNotificationsEnabled), + ), + ) } private suspend fun read(): Preferences = diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt index 1f18ed793b..70e3b981e6 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayAuthStore.kt @@ -59,6 +59,24 @@ class RelayAuthStore( val trustReadFollows = booleanPreferencesKey("relay_auth_trust_read_follows") val trustMessageFollows = booleanPreferencesKey("relay_auth_trust_message_follows") val trustMessageStrangers = booleanPreferencesKey("relay_auth_trust_message_strangers") + + /** + * What the `secret_keeper_` file called these, for the one-shot copy. + * + * The two "trust my relays" spellings differ: the legacy key grew a + * `_and_venues` suffix that the new one dropped. + */ + val legacyTable = + LegacyKeyTable( + "migrated.relayAuth", + listOf( + LegacyStringKey("default_relay_auth_policy", policyName), + LegacyBooleanKey("relay_auth_trust_my_relays_and_venues", trustMyRelays), + LegacyBooleanKey("relay_auth_trust_read_follows", trustReadFollows), + LegacyBooleanKey("relay_auth_trust_message_follows", trustMessageFollows), + LegacyBooleanKey("relay_auth_trust_message_strangers", trustMessageStrangers), + ), + ) } suspend fun load(): RelayAuth { diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt index 1e07d3154c..e14d87a219 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStore.kt @@ -95,6 +95,20 @@ enum class FollowListSlot( class TopNavFollowListStore( private val store: DataStore, ) { + companion object { + /** + * The one-shot copy out of `secret_keeper_`. + * + * Both names come off the same enum entry, so this table cannot drift + * from the slots the store actually reads. + */ + val legacyTable = + LegacyKeyTable( + "migrated.followLists", + FollowListSlot.entries.map { LegacyStringKey(it.prefKey, it.key) }, + ) + } + /** * Every slot's current filter, falling back to [FollowListSlot.default] * where the key is unset or unreadable. diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt index c63769dae7..632afa0670 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UploadSettingsStore.kt @@ -58,6 +58,20 @@ class UploadSettingsStore( val useLocalBlossomCache = booleanPreferencesKey("useLocalBlossomCache") val localBlossomCacheProfilePicturesOnly = booleanPreferencesKey("localBlossomCacheProfilePicturesOnly") val defaultFileServerJson = stringPreferencesKey("defaultFileServer") + + /** What the `secret_keeper_` file called these, for the one-shot copy. */ + val legacyTable = + LegacyKeyTable( + "migrated.uploadSettings", + listOf( + LegacyBooleanKey("stripLocationOnUpload", stripLocationOnUpload), + LegacyBooleanKey("optimizeMediaOnUpload", optimizeMediaOnUpload), + LegacyBooleanKey("mirrorUploadsToAllServers", mirrorUploadsToAllServers), + LegacyBooleanKey("useLocalBlossomCache", useLocalBlossomCache), + LegacyBooleanKey("localBlossomCacheProfilePicturesOnly", localBlossomCacheProfilePicturesOnly), + LegacyStringKey("defaultFileServer", defaultFileServerJson), + ), + ) } suspend fun load(): UploadSettings { diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt index 220d73546c..7a18508ff1 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt @@ -78,3 +78,60 @@ internal object AccountSecretKeys { */ const val SET_SEPARATOR = "\n" } + +/** + * The names [AccountSecrets] had in the `secret_keeper_` file, and how to + * read a set of them back out. + * + * Unlike the plain-store groups, these are still written to both stores on + * every save, so this is not only a migration source: it is what lets a check + * read the legacy file and the current one and assert they agree before the + * legacy file is deleted. + */ +object LegacyAccountSecretNames { + const val NIP46_SIGNER_ENABLED = "nip46SignerEnabled" + const val NIP46_BUNKER_SECRET = "nip46BunkerSecret" + const val NIP46_TRANSPORT_KEY = "nip46TransportKey" + const val NIP46_SEEN_IDS = "nip46SeenRequestIds" + const val NWC_WALLETS = "nwcWallets" + const val CLINK_DEBIT_WALLETS = "clinkDebitWallets" + const val DEFAULT_PAYMENT_SOURCE_ID = "defaultPaymentSourceId" + const val DEFAULT_NWC_WALLET_ID = "defaultNwcWalletId" + const val ZAP_PAYMENT_REQUEST_SERVER = "zapPaymentServer" + + /** The private key, which lives in its own store rather than in [AccountSecrets]. */ + const val NOSTR_PRIVKEY = "nostr_privkey" + + val all = + setOf( + NIP46_SIGNER_ENABLED, + NIP46_BUNKER_SECRET, + NIP46_TRANSPORT_KEY, + NIP46_SEEN_IDS, + NWC_WALLETS, + CLINK_DEBIT_WALLETS, + DEFAULT_PAYMENT_SOURCE_ID, + DEFAULT_NWC_WALLET_ID, + ZAP_PAYMENT_REQUEST_SERVER, + NOSTR_PRIVKEY, + ) +} + +/** + * The secrets as the legacy file holds them. + * + * Absent keys become the same defaults the loader has always applied, so this + * is directly comparable with what the current store returns. + */ +fun readLegacyAccountSecrets(source: LegacyPreferenceSource) = + AccountSecrets( + nip46SignerEnabled = source.getBoolean(LegacyAccountSecretNames.NIP46_SIGNER_ENABLED) ?: false, + nip46BunkerSecret = source.getString(LegacyAccountSecretNames.NIP46_BUNKER_SECRET) ?: "", + nip46TransportKey = source.getString(LegacyAccountSecretNames.NIP46_TRANSPORT_KEY) ?: "", + nip46SeenRequestIds = source.getStringSet(LegacyAccountSecretNames.NIP46_SEEN_IDS) ?: emptySet(), + nwcWalletsJson = source.getString(LegacyAccountSecretNames.NWC_WALLETS), + clinkDebitWalletsJson = source.getString(LegacyAccountSecretNames.CLINK_DEBIT_WALLETS), + defaultPaymentSourceId = source.getString(LegacyAccountSecretNames.DEFAULT_PAYMENT_SOURCE_ID), + legacyDefaultNwcWalletId = source.getString(LegacyAccountSecretNames.DEFAULT_NWC_WALLET_ID), + legacyZapPaymentRequestServer = source.getString(LegacyAccountSecretNames.ZAP_PAYMENT_REQUEST_SERVER), + ) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStoreTest.kt new file mode 100644 index 0000000000..f9e19f0e29 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountIdentityStoreTest.kt @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataMigration +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertSame +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +class AccountIdentityStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun raw(migrations: List> = emptyList()): DataStore { + val file = File(folder.root, "identity_${seq++}.preferences_pb") + return PreferenceDataStoreFactory.createWithPath( + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + migrations = migrations, + produceFile = { file.toOkioPath() }, + ) + } + + @Test + fun defaultsMatchTheLegacyOnes() = + runTest { + val loaded = AccountIdentityStore(raw()).load() + + assertNull(loaded.pubKeyHex) + assertEquals(false, loaded.loginWithExternalSigner) + assertNull(loaded.externalSignerPackageName) + assertEquals(emptySet(), loaded.localRelayServers) + assertNull(loaded.openBackupConflictsJson) + } + + @Test + fun roundTrip() = + runTest { + val store = AccountIdentityStore(raw()) + val value = + AccountIdentity( + pubKeyHex = "aabbcc", + loginWithExternalSigner = true, + externalSignerPackageName = "com.greenart7c3.nostrsigner", + localRelayServers = setOf("ws://localhost:4869"), + openBackupConflictsJson = """[["a","b","c"]]""", + ) + + store.save(value) + + assertEquals(value, store.load()) + } + + /** + * Dropping an external signer, clearing the local relays or answering the + * last backup conflict has to leave those keys absent — not holding + * yesterday's value. + */ + @Test + fun savingEmptyValuesClearsWhatWasThere() = + runTest { + val store = AccountIdentityStore(raw()) + store.save( + AccountIdentity( + pubKeyHex = "aabbcc", + loginWithExternalSigner = true, + externalSignerPackageName = "com.example.signer", + localRelayServers = setOf("ws://localhost:4869"), + openBackupConflictsJson = "[]", + ), + ) + + store.save(AccountIdentity(pubKeyHex = "aabbcc")) + + val loaded = store.load() + assertEquals("aabbcc", loaded.pubKeyHex) + assertEquals(false, loaded.loginWithExternalSigner) + assertNull(loaded.externalSignerPackageName) + assertEquals(emptySet(), loaded.localRelayServers) + assertNull(loaded.openBackupConflictsJson) + } + + /** Absent means "already backed up elsewhere", so the nudge stays off. */ + @Test + fun hasBackedUpKeysDefaultsToTrue() = + runTest { + assertEquals(true, AccountIdentityStore(raw()).hasBackedUpKeys()) + } + + /** + * The nudge writes this on its own. A group save must not carry a value + * its caller never knew about and flip the nudge back on. + */ + @Test + fun aGroupSaveLeavesHasBackedUpKeysAlone() = + runTest { + val store = AccountIdentityStore(raw()) + store.setHasBackedUpKeys(false) + + store.save(AccountIdentity(pubKeyHex = "aabbcc", localRelayServers = setOf("ws://x"))) + + assertEquals(false, store.hasBackedUpKeys()) + } + + @Test + fun theLegacyCopyCarriesEveryFieldIncludingTheBackupFlag() = + runTest { + val legacy = + FakeLegacySource( + mapOf( + "nostr_pubkey" to "aabbcc", + "login_with_external_signer" to true, + "signer_package_name" to "com.example.signer", + "localRelayServers" to setOf("ws://localhost:4869"), + "openBackupConflicts" to """[["a","b","c"]]""", + "has_backed_up_keys" to false, + ), + ) + + val store = AccountIdentityStore(raw(listOf(AccountIdentityStore.legacyTable.migration { legacy }))) + + assertEquals( + AccountIdentity( + pubKeyHex = "aabbcc", + loginWithExternalSigner = true, + externalSignerPackageName = "com.example.signer", + localRelayServers = setOf("ws://localhost:4869"), + openBackupConflictsJson = """[["a","b","c"]]""", + ), + store.load(), + ) + assertEquals(false, store.hasBackedUpKeys()) + } + + /** + * The fallback is all-or-nothing, and that is the point: with no pubkey + * the store answered from `emptyPreferences()`, where an absent boolean and + * a false one are the same value. Merging field by field would report an + * external-signer account as a local one — and a local one has no signer, + * so the account would go read-only. + */ + @Test + fun anIdentityWithoutAPubKeyFallsBackWholesale() { + val legacy = + AccountIdentity( + pubKeyHex = "aabbcc", + loginWithExternalSigner = true, + externalSignerPackageName = "com.example.signer", + ) + + assertEquals(legacy, AccountIdentity().orIfUnusable { legacy }) + } + + @Test + fun anIdentityWithAPubKeyIsAuthoritative() { + val stored = AccountIdentity(pubKeyHex = "aabbcc") + var called = false + + val result = + stored.orIfUnusable { + called = true + AccountIdentity(pubKeyHex = "ddeeff") + } + + assertSame(stored, result) + assertTrue(!called) + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTableTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTableTest.kt new file mode 100644 index 0000000000..8b5787bc83 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/LegacyKeyTableTest.kt @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import androidx.datastore.preferences.core.stringSetPreferencesKey +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.job +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** A [LegacyPreferenceSource] over a map, standing in for the encrypted file. */ +class FakeLegacySource( + private val values: Map, +) : LegacyPreferenceSource { + var opened = 0 + private set + + init { + opened++ + } + + override fun keys() = values.keys + + override fun getBoolean(name: String) = values[name] as Boolean? + + override fun getString(name: String) = values[name] as String? + + @Suppress("UNCHECKED_CAST") + override fun getStringSet(name: String) = values[name] as Set? +} + +class LegacyKeyTableTest { + @get:Rule + val folder = TemporaryFolder() + + private val flag = booleanPreferencesKey("flag") + private val text = stringPreferencesKey("text") + private val bag = stringSetPreferencesKey("bag") + + private val table = + LegacyKeyTable( + "migrated.test", + listOf( + LegacyBooleanKey("legacy_flag", flag), + LegacyStringKey("legacy_text", text), + LegacyStringSetKey("legacy_bag", bag), + ), + ) + + private var seq = 0 + + private fun store( + source: () -> LegacyPreferenceSource, + name: String = "t_${seq++}", + ): DataStore { + val file = File(folder.root, "$name.preferences_pb") + return PreferenceDataStoreFactory.createWithPath( + scope = CoroutineScope(Dispatchers.IO + SupervisorJob()), + migrations = listOf(table.migration(source)), + produceFile = { file.toOkioPath() }, + ) + } + + @Test + fun copiesEveryTypeAcrossTheRename() = + runTest { + val legacy = + FakeLegacySource( + mapOf( + "legacy_flag" to true, + "legacy_text" to "hello", + "legacy_bag" to setOf("a", "b"), + ), + ) + + val prefs = store({ legacy }).data.first() + + assertEquals(true, prefs[flag]) + assertEquals("hello", prefs[text]) + assertEquals(setOf("a", "b"), prefs[bag]) + } + + /** + * The distinction the whole copy rests on: a key the user never set must + * stay absent, so it keeps reading as unset and falls back to its own + * default. Writing `false` here would turn off features whose default is on. + */ + @Test + fun anAbsentLegacyKeyStaysAbsent() = + runTest { + val prefs = store({ FakeLegacySource(mapOf("legacy_text" to "only me")) }).data.first() + + assertEquals("only me", prefs[text]) + assertNull(prefs[flag]) + assertNull(prefs[bag]) + } + + @Test + fun hasRunReportsTheMarker() = + runTest { + assertFalse(table.hasRun(emptyPreferences())) + + val prefs = store({ FakeLegacySource(emptyMap()) }).data.first() + + assertTrue(table.hasRun(prefs)) + } + + /** + * Decrypting an `EncryptedSharedPreferences` is not free, so the legacy + * file must not be opened on launches where the copy has already run. + */ + @Test + fun theLegacyFileIsNotOpenedOnceTheCopyHasRun() = + runTest { + var opens = 0 + val open = { + opens++ + FakeLegacySource(mapOf("legacy_text" to "x")) as LegacyPreferenceSource + } + val file = File(folder.root, "reopen.preferences_pb") + + // DataStore registers a live store per file path and only releases + // it when the owning scope ends, so each "launch" gets its own + // scope and gives it back. + fun open(scope: CoroutineScope) = + PreferenceDataStoreFactory.createWithPath( + scope = scope, + migrations = listOf(table.migration(open)), + produceFile = { file.toOkioPath() }, + ) + + val first = CoroutineScope(Dispatchers.IO + SupervisorJob()) + assertEquals("x", open(first).data.first()[text]) + assertEquals(1, opens) + first.cancel() + first.coroutineContext.job.join() + + val second = CoroutineScope(Dispatchers.IO + SupervisorJob()) + assertEquals("x", open(second).data.first()[text]) + assertEquals(1, opens) + second.cancel() + } + + /** + * The legacy names are what the Android app has written since its first + * release. A rename here resets that setting for everyone who had it, so + * the list is pinned rather than regenerated. + */ + @Test + fun theShippedTablesCoverTheirKeys() { + assertEquals( + setOf( + "stripLocationOnUpload", + "optimizeMediaOnUpload", + "mirrorUploadsToAllServers", + "useLocalBlossomCache", + "localBlossomCacheProfilePicturesOnly", + "defaultFileServer", + ), + UploadSettingsStore.legacyTable.legacyNames, + ) + + assertEquals( + setOf( + "nostr_pubkey", + "login_with_external_signer", + "signer_package_name", + "localRelayServers", + "openBackupConflicts", + "has_backed_up_keys", + ), + AccountIdentityStore.legacyTable.legacyNames, + ) + + assertEquals(FollowListSlot.entries.size, TopNavFollowListStore.legacyTable.keys.size) + assertEquals(LatestEventSlot.entries.size, LatestEventCacheStore.legacyTable.keys.size) + } + + /** Several tables share one store, so their markers must not collide. */ + @Test + fun everyShippedMarkerIsDistinct() { + val markers = + listOf( + TopNavFollowListStore.legacyTable, + LatestEventCacheStore.legacyTable, + UploadSettingsStore.legacyTable, + DialogDismissalStore.legacyTable, + RelayAuthStore.legacyTable, + FeedVisibilityStore.legacyTable, + NotificationPrefsStore.legacyTable, + AccountIdentityStore.legacyTable, + ).map { it.markerName } + + assertEquals(markers.size, markers.toSet().size) + } +} From 75a0f738c8b738e0e5fc3531050e5e8090e154e3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 22:25:18 +0000 Subject: [PATCH 14/57] feat: gate deleting a legacy preference file behind a read-back MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LegacyPreferenceCleanup runs after each successful account load and deletes that account's `secret_keeper_` file only when it can show nothing in it would be lost. It refuses today, deliberately, and says why. The check is not one rule, because the two halves of the migration are in different states. The plain per-account groups stopped being legacy-written when they moved, so that file is a frozen snapshot of the day they migrated — comparing values would flag every setting the user has changed since. For those the question is "did the copy run", which the migration marker answers exactly: CopyOnceMigration commits the values and the marker as one Preferences, so the marker cannot be set without them. The secrets and the private key *are* still written to both stores, so for those the stronger question is available and is asked: read both back, require them to agree. Coverage runs from the file's own keys rather than a checklist. A checklist fails silently in the one direction that matters — a key added later that no migration carries — so instead every key present must be claimed by a table, be one of the secrets, or be on the accepted-loss list, and anything else stops the deletion by name. LegacyKeyCoverageTest reflects over PrefKeys and fails the build if a key falls outside all of those, so that surfaces at the commit that adds it rather than as a file that quietly never gets deleted. A store that cannot be read is a reason, never a pass. Nothing is deleted yet, and not because the check fails: LEGACY_WRITES_RETIRED is false. The identity, key, secret and roster stores still mirror into the legacy file so a rolled-back build finds a complete account, and while that is true, deleting the file achieves nothing — the next save recreates it — and would look like it had worked. Retiring those writes ends the rollback window and waits on the device pass, which nothing here has had: no AndroidKeyStore path has executed in this environment, so what is tested is the decision logic against fakes. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- ...2026-09-23-encrypted-storage-retirement.md | 109 ++++-- .../vitorpamplona/amethyst/AccountKeyStore.kt | 7 + .../amethyst/AccountSecretsStore.kt | 8 + .../amethyst/LegacyPreferenceCleanup.kt | 302 ++++++++++++++++ .../amethyst/LocalPreferences.kt | 283 ++++++++------- .../amethyst/LegacyKeyCoverageTest.kt | 117 +++++++ .../amethyst/LegacyPreferenceCleanupTest.kt | 321 ++++++++++++++++++ 7 files changed, 981 insertions(+), 166 deletions(-) create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt create mode 100644 amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyKeyCoverageTest.kt create mode 100644 amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt diff --git a/amethyst/plans/2026-09-23-encrypted-storage-retirement.md b/amethyst/plans/2026-09-23-encrypted-storage-retirement.md index 4a6ff1ab2f..ceb220068c 100644 --- a/amethyst/plans/2026-09-23-encrypted-storage-retirement.md +++ b/amethyst/plans/2026-09-23-encrypted-storage-retirement.md @@ -1,15 +1,17 @@ # Retiring EncryptedStorage -Status: **blocked** — the legacy files cannot be deleted yet, and the reader -can never be. +Status: **migrated, not yet deleted.** Every key has a home in the new stores. +The legacy files are still written, so they are still there — and the reader +can never go. ## The constraint Every migration in the preference layer is *lazy*: it reads the legacy store -when it runs, not when the app is installed. Nine come through -`EncryptedStorage` — the seven `CopyOnceMigration`s in `LocalPreferences` plus -the key, secret and roster stores. Only the Cashu counters and calendar -reminders read a plain (non-encrypted) source and would survive its removal. +when it runs, not when the app is installed. Ten come through +`EncryptedStorage` — the eight `LegacyKeyTable` copies on the per-account +DataStore plus the key, secret and roster stores. Only the Cashu counters and +calendar reminders read a plain (non-encrypted) source and would survive its +removal. So deleting `EncryptedStorage` does not merely affect installs that have not upgraded yet. It strands anyone who **skips** the release introducing the new @@ -25,54 +27,89 @@ from a backup all skip releases. an unmaintained-library risk, not an active vulnerability, and a much smaller cost than stranding users. -## Outstanding before any legacy file is deleted +## Where each key went -Deletion is only safe for an account whose every key has a new home. These do -not yet, and are still read from the legacy files: +`LegacyKeyCoverageTest` holds this to being exhaustive: every constant in +`PrefKeys` is either claimed by a migration table, one of the secrets, on the +accepted-loss list, or a key of the global file. A key added to `PrefKeys` and +to none of those fails that test at the commit that adds it. -| key | scope | if deleted today | +| group | destination | legacy write | |---|---|---| -| `NOSTR_PUBKEY` | per-account | **fatal** — `loadAccountConfigFromEncryptedStorage` returns null without it, so the account disappears even though its private key migrated | -| `LOGIN_WITH_EXTERNAL_SIGNER` | per-account | external-signer accounts stop resolving their signer | -| `SIGNER_PACKAGE_NAME` | per-account | as above | -| `HAS_BACKED_UP_KEYS` | per-account | the key-backup nag returns for everyone | -| `LOCAL_RELAY_SERVERS` | per-account | silently lost | -| `OPEN_BACKUP_CONFLICTS` | per-account | silently lost | -| `SHARED_SETTINGS` | global | UI settings reset | +| follow lists, cached events, upload, dialogs, relay auth, feed visibility, notifications | the account's plain DataStore | already retired | +| identity — pubkey, signer, local relays, backup conflicts, backup flag | the account's plain DataStore | **kept** | +| private key | `SecureKeyStorage` | **kept** | +| NIP-46 material, wallets, payment source | the account's encrypted DataStore | **kept** | +| current account, saved accounts | the encrypted roster store | **kept** | +| UI settings (`shared_settings`) | `UiSharedPreferences`' own DataStore | none left | + +The three stores that still mirror are the ones whose loss is not an +annoyance: an account that cannot be listed, signed with, or paid from. They +keep the rollback window open until the device pass below has happened. + +The UI settings copy is **guarded** where the others are not. That store has +been the real home of these settings for a while, so most installs already +have a populated one and copying the old blob over it would undo every UI +change since. The copy only runs into a store that has never been saved +(`ui.theme` absent, which `save` always writes). ## Deliberately not migrated -Three keys are accepted losses rather than outstanding work — the cost of -losing them is one-off and small, and carrying them is not worth the code: - | key | what is lost | |---|---| | `PENDING_ATTESTATIONS` | queued OTS attestations are not published | | `NOTIF_GLOBAL_TO_CURATED_MIGRATED` | the one-shot notification filter migration runs once more | | `LAST_READ_PER_ROUTE` | every feed reads as unread once | +| `USE_PROXY`, `PROXY_PORT` | nothing — only ever removed, never read | +| `TOR_SETTINGS` | nothing — no reader left anywhere | -`NotificationPrefsStore` was given `hasRunGlobalToCuratedMigration`, -`markGlobalToCuratedMigrated`, `lastReadPerRoute` and `saveLastReadPerRoute` -for the last two of these. Nothing ever called them, and now nothing will; -they have been removed rather than left looking like a feature. +These are listed in `LegacyAccountKeys.accepted`, which is what lets the +cleanup treat any *other* unclaimed key as a reason to keep the file. -`USE_PROXY` and `PROXY_PORT` need nothing either: they are only ever `remove`d, -being cleaned up rather than read. +## Deleting a legacy file + +`LegacyPreferenceCleanup` runs after every successful account load and deletes +that account's file only when it can prove nothing would be lost: + +1. **Every key in the file is accounted for** — claimed by a table, one of the + secrets, or on the accepted list. Driven from the file's own keys, not from + a checklist, because a checklist fails silently in the one direction that + matters. +2. **Every copy that had something to copy has run.** Marker-based, not a value + comparison: those groups stopped being legacy-written when they moved, so + the file is a frozen snapshot and the two are *expected* to diverge as soon + as the user changes a setting. `CopyOnceMigration` commits the values and + its marker as one `Preferences`, so the marker cannot be set without them. +3. **The secrets and the private key read back identical** from the current + stores. Those *are* still dual-written, so the stronger question is + available and is asked. +4. A store that cannot be read is a reason, never a pass. + +It refuses today, and says so, because of the fifth condition: +`LEGACY_WRITES_RETIRED` is false. While the app still mirrors into the file, +deleting it achieves nothing — the next save recreates it — and would look +like it had worked. ## Order of work -1. Migrate the seven keys above, on the same dual-store terms as the rest. -2. Add a per-account completeness check — every key present in the new stores — - and only then delete that account's legacy file, after reading back what was - written. -3. Retire the legacy writes once (2) holds for every account on a device. -4. Keep the reader, and the dependency, indefinitely. +1. ~~Migrate the remaining keys.~~ Done. +2. ~~Gate deletion on a per-account read-back.~~ Done. +3. Do the device pass below. +4. Flip `LEGACY_WRITES_RETIRED` and drop the legacy writes for the identity, + key, secret and roster stores. This ends the rollback window, so it is a + release of its own. +5. Keep the reader, and `androidx.security.crypto`, indefinitely. ## Verification this needs and has not had None of the AndroidKeyStore paths have executed: this environment has no device or emulator, and `commons` has no Robolectric. What is tested is the decision -logic against fakes. On a real device, before any deletion ships: upgrade an -install holding accounts and confirm they all list; open one and sign; -force-stop and relaunch; add and remove an account; pair a NIP-46 signer; pay -from a wallet. +logic against fakes — which is why step 3 is not optional, and why deletion is +the one irreversible step in the whole series. + +On a real device, before step 4 ships: upgrade an install holding accounts and +confirm they all list; open one and sign; force-stop and relaunch; add and +remove an account; pair a NIP-46 signer; pay from a wallet; check the +key-backup nudge stays dismissed; confirm UI settings survive the upgrade. +Then let the cleanup run with the flag flipped, and confirm the files are gone +and everything above still holds on the next cold start. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt index 71ac28878d..5ef8b4af68 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountKeyStore.kt @@ -168,6 +168,13 @@ class AccountKeyStore( } } + /** + * What the current store holds, with no fallback to the legacy value. + * + * For [LegacyPreferenceCleanup]; [read] deliberately hides this distinction. + */ + suspend fun stored(npub: String): String? = vault.get(npub) + /** Drops the key from the new store; the caller clears the legacy file itself. */ suspend fun delete(npub: String) { try { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt index 6e3c3bcf12..e60aaa48cf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt @@ -90,6 +90,14 @@ class AccountSecretsStore( } } + /** + * What the current store holds, with no fallback to the legacy file. + * + * For [LegacyPreferenceCleanup], which has to tell "migrated" from + * "falling back and looking migrated" — the read above deliberately cannot. + */ + suspend fun stored(npub: String): AccountSecrets? = stores.loadSecrets(npub) + suspend fun delete(npub: String) { try { stores.removeAccount(npub) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt new file mode 100644 index 0000000000..fc7973abe6 --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import androidx.datastore.preferences.core.Preferences +import com.vitorpamplona.amethyst.commons.model.preferences.AccountIdentityStore +import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets +import com.vitorpamplona.amethyst.commons.model.preferences.DialogDismissalStore +import com.vitorpamplona.amethyst.commons.model.preferences.FeedVisibilityStore +import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventCacheStore +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyAccountSecretNames +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyKeyTable +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyPreferenceSource +import com.vitorpamplona.amethyst.commons.model.preferences.NotificationPrefsStore +import com.vitorpamplona.amethyst.commons.model.preferences.RelayAuthStore +import com.vitorpamplona.amethyst.commons.model.preferences.TopNavFollowListStore +import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettingsStore +import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyAccountSecrets +import com.vitorpamplona.quartz.utils.Log + +/** + * How every key that can appear in a `secret_keeper_` file is accounted + * for. + * + * Together with [LegacyAccountSecretNames], these two lists are what let + * [LegacyPreferenceCleanup] treat any *other* key in the file as a reason not + * to delete it. `LegacyKeyCoverageTest` holds them to covering all of + * `PrefKeys`, so a key added later cannot quietly fall outside both. + */ +internal object LegacyAccountKeys { + /** + * The one-shot copies out of the account's legacy file. + * + * Each store owns the table of legacy names it came from, so the copy and + * the check that the copy happened read the same list — see [LegacyKeyTable]. + */ + val tables = + listOf( + TopNavFollowListStore.legacyTable, + LatestEventCacheStore.legacyTable, + UploadSettingsStore.legacyTable, + DialogDismissalStore.legacyTable, + RelayAuthStore.legacyTable, + FeedVisibilityStore.legacyTable, + NotificationPrefsStore.legacyTable, + AccountIdentityStore.legacyTable, + ) + + /** + * Keys that are deliberately not carried across. + * + * Each costs something once and nothing after, and none is worth the code + * to move it: queued attestations go unpublished, the one-shot + * Global -> Curated notification rewrite runs one more time, and every feed + * reads as unread once. `use_proxy` and `proxy_port` are only ever removed, + * never read, and `tor_settings` has no reader left at all. + */ + val accepted = + setOf( + PrefKeys.PENDING_ATTESTATIONS, + PrefKeys.NOTIF_GLOBAL_TO_CURATED_MIGRATED, + PrefKeys.LAST_READ_PER_ROUTE, + PrefKeys.USE_PROXY, + PrefKeys.PROXY_PORT, + PrefKeys.TOR_SETTINGS, + ) +} + +/** What [LegacyPreferenceCleanup] did, and why. */ +sealed interface LegacyCleanupResult { + /** There was no legacy file for this account. */ + data object NothingToDelete : LegacyCleanupResult + + data object Deleted : LegacyCleanupResult + + /** Nothing was touched. Each reason names one thing that would have been lost. */ + data class Kept( + val reasons: List, + ) : LegacyCleanupResult +} + +/** The per-account legacy file, as this needs it. */ +interface LegacyAccountFiles { + fun source(npub: String): LegacyPreferenceSource + + fun exists(npub: String): Boolean + + /** Returns false when there was nothing to delete. */ + suspend fun delete(npub: String): Boolean +} + +/** What the current, encrypted stores hold for an account. */ +interface MigratedSecrets { + /** Null when this account has not been copied across yet. */ + suspend fun secrets(npub: String): AccountSecrets? + + /** Null only when the account genuinely has no private key. Throws when the store is unreadable. */ + suspend fun privateKey(npub: String): String? +} + +/** + * Deletes an account's `secret_keeper_` file, but only once it can prove + * nothing in it would be lost. + * + * # Why the check is not one rule + * + * The two halves of the migration are in different states, and asking the same + * question of both would give the wrong answer for one of them. + * + * The plain per-account groups — settings, dialogs, feeds, cached events — + * stopped being written to the legacy file when they moved, so that file is a + * frozen snapshot of the day they migrated. Comparing values would flag every + * setting the user has changed since. What is actually being asked of them is + * "did the copy run", and [LegacyKeyTable.hasRun] answers it exactly: + * `CopyOnceMigration` writes the values and its marker as a single + * `Preferences`, committed atomically, so the marker cannot be set without them. + * + * The secrets and the private key are still written to *both* stores on every + * save, so for those the stronger question is available and is asked: read both + * back and require them to agree. + * + * # Why an unrecognised key blocks + * + * A list of keys to check, maintained by hand, fails silently in the one + * direction that matters: a key added later that no migration carries. So the + * check runs the other way round — every key *in the file* must be claimed by + * a table, be one of the secrets, or be on [accepted], the short list of + * deliberate losses. Anything else stops the deletion and says so by name. + * + * # Cost + * + * [LegacyPreferenceSource.keys] goes through `EncryptedSharedPreferences.all`, + * which decrypts every value in the file — there is no keys-only API. It is + * called from the one place an account load is not already cached, so it costs + * at most once per account per process, and nothing at all while + * [legacyWritesRetired] is false. + * + * # Why deletion also waits on the legacy writes + * + * [legacyWritesRetired] is the other half. While the app still mirrors into + * this file on every save, deleting it achieves nothing — the next save + * recreates it, with a subset of what was there. Worse, it would look like it + * had worked. So the file is only removed once it is no longer being written, + * which is a separate release from this one. + */ +class LegacyPreferenceCleanup( + private val tables: List, + private val accepted: Set, + private val files: LegacyAccountFiles, + private val currentStore: suspend (String) -> Preferences, + private val secrets: MigratedSecrets, + private val legacyWritesRetired: Boolean, +) { + companion object { + private const val TAG = "LegacyPreferenceCleanup" + + const val STILL_WRITTEN = "the legacy file is still written on every save" + } + + private val claimed: Set = tables.flatMapTo(mutableSetOf()) { it.legacyNames } + LegacyAccountSecretNames.all + + /** + * Everything that would be lost by deleting this account's legacy file. + * Empty means nothing would be. + * + * A store that cannot be read is a reason, never a pass: the whole point is + * to be sure, and "the check itself failed" is not sure. + */ + suspend fun verify(npub: String): List { + val legacy = + try { + files.source(npub) + } catch (e: Exception) { + Log.w(TAG, "Could not open the legacy file for $npub", e) + return listOf("the legacy file could not be read") + } + + val reasons = mutableListOf() + + val present = legacy.keys() + (present - claimed - accepted).sorted().forEach { + reasons += "no migration claims '$it'" + } + + val current = + try { + currentStore(npub) + } catch (e: Exception) { + Log.w(TAG, "Could not read the current store for $npub", e) + return reasons + "the current store could not be read" + } + + tables.forEach { table -> + // A table whose keys the file never held has nothing to prove. + if (present.none { it in table.legacyNames }) return@forEach + if (!table.hasRun(current)) reasons += "the '${table.markerName}' copy has not run" + } + + reasons += secretMismatches(npub, legacy) + + return reasons + } + + private suspend fun secretMismatches( + npub: String, + legacy: LegacyPreferenceSource, + ): List { + val expected = readLegacyAccountSecrets(legacy) + val reasons = mutableListOf() + + try { + val stored = secrets.secrets(npub) + when { + stored == null -> reasons += "the secrets have not been copied across" + // Field names only. These values are bunker secrets and wallet + // connection strings; a log line is the last place for them. + stored != expected -> reasons += "the stored secrets differ from the legacy file: ${differingFields(expected, stored)}" + } + } catch (e: Exception) { + Log.w(TAG, "Could not read the secrets store for $npub", e) + reasons += "the secrets store could not be read" + } + + val legacyKey = legacy.getString(LegacyAccountSecretNames.NOSTR_PRIVKEY) + if (legacyKey != null) { + try { + when (secrets.privateKey(npub)) { + null -> reasons += "the private key has not been copied across" + legacyKey -> Unit + else -> reasons += "the stored private key differs from the legacy file" + } + } catch (e: Exception) { + Log.w(TAG, "Could not read the key store for $npub", e) + reasons += "the key store could not be read" + } + } + + return reasons + } + + private fun differingFields( + expected: AccountSecrets, + stored: AccountSecrets, + ): String = + listOfNotNull( + "nip46SignerEnabled".takeIf { expected.nip46SignerEnabled != stored.nip46SignerEnabled }, + "nip46BunkerSecret".takeIf { expected.nip46BunkerSecret != stored.nip46BunkerSecret }, + "nip46TransportKey".takeIf { expected.nip46TransportKey != stored.nip46TransportKey }, + "nip46SeenRequestIds".takeIf { expected.nip46SeenRequestIds != stored.nip46SeenRequestIds }, + "nwcWallets".takeIf { expected.nwcWalletsJson != stored.nwcWalletsJson }, + "clinkDebitWallets".takeIf { expected.clinkDebitWalletsJson != stored.clinkDebitWalletsJson }, + "defaultPaymentSourceId".takeIf { expected.defaultPaymentSourceId != stored.defaultPaymentSourceId }, + "defaultNwcWalletId".takeIf { expected.legacyDefaultNwcWalletId != stored.legacyDefaultNwcWalletId }, + "zapPaymentServer".takeIf { expected.legacyZapPaymentRequestServer != stored.legacyZapPaymentRequestServer }, + ).joinToString() + + /** + * Deletes the account's legacy file if — and only if — [verify] comes back + * empty and the app has stopped writing to it. + */ + suspend fun deleteIfVerified(npub: String): LegacyCleanupResult { + if (!files.exists(npub)) return LegacyCleanupResult.NothingToDelete + + if (!legacyWritesRetired) return LegacyCleanupResult.Kept(listOf(STILL_WRITTEN)) + + val reasons = verify(npub) + if (reasons.isNotEmpty()) { + Log.i(TAG) { "Keeping the legacy file for $npub: ${reasons.joinToString("; ")}" } + return LegacyCleanupResult.Kept(reasons) + } + + return try { + if (files.delete(npub)) { + Log.i(TAG) { "Deleted the migrated legacy file for $npub" } + LegacyCleanupResult.Deleted + } else { + LegacyCleanupResult.NothingToDelete + } + } catch (e: Exception) { + Log.w(TAG, "Could not delete the legacy file for $npub", e) + LegacyCleanupResult.Kept(listOf("the legacy file could not be deleted")) + } + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 37e72033e3..9df3f2a2f5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -34,6 +34,8 @@ import com.vitorpamplona.amethyst.commons.model.mediaServers.ServerName import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupViewMode import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntry import com.vitorpamplona.amethyst.commons.model.nip47WalletConnect.NwcWalletEntryNorm +import com.vitorpamplona.amethyst.commons.model.preferences.AccountIdentity +import com.vitorpamplona.amethyst.commons.model.preferences.AccountIdentityStore import com.vitorpamplona.amethyst.commons.model.preferences.AccountPreferenceStores import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration @@ -44,6 +46,7 @@ import com.vitorpamplona.amethyst.commons.model.preferences.FeedVisibilityStore import com.vitorpamplona.amethyst.commons.model.preferences.FollowListSlot import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventCacheStore import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventSlot +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyPreferenceSource import com.vitorpamplona.amethyst.commons.model.preferences.NotificationPrefs import com.vitorpamplona.amethyst.commons.model.preferences.NotificationPrefsStore import com.vitorpamplona.amethyst.commons.model.preferences.RelayAuth @@ -51,12 +54,15 @@ import com.vitorpamplona.amethyst.commons.model.preferences.RelayAuthStore import com.vitorpamplona.amethyst.commons.model.preferences.TopNavFollowListStore import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettings import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettingsStore +import com.vitorpamplona.amethyst.commons.model.preferences.orIfUnusable +import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyAccountSecrets import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthPolicy import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.amethyst.model.UiSettings import com.vitorpamplona.amethyst.model.backups.BackupConflictStorage import com.vitorpamplona.amethyst.model.nip60Cashu.CashuPreferences +import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences import com.vitorpamplona.amethyst.service.checkNotInMainThread import com.vitorpamplona.quartz.concord.cord02Community.ConcordCommunityListEvent import com.vitorpamplona.quartz.experimental.ephemChat.list.EphemeralChatListEvent @@ -98,6 +104,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.first import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.withContext @@ -120,7 +127,7 @@ data class AccountInfo( val isTransient: Boolean = false, ) -private object PrefKeys { +internal object PrefKeys { const val CURRENT_ACCOUNT = "currently_logged_in_account" // Global (non-account) master switch for the always-on notification service. @@ -268,12 +275,13 @@ object LocalPreferences { private val cachedAccounts: MutableMap = mutableMapOf() /** - * The per-account DataStore, and the top-nav filter selections inside it. + * The per-account DataStore: every non-secret setting this account has. * - * Each account's store carries a [CopyOnceMigration] that lifts the filters - * out of that account's legacy encrypted SharedPreferences the first time - * the store is read. The copy leaves the legacy keys in place, so a build - * that reads the old location still works — see [CopyOnceMigration]. + * Each account's store carries one [CopyOnceMigration] per group in + * [LegacyAccountKeys.tables], lifting that group out of the account's legacy + * encrypted SharedPreferences the first time the store is read. The copies + * leave the legacy keys in place, so a build that reads the old location + * still works — see [CopyOnceMigration]. */ private val accountStores: AccountPreferenceStores by lazy { AccountPreferenceStores( @@ -282,8 +290,7 @@ object LocalPreferences { .toOkioPath() }, migrations = { npub -> - listOf(followListMigration(npub), latestEventMigration(npub)) + - listOf(uploadSettingsMigration(npub), dialogDismissalMigration(npub), relayAuthMigration(npub), feedVisibilityMigration(npub), notificationPrefsMigration(npub)) + LegacyAccountKeys.tables.map { it.migration { legacySource(npub) } } }, ) } @@ -302,68 +309,64 @@ object LocalPreferences { private fun notificationPrefsStore(npub: String) = NotificationPrefsStore(accountStores.getDataStore(npub)) - private fun uploadSettingsMigration(npub: String) = - CopyOnceMigration("migrated.uploadSettings") { out -> - withContext(Dispatchers.IO) { - val legacy = encryptedPreferences(npub) - if (legacy.contains(PrefKeys.STRIP_LOCATION_ON_UPLOAD)) out[UploadSettingsStore.stripLocationOnUpload] = legacy.getBoolean(PrefKeys.STRIP_LOCATION_ON_UPLOAD, false) - if (legacy.contains(PrefKeys.OPTIMIZE_MEDIA_ON_UPLOAD)) out[UploadSettingsStore.optimizeMediaOnUpload] = legacy.getBoolean(PrefKeys.OPTIMIZE_MEDIA_ON_UPLOAD, false) - if (legacy.contains(PrefKeys.MIRROR_UPLOADS_TO_ALL_SERVERS)) out[UploadSettingsStore.mirrorUploadsToAllServers] = legacy.getBoolean(PrefKeys.MIRROR_UPLOADS_TO_ALL_SERVERS, false) - if (legacy.contains(PrefKeys.USE_LOCAL_BLOSSOM_CACHE)) out[UploadSettingsStore.useLocalBlossomCache] = legacy.getBoolean(PrefKeys.USE_LOCAL_BLOSSOM_CACHE, false) - if (legacy.contains(PrefKeys.LOCAL_BLOSSOM_CACHE_PROFILE_PICTURES_ONLY)) out[UploadSettingsStore.localBlossomCacheProfilePicturesOnly] = legacy.getBoolean(PrefKeys.LOCAL_BLOSSOM_CACHE_PROFILE_PICTURES_ONLY, false) - legacy.getString(PrefKeys.DEFAULT_FILE_SERVER, null)?.let { out[UploadSettingsStore.defaultFileServerJson] = it } - } - } + private fun identityStore(npub: String) = AccountIdentityStore(accountStores.getDataStore(npub)) - private fun dialogDismissalMigration(npub: String) = - CopyOnceMigration("migrated.dialogDismissal") { out -> - withContext(Dispatchers.IO) { - val legacy = encryptedPreferences(npub) - if (legacy.contains(PrefKeys.HIDE_DELETE_REQUEST_DIALOG)) out[DialogDismissalStore.hideDeleteRequestDialog] = legacy.getBoolean(PrefKeys.HIDE_DELETE_REQUEST_DIALOG, false) - if (legacy.contains(PrefKeys.HIDE_BLOCK_ALERT_DIALOG)) out[DialogDismissalStore.hideBlockAlertDialog] = legacy.getBoolean(PrefKeys.HIDE_BLOCK_ALERT_DIALOG, false) - if (legacy.contains(PrefKeys.HIDE_NIP_17_WARNING_DIALOG)) out[DialogDismissalStore.hideNip17WarningDialog] = legacy.getBoolean(PrefKeys.HIDE_NIP_17_WARNING_DIALOG, false) - if (legacy.contains(PrefKeys.HIDE_COMMUNITY_RULES_VIOLATIONS)) out[DialogDismissalStore.hideCommunityRulesViolations] = legacy.getBoolean(PrefKeys.HIDE_COMMUNITY_RULES_VIOLATIONS, false) - legacy.getStringSet(PrefKeys.DISMISSED_POLL_NOTE_IDS, null)?.let { out[DialogDismissalStore.dismissedPollNoteIds] = it } - legacy.getStringSet(PrefKeys.DISMISSED_CHANNEL_INVITES, null)?.let { out[DialogDismissalStore.dismissedChannelInvites] = it } - legacy.getStringSet(PrefKeys.MUTED_PUBLIC_CHATS, null)?.let { out[DialogDismissalStore.mutedPublicChats] = it } - legacy.getStringSet(PrefKeys.HAS_DONATED_IN_VERSION, null)?.let { out[DialogDismissalStore.hasDonatedInVersion] = it } - legacy.getString(PrefKeys.VIEWED_POLL_RESULT_NOTE_IDS, null)?.let { out[DialogDismissalStore.viewedPollResultNoteIdsJson] = it } - } - } + private fun legacySource(npub: String): LegacyPreferenceSource = LegacySharedPreferences(encryptedPreferences(npub)) - private fun relayAuthMigration(npub: String) = - CopyOnceMigration("migrated.relayAuth") { out -> - withContext(Dispatchers.IO) { - val legacy = encryptedPreferences(npub) - legacy.getString(PrefKeys.DEFAULT_RELAY_AUTH_POLICY, null)?.let { out[RelayAuthStore.policyName] = it } - if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_MY_RELAYS)) out[RelayAuthStore.trustMyRelays] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_MY_RELAYS, false) - if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_READ_FOLLOWS)) out[RelayAuthStore.trustReadFollows] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_READ_FOLLOWS, false) - if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_FOLLOWS)) out[RelayAuthStore.trustMessageFollows] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_FOLLOWS, false) - if (legacy.contains(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_STRANGERS)) out[RelayAuthStore.trustMessageStrangers] = legacy.getBoolean(PrefKeys.RELAY_AUTH_TRUST_MESSAGE_STRANGERS, false) - } - } + /** + * Whether the app has stopped mirroring into `secret_keeper_`. + * + * False, and deliberately so: the private key, the secrets and the identity + * group are all still written there, so that a build rolled back to reading + * only the legacy file still finds a complete account. Deleting the file + * while that is true would achieve nothing — the next save recreates it — + * so [legacyCleanup] refuses to. + * + * Flipping this is a release of its own, and it ends the rollback window. + * It waits on the device pass in + * `amethyst/plans/2026-09-23-encrypted-storage-retirement.md`. + */ + private const val LEGACY_WRITES_RETIRED = false - private fun feedVisibilityMigration(npub: String) = - CopyOnceMigration("migrated.feedVisibility") { out -> - withContext(Dispatchers.IO) { - val legacy = encryptedPreferences(npub) - legacy.getString(PrefKeys.DISABLED_CHAT_FEEDS, null)?.let { out[FeedVisibilityStore.disabledChatFeeds] = it } - legacy.getString(PrefKeys.DISABLED_HOME_FEED_TYPES, null)?.let { out[FeedVisibilityStore.disabledHomeFeedTypes] = it } - legacy.getString(PrefKeys.RELAY_GROUP_VIEW_MODE, null)?.let { out[FeedVisibilityStore.relayGroupViewMode] = it } - legacy.getString(PrefKeys.CONCORD_VIEW_MODE, null)?.let { out[FeedVisibilityStore.concordViewMode] = it } - if (legacy.contains(PrefKeys.CALLS_ENABLED)) out[FeedVisibilityStore.callsEnabled] = legacy.getBoolean(PrefKeys.CALLS_ENABLED, false) - } - } + private val legacyCleanup: LegacyPreferenceCleanup by lazy { + LegacyPreferenceCleanup( + tables = LegacyAccountKeys.tables, + accepted = LegacyAccountKeys.accepted, + files = + object : LegacyAccountFiles { + override fun source(npub: String) = legacySource(npub) - private fun notificationPrefsMigration(npub: String) = - CopyOnceMigration("migrated.notificationPrefs") { out -> - withContext(Dispatchers.IO) { - val legacy = encryptedPreferences(npub) - if (legacy.contains(PrefKeys.ALWAYS_ON_NOTIFICATION_SERVICE)) out[NotificationPrefsStore.alwaysOnService] = legacy.getBoolean(PrefKeys.ALWAYS_ON_NOTIFICATION_SERVICE, false) - if (legacy.contains(PrefKeys.SHOW_MESSAGES_IN_NOTIFICATIONS)) out[NotificationPrefsStore.showMessagesInNotifications] = legacy.getBoolean(PrefKeys.SHOW_MESSAGES_IN_NOTIFICATIONS, false) - if (legacy.contains(PrefKeys.SPLIT_NOTIFICATIONS_ENABLED)) out[NotificationPrefsStore.splitNotificationsEnabled] = legacy.getBoolean(PrefKeys.SPLIT_NOTIFICATIONS_ENABLED, false) - } - } + override fun exists(npub: String) = legacyAccountFile(npub).exists() + + override suspend fun delete(npub: String): Boolean { + // Clear before unlinking, as deleteAccount does: the live + // SharedPreferences still holds the values in memory and + // would write them straight back out. + encryptedPreferences(npub).edit(commit = true) { clear() } + return legacyAccountFile(npub).delete() + } + }, + currentStore = { npub -> accountStores.getDataStore(npub).data.first() }, + secrets = + object : MigratedSecrets { + override suspend fun secrets(npub: String) = accountSecretsStore.stored(npub) + + override suspend fun privateKey(npub: String) = accountKeyStore.stored(npub) + }, + legacyWritesRetired = LEGACY_WRITES_RETIRED, + ) + } + + /** + * The file behind [encryptedPreferences], following the same branch it + * does — a name taken from the other side of that `if` would have the + * cleanup checking for, and deleting, a file that is not the one being + * read. + */ + private fun legacyAccountFile(npub: String): File { + val name = if (BuildConfig.DEBUG && DEBUG_PLAINTEXT_PREFERENCES) "${DEBUG_PREFERENCES_NAME}_$npub" else EncryptedStorage.prefsFileName(npub) + return File(prefsDirPath, "$name.xml") + } /** * Everything the account's DataStore holds, read in one hop. @@ -375,6 +378,7 @@ object LocalPreferences { * over. One call, one state. */ private class AccountStoreData( + val identity: AccountIdentity, val followLists: Map, val latestEvents: Map, val uploadSettings: UploadSettings, @@ -384,36 +388,19 @@ object LocalPreferences { val notificationPrefs: NotificationPrefs, ) - private suspend fun loadAccountStores(npub: String) = - AccountStoreData( - followLists = followListStore(npub).load(), - latestEvents = latestEventStore(npub).load(), - uploadSettings = uploadSettingsStore(npub).load(), - dialogDismissal = dialogDismissalStore(npub).load(), - relayAuth = relayAuthStore(npub).load(), - feedVisibility = feedVisibilityStore(npub).load(), - notificationPrefs = notificationPrefsStore(npub).load(), - ) - - private fun followListMigration(npub: String) = - CopyOnceMigration("migrated.followLists") { out -> - withContext(Dispatchers.IO) { - val legacy = encryptedPreferences(npub) - FollowListSlot.entries.forEach { slot -> - legacy.getString(slot.prefKey, null)?.let { out[slot.key] = it } - } - } - } - - private fun latestEventMigration(npub: String) = - CopyOnceMigration("migrated.latestEvents") { out -> - withContext(Dispatchers.IO) { - val legacy = encryptedPreferences(npub) - LatestEventSlot.entries.forEach { slot -> - legacy.getString(slot.prefKey, null)?.let { out[slot.key] = it } - } - } - } + private suspend fun loadAccountStores( + npub: String, + legacyIdentity: () -> AccountIdentity, + ) = AccountStoreData( + identity = identityStore(npub).load().orIfUnusable(legacyIdentity), + followLists = followListStore(npub).load(), + latestEvents = latestEventStore(npub).load(), + uploadSettings = uploadSettingsStore(npub).load(), + dialogDismissal = dialogDismissalStore(npub).load(), + relayAuth = relayAuthStore(npub).load(), + feedVisibility = feedVisibilityStore(npub).load(), + notificationPrefs = notificationPrefsStore(npub).load(), + ) // NOT migrated to DataStore, and cannot be: DataStore is suspend-only, while // NotificationRelayService.isEnabled(context) is a synchronous Boolean read @@ -796,6 +783,18 @@ object LocalPreferences { privKeyHex = settings.keyPair.privKey?.toHexKey(), ) } + // Mirrored, not moved: NOSTR_PUBKEY is the one key whose loss empties + // the app, so the legacy write above stays until a release has + // proved this one — see [EncryptedStorage]. + identityStore(settings.keyPair.pubKey.toNpub()).save( + AccountIdentity( + pubKeyHex = settings.keyPair.pubKey.toHexKey(), + loginWithExternalSigner = settings.externalSignerPackageName != null, + externalSignerPackageName = settings.externalSignerPackageName, + localRelayServers = settings.localRelayServers.value, + openBackupConflictsJson = settings.openBackupConflicts().takeIf { it.isNotEmpty() }?.let { BackupConflictStorage.encode(it) }, + ), + ) uploadSettingsStore(settings.keyPair.pubKey.toNpub()).save( UploadSettings( stripLocationOnUpload = settings.stripLocationOnUpload, @@ -915,16 +914,15 @@ object LocalPreferences { suspend fun loadAccountConfigFromEncryptedStorage(): AccountSettings? = currentAccount()?.let { loadAccountConfigFromEncryptedStorage(it) } - fun saveSharedSettings( - sharedSettings: UiSettings, - prefs: SharedPreferences = encryptedPreferences(), - ) { - Log.d("LocalPreferences", "Saving to shared settings") - prefs.edit { - putString(PrefKeys.SHARED_SETTINGS, JsonMapper.toJson(sharedSettings)) - } - } - + /** + * The UI settings as the global `secret_keeper` file holds them. + * + * A migration source only: [UiSharedPreferences] owns these now and writes + * them to its own DataStore, which carries a one-shot copy out of this blob + * for installs that predate it. Nothing writes here any more — the matching + * `saveSharedSettings` was removed once it had no callers — but the read + * stays for good, like every other legacy reader; see [EncryptedStorage]. + */ fun loadSharedSettings(prefs: SharedPreferences = encryptedPreferences()): UiSettings? { Log.d("LocalPreferences", "Load shared settings") with(prefs) { @@ -953,10 +951,9 @@ object LocalPreferences { private suspend fun hasBackedUpKeysFlow(npub: String): MutableStateFlow = hasBackedUpKeysMutex.withLock { hasBackedUpKeysFlows.getOrPut(npub) { - val stored = - withContext(Dispatchers.IO) { - encryptedPreferences(npub).getBoolean(PrefKeys.HAS_BACKED_UP_KEYS, true) - } + // Absent reads as true in both stores, so a store that cannot be + // read leaves the nudge off rather than showing it to everyone. + val stored = withContext(Dispatchers.IO) { identityStore(npub).hasBackedUpKeys() } MutableStateFlow(stored) } } @@ -969,7 +966,10 @@ object LocalPreferences { npub: String, ) { withContext(Dispatchers.IO) { + // Legacy write kept alongside the new one, as for the rest of the + // identity group — see [EncryptedStorage]. encryptedPreferences(npub).edit { putBoolean(PrefKeys.HAS_BACKED_UP_KEYS, value) } + identityStore(npub).setHasBackedUpKeys(value) } hasBackedUpKeysFlow(npub).value = value } @@ -991,6 +991,12 @@ object LocalPreferences { // raced in before the per-npub file finished being written. if (accountSettings != null) { cachedAccounts.put(npub, accountSettings) + + // Everything this account has is now migrated and just been + // read back, which is the only moment the legacy file can be + // shown to be redundant. It will not be, yet — see + // [LEGACY_WRITES_RETIRED]. + legacyCleanup.deleteIfVerified(npub) } return@withContext accountSettings @@ -998,26 +1004,52 @@ object LocalPreferences { } } - private suspend fun innerLoadCurrentAccountFromEncryptedStorage(npub: String?): AccountSettings? { + private suspend fun innerLoadCurrentAccountFromEncryptedStorage(npub: String): AccountSettings? { Log.d("LocalPreferences") { "Load account from file $npub" } val startedAtMs = TimeUtils.nowMillis() val result = withContext(Dispatchers.IO) { return@withContext with(encryptedPreferences(npub)) { Log.d("LocalPreferences") { "Load account from file $npub - opened file" } - // pubKey first: the key store is keyed by npub, which is derived - // from it, and this is the same npub the save side writes under. - val pubKey = getString(PrefKeys.NOSTR_PUBKEY, null) ?: return@with null + // Every store this account has, read in one hop — including + // the identity the rest of this function is derived from, so + // that read does not cost its own state in the generated + // coroutine state machine (see [AccountStoreData]). + // + // Keyed by the npub handed in, which is the npub the save side + // writes under and the name of the legacy file just opened. The + // identity falls back to that file when its store cannot + // produce a pubkey: an account without one vanishes from the + // app entirely, private key intact. + val stores = + loadAccountStores(npub) { + AccountIdentity( + pubKeyHex = getString(PrefKeys.NOSTR_PUBKEY, null), + loginWithExternalSigner = getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false), + externalSignerPackageName = getString(PrefKeys.SIGNER_PACKAGE_NAME, null), + localRelayServers = getStringSet(PrefKeys.LOCAL_RELAY_SERVERS, null) ?: setOf(), + openBackupConflictsJson = getString(PrefKeys.OPEN_BACKUP_CONFLICTS, null), + ) + } + val identity = stores.identity + val pubKey = identity.pubKeyHex ?: return@with null val privKey = accountKeyStore.read( npub = pubKey.hexToByteArray().toNpub(), legacyValue = getString(PrefKeys.NOSTR_PRIVKEY, null), ) - val externalSignerPackageName = getString(PrefKeys.SIGNER_PACKAGE_NAME, null) ?: if (getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false)) "com.greenart7c3.nostrsigner" else null + val externalSignerPackageName = identity.externalSignerPackageName ?: if (identity.loginWithExternalSigner) "com.greenart7c3.nostrsigner" else null val keyPair = KeyPair(privKey = privKey?.hexToByteArray(), pubKey = pubKey.hexToByteArray()) - val stores = loadAccountStores(keyPair.pubKey.toNpub()) + // The npub handed in names the file just read, and the save + // side writes every store under the npub derived from the + // pubkey inside it, so the two are the same by construction. + // Say so if they ever are not: it would mean this load is + // reading stores that a save never wrote. + if (keyPair.pubKey.toNpub() != npub) { + Log.e("LocalPreferences", "Account file $npub holds pubkey ${keyPair.pubKey.toNpub()}; its stores were read under the file's name", null) + } Log.d("LocalPreferences") { "Load account from file $npub - keys ready" } @@ -1043,7 +1075,7 @@ object LocalPreferences { val dismissedChannelInvites = stores.dialogDismissal.dismissedChannelInvites val mutedPublicChats = stores.dialogDismissal.mutedPublicChats val viewedPollResultNoteIdsStr = stores.dialogDismissal.viewedPollResultNoteIdsJson - val localRelayServers = getStringSet(PrefKeys.LOCAL_RELAY_SERVERS, null) ?: setOf() + val localRelayServers = identity.localRelayServers val followListPrefs = toFollowListPrefs(stores.followLists) @@ -1052,18 +1084,9 @@ object LocalPreferences { val secrets = accountSecretsStore.read( npub = keyPair.pubKey.toNpub(), - legacy = - AccountSecrets( - nip46SignerEnabled = getBoolean(PrefKeys.NIP46_SIGNER_ENABLED, false), - nip46BunkerSecret = getString(PrefKeys.NIP46_BUNKER_SECRET, "") ?: "", - nip46TransportKey = getString(PrefKeys.NIP46_TRANSPORT_KEY, "") ?: "", - nip46SeenRequestIds = getStringSet(PrefKeys.NIP46_SEEN_IDS, null) ?: setOf(), - nwcWalletsJson = getString(PrefKeys.NWC_WALLETS, null), - clinkDebitWalletsJson = getString(PrefKeys.CLINK_DEBIT_WALLETS, null), - defaultPaymentSourceId = getString(PrefKeys.DEFAULT_PAYMENT_SOURCE_ID, null), - legacyDefaultNwcWalletId = getString(PrefKeys.DEFAULT_NWC_WALLET_ID, null), - legacyZapPaymentRequestServer = getString(PrefKeys.ZAP_PAYMENT_REQUEST_SERVER, null), - ), + // Through the shared reader, so the loader and the check + // that gates deleting this file read the same keys. + legacy = readLegacyAccountSecrets(LegacySharedPreferences(this)), ) val nip46SignerEnabled = secrets.nip46SignerEnabled val nip46BunkerSecret = secrets.nip46BunkerSecret @@ -1077,7 +1100,7 @@ object LocalPreferences { val defaultFileServerStr = stores.uploadSettings.defaultFileServerJson val pendingAttestationsStr = getString(PrefKeys.PENDING_ATTESTATIONS, null) - val openBackupConflictsStr = getString(PrefKeys.OPEN_BACKUP_CONFLICTS, null) + val openBackupConflictsStr = identity.openBackupConflictsJson val latestUserMetadataStr = stores.latestEvents[LatestEventSlot.USER_METADATA] val latestContactListStr = stores.latestEvents[LatestEventSlot.CONTACT_LIST] val latestDmRelayListStr = stores.latestEvents[LatestEventSlot.DM_RELAY_LIST] diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyKeyCoverageTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyKeyCoverageTest.kt new file mode 100644 index 0000000000..e218c8be32 --- /dev/null +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyKeyCoverageTest.kt @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyAccountSecretNames +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test +import java.lang.reflect.Modifier + +/** + * Every key the app has ever written to a `secret_keeper` file has to be + * accounted for somewhere, and this is what says so. + * + * [LegacyPreferenceCleanup] refuses to delete a file holding a key it does not + * recognise, which is the right runtime behaviour but a slow way to find out. + * A key added to `PrefKeys` and to neither a migration table nor the accepted + * list fails here instead — at the commit that adds it, naming it. + */ +class LegacyKeyCoverageTest { + /** Read off the object rather than restated, so the test cannot go stale. */ + private val allPrefKeys: Set = + PrefKeys::class.java.declaredFields + .filter { Modifier.isStatic(it.modifiers) && it.type == String::class.java } + .map { + it.isAccessible = true + it.get(null) as String + }.toSet() + + /** + * Keys of the *global* `secret_keeper` file, which has no per-account + * counterpart and is not what the cleanup deletes. + * `notification_service_enabled` is not even in it — it lives in a plain + * file, deliberately, because it is read synchronously in fresh processes. + */ + private val globalFileKeys = + setOf( + PrefKeys.CURRENT_ACCOUNT, + PrefKeys.SAVED_ACCOUNTS, + PrefKeys.ALL_ACCOUNT_INFO, + PrefKeys.SHARED_SETTINGS, + PrefKeys.NOTIFICATION_SERVICE_ENABLED, + ) + + @Test + fun thePrefKeysListWasActuallyRead() { + assertTrue(allPrefKeys.size.toString(), allPrefKeys.size > 100) + assertTrue(PrefKeys.NOSTR_PUBKEY in allPrefKeys) + } + + @Test + fun everyLegacyKeyIsEitherMigratedOrDeliberatelyDropped() { + val migrated = LegacyAccountKeys.tables.flatMapTo(mutableSetOf()) { it.legacyNames } + val classified = migrated + LegacyAccountSecretNames.all + LegacyAccountKeys.accepted + globalFileKeys + + assertEquals( + "Unclassified legacy keys. Add each to a migration table, or to LegacyAccountKeys.accepted if losing it is deliberate.", + emptySet(), + allPrefKeys - classified, + ) + } + + /** + * The reverse direction: a table claiming a key `PrefKeys` no longer has + * means the copy is reading a name nothing writes. + */ + @Test + fun noTableClaimsAKeyThatNoLongerExists() { + val migrated = LegacyAccountKeys.tables.flatMapTo(mutableSetOf()) { it.legacyNames } + + assertEquals(emptySet(), migrated - allPrefKeys) + assertEquals(emptySet(), LegacyAccountSecretNames.all - allPrefKeys) + assertEquals(emptySet(), LegacyAccountKeys.accepted - allPrefKeys) + } + + /** + * The seven that were still read only from the legacy file. Named + * individually because `nostr_pubkey` is the one whose loss empties the + * app: without it the loader returns null and the account disappears, with + * its private key sitting safe and unreachable in the key store. + */ + @Test + fun theLastSevenKeysAreMigrated() { + val migrated = LegacyAccountKeys.tables.flatMapTo(mutableSetOf()) { it.legacyNames } + + listOf( + PrefKeys.NOSTR_PUBKEY, + PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, + PrefKeys.SIGNER_PACKAGE_NAME, + PrefKeys.HAS_BACKED_UP_KEYS, + PrefKeys.LOCAL_RELAY_SERVERS, + PrefKeys.OPEN_BACKUP_CONFLICTS, + ).forEach { assertTrue(it, it in migrated) } + + // The seventh is global, and moved into the UI settings DataStore + // rather than a per-account one. + assertTrue(PrefKeys.SHARED_SETTINGS in globalFileKeys) + } +} diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt new file mode 100644 index 0000000000..c79704c29a --- /dev/null +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst + +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.mutablePreferencesOf +import androidx.datastore.preferences.core.stringPreferencesKey +import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyBooleanKey +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyKeyTable +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyPreferenceSource +import com.vitorpamplona.amethyst.commons.model.preferences.LegacyStringKey +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test + +private const val NPUB = "npub1test" + +private class MapSource( + private val values: Map, +) : LegacyPreferenceSource { + override fun keys() = values.keys + + override fun getBoolean(name: String) = values[name] as Boolean? + + override fun getString(name: String) = values[name] as String? + + @Suppress("UNCHECKED_CAST") + override fun getStringSet(name: String) = values[name] as Set? +} + +private class FakeFiles( + private val values: Map, +) : LegacyAccountFiles { + var deleted = false + private set + + var present = true + + override fun source(npub: String) = MapSource(values) + + override fun exists(npub: String) = present + + override suspend fun delete(npub: String): Boolean { + deleted = true + present = false + return true + } +} + +private class FakeSecrets( + private val stored: AccountSecrets? = AccountSecrets(), + private val key: String? = null, + private val throws: Boolean = false, +) : MigratedSecrets { + override suspend fun secrets(npub: String): AccountSecrets? { + if (throws) throw IllegalStateException("keystore unavailable") + return stored + } + + override suspend fun privateKey(npub: String): String? { + if (throws) throw IllegalStateException("keystore unavailable") + return key + } +} + +/** + * The gate in front of deleting an account's `secret_keeper_` file. + * + * Every test here is a way the deletion could destroy something, so the + * assertions are mostly that it did *not* happen. + */ +class LegacyPreferenceCleanupTest { + private val flag = booleanPreferencesKey("flag") + private val text = stringPreferencesKey("text") + + private val table = + LegacyKeyTable( + "migrated.group", + listOf(LegacyBooleanKey("legacy_flag", flag), LegacyStringKey("legacy_text", text)), + ) + + private val migrated = mutablePreferencesOf().also { it[booleanPreferencesKey("migrated.group")] = true } + + private fun cleanup( + values: Map, + current: Preferences = migrated, + secrets: MigratedSecrets = FakeSecrets(), + files: FakeFiles = FakeFiles(values), + retired: Boolean = true, + accepted: Set = setOf("pending_attestations"), + ) = files to + LegacyPreferenceCleanup( + tables = listOf(table), + accepted = accepted, + files = files, + currentStore = { current }, + secrets = secrets, + legacyWritesRetired = retired, + ) + + @Test + fun deletesOnceEverythingIsAccountedFor() = + runTest { + val (files, subject) = cleanup(mapOf("legacy_flag" to true, "pending_attestations" to "[]")) + + assertEquals(emptyList(), subject.verify(NPUB)) + assertEquals(LegacyCleanupResult.Deleted, subject.deleteIfVerified(NPUB)) + assertTrue(files.deleted) + } + + /** + * The hole a hand-maintained checklist leaves: a key added later that no + * migration carries. The check runs from the file's own keys so that it + * cannot be missed. + */ + @Test + fun anUnrecognisedKeyStopsTheDeletion() = + runTest { + val (files, subject) = cleanup(mapOf("legacy_flag" to true, "something_new" to "value")) + + val result = subject.deleteIfVerified(NPUB) + + assertEquals(LegacyCleanupResult.Kept(listOf("no migration claims 'something_new'")), result) + assertTrue(!files.deleted) + } + + @Test + fun aCopyThatHasNotRunStopsTheDeletion() = + runTest { + val (files, subject) = cleanup(mapOf("legacy_flag" to true), current = emptyPreferences()) + + val result = subject.deleteIfVerified(NPUB) + + assertEquals(LegacyCleanupResult.Kept(listOf("the 'migrated.group' copy has not run")), result) + assertTrue(!files.deleted) + } + + /** + * A file that never held a group's keys has nothing for that copy to prove, + * so an account predating a setting is not held back by it forever. + */ + @Test + fun aGroupTheFileNeverHeldDoesNotBlock() = + runTest { + val (_, subject) = cleanup(mapOf("pending_attestations" to "[]"), current = emptyPreferences()) + + assertEquals(emptyList(), subject.verify(NPUB)) + } + + @Test + fun secretsThatHaveNotBeenCopiedStopTheDeletion() = + runTest { + val (files, subject) = cleanup(mapOf("legacy_flag" to true), secrets = FakeSecrets(stored = null)) + + val result = subject.deleteIfVerified(NPUB) + + assertEquals(LegacyCleanupResult.Kept(listOf("the secrets have not been copied across")), result) + assertTrue(!files.deleted) + } + + /** Both stores are still written, so a disagreement means a write was lost. */ + @Test + fun secretsThatDisagreeStopTheDeletion() = + runTest { + val (files, subject) = + cleanup( + mapOf("legacy_flag" to true, "nip46BunkerSecret" to "from-the-file"), + secrets = FakeSecrets(stored = AccountSecrets(nip46BunkerSecret = "stale")), + ) + + val result = subject.deleteIfVerified(NPUB) + + assertEquals( + LegacyCleanupResult.Kept(listOf("the stored secrets differ from the legacy file: nip46BunkerSecret")), + result, + ) + assertTrue(!files.deleted) + } + + /** The values themselves are bunker secrets and wallet strings. */ + @Test + fun aSecretsMismatchNamesTheFieldAndNotTheValue() = + runTest { + val (_, subject) = + cleanup( + mapOf("nwcWallets" to "nostr+walletconnect://deadbeef?secret=hunter2"), + secrets = FakeSecrets(stored = AccountSecrets()), + ) + + val reason = subject.verify(NPUB).single() + + assertTrue(reason, !reason.contains("hunter2")) + assertTrue(reason, reason.contains("nwcWallets")) + } + + @Test + fun aPrivateKeyThatHasNotBeenCopiedStopsTheDeletion() = + runTest { + val (files, subject) = + cleanup( + mapOf("nostr_privkey" to "abc123"), + secrets = FakeSecrets(key = null), + ) + + val result = subject.deleteIfVerified(NPUB) + + assertEquals(LegacyCleanupResult.Kept(listOf("the private key has not been copied across")), result) + assertTrue(!files.deleted) + } + + @Test + fun aPrivateKeyThatDisagreesStopsTheDeletion() = + runTest { + val (_, subject) = cleanup(mapOf("nostr_privkey" to "abc123"), secrets = FakeSecrets(key = "def456")) + + assertEquals(listOf("the stored private key differs from the legacy file"), subject.verify(NPUB)) + } + + @Test + fun aMatchingPrivateKeyPasses() = + runTest { + val (_, subject) = cleanup(mapOf("nostr_privkey" to "abc123"), secrets = FakeSecrets(key = "abc123")) + + assertEquals(emptyList(), subject.verify(NPUB)) + } + + /** + * An external-signer account has no private key in either store, and must + * not be held back for the one it never had. + */ + @Test + fun anAccountWithNoPrivateKeyIsNotHeldBack() = + runTest { + val (_, subject) = cleanup(mapOf("legacy_flag" to true), secrets = FakeSecrets(key = null)) + + assertEquals(emptyList(), subject.verify(NPUB)) + } + + /** "The check itself failed" is not "the check passed". */ + @Test + fun aStoreThatCannotBeReadStopsTheDeletion() = + runTest { + val (files, subject) = cleanup(mapOf("nostr_privkey" to "abc123"), secrets = FakeSecrets(throws = true)) + + val result = subject.deleteIfVerified(NPUB) + + assertEquals( + LegacyCleanupResult.Kept(listOf("the secrets store could not be read", "the key store could not be read")), + result, + ) + assertTrue(!files.deleted) + } + + /** + * While the app still mirrors into this file, deleting it achieves nothing + * — the next save recreates it — and would look like it had worked. + */ + @Test + fun nothingIsDeletedWhileTheLegacyFileIsStillWritten() = + runTest { + val (files, subject) = cleanup(mapOf("legacy_flag" to true), retired = false) + + val result = subject.deleteIfVerified(NPUB) + + assertEquals(LegacyCleanupResult.Kept(listOf(LegacyPreferenceCleanup.STILL_WRITTEN)), result) + assertTrue(!files.deleted) + } + + @Test + fun anAccountWithNoLegacyFileIsAlreadyDone() = + runTest { + val files = FakeFiles(emptyMap()).also { it.present = false } + val (_, subject) = cleanup(emptyMap(), files = files) + + assertEquals(LegacyCleanupResult.NothingToDelete, subject.deleteIfVerified(NPUB)) + } + + /** Every reason is reported, so one fix does not merely reveal the next. */ + @Test + fun everyReasonIsReportedAtOnce() = + runTest { + val (_, subject) = + cleanup( + mapOf("legacy_flag" to true, "mystery" to "x", "nostr_privkey" to "abc123"), + current = emptyPreferences(), + secrets = FakeSecrets(stored = null, key = null), + ) + + assertEquals( + listOf( + "no migration claims 'mystery'", + "the 'migrated.group' copy has not run", + "the secrets have not been copied across", + "the private key has not been copied across", + ), + subject.verify(NPUB), + ) + } +} From e8af62717ebafa28a44c4a1ad14eae0358d18556 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 23:12:12 +0000 Subject: [PATCH 15/57] fix: correctness and cost problems found reviewing the migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A review pass over the full range turned up eleven things. The two that lose user data: **A deleted account came back.** deleteAccount cleared the legacy file, the key store and the secrets store, but never the account's plain DataStore — deleteUserPreferenceFile sweeps shared_prefs/ and that store lives in filesDir/datastore/. AccountPreferenceStores.removeAccount existed and had no caller. Before this branch the orphan was merely litter, because nothing read it; now it holds nostr_pubkey, so re-adding the same npub found a live identity, setDefaultAccount's downgrade guard saw a writeable account and restored the one the user had just deleted. Everything else in there — cached contact and mute lists, 31 follow-list filters, dismissed polls — also stayed on disk unencrypted for good. **The notifications Global -> Selected migration stamped itself done and threw the result away.** It wrote the corrected filter to the legacy DEFAULT_NOTIFICATION_FOLLOW_LIST, which nothing reads once the follow-list copy marker is set, while the stamp went somewhere that persists. End a session with no save and the next launch skips the migration and reads Global back out of the DataStore — the account stays on raw Global notifications permanently. It now writes through followListStore and stamps only after that write succeeds. Two more that would have bitten later: - The SAVED_ACCOUNTS upgrade branch wrote ALL_ACCOUNT_INFO to the legacy file without mirroring it into the roster store, whose own copy had already run against a key that did not exist yet and whose marker was already set. Those installs would open as a fresh install the moment the legacy write goes — the failure AccountRoster's KDoc calls the most consequential to get wrong. - deletePrivateKey gated its removal on a decrypting read, so a rotated or wiped keystore — exactly when the value is unreadable — skipped the delete and left a deleted account's key on disk. It now tests presence without decrypting, via a new EncryptedDataStore.contains. Two crashes from DataStore's one-store-per-path registry, which only releases on scope cancellation: desktopChessDismissedGamesStore() and Android's SecureKeyStorage both built a store per call over a fixed path. The chess one is reachable today — the view model builds one in its constructor under a remember(account), so reopening that screen threw from an unhandled scope.launch and took the screen's scope down with it. Both are now one store per process. EncryptedSharedPreferences.create was idempotent, which is why neither needed this before. Chess dismissals were fire-and-forget saves of a read-modify-write snapshot, so two in quick succession could land out of order and drop one, and a dismissal racing the async seed wrote a snapshot missing everything already stored. They now go through a single conflated channel with one consumer that writes the current set, and the seed asks for a write when it finds it unioned into a set someone had already persisted. Cost, on paths that run constantly: - saveSecrets did ten separate encrypted-file rewrites per account save, none of which DataStore could skip since AES-GCM re-randomises the IV so the ciphertext differs even when the value does not. One edit now — which also makes the marker mean what LegacyPreferenceCleanup reads it as, since it can no longer exist without the values beside it. loadSecrets likewise reads one snapshot instead of ten flow collections. - SecretEncryption was default-constructed per store: eight AndroidKeyStore loads and eight per-thread Cipher caches for one key alias. One shared instance; both actuals document concurrent use. - updateSavedAccounts compared a MutableStateFlow to a List, so the guard was unconditionally true and every call rewrote both stores. Pre-existing, but this branch put an encrypt and an encrypted-store write behind it. - The cleanup ran inside the mutex that serialises every account load, so once enabled each account on a multi-account cold start would wait for the previous one's full pass. It now runs outside the lock, once, on the call that did the loading. And one design flaw in the new cleanup itself: it compared the stored secrets against the legacy file, justified by their being dual-written — but the check only runs once LEGACY_WRITES_RETIRED turns that off, from which point the legacy copy is frozen. Any account that re-paired a bunker after upgrading would have differed forever and never had its file deleted. Secrets are now gated on the migration marker, like the plain groups. The private-key comparison stays: an npub is derived from its key, so that one cannot legitimately change. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/LegacyPreferenceCleanup.kt | 42 +++---- .../amethyst/LocalPreferences.kt | 116 +++++++++++------- .../amethyst/LegacyPreferenceCleanupTest.kt | 43 +++---- .../commons/keystorage/SecureKeyStorage.kt | 44 +++++-- .../commons/nip64Chess/ChessLobbyLogic.kt | 48 +++++--- .../AccountSecretsEncryptedStores.kt | 68 +++++----- .../model/preferences/EncryptedDataStore.kt | 86 ++++++++++++- .../nip64Chess/ChessDismissedGamesStoreJvm.kt | 18 ++- .../preferences/EncryptedDataStoreTest.kt | 84 +++++++++++++ .../ChessDismissedGamesStoreTest.kt | 15 +++ 10 files changed, 405 insertions(+), 159 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt index fc7973abe6..9872ab3ac8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt @@ -33,7 +33,6 @@ import com.vitorpamplona.amethyst.commons.model.preferences.NotificationPrefsSto import com.vitorpamplona.amethyst.commons.model.preferences.RelayAuthStore import com.vitorpamplona.amethyst.commons.model.preferences.TopNavFollowListStore import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettingsStore -import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyAccountSecrets import com.vitorpamplona.quartz.utils.Log /** @@ -133,9 +132,19 @@ interface MigratedSecrets { * `CopyOnceMigration` writes the values and its marker as a single * `Preferences`, committed atomically, so the marker cannot be set without them. * - * The secrets and the private key are still written to *both* stores on every - * save, so for those the stronger question is available and is asked: read both - * back and require them to agree. + * The private key takes the strongest form: read it back and require it to + * equal the legacy one. That comparison stays valid forever, because an npub is + * derived from its private key, so the key for a given npub can never change. + * + * The secrets cannot be compared, and the reason is worth stating because the + * obvious reading is wrong. They *are* dual-written today — but this whole + * check only runs once [legacyWritesRetired] is true, and from that release on + * the legacy copy is frozen while the live one keeps moving. An account that + * re-pairs a bunker or adds a wallet after upgrading would then differ from the + * file forever and never have it deleted. So they are gated the same way as the + * plain groups: on the copy having run, which + * [AccountSecretsEncryptedStores.loadSecrets] reports by returning non-null + * only once its marker is set, and it writes that marker last. * * # Why an unrecognised key blocks * @@ -223,17 +232,10 @@ class LegacyPreferenceCleanup( npub: String, legacy: LegacyPreferenceSource, ): List { - val expected = readLegacyAccountSecrets(legacy) val reasons = mutableListOf() try { - val stored = secrets.secrets(npub) - when { - stored == null -> reasons += "the secrets have not been copied across" - // Field names only. These values are bunker secrets and wallet - // connection strings; a log line is the last place for them. - stored != expected -> reasons += "the stored secrets differ from the legacy file: ${differingFields(expected, stored)}" - } + if (secrets.secrets(npub) == null) reasons += "the secrets have not been copied across" } catch (e: Exception) { Log.w(TAG, "Could not read the secrets store for $npub", e) reasons += "the secrets store could not be read" @@ -256,22 +258,6 @@ class LegacyPreferenceCleanup( return reasons } - private fun differingFields( - expected: AccountSecrets, - stored: AccountSecrets, - ): String = - listOfNotNull( - "nip46SignerEnabled".takeIf { expected.nip46SignerEnabled != stored.nip46SignerEnabled }, - "nip46BunkerSecret".takeIf { expected.nip46BunkerSecret != stored.nip46BunkerSecret }, - "nip46TransportKey".takeIf { expected.nip46TransportKey != stored.nip46TransportKey }, - "nip46SeenRequestIds".takeIf { expected.nip46SeenRequestIds != stored.nip46SeenRequestIds }, - "nwcWallets".takeIf { expected.nwcWalletsJson != stored.nwcWalletsJson }, - "clinkDebitWallets".takeIf { expected.clinkDebitWalletsJson != stored.clinkDebitWalletsJson }, - "defaultPaymentSourceId".takeIf { expected.defaultPaymentSourceId != stored.defaultPaymentSourceId }, - "defaultNwcWalletId".takeIf { expected.legacyDefaultNwcWalletId != stored.legacyDefaultNwcWalletId }, - "zapPaymentServer".takeIf { expected.legacyZapPaymentRequestServer != stored.legacyZapPaymentRequestServer }, - ).joinToString() - /** * Deletes the account's legacy file if — and only if — [verify] comes back * empty and the app has stopped writing to it. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 9df3f2a2f5..8c514f3774 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -390,10 +390,19 @@ object LocalPreferences { private suspend fun loadAccountStores( npub: String, - legacyIdentity: () -> AccountIdentity, + legacy: SharedPreferences, ) = AccountStoreData( - identity = identityStore(npub).load().orIfUnusable(legacyIdentity), - followLists = followListStore(npub).load(), + identity = + identityStore(npub).load().orIfUnusable { + AccountIdentity( + pubKeyHex = legacy.getString(PrefKeys.NOSTR_PUBKEY, null), + loginWithExternalSigner = legacy.getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false), + externalSignerPackageName = legacy.getString(PrefKeys.SIGNER_PACKAGE_NAME, null), + localRelayServers = legacy.getStringSet(PrefKeys.LOCAL_RELAY_SERVERS, null) ?: setOf(), + openBackupConflictsJson = legacy.getString(PrefKeys.OPEN_BACKUP_CONFLICTS, null), + ) + }, + followLists = migrateNotificationFilter(npub, legacy, followListStore(npub).load()), latestEvents = latestEventStore(npub).load(), uploadSettings = uploadSettingsStore(npub).load(), dialogDismissal = dialogDismissalStore(npub).load(), @@ -522,9 +531,17 @@ object LocalPreferences { ) } + val json = JsonMapper.toJson(migrated) edit { - putString(PrefKeys.ALL_ACCOUNT_INFO, JsonMapper.toJson(migrated)) + putString(PrefKeys.ALL_ACCOUNT_INFO, json) } + // Mirrored as well, exactly as updateSavedAccounts does. The + // roster's own copy has already run by this point, against an + // ALL_ACCOUNT_INFO that did not exist yet, and its marker is + // set — so without this the roster store stays permanently + // empty for these installs and they open as a fresh install + // the moment the legacy write goes. + accountRoster.mirrorAllAccountInfoJson(json) migrated } @@ -535,7 +552,10 @@ object LocalPreferences { private suspend fun updateSavedAccounts(accounts: List) = withContext(Dispatchers.IO) { - if (savedAccounts != accounts) { + // .value, not the flow: StateFlow does not override equals, so + // comparing the holder to a List was unconditionally true and every + // call rewrote both stores. + if (savedAccounts.value != accounts) { savedAccounts.emit(accounts) val json = JsonMapper.toJson(accounts.filter { !it.isTransient }) @@ -614,6 +634,12 @@ object LocalPreferences { encryptedPreferences(accountInfo.npub).edit(commit = true) { clear() } accountKeyStore.delete(accountInfo.npub) accountSecretsStore.delete(accountInfo.npub) + // The account's plain DataStore, which deleteUserPreferenceFile cannot + // reach: that sweeps shared_prefs/, this lives in filesDir/datastore/. + // Left behind it would keep the deleted account's pubkey, signer and + // cached events on disk — and re-adding the same npub would find a + // live identity there and resurrect the account that was just deleted. + accountStores.removeAccount(accountInfo.npub) removeAccount(accountInfo) deleteUserPreferenceFile(accountInfo.npub) @@ -981,26 +1007,33 @@ object LocalPreferences { cachedAccounts[npub]?.let { return it } return withContext(Dispatchers.IO) { - mutex.withLock { - cachedAccounts[npub]?.let { return@withContext it } + var loadedHere = false - val accountSettings = innerLoadCurrentAccountFromEncryptedStorage(npub) + val accountSettings = + mutex.withLock { + cachedAccounts[npub]?.let { return@withLock it } - // Only cache successful loads. Caching null would leave the account - // permanently unreachable for the rest of the session if a reader - // raced in before the per-npub file finished being written. - if (accountSettings != null) { - cachedAccounts.put(npub, accountSettings) + val loaded = innerLoadCurrentAccountFromEncryptedStorage(npub) - // Everything this account has is now migrated and just been - // read back, which is the only moment the legacy file can be - // shown to be redundant. It will not be, yet — see - // [LEGACY_WRITES_RETIRED]. - legacyCleanup.deleteIfVerified(npub) + // Only cache successful loads. Caching null would leave the account + // permanently unreachable for the rest of the session if a reader + // raced in before the per-npub file finished being written. + if (loaded != null) { + cachedAccounts.put(npub, loaded) + loadedHere = true + } + + loaded } - return@withContext accountSettings - } + // Outside the lock, and only for the call that did the loading. + // Verifying decrypts the whole legacy file and reads three stores, + // while `mutex` serialises every account load — under the lock, each + // account on a multi-account cold start would wait for the previous + // one's full cleanup pass. Nothing here feeds the load. + if (loadedHere) legacyCleanup.deleteIfVerified(npub) + + accountSettings } } @@ -1021,16 +1054,7 @@ object LocalPreferences { // identity falls back to that file when its store cannot // produce a pubkey: an account without one vanishes from the // app entirely, private key intact. - val stores = - loadAccountStores(npub) { - AccountIdentity( - pubKeyHex = getString(PrefKeys.NOSTR_PUBKEY, null), - loginWithExternalSigner = getBoolean(PrefKeys.LOGIN_WITH_EXTERNAL_SIGNER, false), - externalSignerPackageName = getString(PrefKeys.SIGNER_PACKAGE_NAME, null), - localRelayServers = getStringSet(PrefKeys.LOCAL_RELAY_SERVERS, null) ?: setOf(), - openBackupConflictsJson = getString(PrefKeys.OPEN_BACKUP_CONFLICTS, null), - ) - } + val stores = loadAccountStores(npub, this) val identity = stores.identity val pubKey = identity.pubKeyHex ?: return@with null val privKey = @@ -1427,17 +1451,27 @@ object LocalPreferences { * deliberate raw-Global choice is never reverted. Accounts created after the * split are stamped at save time, so they are never touched here. */ - private fun SharedPreferences.migrateNotificationFilter(current: TopFilter): TopFilter { - if (getBoolean(PrefKeys.NOTIF_GLOBAL_TO_CURATED_MIGRATED, false)) return current + private suspend fun migrateNotificationFilter( + npub: String, + legacy: SharedPreferences, + filters: Map, + ): Map { + if (legacy.getBoolean(PrefKeys.NOTIF_GLOBAL_TO_CURATED_MIGRATED, false)) return filters + val current = filters.getValue(FollowListSlot.NOTIFICATION) val migrated = if (current is TopFilter.Global) TopFilter.Selected else current - edit { - if (migrated !== current) { - putString(PrefKeys.DEFAULT_NOTIFICATION_FOLLOW_LIST, JsonMapper.toJson(migrated)) - } - putBoolean(PrefKeys.NOTIF_GLOBAL_TO_CURATED_MIGRATED, true) - } - return migrated + + // Into the store the loader reads, not the legacy key it no longer does. + // Writing it to the legacy file and stamping anyway left the account on + // raw Global for good: the stamp survives, the corrected value does not, + // and the next launch reads Global back out of the DataStore. + if (migrated !== current) followListStore(npub).save(FollowListSlot.NOTIFICATION, migrated) + + // Stamped only once the value is actually stored, so a failed write + // means the migration runs again rather than being lost. + legacy.edit { putBoolean(PrefKeys.NOTIF_GLOBAL_TO_CURATED_MIGRATED, true) } + + return if (migrated === current) filters else filters + (FollowListSlot.NOTIFICATION to migrated) } /** @@ -1446,11 +1480,11 @@ object LocalPreferences { * returns every slot, so a missing one is a bug in this mapping rather * than a user with no saved filter, and should fail loudly. */ - private fun SharedPreferences.toFollowListPrefs(filters: Map): FollowListPrefs = + private fun toFollowListPrefs(filters: Map): FollowListPrefs = FollowListPrefs( home = filters.getValue(FollowListSlot.HOME), stories = filters.getValue(FollowListSlot.STORIES), - notification = migrateNotificationFilter(filters.getValue(FollowListSlot.NOTIFICATION)), + notification = filters.getValue(FollowListSlot.NOTIFICATION), discovery = filters.getValue(FollowListSlot.DISCOVERY), polls = filters.getValue(FollowListSlot.POLLS), pictures = filters.getValue(FollowListSlot.PICTURES), diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt index c79704c29a..18bad7f959 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt @@ -180,39 +180,28 @@ class LegacyPreferenceCleanupTest { assertTrue(!files.deleted) } - /** Both stores are still written, so a disagreement means a write was lost. */ + /** + * A migrated secrets group that has since moved on from the legacy file + * must not block deletion. + * + * This check only ever runs in the release that stopped writing the legacy + * file, so from then on that copy is frozen while the live one keeps + * changing. Comparing the two would mean any account that re-pairs a bunker + * or adds a wallet after upgrading never gets its file deleted. The gate is + * the migration marker, which is what a non-null read reports. + */ @Test - fun secretsThatDisagreeStopTheDeletion() = + fun secretsThatHaveMovedOnSinceTheCopyDoNotBlock() = runTest { val (files, subject) = cleanup( - mapOf("legacy_flag" to true, "nip46BunkerSecret" to "from-the-file"), - secrets = FakeSecrets(stored = AccountSecrets(nip46BunkerSecret = "stale")), + mapOf("legacy_flag" to true, "nip46BunkerSecret" to "what-the-file-still-says"), + secrets = FakeSecrets(stored = AccountSecrets(nip46BunkerSecret = "re-paired since")), ) - val result = subject.deleteIfVerified(NPUB) - - assertEquals( - LegacyCleanupResult.Kept(listOf("the stored secrets differ from the legacy file: nip46BunkerSecret")), - result, - ) - assertTrue(!files.deleted) - } - - /** The values themselves are bunker secrets and wallet strings. */ - @Test - fun aSecretsMismatchNamesTheFieldAndNotTheValue() = - runTest { - val (_, subject) = - cleanup( - mapOf("nwcWallets" to "nostr+walletconnect://deadbeef?secret=hunter2"), - secrets = FakeSecrets(stored = AccountSecrets()), - ) - - val reason = subject.verify(NPUB).single() - - assertTrue(reason, !reason.contains("hunter2")) - assertTrue(reason, reason.contains("nwcWallets")) + assertEquals(emptyList(), subject.verify(NPUB)) + assertEquals(LegacyCleanupResult.Deleted, subject.deleteIfVerified(NPUB)) + assertTrue(files.deleted) } @Test diff --git a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt index f3b08ae257..65ce93363e 100644 --- a/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt +++ b/commons/src/androidMain/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorage.kt @@ -68,21 +68,33 @@ actual class SecureKeyStorage private actual constructor() { appContext = context.applicationContext return SecureKeyStorage() } - } - private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + /** + * One scope and one store for the whole process, not one per instance. + * + * [create] hands out a new [SecureKeyStorage] on every call — harmless + * when the store was `EncryptedSharedPreferences.create`, which is + * idempotent, but DataStore keeps a process-wide registry keyed by file + * path and only releases an entry when the owning scope ends. A + * per-instance store over a fixed path meant the second instance threw + * "multiple DataStores active for the same file" on its first read — + * which, for this store, reads as the account having no private key. + */ + private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) - private val store by lazy { - EncryptedDataStore( - PreferenceDataStoreFactory.createWithPath( + private val sharedStore by lazy { + EncryptedDataStore( + PreferenceDataStoreFactory.createWithPath( + scope = scope, + produceFile = { File(appContext.filesDir, STORE_FILE).toOkioPath() }, + ), scope = scope, - produceFile = { File(appContext.filesDir, STORE_FILE).toOkioPath() }, - ), - SecretEncryption(), - scope = scope, - ) + ) + } } + private val store get() = sharedStore + private fun keyFor(npub: String) = stringPreferencesKey(KEY_PREFIX + npub) actual suspend fun savePrivateKey( @@ -117,10 +129,18 @@ actual class SecureKeyStorage private actual constructor() { throw SecureStorageException("Failed to retrieve private key", e) } + /** + * Removes the key unconditionally, and reports whether one was there. + * + * The presence test deliberately does not decrypt. Gating the removal on a + * successful decrypting read meant a rotated or wiped AndroidKeyStore — + * exactly when the value is unreadable — skipped the delete, leaving the + * private key of a deleted account on disk. + */ actual suspend fun deletePrivateKey(npub: String): Boolean = try { - val existed = store.get(keyFor(npub)) != null - if (existed) store.remove(keyFor(npub)) + val existed = store.contains(keyFor(npub)) + store.remove(keyFor(npub)) existed } catch (e: Exception) { throw SecureStorageException("Failed to delete private key", e) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt index d799e48997..eda246f63e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessLobbyLogic.kt @@ -35,6 +35,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils import com.vitorpamplona.quartz.utils.cache.LargeCache import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -141,16 +142,43 @@ class ChessLobbyLogic( * or two. * * The seed unions rather than replaces, so a dismissal the user makes - * before the read lands is not overwritten by it. + * before the read lands is not overwritten by it — and it asks for a write + * when it did union something in, because that earlier dismissal already + * persisted a snapshot that did not have the stored ids in it. */ private val dismissedGameIds: MutableSet = mutableSetOf() + /** + * Serialises persistence, so a save cannot land out of order. + * + * Each dismissal used to launch its own `storage.save(snapshot)`. Two of + * them are unordered on the same dispatcher, so the first dismissal's + * smaller snapshot could be written *after* the second's and drop it — the + * game came back on the next launch. One consumer, writing whatever the set + * currently holds, cannot reorder; conflation is safe for the same reason, + * since a dropped signal is one whose contents the next write includes. + */ + private val persistRequests = Channel(Channel.CONFLATED) + init { dismissedStorage?.let { storage -> + scope.launch { + for (unused in persistRequests) { + storage.save(userPubkey, dismissedGameIdsLock.withLock { dismissedGameIds.toSet() }) + } + } scope.launch { val stored = storage.load(userPubkey) if (stored.isNotEmpty()) { - dismissedGameIdsLock.withLock { dismissedGameIds.addAll(stored) } + val union = + dismissedGameIdsLock.withLock { + dismissedGameIds.addAll(stored) + dismissedGameIds.size + } + // Larger than what was on disk means a dismissal beat this + // read, and the snapshot it wrote is missing everything that + // was already stored. Write the union back. + if (union > stored.size) persistRequests.trySend(Unit) } } } @@ -984,23 +1012,15 @@ class ChessLobbyLogic( fun dismissCompletedGame(gameId: String) { state.removeCompletedGame(gameId) - val snapshot = - dismissedGameIdsLock.withLock { - dismissedGameIds.add(gameId) - dismissedGameIds.toSet() - } - dismissedStorage?.let { storage -> scope.launch { storage.save(userPubkey, snapshot) } } + dismissedGameIdsLock.withLock { dismissedGameIds.add(gameId) } + persistRequests.trySend(Unit) } fun dismissAllCompletedGames() { val allIds = state.completedGames.value.map { it.gameId } state.clearCompletedGames() - val snapshot = - dismissedGameIdsLock.withLock { - dismissedGameIds.addAll(allIds) - dismissedGameIds.toSet() - } - dismissedStorage?.let { storage -> scope.launch { storage.save(userPubkey, snapshot) } } + dismissedGameIdsLock.withLock { dismissedGameIds.addAll(allIds) } + persistRequests.trySend(Unit) } /** diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt index c56bf6b9bd..a359fbcfd2 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt @@ -126,53 +126,53 @@ class AccountSecretsEncryptedStores( * genuinely holds no secrets must not trigger it forever. */ suspend fun loadSecrets(npub: String): AccountSecrets? { - val store = getDataStore(npub) - if (store.get(AccountSecretKeys.migrated) == null) return null + // One snapshot for the whole group rather than ten flow collections. + val stored = getDataStore(npub).snapshot() + if (stored[AccountSecretKeys.migrated] == null) return null return AccountSecrets( - nip46SignerEnabled = store.get(AccountSecretKeys.nip46SignerEnabled).toBoolean(), - nip46BunkerSecret = store.get(AccountSecretKeys.nip46BunkerSecret) ?: "", - nip46TransportKey = store.get(AccountSecretKeys.nip46TransportKey) ?: "", - nip46SeenRequestIds = decodeSet(store.get(AccountSecretKeys.nip46SeenRequestIds)), - nwcWalletsJson = store.get(AccountSecretKeys.nwcWallets), - clinkDebitWalletsJson = store.get(AccountSecretKeys.clinkDebitWallets), - defaultPaymentSourceId = store.get(AccountSecretKeys.defaultPaymentSourceId), - legacyDefaultNwcWalletId = store.get(AccountSecretKeys.legacyDefaultNwcWalletId), - legacyZapPaymentRequestServer = store.get(AccountSecretKeys.legacyZapPaymentRequestServer), + nip46SignerEnabled = stored[AccountSecretKeys.nip46SignerEnabled].toBoolean(), + nip46BunkerSecret = stored[AccountSecretKeys.nip46BunkerSecret] ?: "", + nip46TransportKey = stored[AccountSecretKeys.nip46TransportKey] ?: "", + nip46SeenRequestIds = decodeSet(stored[AccountSecretKeys.nip46SeenRequestIds]), + nwcWalletsJson = stored[AccountSecretKeys.nwcWallets], + clinkDebitWalletsJson = stored[AccountSecretKeys.clinkDebitWallets], + defaultPaymentSourceId = stored[AccountSecretKeys.defaultPaymentSourceId], + legacyDefaultNwcWalletId = stored[AccountSecretKeys.legacyDefaultNwcWalletId], + legacyZapPaymentRequestServer = stored[AccountSecretKeys.legacyZapPaymentRequestServer], ) } /** - * Writes the group, then the marker. + * Writes the group and its marker as one edit. * - * Marker last on purpose: a crash midway leaves the account looking - * unmigrated, so the next load copies from the legacy file again rather - * than reading a half-written set of secrets as complete. + * One edit, not ten. Every account save runs this, and a key at a time cost + * ten encrypted-file rewrites — none of which DataStore could skip, because + * AES-GCM re-randomises the IV so the ciphertext differs even when the value + * does not. + * + * It also makes the marker meaningful. Written in its own transaction after + * the others it merely *tended* to be last; in the same one it cannot exist + * without them, so a marker found on disk proves a complete group — which is + * what `LegacyPreferenceCleanup` reads it as before deleting the legacy file. */ suspend fun saveSecrets( npub: String, value: AccountSecrets, ) { - val store = getDataStore(npub) + getDataStore(npub).edit { + put(AccountSecretKeys.nip46SignerEnabled, value.nip46SignerEnabled.toString()) + put(AccountSecretKeys.nip46BunkerSecret, value.nip46BunkerSecret) + put(AccountSecretKeys.nip46TransportKey, value.nip46TransportKey) + put(AccountSecretKeys.nip46SeenRequestIds, value.nip46SeenRequestIds.joinToString(AccountSecretKeys.SET_SEPARATOR)) + putOrRemove(AccountSecretKeys.nwcWallets, value.nwcWalletsJson) + putOrRemove(AccountSecretKeys.clinkDebitWallets, value.clinkDebitWalletsJson) + putOrRemove(AccountSecretKeys.defaultPaymentSourceId, value.defaultPaymentSourceId) + putOrRemove(AccountSecretKeys.legacyDefaultNwcWalletId, value.legacyDefaultNwcWalletId) + putOrRemove(AccountSecretKeys.legacyZapPaymentRequestServer, value.legacyZapPaymentRequestServer) - store.save(AccountSecretKeys.nip46SignerEnabled, value.nip46SignerEnabled.toString()) - store.save(AccountSecretKeys.nip46BunkerSecret, value.nip46BunkerSecret) - store.save(AccountSecretKeys.nip46TransportKey, value.nip46TransportKey) - store.save(AccountSecretKeys.nip46SeenRequestIds, value.nip46SeenRequestIds.joinToString(AccountSecretKeys.SET_SEPARATOR)) - store.putOrRemove(AccountSecretKeys.nwcWallets, value.nwcWalletsJson) - store.putOrRemove(AccountSecretKeys.clinkDebitWallets, value.clinkDebitWalletsJson) - store.putOrRemove(AccountSecretKeys.defaultPaymentSourceId, value.defaultPaymentSourceId) - store.putOrRemove(AccountSecretKeys.legacyDefaultNwcWalletId, value.legacyDefaultNwcWalletId) - store.putOrRemove(AccountSecretKeys.legacyZapPaymentRequestServer, value.legacyZapPaymentRequestServer) - - store.save(AccountSecretKeys.migrated, "true") - } - - private suspend fun EncryptedDataStore.putOrRemove( - key: androidx.datastore.preferences.core.Preferences.Key, - value: String?, - ) { - if (value != null) save(key, value) else remove(key) + put(AccountSecretKeys.migrated, "true") + } } private fun decodeSet(raw: String?): Set = diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt index 01b26082bb..477e50fe0b 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStore.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.commons.model.preferences import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.MutablePreferences import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.emptyPreferences @@ -41,7 +42,7 @@ import kotlin.io.encoding.Base64 */ class EncryptedDataStore( private val store: DataStore, - private val encryption: SecretEncryption = SecretEncryption(), + private val encryption: SecretEncryption = sharedSecretEncryption, private val scope: CoroutineScope, ) { private fun encrypt(value: String): String = Base64.encode(encryption.encrypt(value.encodeToByteArray())) @@ -74,6 +75,19 @@ class EncryptedDataStore( ?.get(key) ?.let { decrypt(it) } + /** + * Whether the key is present, without decrypting it. + * + * For callers that only need presence — deleting, say. [get] would report a + * value it cannot decrypt as absent, which is the wrong answer when the + * decision being made is whether to remove it. + */ + suspend fun contains(key: Preferences.Key): Boolean = + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .firstOrNull() + ?.contains(key) == true + /** * The value, or null only when the key is genuinely absent. * @@ -84,6 +98,66 @@ class EncryptedDataStore( */ suspend fun getOrThrow(key: Preferences.Key): String? = store.data.first()[key]?.let { decrypt(it) } + /** + * Reads or writes several keys against one snapshot of the store. + * + * A key at a time costs a full DataStore round trip each — a transform, a + * serialize, a temp-file write, an fsync and a rename to save; a fresh flow + * collection to read. Worse for writes, AES-GCM re-randomises the IV, so the + * ciphertext differs every time and DataStore's "value unchanged, skip the + * write" shortcut never fires: all of them always reach disk. + * + * One [edit] is also a single transaction, which is what lets a group be + * written with its own migration marker and never be seen half-applied. + */ + suspend fun edit(block: Editor.() -> Unit) { + store.edit { prefs -> Editor(prefs, ::encrypt).block() } + } + + class Editor internal constructor( + private val prefs: MutablePreferences, + private val encrypt: (String) -> String, + ) { + fun put( + key: Preferences.Key, + value: String, + ) { + prefs[key] = encrypt(value) + } + + fun remove(key: Preferences.Key) { + prefs.remove(key) + } + + fun putOrRemove( + key: Preferences.Key, + value: String?, + ) { + if (value != null) put(key, value) else remove(key) + } + } + + /** + * One snapshot of the store, decrypting on access. + * + * Reads every key of a group against the same collection, and — since the + * values are one atomic write — against the same version of it. + */ + suspend fun snapshot(): Snapshot = + Snapshot( + store.data + .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e } + .firstOrNull() ?: emptyPreferences(), + ::decrypt, + ) + + class Snapshot internal constructor( + private val prefs: Preferences, + private val decrypt: (String) -> String?, + ) { + operator fun get(key: Preferences.Key): String? = prefs[key]?.let(decrypt) + } + fun getProperty( key: Preferences.Key, parser: (String) -> T, @@ -108,3 +182,13 @@ class EncryptedDataStore( scope = scope, ) } + +/** + * The one [SecretEncryption] every encrypted store shares. + * + * Its constructor loads the AndroidKeyStore and its first use probes the key's + * security level, and each instance keeps its own per-thread Cipher cache — all + * for a single key alias. There were eight instances doing that independently. + * Both actuals are documented as safe for concurrent use, so one will do. + */ +internal val sharedSecretEncryption: SecretEncryption by lazy { SecretEncryption() } diff --git a/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt index 5d0153c51d..436f56a2a9 100644 --- a/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt +++ b/commons/src/jvmMain/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreJvm.kt @@ -33,8 +33,22 @@ import java.io.File * carrying it over — the dismissed list is a convenience, and chess has few * enough users that a migration is not worth the code. */ -fun desktopChessDismissedGamesStore(): ChessDismissedGamesStore { +fun desktopChessDismissedGamesStore(): ChessDismissedGamesStore = sharedStore + +/** + * One store for the process. + * + * DataStore keeps a process-wide registry keyed by file path and only releases + * an entry when the owning scope ends; the factory's own scope never does. So + * building a fresh store per call — and the chess view model builds one in its + * constructor, under a `remember(account)` — made the second one throw + * "multiple DataStores active for the same file" on its first read. That + * surfaced from a `scope.launch` with no handler, taking the screen's whole + * scope down with it. The `java.util.prefs` node this replaced was safe to + * construct repeatedly, so nothing here used to need a singleton. + */ +private val sharedStore: ChessDismissedGamesStore by lazy { val file = File(appDataDir, "chess_dismissed_games.preferences_pb") file.parentFile?.mkdirs() - return ChessDismissedGamesStore(PreferenceDataStoreFactory.createWithPath(produceFile = { file.toOkioPath() })) + ChessDismissedGamesStore(PreferenceDataStoreFactory.createWithPath(produceFile = { file.toOkioPath() })) } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt index 6354f5e924..97c2b6ec3a 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.commons.model.preferences import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -211,4 +212,87 @@ class EncryptedDataStoreTest { ) scope.cancel() } + + @Test + fun editWritesEveryKeyInOneGo() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val subject = store(scope) + val other = stringPreferencesKey("bunker") + + subject.edit { + put(key, "wallet") + put(other, "secret") + } + + val snapshot = subject.snapshot() + assertEquals("wallet", snapshot[key]) + assertEquals("secret", snapshot[other]) + } + + /** + * The whole point of writing a group in one edit: a marker written beside + * its values cannot be found on disk without them. + */ + @Test + fun editIsOneTransaction() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val subject = store(scope) + val marker = stringPreferencesKey("migrated") + + runCatching { + subject.edit { + put(key, "wallet") + put(marker, "true") + throw IllegalStateException("crash midway") + } + } + + val snapshot = subject.snapshot() + assertNull(snapshot[marker]) + assertNull(snapshot[key]) + } + + @Test + fun putOrRemoveClearsANullValue() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val subject = store(scope) + + subject.edit { put(key, "wallet") } + subject.edit { putOrRemove(key, null) } + + assertNull(subject.snapshot()[key]) + } + + /** + * `contains` must not decrypt. + * + * A value the current key cannot decrypt — a rotated or wiped keystore — is + * still a value that is there, and deleting it has to happen anyway. + * `deletePrivateKey` gated its removal on a decrypting read and so skipped + * exactly the case that needed it, leaving a deleted account's private key + * on disk. + */ + @Test + fun containsSeesAValueThatCannotBeDecrypted() = + runTest { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + val n = seq++ + val dataFile = File(folder.root, "secrets_$n.preferences_pb") + val raw = + PreferenceDataStoreFactory.createWithPath(scope = scope, produceFile = { dataFile.toOkioPath() }) + // Ciphertext this store's key was never used to produce. + raw.edit { prefs -> prefs[key] = "bm90LWFjdHVhbGx5LWNpcGhlcnRleHQ=" } + + val subject = + EncryptedDataStore(raw, SecretEncryption(File(folder.root, "secret_$n.key")), scope = scope) + + assertTrue(subject.contains(key)) + assertNull(runCatching { subject.get(key) }.getOrNull()) + + subject.remove(key) + assertTrue(!subject.contains(key)) + } } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt index 0d4efd334f..9e28130961 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/nip64Chess/ChessDismissedGamesStoreTest.kt @@ -31,6 +31,7 @@ import kotlinx.coroutines.test.runTest import okio.Path.Companion.toOkioPath import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse +import org.junit.Assert.assertSame import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test @@ -104,4 +105,18 @@ class ChessDismissedGamesStoreTest { assertEquals(setOf("c"), store.load("npub1")) } + + /** + * The desktop factory has to hand back one store, not a new one per call. + * + * DataStore registers a live store per file path and only releases it when + * the owning scope ends — and the factory's own scope never does. Building + * a fresh one per call meant the second `IllegalStateException: multiple + * DataStores active for the same file`, thrown from the chess view model's + * constructor the second time that screen opened. + */ + @Test + fun theDesktopFactoryReturnsOneStore() { + assertSame(desktopChessDismissedGamesStore(), desktopChessDismissedGamesStore()) + } } From aed654b76beb2f5fbdd4be3367a9cc80a26e59da Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 00:30:47 +0000 Subject: [PATCH 16/57] fix: wait for a removed account's DataStore to shut down, not just ask it to MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI caught this on `:commons:jvmTest`: "There are multiple DataStores active for the same file: .../npub1abc.secrets.preferences_pb", from AccountSecretsStoreTest. It passes locally and fails on a loaded runner, which is the tell. `removeAccount` cancelled the store's scope and moved on. But DataStore keeps its process-wide registry entry until the owning scope's job actually *completes* — cancel() only asks. Anything that opens the same path inside that window throws, and for a per-account store that window is exactly the delete-then-add-the-same-npub flow. Reproduced it deterministically before fixing: cancel a scope holding a child that takes a moment to wind down, open a second store on the same path, and it throws the CI message verbatim. Adding `job.join()` after the cancel makes it pass. Both per-account stores had the pattern, so both now join, and both removeAccount are suspend for it — every caller already was. AccountSecretsStoreTest gains the other half of the flow it was missing: remove the account, then add the same npub back. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../preferences/AccountPreferenceStores.kt | 14 ++++++++++-- .../AccountSecretsEncryptedStores.kt | 15 +++++++++---- .../preferences/AccountSecretsStoreTest.kt | 22 +++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt index 9695fe17a5..1cdcc25588 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountPreferenceStores.kt @@ -31,6 +31,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel +import kotlinx.coroutines.job import okio.Path /** @@ -92,9 +93,18 @@ class AccountPreferenceStores( * would leave it writing the account's settings back out on the next edit, * re-creating what this call is meant to erase — and would keep the path * registered, so the same account could not be added again. + * + * Cancelling is not enough on its own, and this is suspend for that + * reason. `cancel()` only *asks*; DataStore releases the path when the + * scope's job actually completes, so a store opened on it before then + * still throws "multiple DataStores active for the same file". The window + * is small enough to pass locally and fail on a loaded CI runner. */ - fun removeAccount(npub: String): Boolean { - storeCache.get(npub)?.scope?.cancel() + suspend fun removeAccount(npub: String): Boolean { + storeCache.get(npub)?.scope?.let { + it.cancel() + it.coroutineContext.job.join() + } storeCache.remove(npub) val path = file(npub) if (!platformFileSystem.exists(path)) return false diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt index a359fbcfd2..082c14fd06 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel +import kotlinx.coroutines.job import okio.Path /** @@ -103,11 +104,17 @@ class AccountSecretsEncryptedStores( /** * Drops the account's secrets. * - * Cancels the store's scope before deleting, so DataStore releases the - * path and the same account can be added again in this session. + * Cancels the store's scope and waits for it, so DataStore releases the + * path and the same account can be added again in this session. The wait + * is the point: `cancel()` only asks, and the path stays registered until + * the job completes — [AccountPreferenceStores.removeAccount] has the + * longer note. */ - fun removeAccount(npub: String): Boolean { - storeCache.get(npub)?.scope?.cancel() + suspend fun removeAccount(npub: String): Boolean { + storeCache.get(npub)?.scope?.let { + it.cancel() + it.coroutineContext.job.join() + } storeCache.remove(npub) val path = file(npub) if (!platformFileSystem.exists(path)) return false diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt index d560d48709..32962ebd25 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt @@ -184,4 +184,26 @@ class AccountSecretsStoreTest { assertNull(subject.loadSecrets(npub)) } + + /** + * Delete an account, then add the same npub back. + * + * DataStore keeps a process-wide registry keyed by file path and releases + * an entry only when the owning scope's job *completes* — cancelling it is + * just the request. [AccountSecretsEncryptedStores.removeAccount] waits for + * that, and without the wait this throws "multiple DataStores active for + * the same file" whenever the next open wins the race, which on a loaded + * machine it does. + */ + @Test + fun anAccountCanBeAddedBackAfterBeingRemoved() = + runTest { + val subject = stores() + subject.saveSecrets(npub, filled) + subject.removeAccount(npub) + + subject.saveSecrets(npub, filled) + + assertEquals(filled, subject.loadSecrets(npub)) + } } From 0abebe71ee55bf035fefffcedb9c920b7ab2f0a4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 00:35:46 +0000 Subject: [PATCH 17/57] fix: do not assert POSIX permissions on a filesystem without them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows CI failed SecretEncryptionTest.keyFileIsOwnerOnly with UnsupportedOperationException: NTFS has no POSIX permissions, and asking for them raises rather than returning an empty set. The production side was already right — `restrictToOwner` catches that exception and documents Windows as a silent no-op where the user profile's ACLs apply instead. Only the test assumed otherwise, and it is the one test in the file that cannot hold there. Guarded the same way FilePermissionsTest and ScheduledPostStoreTest already do in this repo, a convention I should have followed when writing it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../commons/model/preferences/SecretEncryptionTest.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt index 854eef57ab..65a93958ec 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/SecretEncryptionTest.kt @@ -30,6 +30,7 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder import java.io.File +import java.nio.file.FileSystems import java.nio.file.Files import java.nio.file.attribute.PosixFilePermission @@ -92,8 +93,16 @@ class SecretEncryptionTest { assertThrows(Exception::class.java) { subject("second.key").decrypt(ciphertext) } } + private fun isPosix() = FileSystems.getDefault().supportedFileAttributeViews().contains("posix") + @Test fun keyFileIsOwnerOnly() { + // Windows has no POSIX permissions, and `restrictToOwner` is documented + // as a silent no-op there — the user profile's NTFS ACLs apply instead. + // Asking for them anyway raises UnsupportedOperationException, which is + // how this failed on the Windows CI runner while passing everywhere else. + if (!isPosix()) return + subject().encrypt("x".encodeToByteArray()) val perms = Files.getPosixFilePermissions(File(folder.root, "secret.key").toPath()) From 08a2710039de89a622b846a3516b2d632571d2ce Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 01:50:47 +0000 Subject: [PATCH 18/57] ci: give the Android job room for a cold Gradle cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test-and-build-android was killed at its 60-minute cap, 64 minutes into the Gradle step, with no test report — the step was still running, so steps 6-11 (lint reports, test report, APK uploads) never ran. Not a test failure, and not a slow runner. On main the same step takes ~46 minutes, using 76% of the budget. PR runs set `cache-read-only`, so they restore main's Gradle cache and never save one; a PR touching `quartz` or `commons` invalidates most of what that cache holds downstream and rebuilds it cold. Measured across this PR's runs, every job takes 2-3x its main-branch time — Windows desktop 10m to 21m, macOS 8m to 25m, Linux deb 3.5m to 11m. Android had the least headroom, so it is the one that died. Re-running would not help: `cache-read-only` means the timed-out attempt saved nothing, and the next attempt starts from the same main cache. 90 rather than 60. It costs nothing on runs that finish early — the setting bounds a job, it does not reserve the time — and leaves room for the observed 2x without hiding a genuine hang behind an enormous cap. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .github/workflows/build.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc5c96b109..9e5dc9e284 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -338,7 +338,16 @@ jobs: test-and-build-android: needs: lint runs-on: ubuntu-latest - timeout-minutes: 60 + # 90, not 60. On main this job's Gradle step takes ~46 minutes, which used + # 76% of a 60-minute budget — fine for an incremental run, but PR runs set + # `cache-read-only` (below), so they restore main's Gradle cache and never + # save. A PR that touches `quartz` or `commons` invalidates most of what + # that cache holds for everything downstream, and the job then rebuilds it + # from cold: measured 2-3x the main-branch time across every job in the + # workflow, which puts this one past the cap and gets it killed mid-step + # with no test report. Raising the cap costs nothing on runs that finish + # early — `timeout-minutes` bounds a job, it does not reserve the time. + timeout-minutes: 90 steps: - name: Checkout code uses: actions/checkout@v7 From 766c38fc8946e0071813c13e6b51a01bc8c3feba Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 02:21:58 +0000 Subject: [PATCH 19/57] refactor: move six app-wide settings stores into commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The per-account preference layer moved to commons earlier in this branch; the app-wide stores did not, and stayed behind on `Context.sharedPreferencesDataStore`. Six of them move here: Ots, Namecoin, the three Buzz groups and RelayGroupDeletion. Each was already a DataStore — the only thing tying it to Android was taking a `Context` to find the file. `AppPreferenceStores` is the app-wide counterpart to `AccountPreferenceStores`, keyed by file name rather than npub. It reproduces exactly what Android's `preferencesDataStore(name)` delegate resolves to, `filesDir/datastore/.preferences_pb`, so a store taken off the delegate opens the file it was already using: nothing to migrate, and a rollback finds its data where it left it. `AppPreferenceStoresTest` pins that path shape, because getting it wrong would silently start every install from empty settings rather than failing. The stores are not yet built through it. They take a `DataStore` and the call sites still hand them `appContext.sharedPreferencesDataStore` — deliberately, because these six share one file with UI and Tor, which have not moved yet. Two DataStores on one path is not a merge conflict, it is an IllegalStateException; the provider swaps in one step once the whole family is across. OtsSettingsStore lands in `jvmAndroid` rather than `commonMain` because OtsSettings does — it names OkHttp's explorer constants. Its blocking initial load moves out to AppModules: `current` has to answer synchronously for the resolver builder, so someone has to wait, and commonMain has no `runBlocking` to hide that behind. Explicit at the call site is an improvement. Renamed from `*SharedPreferences`/`*Preferences` to `*Store`, matching the commons convention and no longer naming a SharedPreferences that has not been involved for some time. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 35 +++--- .../vitorpamplona/amethyst/model/Account.kt | 6 +- .../DrawerSectionCollapsePreferences.kt | 2 +- .../loggedIn/buzz/AgentAttestationScreen.kt | 2 +- .../settings/NamecoinSettingsScreen.kt | 4 +- .../loggedIn/settings/OtsSettingsScreen.kt | 4 +- .../model/preferences/AppPreferenceStores.kt | 106 ++++++++++++++++++ .../model/preferences/BuzzAttestationStore.kt | 15 +-- .../model/preferences/BuzzChannelStarStore.kt | 13 ++- .../model/preferences/BuzzWorkspaceStore.kt | 13 ++- .../preferences/NamecoinSettingsStore.kt | 33 +++--- .../preferences/RelayGroupDeletionStore.kt | 13 ++- .../model/preferences/OtsSettingsStore.kt | 68 ++++++----- .../preferences/AppPreferenceStoresTest.kt | 88 +++++++++++++++ .../preferences/BuzzAttestationRestoreTest.kt | 16 +-- 15 files changed, 311 insertions(+), 107 deletions(-) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzAttestationPreferences.kt => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzAttestationStore.kt (95%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzChannelStarPreferences.kt => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzChannelStarStore.kt (92%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzWorkspacePreferences.kt => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzWorkspaceStore.kt (94%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/NamecoinSharedPreferences.kt => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NamecoinSettingsStore.kt (90%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/RelayGroupDeletionPreferences.kt => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayGroupDeletionStore.kt (89%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/OtsSharedPreferences.kt => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/OtsSettingsStore.kt (60%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt rename {amethyst/src/test/java/com/vitorpamplona/amethyst => commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons}/model/preferences/BuzzAttestationRestoreTest.kt (81%) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index a1c418dba3..80e1666fc1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -32,6 +32,12 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.BitcoinExplorerEndpoint import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.IncomingOtsEventVerifier import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.TorAwareOkHttpOtsResolverBuilder +import com.vitorpamplona.amethyst.commons.model.preferences.BuzzAttestationStore +import com.vitorpamplona.amethyst.commons.model.preferences.BuzzChannelStarStore +import com.vitorpamplona.amethyst.commons.model.preferences.BuzzWorkspaceStore +import com.vitorpamplona.amethyst.commons.model.preferences.NamecoinSettingsStore +import com.vitorpamplona.amethyst.commons.model.preferences.OtsSettingsStore +import com.vitorpamplona.amethyst.commons.model.preferences.RelayGroupDeletionStore import com.vitorpamplona.amethyst.commons.napplet.permissions.NappletPermissionLedger import com.vitorpamplona.amethyst.commons.relayClient.BlockedRelayFilteringClient import com.vitorpamplona.amethyst.commons.relayClient.diagnostics.BootRelayDiagnostics @@ -62,13 +68,7 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.UiSettings import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever -import com.vitorpamplona.amethyst.model.preferences.BuzzAttestationPreferences -import com.vitorpamplona.amethyst.model.preferences.BuzzChannelStarPreferences -import com.vitorpamplona.amethyst.model.preferences.BuzzWorkspacePreferences import com.vitorpamplona.amethyst.model.preferences.DrawerSectionCollapsePreferences -import com.vitorpamplona.amethyst.model.preferences.NamecoinSharedPreferences -import com.vitorpamplona.amethyst.model.preferences.OtsSharedPreferences -import com.vitorpamplona.amethyst.model.preferences.RelayGroupDeletionPreferences import com.vitorpamplona.amethyst.model.preferences.TorSharedPreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences import com.vitorpamplona.amethyst.model.preferences.sharedPreferencesDataStore @@ -258,14 +258,20 @@ class AppModules( // Namecoin ElectrumX server preferences (global, like Tor settings) val namecoinPrefs by lazy { - Log.d("AppModules", "NamecoinSharedPreferences Init") - NamecoinSharedPreferences(appContext, applicationIOScope) + Log.d("AppModules", "NamecoinSettingsStore Init") + NamecoinSettingsStore(appContext.sharedPreferencesDataStore, applicationIOScope) } // OTS blockchain explorer preferences (global, like Tor settings) + // + // The blocking load is the one the store used to do inside its own + // constructor: `current` has to answer synchronously for the resolver + // builder, so somebody has to wait. It is explicit here rather than hidden + // in commonMain, which has no runBlocking to hide it behind. val otsPrefs by lazy { - Log.d("AppModules", "OtsSharedPreferences Init") - OtsSharedPreferences(appContext, applicationIOScope) + Log.d("AppModules", "OtsSettingsStore Init") + val store = appContext.sharedPreferencesDataStore + OtsSettingsStore(store, runBlocking { OtsSettingsStore.load(store) }) } // App services that should be run as soon as there are subscribers to their @@ -308,7 +314,8 @@ class AppModules( // Restore + persist the set of relay-group channels deleted (kind-9008) on this device, so a // deleted channel stays hidden across a restart even if the host relay re-announces a stale // kind-44100 for it (device-global; a delete is authoritative and terminal for everyone). - val relayGroupDeletionPrefs = RelayGroupDeletionPreferences(appContext, applicationIOScope) + val relayGroupDeletionPrefs = + RelayGroupDeletionStore(appContext.sharedPreferencesDataStore, applicationIOScope) // Restore + persist which drawer section headings the user has folded away, so the side menu // opens the way they left it (device-global: a collapsed heading is a per-device view choice, @@ -969,11 +976,11 @@ class AppModules( // start — Buzz membership is server-side) and the starred channels. Per account: the // joined set makes a relay first-party for NIP-42, and a star is personal. startBuzzPersistence = { account -> - BuzzWorkspacePreferences(appContext, account.scope, account.pubKey, account.buzzWorkspaces) - BuzzChannelStarPreferences(appContext, account.scope, account.pubKey, account.buzzChannelStars) + BuzzWorkspaceStore(appContext.sharedPreferencesDataStore, account.scope, account.pubKey, account.buzzWorkspaces) + BuzzChannelStarStore(appContext.sharedPreferencesDataStore, account.scope, account.pubKey, account.buzzChannelStars) // Eager like the rest, so a held NIP-OA attestation is loaded before this account's // first Buzz-relay AUTH rather than after it. - BuzzAttestationPreferences(appContext, account.scope, account.pubKey, account.buzzAttestation) + BuzzAttestationStore(appContext.sharedPreferencesDataStore, account.scope, account.pubKey, account.buzzAttestation) }, ) 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 3ba243658a..c9fcdde9a7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -457,17 +457,17 @@ class Account( // redeemed by this key and the relay grants membership to it alone — and this set makes the // relay first-party for NIP-42 (see AuthCoordinator.isFirstParty), so a device-global set would // hand every other logged-in account an automatic login on a workspace it never joined. - // Restored/persisted per account by BuzzWorkspacePreferences (see AccountCacheState). + // Restored/persisted per account by BuzzWorkspaceStore (see AccountCacheState). val buzzWorkspaces = BuzzWorkspaces() // The Buzz channels THIS account pinned. A star says which channels this user wants at the top // of the community view, so a shared set let one account reorder and badge every other one's - // channel list. Restored/persisted per account by BuzzChannelStarPreferences. + // channel list. Restored/persisted per account by BuzzChannelStarStore. val buzzChannelStars = BuzzChannelStars() // The NIP-OA attestation an owner issued to THIS account's key, attached to its Buzz-relay // AUTH so the relay grants virtual membership. Restored/persisted per account by - // BuzzAttestationPreferences. + // BuzzAttestationStore. val buzzAttestation = BuzzHeldAttestations(pubKey) // The relays this account approved by answering the NIP-42 prompt *without* the "remember" diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferences.kt index acca11936f..c29ae2cf13 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferences.kt @@ -45,7 +45,7 @@ import kotlin.coroutines.cancellation.CancellationException * headings are folded is a per-device view choice, so unlike the hidden rows beside it in the drawer * it is never published to relays. * - * Mirrors [RelayGroupDeletionPreferences]: app-wide (not per-account), loads the saved names on + * Mirrors [RelayGroupDeletionStore]: app-wide (not per-account), loads the saved names on * construction, then writes every later change back. Takes the [DataStore] rather than a `Context` * so the whole cycle is exercised by a plain unit test against a temp file. * diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/AgentAttestationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/AgentAttestationScreen.kt index d19c2c0c36..ccbbe2739b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/AgentAttestationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/buzz/AgentAttestationScreen.kt @@ -181,7 +181,7 @@ fun AgentAttestationScreen( * Agent-side: paste an `auth` tag an owner issued to this account's key. [parseHeldAttestation] * turns it into a typed failure the field can show, and [BuzzHeldAttestations.put] re-checks the * signature before storing, so the auth coordinator attaches it when this account AUTHs to a Buzz - * relay. Persisted across restarts, per account, by `BuzzAttestationPreferences`. + * relay. Persisted across restarts, per account, by `BuzzAttestationStore`. */ @Composable private fun HoldAttestationSection( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/NamecoinSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/NamecoinSettingsScreen.kt index 965b48da38..c20834d797 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/NamecoinSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/NamecoinSettingsScreen.kt @@ -34,12 +34,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.model.preferences.NamecoinSettingsStore import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.namecoin_settings import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.model.preferences.NamecoinSharedPreferences import com.vitorpamplona.quartz.nip05DnsIdentifiers.namecoin.ElectrumXClient import com.vitorpamplona.quartz.nip05DnsIdentifiers.namecoin.NamecoinCoreRpcClient import kotlinx.coroutines.launch @@ -58,7 +58,7 @@ fun NamecoinSettingsScreen(nav: INav) { @OptIn(ExperimentalMaterial3Api::class) @Composable fun NamecoinSettingsScreen( - namecoinPrefs: NamecoinSharedPreferences, + namecoinPrefs: NamecoinSettingsStore, electrumXClient: () -> ElectrumXClient, namecoinCoreRpcClient: () -> NamecoinCoreRpcClient, nav: INav, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt index afcfd317da..97ee6ae701 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt @@ -34,13 +34,13 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.model.preferences.OtsSettingsStore import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.ots_explorer_settings import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.model.preferences.OtsSharedPreferences import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import kotlinx.coroutines.launch @@ -53,7 +53,7 @@ fun OtsSettingsScreen(nav: INav) { @OptIn(ExperimentalMaterial3Api::class) @Composable fun OtsSettingsScreen( - otsPrefs: OtsSharedPreferences, + otsPrefs: OtsSettingsStore, torSettings: TorSettingsFlow, nav: INav, ) { diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt new file mode 100644 index 0000000000..c1f7bd5c5b --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import com.vitorpamplona.quartz.utils.cache.LargeCache +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO +import kotlinx.coroutines.SupervisorJob +import okio.Path + +/** + * The app-wide DataStore files — the ones that belong to the install rather + * than to an account. + * + * [AccountPreferenceStores] is the same idea keyed by npub; this is keyed by + * file name, because these stores are one-per-app and several of them share a + * single file under different key prefixes (see [SHARED_SETTINGS]). + * + * # Why a holder rather than a `Context` delegate + * + * Android's `Context.preferencesDataStore(name)` delegate does this job, but + * only on Android and only from a `Context`. Taking the root directory as a + * parameter is what lets the stores themselves live in `commonMain` — every + * front end says where its data lives: `filesDir` on Android, the app data + * directory on desktop, a temp folder in tests. + * + * # The paths are the delegate's paths + * + * `preferencesDataStore(name = "x")` resolves to + * `filesDir/datastore/x.preferences_pb`, and [file] reproduces that exactly. + * Wired with `filesDir` as the root, a store moved off the delegate onto this + * holder opens the file it was already using, so nothing has to be migrated + * and a rollback finds its data where it left it. Changing [file]'s shape + * would silently orphan every existing install's settings. + */ +class AppPreferenceStores( + val rootFilesDir: () -> Path, +) { + companion object { + /** + * The file that UI, Tor, OTS, Namecoin and several smaller settings + * groups all share, each under its own key prefix (`ui.`, `tor.`, …). + * + * One file rather than one per group, which is how it has always been + * on Android: these are read together at startup, and a DataStore is + * a whole-file read. + */ + const val SHARED_SETTINGS = "shared_settings" + } + + /** + * One store per file, each on a scope this class owns. + * + * DataStore keeps a process-wide registry keyed by file path and refuses a + * second store on a path that already has a live one. Handing out a new + * store per call is therefore a crash rather than a waste — it has already + * happened twice in this codebase — so going through the cache is the + * point of the class, not an optimisation. + */ + private class Entry( + val scope: CoroutineScope, + val store: DataStore, + ) + + private val storeCache = LargeCache() + + fun file(name: String): Path = rootFilesDir() / "datastore" / "$name.preferences_pb" + + fun getDataStore(name: String): DataStore = + storeCache + .getOrCreate(name) { + val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) + Entry( + scope, + PreferenceDataStoreFactory.createWithPath( + scope = scope, + produceFile = { file(name) }, + ), + ) + }.store + + /** The file UI, Tor, OTS, Namecoin and friends share. */ + fun sharedSettings(): DataStore = getDataStore(SHARED_SETTINGS) +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzAttestationPreferences.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzAttestationStore.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzAttestationPreferences.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzAttestationStore.kt index 618518e919..c7336b9cfd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzAttestationPreferences.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzAttestationStore.kt @@ -18,10 +18,11 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences -import android.content.Context import androidx.compose.runtime.Stable +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import com.vitorpamplona.amethyst.commons.model.buzz.BuzzHeldAttestations @@ -49,8 +50,8 @@ import kotlin.coroutines.cancellation.CancellationException * by the same gate that rejects a mistyped one. Construct once per account, eagerly. */ @Stable -class BuzzAttestationPreferences( - private val context: Context, +class BuzzAttestationStore( + private val store: DataStore, private val scope: CoroutineScope, private val pubKeyHex: HexKey, private val attestation: BuzzHeldAttestations, @@ -84,7 +85,7 @@ class BuzzAttestationPreferences( private suspend fun restoreFromDisk() { try { - val prefs = context.sharedPreferencesDataStore.data.first() + val prefs = store.data.first() // put() verifies, so a credential that no longer checks out is dropped either way. restoreFrom(prefs[key], prefs[LEGACY_KEY], pubKeyHex)?.let(attestation::put) } catch (e: Exception) { @@ -95,7 +96,7 @@ class BuzzAttestationPreferences( private suspend fun persist(held: OwnerAttestation?) { try { - context.sharedPreferencesDataStore.edit { prefs -> + store.edit { prefs -> // Write [NONE] rather than removing the key: removing it is indistinguishable from // never having migrated, which would let the legacy list re-seed a credential the // user just deleted. See [restoreFrom]. @@ -126,7 +127,7 @@ class BuzzAttestationPreferences( /** * Which attestation to reinstate, given this account's saved value and the pre-namespacing - * device-global list. Pure, so the migration precedence is testable without a `Context`. + * device-global list. Pure, so the migration precedence is testable without a store. * * [saved] wins whenever it is present, [NONE] included. Only a never-migrated account falls * back to [legacy], and it takes just the entry issued to its own key — that list was diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzChannelStarPreferences.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzChannelStarStore.kt similarity index 92% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzChannelStarPreferences.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzChannelStarStore.kt index 96c62f23eb..d4597fb1e3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzChannelStarPreferences.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzChannelStarStore.kt @@ -18,10 +18,11 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences -import android.content.Context import androidx.compose.runtime.Stable +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringSetPreferencesKey import com.vitorpamplona.amethyst.commons.model.buzz.BuzzChannelStars @@ -42,8 +43,8 @@ import kotlin.coroutines.cancellation.CancellationException * then writes every later change back. Construct once per account, eagerly. */ @Stable -class BuzzChannelStarPreferences( - private val context: Context, +class BuzzChannelStarStore( + private val store: DataStore, private val scope: CoroutineScope, private val pubKeyHex: HexKey, private val stars: BuzzChannelStars, @@ -60,7 +61,7 @@ class BuzzChannelStarPreferences( private suspend fun restoreFromDisk() { try { - val prefs = context.sharedPreferencesDataStore.data.first() + val prefs = store.data.first() // Fall back to the pre-namespacing device-global key so an upgrade doesn't unpin // everything. That set is what every account already saw; the next toggle writes to this // account's own key and takes over. The legacy key is left for other accounts to seed @@ -78,7 +79,7 @@ class BuzzChannelStarPreferences( // Always write the starred set, empty included — never remove the key. An absent key // means "never migrated" and re-seeds from the legacy one above, so removing it // would undo the user's last removal on the next launch. - context.sharedPreferencesDataStore.edit { prefs -> prefs[key] = ids } + store.edit { prefs -> prefs[key] = ids } } catch (e: Exception) { if (e is CancellationException) throw e Log.e("BuzzChannelStarPrefs") { "Error writing starred channels: ${e.message}" } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzWorkspacePreferences.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzWorkspaceStore.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzWorkspacePreferences.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzWorkspaceStore.kt index 10cc89faa1..60d051c855 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/BuzzWorkspacePreferences.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzWorkspaceStore.kt @@ -18,10 +18,11 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences -import android.content.Context import androidx.compose.runtime.Stable +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringSetPreferencesKey import com.vitorpamplona.amethyst.commons.model.buzz.BuzzWorkspaces @@ -57,8 +58,8 @@ import kotlin.coroutines.cancellation.CancellationException * per account, eagerly. */ @Stable -class BuzzWorkspacePreferences( - private val context: Context, +class BuzzWorkspaceStore( + private val store: DataStore, private val scope: CoroutineScope, private val pubKeyHex: HexKey, private val workspaces: BuzzWorkspaces, @@ -76,7 +77,7 @@ class BuzzWorkspacePreferences( private suspend fun restoreFromDisk() { try { - val prefs = context.sharedPreferencesDataStore.data.first() + val prefs = store.data.first() // Fall back to the pre-namespacing device-global key so an upgrade doesn't empty the // workspaces hub. That set is whatever any account joined, which is exactly what every // account already saw before this became per-account — so seeding from it changes @@ -97,7 +98,7 @@ class BuzzWorkspacePreferences( // Always write the joined set, empty included — never remove the key. An absent key // means "never migrated" and re-seeds from the legacy one above, so removing it // would undo the user's last removal on the next launch. - context.sharedPreferencesDataStore.edit { prefs -> + store.edit { prefs -> prefs[key] = relays.map { it.url }.toSet() } } catch (e: Exception) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/NamecoinSharedPreferences.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NamecoinSettingsStore.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/NamecoinSharedPreferences.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NamecoinSettingsStore.kt index 0844905ab4..964157ff42 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/NamecoinSharedPreferences.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/NamecoinSettingsStore.kt @@ -18,10 +18,11 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences -import android.content.Context import androidx.compose.runtime.Stable +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey @@ -39,20 +40,20 @@ import kotlinx.serialization.json.Json import kotlin.coroutines.cancellation.CancellationException /** - * Persistent storage for [NamecoinSettings], following the same pattern as - * [TorSharedPreferences]. + * Persistent storage for [NamecoinSettings] — which ElectrumX servers and + * backend resolve `.bit` names, and the certificates the user has pinned. * - * Uses the app-wide [sharedPreferencesDataStore] so Namecoin resolution - * settings (like Tor settings) are global — not per-account. + * App-wide, not per-account, and shares [AppPreferenceStores.SHARED_SETTINGS] + * with the other global settings groups under its own `namecoin.` key prefix. * * The current settings are available synchronously via [settings] (a * [StateFlow]) and can be read in non-suspend contexts (e.g. in a * `serverListProvider` lambda). */ @Stable -class NamecoinSharedPreferences( - private val context: Context, - private val scope: CoroutineScope, +class NamecoinSettingsStore( + private val store: DataStore, + scope: CoroutineScope, ) { private val json = Json { ignoreUnknownKeys = true } @@ -148,18 +149,18 @@ class NamecoinSharedPreferences( private suspend fun savePinnedCerts(certs: List) { try { - context.sharedPreferencesDataStore.edit { prefs -> + store.edit { prefs -> prefs[KEY_PINNED_CERTS] = json.encodeToString(certs) } } catch (e: Exception) { if (e is CancellationException) throw e - Log.e("NamecoinPrefs") { "Error writing pinned certs: ${e.message}" } + Log.e("NamecoinSettingsStore") { "Error writing pinned certs: ${e.message}" } } } private suspend fun loadPinnedCertsFromDisk(): List = try { - val prefs = context.sharedPreferencesDataStore.data.first() + val prefs = store.data.first() val certsJson = prefs[KEY_PINNED_CERTS] if (certsJson != null) { json.decodeFromString>(certsJson) @@ -176,7 +177,7 @@ class NamecoinSharedPreferences( private suspend fun persist(settings: NamecoinSettings) { _settings.value = settings try { - context.sharedPreferencesDataStore.edit { prefs -> + store.edit { prefs -> prefs[KEY_ENABLED] = settings.enabled prefs[KEY_CUSTOM_SERVERS] = json.encodeToString( @@ -189,13 +190,13 @@ class NamecoinSharedPreferences( } } catch (e: Exception) { if (e is CancellationException) throw e - Log.e("NamecoinPrefs") { "Error writing DataStore: ${e.message}" } + Log.e("NamecoinSettingsStore") { "Error writing DataStore: ${e.message}" } } } private suspend fun loadFromDisk(): NamecoinSettings? = try { - val prefs = context.sharedPreferencesDataStore.data.first() + val prefs = store.data.first() val enabled = prefs[KEY_ENABLED] ?: true val serversJson = prefs[KEY_CUSTOM_SERVERS] val servers = @@ -236,7 +237,7 @@ class NamecoinSharedPreferences( ) } catch (e: Exception) { if (e is CancellationException) throw e - Log.e("NamecoinPrefs") { "Error reading DataStore: ${e.message}" } + Log.e("NamecoinSettingsStore") { "Error reading DataStore: ${e.message}" } null } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/RelayGroupDeletionPreferences.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayGroupDeletionStore.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/RelayGroupDeletionPreferences.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayGroupDeletionStore.kt index 99e1f99c01..2a00912633 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/RelayGroupDeletionPreferences.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/RelayGroupDeletionStore.kt @@ -18,10 +18,11 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences -import android.content.Context import androidx.compose.runtime.Stable +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringSetPreferencesKey import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupDeletions @@ -40,8 +41,8 @@ import kotlin.coroutines.cancellation.CancellationException * back. Construct once, eagerly. */ @Stable -class RelayGroupDeletionPreferences( - private val context: Context, +class RelayGroupDeletionStore( + private val store: DataStore, private val scope: CoroutineScope, ) { init { @@ -54,7 +55,7 @@ class RelayGroupDeletionPreferences( private suspend fun restoreFromDisk() { try { - val raw = context.sharedPreferencesDataStore.data.first()[KEY] ?: return + val raw = store.data.first()[KEY] ?: return if (raw.isNotEmpty()) RelayGroupDeletions.restore(raw) } catch (e: Exception) { if (e is CancellationException) throw e @@ -64,7 +65,7 @@ class RelayGroupDeletionPreferences( private suspend fun persist(keys: Set) { try { - context.sharedPreferencesDataStore.edit { prefs -> prefs[KEY] = keys } + store.edit { prefs -> prefs[KEY] = keys } } catch (e: Exception) { if (e is CancellationException) throw e Log.e("RelayGroupDeletionPrefs") { "Error writing deleted channels: ${e.message}" } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/OtsSharedPreferences.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/OtsSettingsStore.kt similarity index 60% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/OtsSharedPreferences.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/OtsSettingsStore.kt index 9063633321..b3e7815201 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/OtsSharedPreferences.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/OtsSettingsStore.kt @@ -18,51 +18,62 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences -import android.content.Context import androidx.compose.runtime.Stable +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.OtsSettings import com.vitorpamplona.quartz.utils.Log -import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking import kotlin.coroutines.cancellation.CancellationException /** - * Persistent storage for [OtsSettings], following the same pattern as - * [NamecoinSharedPreferences]. + * Persistent storage for [OtsSettings] — which blockchain explorer the user + * has pointed OpenTimestamps at. * - * Uses the app-wide [sharedPreferencesDataStore] so OTS explorer settings - * are global — not per-account. + * App-wide, not per-account, and shares [AppPreferenceStores.SHARED_SETTINGS] + * with the other global settings groups under its own `ots.` key prefix. + * + * Lives in `jvmAndroid` rather than `commonMain` only because [OtsSettings] + * does: it names OkHttp's explorer constants, and OkHttp is JVM-bound. Android + * and Desktop still share it. + * + * [initial] is taken rather than read here because the current value has to be + * available synchronously from [current] — a resolver builder reads it from a + * non-suspending lambda. The caller loads it with [load] and decides how to + * wait; commonMain has no `runBlocking` to hide that decision behind. */ @Stable -class OtsSharedPreferences( - private val context: Context, - private val scope: CoroutineScope, +class OtsSettingsStore( + private val store: DataStore, + initial: OtsSettings, ) { companion object { val KEY_CUSTOM_EXPLORER_URL = stringPreferencesKey("ots.customExplorerUrl") + + /** The stored settings, or [OtsSettings.DEFAULT] if unset or unreadable. */ + suspend fun load(store: DataStore): OtsSettings = + try { + val url = store.data.first()[KEY_CUSTOM_EXPLORER_URL]?.takeIf { it.isNotBlank() } + OtsSettings(customExplorerUrl = url) + } catch (e: Exception) { + if (e is CancellationException) throw e + Log.e("OtsSettingsStore") { "Error reading DataStore: ${e.message}" } + OtsSettings.DEFAULT + } } - /** - * Current settings, loaded synchronously at init to avoid races. - */ - private val _settings = - MutableStateFlow( - runBlocking { loadFromDisk() ?: OtsSettings.DEFAULT }, - ) + private val _settings = MutableStateFlow(initial) val settings: StateFlow = _settings /** Synchronous snapshot — safe to call from resolver builder lambdas. */ val current: OtsSettings get() = _settings.value - // ── Mutators ─────────────────────────────────────────────────────── - suspend fun setCustomExplorerUrl(url: String?) { val normalized = url?.trim()?.takeIf { it.isNotBlank() } persist(current.copy(customExplorerUrl = normalized)) @@ -72,12 +83,10 @@ class OtsSharedPreferences( persist(OtsSettings.DEFAULT) } - // ── Internal ─────────────────────────────────────────────────────── - private suspend fun persist(settings: OtsSettings) { _settings.value = settings try { - context.sharedPreferencesDataStore.edit { prefs -> + store.edit { prefs -> val customExplorerUrl = settings.customExplorerUrl if (customExplorerUrl != null) { prefs[KEY_CUSTOM_EXPLORER_URL] = customExplorerUrl @@ -87,18 +96,7 @@ class OtsSharedPreferences( } } catch (e: Exception) { if (e is CancellationException) throw e - Log.e("OtsPrefs") { "Error writing DataStore: ${e.message}" } + Log.e("OtsSettingsStore") { "Error writing DataStore: ${e.message}" } } } - - private suspend fun loadFromDisk(): OtsSettings? = - try { - val prefs = context.sharedPreferencesDataStore.data.first() - val url = prefs[KEY_CUSTOM_EXPLORER_URL]?.takeIf { it.isNotBlank() } - OtsSettings(customExplorerUrl = url) - } catch (e: Exception) { - if (e is CancellationException) throw e - Log.e("OtsPrefs") { "Error reading DataStore: ${e.message}" } - null - } } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt new file mode 100644 index 0000000000..3c8106602f --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertSame +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class AppPreferenceStoresTest { + @get:Rule + val folder = TemporaryFolder() + + private fun stores() = AppPreferenceStores(rootFilesDir = { folder.root.toOkioPath() }) + + /** + * The load-bearing assumption of the whole move. + * + * Android's `Context.preferencesDataStore(name = "x")` resolves to + * `filesDir/datastore/x.preferences_pb`. A store taken off that delegate + * and put on this holder has to land on the same file, or every existing + * install silently starts from empty settings. This pins the shape. + */ + @Test + fun theFilePathMatchesTheAndroidDelegate() { + val root = folder.root.toOkioPath() + + assertEquals(root / "datastore" / "shared_settings.preferences_pb", stores().file("shared_settings")) + assertEquals(root / "datastore" / "favorite_apps.preferences_pb", stores().file("favorite_apps")) + } + + /** DataStore refuses a second live store on one path, so this must dedupe. */ + @Test + fun oneStorePerFile() { + val subject = stores() + + assertSame(subject.getDataStore("shared_settings"), subject.getDataStore("shared_settings")) + assertSame(subject.sharedSettings(), subject.getDataStore("shared_settings")) + } + + @Test + fun differentNamesAreDifferentStores() = + runTest { + val subject = stores() + val key = stringPreferencesKey("k") + + subject.getDataStore("one").edit { it[key] = "first" } + subject.getDataStore("two").edit { it[key] = "second" } + + assertEquals("first", subject.getDataStore("one").data.first()[key]) + assertEquals("second", subject.getDataStore("two").data.first()[key]) + } + + @Test + fun writesLandInTheExpectedFile() = + runTest { + val subject = stores() + subject.sharedSettings().edit { it[stringPreferencesKey("ui.theme")] = "DARK" } + + val expected = java.io.File(folder.root, "datastore/shared_settings.preferences_pb") + assertTrue(expected.absolutePath, expected.exists()) + } +} diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/preferences/BuzzAttestationRestoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzAttestationRestoreTest.kt similarity index 81% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/model/preferences/BuzzAttestationRestoreTest.kt rename to commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzAttestationRestoreTest.kt index a14c8cdac8..77c9c06c99 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/preferences/BuzzAttestationRestoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/BuzzAttestationRestoreTest.kt @@ -18,17 +18,17 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test /** - * The migration precedence in [BuzzAttestationPreferences.restoreFrom]: which of the two on-disk + * The migration precedence in [BuzzAttestationStore.restoreFrom]: which of the two on-disk * shapes wins when the held attestation moved from one device-global list to a per-account key. * - * The store itself needs a `Context`, so the decision is pulled out as a pure function — this is + * The store itself needs a DataStore, so the decision is pulled out as a pure function — this is * the part with the sharp edge, and it is the part the DataStore round-trip cannot express. */ class BuzzAttestationRestoreTest { @@ -46,12 +46,12 @@ class BuzzAttestationRestoreTest { @Test fun nothingSavedAnywhereRestoresNothing() { - assertNull(BuzzAttestationPreferences.restoreFrom(null, null, me)) + assertNull(BuzzAttestationStore.restoreFrom(null, null, me)) } @Test fun thisAccountsOwnKeyWins() { - val restored = BuzzAttestationPreferences.restoreFrom(saved(), legacyList(me), me) + val restored = BuzzAttestationStore.restoreFrom(saved(), legacyList(me), me) assertEquals(owner, restored?.ownerPubKey) } @@ -61,12 +61,12 @@ class BuzzAttestationRestoreTest { // per-account key, which is indistinguishable from "never migrated" — so the next launch // seeded it straight back out of the legacy list, which nothing ever clears. An explicit // tombstone is the only thing that can say "migrated, and holding nothing". - assertNull(BuzzAttestationPreferences.restoreFrom("", legacyList(me), me)) + assertNull(BuzzAttestationStore.restoreFrom("", legacyList(me), me)) } @Test fun aNeverMigratedAccountTakesItsOwnEntryFromTheLegacyList() { - val restored = BuzzAttestationPreferences.restoreFrom(null, legacyList(someoneElse, me), me) + val restored = BuzzAttestationStore.restoreFrom(null, legacyList(someoneElse, me), me) assertEquals(owner, restored?.ownerPubKey) } @@ -74,6 +74,6 @@ class BuzzAttestationRestoreTest { fun anotherAgentsLegacyEntryIsNeverPickedUp() { // The legacy list was already agent-keyed, so the migration is exact rather than // best-effort: there is no shared blob to accidentally inherit. - assertNull(BuzzAttestationPreferences.restoreFrom(null, legacyList(someoneElse), me)) + assertNull(BuzzAttestationStore.restoreFrom(null, legacyList(someoneElse), me)) } } From 0387ef33066cbf9782df7cc955045e97ea713c5e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 12:53:20 +0000 Subject: [PATCH 20/57] refactor: move the UI settings model and store into commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UiSettings could not follow the other preference groups into commons because its eight enums each carried a `resourceId: StringResource` pointing at commonsUI's generated `Res` class. commonsUI depends on commons, not the reverse, so commons structurally cannot see it and verifyKmpPurity would reject it either way. The settings themselves are plain data any front end may read, so the data moves and the labels stay. - commons/model: UiSettings, UiSettingsFlow and the nine enums, without the resource ids. Pure data, CLI-safe, per commons/ARCHITECTURE.md §1. - commons/model/preferences/UiSettingsStore: the key table, the defaults and the one-shot copy out of the old shared_settings blob. The legacy reader is injected, because that file is Android's and this store is not. - commonsUI/ui/settings/UiSettingsLabels: the labels, as extension properties keeping the `resourceId` name so no call site changes spelling. Each `when` is exhaustive, so a new enum constant is still a compile error rather than a missing label at runtime. - amethyst keeps what is genuinely platform work: the per-application night mode override the launch splash reads, and AppCompat's locale list. Neither has a desktop equivalent. The shared_settings migration moves to the file's delegate rather than sitting inside the UI store: seven other stores share that file, and DataStore runs a file's migrations once, on whichever store opens it first. Hanging the copy off the UI store alone would have made it depend on construction order. Three of the nine labels went unused — ConnectivityType, FeatureSetType and FontFamilyType are picked through the narrower `shortLabelRes` helpers in AppSettingsScreen — and BooleanType's was misspelled `reourceId`, which is how it stayed unread. They are dropped rather than carried across; the strings they named are still used by those short labels. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../components/SelectNotificationProvider.kt | 2 +- .../com/vitorpamplona/amethyst/AppModules.kt | 2 +- .../amethyst/LocalPreferences.kt | 2 +- .../amethyst/favorites/FavoriteAppLauncher.kt | 2 +- .../model/preferences/UISharedPreferences.kt | 215 ++------------- .../amethyst/napplet/NappletLauncher.kt | 2 +- .../ui/broadcast/DisplayBroadcastProgress.kt | 2 +- .../note/elements/NoteHeaderMarkersPreview.kt | 2 +- .../amethyst/ui/screen/UiSettingsState.kt | 10 +- .../ui/screen/loggedIn/AccountViewModel.kt | 2 +- .../loggedIn/embed/EmbeddedTabFactory.kt | 2 +- .../loggedIn/embed/EmbeddedTabThemeWatcher.kt | 2 +- .../loggedIn/home/ShortNotePostScreen.kt | 2 +- .../loggedIn/home/ShortNotePostViewModel.kt | 2 +- .../notifications/NotificationScreen.kt | 2 +- .../loggedIn/settings/AppSettingsScreen.kt | 17 +- .../settings/ComposeSettingsScreen.kt | 4 +- .../settings/HomeTabsSettingsScreen.kt | 2 +- .../settings/ProfileUiSettingsScreen.kt | 5 +- .../settings/SecurityFiltersScreen.kt | 5 +- .../suggestion/DetectedWorkoutCarousel.kt | 2 +- .../vitorpamplona/amethyst/ui/theme/Theme.kt | 8 +- .../components/SelectNotificationProvider.kt | 2 +- .../amethyst/commons}/model/UiSettings.kt | 101 +++---- .../amethyst/commons}/model/UiSettingsFlow.kt | 2 +- .../model/preferences/UiSettingsStore.kt | 247 ++++++++++++++++++ .../commons/ui/settings/UiSettingsLabels.kt | 111 ++++++++ 27 files changed, 459 insertions(+), 298 deletions(-) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/model/UiSettings.kt (66%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/model/UiSettingsFlow.kt (99%) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStore.kt create mode 100644 commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/UiSettingsLabels.kt diff --git a/amethyst/src/fdroid/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt b/amethyst/src/fdroid/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt index 78a6fcd112..114e9c5ee7 100644 --- a/amethyst/src/fdroid/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt +++ b/amethyst/src/fdroid/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt @@ -56,6 +56,7 @@ import com.halilibo.richtext.ui.material3.RichText import com.halilibo.richtext.ui.resolveDefaults import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.error_dialog_button_ok import com.vitorpamplona.amethyst.commons.resources.push_server_explainer @@ -71,7 +72,6 @@ import com.vitorpamplona.amethyst.commons.ui.components.SpinnerSelectionDialog import com.vitorpamplona.amethyst.commons.ui.components.TextSpinner import com.vitorpamplona.amethyst.commons.ui.components.TitleExplainer import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.model.UiSettingsFlow import com.vitorpamplona.amethyst.service.notifications.PushDistributorHandler import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsBlockTile import com.vitorpamplona.quartz.utils.Log diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 80e1666fc1..781ac1b91d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -28,6 +28,7 @@ import androidx.security.crypto.EncryptedSharedPreferences import coil3.disk.DiskCache import coil3.memory.MemoryCache import com.vitorpamplona.amethyst.commons.model.NoteState +import com.vitorpamplona.amethyst.commons.model.UiSettings import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.BitcoinExplorerEndpoint import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.IncomingOtsEventVerifier @@ -65,7 +66,6 @@ import com.vitorpamplona.amethyst.commons.tor.TorSettings import com.vitorpamplona.amethyst.connectedApps.DataStoreNostrSignerPermissionStore import com.vitorpamplona.amethyst.connectedApps.nip46.DataStoreNip46ClientStore import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.model.UiSettings import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.model.preferences.DrawerSectionCollapsePreferences diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 8c514f3774..430f20be37 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -26,6 +26,7 @@ import android.content.SharedPreferences import androidx.compose.runtime.Immutable import androidx.core.content.edit import com.vitorpamplona.amethyst.commons.model.HomeFeedType +import com.vitorpamplona.amethyst.commons.model.UiSettings import com.vitorpamplona.amethyst.commons.model.chats.ChatFeedType import com.vitorpamplona.amethyst.commons.model.clink.ClinkDebitWalletEntry import com.vitorpamplona.amethyst.commons.model.concord.ConcordViewMode @@ -59,7 +60,6 @@ import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyAccountSec import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthPolicy import com.vitorpamplona.amethyst.model.AccountSettings -import com.vitorpamplona.amethyst.model.UiSettings import com.vitorpamplona.amethyst.model.backups.BackupConflictStorage import com.vitorpamplona.amethyst.model.nip60Cashu.CashuPreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt index e4029c8627..cd6fb36b17 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt @@ -27,8 +27,8 @@ import android.os.Bundle import android.widget.Toast import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp +import com.vitorpamplona.amethyst.commons.model.ThemeType import com.vitorpamplona.amethyst.commons.model.cache.LocalCache -import com.vitorpamplona.amethyst.model.ThemeType import com.vitorpamplona.amethyst.napplet.NappletLauncher import com.vitorpamplona.amethyst.napplet.NappletWebViewProfiles import com.vitorpamplona.amethyst.napplet.WebAppNetworkRegistry diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt index 4148227f82..fe4df20db7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt @@ -27,26 +27,14 @@ import androidx.appcompat.app.AppCompatDelegate import androidx.compose.runtime.Stable import androidx.core.content.getSystemService import androidx.core.os.LocaleListCompat -import androidx.datastore.core.DataMigration import androidx.datastore.core.DataStore -import androidx.datastore.preferences.core.MutablePreferences import androidx.datastore.preferences.core.Preferences -import androidx.datastore.preferences.core.booleanPreferencesKey -import androidx.datastore.preferences.core.edit -import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import com.vitorpamplona.amethyst.LocalPreferences -import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration -import com.vitorpamplona.amethyst.model.AccentColorType -import com.vitorpamplona.amethyst.model.BooleanType -import com.vitorpamplona.amethyst.model.ConnectivityType -import com.vitorpamplona.amethyst.model.FeatureSetType -import com.vitorpamplona.amethyst.model.FontFamilyType -import com.vitorpamplona.amethyst.model.FontSizeType -import com.vitorpamplona.amethyst.model.ProfileGalleryType -import com.vitorpamplona.amethyst.model.ThemeType -import com.vitorpamplona.amethyst.model.UiSettings -import com.vitorpamplona.amethyst.model.UiSettingsFlow +import com.vitorpamplona.amethyst.commons.model.ThemeType +import com.vitorpamplona.amethyst.commons.model.UiSettings +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow +import com.vitorpamplona.amethyst.commons.model.preferences.UiSettingsStore import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -54,25 +42,43 @@ import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withContext import kotlin.coroutines.cancellation.CancellationException -/** The UI settings store. See [UiSharedPreferences.migrations] for the copy it carries. */ +/** + * The file UI, Tor, Namecoin, OTS and the Buzz stores all share, each under its + * own key prefix. + * + * The migration is attached here, at the file, rather than inside + * [UiSettingsStore]: whichever of those stores is constructed first is the one + * that opens the file, and DataStore runs a file's migrations once, on that + * first open. Hanging it off the UI store alone would make the copy depend on + * load order. + */ val Context.sharedPreferencesDataStore: DataStore by preferencesDataStore( name = "shared_settings", - produceMigrations = { UiSharedPreferences.migrations() }, + produceMigrations = { UiSettingsStore.migrations { LocalPreferences.loadSharedSettings() } }, ) +/** + * The Android half of the UI settings: the flows the app observes, and the two + * platform side effects that a theme or language change has to perform. + * + * Persistence is [UiSettingsStore] in `commons`, which every front end shares. + * What stays here is the part that has no desktop equivalent — the per-app night + * mode override that the launch splash reads, and AppCompat's locale list. + */ @Stable class UiSharedPreferences( prefs: UiSettings, val context: Context, val scope: CoroutineScope, ) { + private val store = UiSettingsStore(context.sharedPreferencesDataStore) { LocalPreferences.loadSharedSettings() } + // UI Preferences. Makes sure to wait for it to avoid blinking themes and language preferences val value = UiSettingsFlow.build(prefs) @@ -182,7 +188,7 @@ class UiSharedPreferences( .debounce(1000) .distinctUntilChanged() .onEach { - save(it, context) + store.save(it) }.flowOn(Dispatchers.IO) .stateIn( scope, @@ -191,173 +197,6 @@ class UiSharedPreferences( ) companion object { - // loads faster when individualized - val UI_THEME = stringPreferencesKey("ui.theme") - val UI_LANGUAGE = stringPreferencesKey("ui.language") - val UI_SHOW_IMAGES = stringPreferencesKey("ui.show_images") - val UI_START_PLAYBACK = stringPreferencesKey("ui.start_playback") - val UI_PLAY_VIDEOS = stringPreferencesKey("ui.play_videos") - val UI_SHOW_URL_PREVIEW = stringPreferencesKey("ui.show_url_preview") - val UI_HIDE_NAVIGATION_BARS = stringPreferencesKey("ui.hide_navigation_bars") - val UI_SHOW_PROFILE_PICTURES = stringPreferencesKey("ui.show_profile_pictures") - val UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR = booleanPreferencesKey("ui.dont_show_push_notification_selector") - val UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS = booleanPreferencesKey("ui.dont_ask_for_notification_permissions") - val UI_FEATURE_SET = stringPreferencesKey("ui.feature_set") - val UI_GALLERY_SET = stringPreferencesKey("ui.gallery_set") - val UI_PROPOSE_AI_IMPROVEMENTS = stringPreferencesKey("ui.propose_ai_improvements") - val UI_USE_TRACKED_BROADCASTS = stringPreferencesKey("ui.use_tracked_broadcasts") - val UI_AUTOMATICALLY_CREATE_DRAFTS = stringPreferencesKey("ui.automatically_create_drafts") - val UI_SHOW_HOME_NEW_THREADS_TAB = booleanPreferencesKey("ui.show_home_new_threads_tab") - val UI_SHOW_HOME_CONVERSATIONS_TAB = booleanPreferencesKey("ui.show_home_conversations_tab") - val UI_SHOW_HOME_EVERYTHING_TAB = booleanPreferencesKey("ui.show_home_everything_tab") - val UI_SHOW_PROFILE_BADGES = booleanPreferencesKey("ui.show_profile_badges") - val UI_SHOW_PROFILE_APP_RECOMMENDATIONS = booleanPreferencesKey("ui.show_profile_app_recommendations") - val UI_SHOW_PROFILE_ZAP_RECEIVED_FEED = booleanPreferencesKey("ui.show_profile_zap_received_feed") - val UI_SHOW_PROFILE_FOLLOWERS_FEED = booleanPreferencesKey("ui.show_profile_followers_feed") - val UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING = booleanPreferencesKey("ui.dont_show_onchain_public_warning") - val UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT = stringPreferencesKey("ui.suggest_workouts_from_health_connect") - val UI_ACCENT_COLOR = stringPreferencesKey("ui.accent_color") - val UI_FONT_FAMILY = stringPreferencesKey("ui.font_family") - val UI_FONT_SIZE = stringPreferencesKey("ui.font_size") - val UI_COMPOSE_SIGNATURE = stringPreferencesKey("ui.compose_signature") - val UI_SHOW_ONCHAIN_WALLET = booleanPreferencesKey("ui.show_onchain_wallet") - val UI_SHOW_PAYTO_ZAP_CHIP = booleanPreferencesKey("ui.show_payto_zap_chip") - - suspend fun uiPreferences(context: Context): UiSettings? = - try { - // Get the preference flow and take the first value. - val preferences = context.sharedPreferencesDataStore.data.first() - - val featureSet = preferences[UI_FEATURE_SET]?.let { FeatureSetType.valueOf(it) } ?: FeatureSetType.SIMPLIFIED - - UiSettings( - theme = preferences[UI_THEME]?.let { ThemeType.valueOf(it) } ?: ThemeType.SYSTEM, - preferredLanguage = preferences[UI_LANGUAGE]?.ifBlank { null }, - automaticallyShowImages = preferences[UI_SHOW_IMAGES]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, - automaticallyStartPlayback = preferences[UI_START_PLAYBACK]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, - automaticallyPlayVideos = preferences[UI_PLAY_VIDEOS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, - automaticallyShowUrlPreview = preferences[UI_SHOW_URL_PREVIEW]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, - automaticallyHideNavigationBars = preferences[UI_HIDE_NAVIGATION_BARS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, - automaticallyShowProfilePictures = preferences[UI_SHOW_PROFILE_PICTURES]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, - dontShowPushNotificationSelector = preferences[UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR] ?: false, - dontAskForNotificationPermissions = preferences[UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS] ?: false, - featureSet = featureSet, - gallerySet = preferences[UI_GALLERY_SET]?.let { ProfileGalleryType.valueOf(it) } ?: ProfileGalleryType.CLASSIC, - automaticallyProposeAiImprovements = preferences[UI_PROPOSE_AI_IMPROVEMENTS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, - useTrackedBroadcasts = - preferences[UI_USE_TRACKED_BROADCASTS]?.let { BooleanType.valueOf(it) } - ?: if (featureSet == FeatureSetType.COMPLETE) BooleanType.ALWAYS else BooleanType.NEVER, - automaticallyCreateDrafts = preferences[UI_AUTOMATICALLY_CREATE_DRAFTS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, - showHomeNewThreadsTab = preferences[UI_SHOW_HOME_NEW_THREADS_TAB] ?: true, - showHomeConversationsTab = preferences[UI_SHOW_HOME_CONVERSATIONS_TAB] ?: true, - showHomeEverythingTab = preferences[UI_SHOW_HOME_EVERYTHING_TAB] ?: false, - showProfileBadges = preferences[UI_SHOW_PROFILE_BADGES] ?: true, - showProfileAppRecommendations = preferences[UI_SHOW_PROFILE_APP_RECOMMENDATIONS] ?: true, - showProfileZapReceivedFeed = preferences[UI_SHOW_PROFILE_ZAP_RECEIVED_FEED] ?: true, - showProfileFollowersFeed = preferences[UI_SHOW_PROFILE_FOLLOWERS_FEED] ?: true, - dontShowOnchainPublicWarning = preferences[UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING] ?: false, - suggestWorkoutsFromHealthConnect = - preferences[UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, - accentColor = preferences[UI_ACCENT_COLOR]?.let { AccentColorType.valueOf(it) } ?: AccentColorType.PURPLE, - fontFamily = preferences[UI_FONT_FAMILY]?.let { FontFamilyType.valueOf(it) } ?: FontFamilyType.SYSTEM, - fontSize = preferences[UI_FONT_SIZE]?.let { FontSizeType.valueOf(it) } ?: FontSizeType.NORMAL, - composeSignature = preferences[UI_COMPOSE_SIGNATURE] ?: "", - showOnchainWallet = preferences[UI_SHOW_ONCHAIN_WALLET] ?: true, - showPayToZapChip = preferences[UI_SHOW_PAYTO_ZAP_CHIP] ?: true, - ) - } catch (e: Exception) { - if (e is CancellationException) throw e - // Log any errors that occur while reading the DataStore. - Log.e("SharedPreferences") { "Error reading DataStore preferences: ${e.message}" } - - try { - val oldVersion = LocalPreferences.loadSharedSettings() - if (oldVersion != null) { - save(oldVersion, context) - } - oldVersion - } catch (e: Exception) { - if (e is CancellationException) throw e - null - } - } - - /** - * Writes every UI setting into [preferences]. - * - * Shared by [save] and by the one-shot copy out of the old - * `shared_settings` blob, so the two cannot come to disagree about - * which keys a complete set of UI settings has. - */ - internal fun MutablePreferences.write(sharedSettings: UiSettings) { - val preferences = this - preferences[UI_THEME] = sharedSettings.theme.name - preferences[UI_LANGUAGE] = sharedSettings.preferredLanguage ?: "" - preferences[UI_SHOW_IMAGES] = sharedSettings.automaticallyShowImages.name - preferences[UI_START_PLAYBACK] = sharedSettings.automaticallyStartPlayback.name - preferences[UI_PLAY_VIDEOS] = sharedSettings.automaticallyPlayVideos.name - preferences[UI_SHOW_URL_PREVIEW] = sharedSettings.automaticallyShowUrlPreview.name - preferences[UI_HIDE_NAVIGATION_BARS] = sharedSettings.automaticallyHideNavigationBars.name - preferences[UI_SHOW_PROFILE_PICTURES] = sharedSettings.automaticallyShowProfilePictures.name - preferences[UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR] = sharedSettings.dontShowPushNotificationSelector - preferences[UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS] = sharedSettings.dontAskForNotificationPermissions - preferences[UI_FEATURE_SET] = sharedSettings.featureSet.name - preferences[UI_GALLERY_SET] = sharedSettings.gallerySet.name - preferences[UI_PROPOSE_AI_IMPROVEMENTS] = sharedSettings.automaticallyProposeAiImprovements.name - preferences[UI_USE_TRACKED_BROADCASTS] = sharedSettings.useTrackedBroadcasts.name - preferences[UI_AUTOMATICALLY_CREATE_DRAFTS] = sharedSettings.automaticallyCreateDrafts.name - preferences[UI_SHOW_HOME_NEW_THREADS_TAB] = sharedSettings.showHomeNewThreadsTab - preferences[UI_SHOW_HOME_CONVERSATIONS_TAB] = sharedSettings.showHomeConversationsTab - preferences[UI_SHOW_HOME_EVERYTHING_TAB] = sharedSettings.showHomeEverythingTab - preferences[UI_SHOW_PROFILE_BADGES] = sharedSettings.showProfileBadges - preferences[UI_SHOW_PROFILE_APP_RECOMMENDATIONS] = sharedSettings.showProfileAppRecommendations - preferences[UI_SHOW_PROFILE_ZAP_RECEIVED_FEED] = sharedSettings.showProfileZapReceivedFeed - preferences[UI_SHOW_PROFILE_FOLLOWERS_FEED] = sharedSettings.showProfileFollowersFeed - preferences[UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING] = sharedSettings.dontShowOnchainPublicWarning - preferences[UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT] = sharedSettings.suggestWorkoutsFromHealthConnect.name - preferences[UI_ACCENT_COLOR] = sharedSettings.accentColor.name - preferences[UI_FONT_FAMILY] = sharedSettings.fontFamily.name - preferences[UI_FONT_SIZE] = sharedSettings.fontSize.name - preferences[UI_COMPOSE_SIGNATURE] = sharedSettings.composeSignature - preferences[UI_SHOW_ONCHAIN_WALLET] = sharedSettings.showOnchainWallet - preferences[UI_SHOW_PAYTO_ZAP_CHIP] = sharedSettings.showPayToZapChip - } - - /** - * The one-shot copy out of the single `shared_settings` JSON blob these - * settings used to be kept as, in the global encrypted file. - * - * Guarded, and it has to be. Unlike the per-account migrations, this - * store has been the real home of these settings for a while, so most - * installs already have a populated one — and copying an old blob over - * it would undo every UI change the user has made since. [UI_THEME] is - * the test: [save] writes every key unconditionally and is the only - * writer, so its absence means this store has never been saved, which - * is exactly the install whose settings are still only in the legacy - * file. - */ - internal fun migrations(): List> = - listOf( - CopyOnceMigration("migrated.sharedSettings") { out -> - if (out[UI_THEME] == null) { - withContext(Dispatchers.IO) { - LocalPreferences.loadSharedSettings()?.let { out.write(it) } - } - } - }, - ) - - suspend fun save( - sharedSettings: UiSettings, - context: Context, - ) { - try { - context.sharedPreferencesDataStore.edit { preferences -> preferences.write(sharedSettings) } - } catch (e: Exception) { - if (e is CancellationException) throw e - // Log any errors that occur while reading the DataStore. - Log.e("SharedPreferences") { "Error saving DataStore preferences: ${e.message}" } - } - } + suspend fun uiPreferences(context: Context): UiSettings? = UiSettingsStore(context.sharedPreferencesDataStore) { LocalPreferences.loadSharedSettings() }.load() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletLauncher.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletLauncher.kt index 382242d133..e4619c6624 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletLauncher.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletLauncher.kt @@ -25,10 +25,10 @@ import android.content.Intent import android.content.res.Configuration import android.os.Bundle import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.model.ThemeType import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.napplet.NappletArtifactPolicy import com.vitorpamplona.amethyst.commons.napplet.NappletIdentity -import com.vitorpamplona.amethyst.model.ThemeType import com.vitorpamplona.amethyst.napplethost.HostProfile import com.vitorpamplona.amethyst.napplethost.NappletHostActivity import com.vitorpamplona.amethyst.napplethost.NappletHostContract diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/DisplayBroadcastProgress.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/DisplayBroadcastProgress.kt index 44773b05a0..1c9c1f1772 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/DisplayBroadcastProgress.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/broadcast/DisplayBroadcastProgress.kt @@ -38,9 +38,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.model.BooleanType import com.vitorpamplona.amethyst.commons.service.broadcast.BroadcastEvent import com.vitorpamplona.amethyst.commons.service.pow.PoWJobState -import com.vitorpamplona.amethyst.model.BooleanType import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.collections.immutable.ImmutableList diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteHeaderMarkersPreview.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteHeaderMarkersPreview.kt index fb12ae4b2d..00689c692d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteHeaderMarkersPreview.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteHeaderMarkersPreview.kt @@ -29,12 +29,12 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.vitorpamplona.amethyst.commons.model.FeatureSetType import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.ui.components.GenericLoadable import com.vitorpamplona.amethyst.commons.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn -import com.vitorpamplona.amethyst.model.FeatureSetType import com.vitorpamplona.amethyst.service.location.CachedReversedGeoLocations import com.vitorpamplona.amethyst.ui.note.FirstUserInfoRow import com.vitorpamplona.amethyst.ui.note.types.EditState diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UiSettingsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UiSettingsState.kt index ea6ed3fce7..a68e877ea5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UiSettingsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UiSettingsState.kt @@ -21,11 +21,11 @@ package com.vitorpamplona.amethyst.ui.screen import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.model.BooleanType -import com.vitorpamplona.amethyst.model.ConnectivityType -import com.vitorpamplona.amethyst.model.FeatureSetType -import com.vitorpamplona.amethyst.model.ProfileGalleryType -import com.vitorpamplona.amethyst.model.UiSettingsFlow +import com.vitorpamplona.amethyst.commons.model.BooleanType +import com.vitorpamplona.amethyst.commons.model.ConnectivityType +import com.vitorpamplona.amethyst.commons.model.FeatureSetType +import com.vitorpamplona.amethyst.commons.model.ProfileGalleryType +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow 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 57381f76b9..23ac016ee0 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 @@ -46,6 +46,7 @@ import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Dao import com.vitorpamplona.amethyst.commons.model.LiveHiddenUsers import com.vitorpamplona.amethyst.commons.model.Note +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.backups.ReplaceableBackupConflict import com.vitorpamplona.amethyst.commons.model.cache.LocalCache @@ -111,7 +112,6 @@ import com.vitorpamplona.amethyst.logTime import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.amethyst.model.LatestKeyPackageOwner -import com.vitorpamplona.amethyst.model.UiSettingsFlow import com.vitorpamplona.amethyst.model.UrlCachedPreviewer import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.service.ClinkDebitPayer diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabFactory.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabFactory.kt index fab2842f38..8422c85477 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabFactory.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabFactory.kt @@ -27,9 +27,9 @@ import android.os.Bundle import androidx.annotation.RequiresApi import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp +import com.vitorpamplona.amethyst.commons.model.ThemeType import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.amethyst.favorites.FavoriteAppLauncher -import com.vitorpamplona.amethyst.model.ThemeType import com.vitorpamplona.amethyst.napplet.WebAppNetworkRegistry import com.vitorpamplona.amethyst.napplethost.NappletHostContract import com.vitorpamplona.amethyst.ui.screen.loggedIn.browser.EmbeddedWebAppController diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabThemeWatcher.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabThemeWatcher.kt index 9c0ddcf11a..d3e8c770f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabThemeWatcher.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabThemeWatcher.kt @@ -30,7 +30,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.Amethyst -import com.vitorpamplona.amethyst.model.ThemeType +import com.vitorpamplona.amethyst.commons.model.ThemeType /** * Keeps the warm embedded tabs in sync with the app's DARK/LIGHT theme. An embed WebView resolves its diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt index 65832e94fb..8c5bd12fec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt @@ -81,6 +81,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.BooleanType import com.vitorpamplona.amethyst.commons.model.composer.AudienceSelection import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.nip30CustomEmojis.ui.ShowEmojiSuggestionList @@ -134,7 +135,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.SuggestionListDefaultHeightPa import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.commons.ui.theme.replyModifier -import com.vitorpamplona.amethyst.model.BooleanType import com.vitorpamplona.amethyst.ui.actions.StrippingFailureDialog import com.vitorpamplona.amethyst.ui.actions.mediaServers.FileServerSelectionRow import com.vitorpamplona.amethyst.ui.actions.uploads.MAX_VOICE_RECORD_SECONDS diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt index 72bc69b916..08df10a49e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt @@ -35,6 +35,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.AddressableNote +import com.vitorpamplona.amethyst.commons.model.BooleanType import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.LocalCache @@ -69,7 +70,6 @@ import com.vitorpamplona.amethyst.commons.ui.text.onUiThread import com.vitorpamplona.amethyst.commons.ui.text.replaceCurrentWord import com.vitorpamplona.amethyst.commons.ui.text.setTextAndPlaceCursorAtBeginning import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.model.BooleanType import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.service.ai.WritingAssistantFactory import com.vitorpamplona.amethyst.service.location.LocationState diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt index f7227a9362..cd772a90de 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt @@ -32,6 +32,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.notification_tab_everyone @@ -44,7 +45,6 @@ import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverPagerState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.TabRowHeight -import com.vitorpamplona.amethyst.model.UiSettingsFlow import com.vitorpamplona.amethyst.ui.components.SelectNotificationProvider import com.vitorpamplona.amethyst.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AppSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AppSettingsScreen.kt index 4f580033c9..e3010ffd5c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AppSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/AppSettingsScreen.kt @@ -73,6 +73,14 @@ import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.AccentColorType +import com.vitorpamplona.amethyst.commons.model.BooleanType +import com.vitorpamplona.amethyst.commons.model.ConnectivityType +import com.vitorpamplona.amethyst.commons.model.FeatureSetType +import com.vitorpamplona.amethyst.commons.model.FontFamilyType +import com.vitorpamplona.amethyst.commons.model.FontSizeType +import com.vitorpamplona.amethyst.commons.model.ThemeType +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.accent_color import com.vitorpamplona.amethyst.commons.resources.accent_color_description @@ -118,18 +126,11 @@ import com.vitorpamplona.amethyst.commons.ui.components.TitleExplainer import com.vitorpamplona.amethyst.commons.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton +import com.vitorpamplona.amethyst.commons.ui.settings.resourceId import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow import com.vitorpamplona.amethyst.commons.ui.theme.contentColorOnAccent import com.vitorpamplona.amethyst.commons.ui.theme.isLight -import com.vitorpamplona.amethyst.model.AccentColorType -import com.vitorpamplona.amethyst.model.BooleanType -import com.vitorpamplona.amethyst.model.ConnectivityType -import com.vitorpamplona.amethyst.model.FeatureSetType -import com.vitorpamplona.amethyst.model.FontFamilyType -import com.vitorpamplona.amethyst.model.FontSizeType -import com.vitorpamplona.amethyst.model.ThemeType -import com.vitorpamplona.amethyst.model.UiSettingsFlow import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.theme.previewColor import com.vitorpamplona.amethyst.ui.theme.toFontFamily diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ComposeSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ComposeSettingsScreen.kt index 933b81c1ee..3f0691f2b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ComposeSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ComposeSettingsScreen.kt @@ -45,6 +45,8 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.BooleanType +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.add_client_tag_explainer import com.vitorpamplona.amethyst.commons.resources.add_client_tag_title @@ -96,8 +98,6 @@ import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackBu import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.model.AccountPoWPreferences -import com.vitorpamplona.amethyst.model.BooleanType -import com.vitorpamplona.amethyst.model.UiSettingsFlow import com.vitorpamplona.amethyst.service.ai.WritingAssistantFactory import com.vitorpamplona.amethyst.service.pow.deviceHashesPerSecond import com.vitorpamplona.amethyst.service.pow.loadApproxDuration diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/HomeTabsSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/HomeTabsSettingsScreen.kt index 838ca8b799..ba83376d7a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/HomeTabsSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/HomeTabsSettingsScreen.kt @@ -36,6 +36,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.HomeFeedType +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.conversations import com.vitorpamplona.amethyst.commons.resources.home_content_type_articles @@ -72,7 +73,6 @@ import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow -import com.vitorpamplona.amethyst.model.UiSettingsFlow import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import org.jetbrains.compose.resources.StringResource diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ProfileUiSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ProfileUiSettingsScreen.kt index e533d60817..3fa6edba83 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ProfileUiSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/ProfileUiSettingsScreen.kt @@ -34,6 +34,8 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.ProfileGalleryType +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.gallery_style import com.vitorpamplona.amethyst.commons.resources.gallery_style_description @@ -48,10 +50,9 @@ import com.vitorpamplona.amethyst.commons.resources.settings_section_profile_sec import com.vitorpamplona.amethyst.commons.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton +import com.vitorpamplona.amethyst.commons.ui.settings.resourceId import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow -import com.vitorpamplona.amethyst.model.ProfileGalleryType -import com.vitorpamplona.amethyst.model.UiSettingsFlow import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt index 0e38c36ff5..7a5d836238 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt @@ -38,7 +38,9 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.WarningType import com.vitorpamplona.amethyst.commons.model.navigation.Route +import com.vitorpamplona.amethyst.commons.model.parseWarningType import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.blocked_users import com.vitorpamplona.amethyst.commons.resources.filter_spam_from_strangers_explainer @@ -63,10 +65,9 @@ import com.vitorpamplona.amethyst.commons.resources.warn_when_posts_have_reports import com.vitorpamplona.amethyst.commons.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton +import com.vitorpamplona.amethyst.commons.ui.settings.resourceId import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn -import com.vitorpamplona.amethyst.model.WarningType -import com.vitorpamplona.amethyst.model.parseWarningType import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/suggestion/DetectedWorkoutCarousel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/suggestion/DetectedWorkoutCarousel.kt index fb28dfd9fd..ffc23b3d25 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/suggestion/DetectedWorkoutCarousel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/workouts/suggestion/DetectedWorkoutCarousel.kt @@ -60,6 +60,7 @@ import com.vitorpamplona.amethyst.commons.fitness.TrainingLog import com.vitorpamplona.amethyst.commons.fitness.WorkoutOrigin import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.BooleanType import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.workout_from_health_connect @@ -71,7 +72,6 @@ import com.vitorpamplona.amethyst.commons.resources.workout_suggestion_connect_t import com.vitorpamplona.amethyst.commons.resources.workout_suggestion_distance_km import com.vitorpamplona.amethyst.commons.ui.pluralStringRes import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.model.BooleanType import com.vitorpamplona.amethyst.service.workouts.health.HealthConnectManager import com.vitorpamplona.amethyst.service.workouts.health.publishedWorkoutsOf import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt index 13a092c162..7db63b6a55 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/theme/Theme.kt @@ -44,6 +44,10 @@ import com.patrykandpatrick.vico.compose.common.VicoTheme import com.patrykandpatrick.vico.compose.common.VicoTheme.CandlestickCartesianLayerColors import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.icons.symbols.ProvideAppIcons +import com.vitorpamplona.amethyst.commons.model.AccentColorType +import com.vitorpamplona.amethyst.commons.model.FontFamilyType +import com.vitorpamplona.amethyst.commons.model.FontSizeType +import com.vitorpamplona.amethyst.commons.model.ThemeType import com.vitorpamplona.amethyst.commons.ui.theme.AccentBlueDark import com.vitorpamplona.amethyst.commons.ui.theme.AccentBlueLight import com.vitorpamplona.amethyst.commons.ui.theme.AccentGreenDark @@ -64,10 +68,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.amethystLightColorScheme import com.vitorpamplona.amethyst.commons.ui.theme.isLight import com.vitorpamplona.amethyst.commons.ui.theme.transparentBackground import com.vitorpamplona.amethyst.commons.ui.theme.withFontFamily -import com.vitorpamplona.amethyst.model.AccentColorType -import com.vitorpamplona.amethyst.model.FontFamilyType -import com.vitorpamplona.amethyst.model.FontSizeType -import com.vitorpamplona.amethyst.model.ThemeType // The accent color (primary/secondary/tertiary) is user-selectable in Settings -> Accent Color. // Purple keeps the original Amethyst look (purple primary + teal secondary). Every other accent diff --git a/amethyst/src/play/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt b/amethyst/src/play/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt index dc32830cc4..0915fcb2d2 100644 --- a/amethyst/src/play/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt +++ b/amethyst/src/play/java/com/vitorpamplona/amethyst/ui/components/SelectNotificationProvider.kt @@ -29,7 +29,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.isGranted import com.google.accompanist.permissions.rememberPermissionState -import com.vitorpamplona.amethyst.model.UiSettingsFlow +import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow @OptIn(ExperimentalPermissionsApi::class) @Composable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettings.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/UiSettings.kt similarity index 66% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettings.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/UiSettings.kt index 159afa0514..eb8ae128e1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettings.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/UiSettings.kt @@ -18,40 +18,10 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model +package com.vitorpamplona.amethyst.commons.model import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.resources.Res -import com.vitorpamplona.amethyst.commons.resources.accent_color_blue -import com.vitorpamplona.amethyst.commons.resources.accent_color_green -import com.vitorpamplona.amethyst.commons.resources.accent_color_orange -import com.vitorpamplona.amethyst.commons.resources.accent_color_pink -import com.vitorpamplona.amethyst.commons.resources.accent_color_purple -import com.vitorpamplona.amethyst.commons.resources.accent_color_red -import com.vitorpamplona.amethyst.commons.resources.connectivity_type_always -import com.vitorpamplona.amethyst.commons.resources.connectivity_type_never -import com.vitorpamplona.amethyst.commons.resources.connectivity_type_unmetered_wifi_only -import com.vitorpamplona.amethyst.commons.resources.content_warning_hide_all_sensitive_content_option -import com.vitorpamplona.amethyst.commons.resources.content_warning_see_warnings_option -import com.vitorpamplona.amethyst.commons.resources.content_warning_show_all_sensitive_content_option -import com.vitorpamplona.amethyst.commons.resources.dark -import com.vitorpamplona.amethyst.commons.resources.font_family_monospace -import com.vitorpamplona.amethyst.commons.resources.font_family_sans_serif -import com.vitorpamplona.amethyst.commons.resources.font_family_serif -import com.vitorpamplona.amethyst.commons.resources.font_family_system -import com.vitorpamplona.amethyst.commons.resources.font_size_huge -import com.vitorpamplona.amethyst.commons.resources.font_size_large -import com.vitorpamplona.amethyst.commons.resources.font_size_normal -import com.vitorpamplona.amethyst.commons.resources.font_size_small -import com.vitorpamplona.amethyst.commons.resources.gallery_type_classic -import com.vitorpamplona.amethyst.commons.resources.gallery_type_modern -import com.vitorpamplona.amethyst.commons.resources.light -import com.vitorpamplona.amethyst.commons.resources.system -import com.vitorpamplona.amethyst.commons.resources.ui_feature_set_type_complete -import com.vitorpamplona.amethyst.commons.resources.ui_feature_set_type_performance -import com.vitorpamplona.amethyst.commons.resources.ui_feature_set_type_simplified import kotlinx.serialization.Serializable -import org.jetbrains.compose.resources.StringResource @Stable @Serializable @@ -98,11 +68,10 @@ data class UiSettings( enum class ThemeType( val screenCode: Int, - val resourceId: StringResource, ) { - SYSTEM(0, Res.string.system), - LIGHT(1, Res.string.light), - DARK(2, Res.string.dark), + SYSTEM(0), + LIGHT(1), + DARK(2), } fun parseThemeType(code: Int?): ThemeType = @@ -115,14 +84,13 @@ fun parseThemeType(code: Int?): ThemeType = enum class AccentColorType( val screenCode: Int, - val resourceId: StringResource, ) { - PURPLE(0, Res.string.accent_color_purple), - BLUE(1, Res.string.accent_color_blue), - GREEN(2, Res.string.accent_color_green), - ORANGE(3, Res.string.accent_color_orange), - RED(4, Res.string.accent_color_red), - PINK(5, Res.string.accent_color_pink), + PURPLE(0), + BLUE(1), + GREEN(2), + ORANGE(3), + RED(4), + PINK(5), } fun parseAccentColorType(screenCode: Int): AccentColorType = @@ -138,12 +106,11 @@ fun parseAccentColorType(screenCode: Int): AccentColorType = enum class FontFamilyType( val screenCode: Int, - val resourceId: StringResource, ) { - SYSTEM(0, Res.string.font_family_system), - SANS_SERIF(1, Res.string.font_family_sans_serif), - SERIF(2, Res.string.font_family_serif), - MONOSPACE(3, Res.string.font_family_monospace), + SYSTEM(0), + SANS_SERIF(1), + SERIF(2), + MONOSPACE(3), } fun parseFontFamilyType(screenCode: Int): FontFamilyType = @@ -158,12 +125,11 @@ fun parseFontFamilyType(screenCode: Int): FontFamilyType = enum class FontSizeType( val scale: Float, val screenCode: Int, - val resourceId: StringResource, ) { - SMALL(0.85f, 0, Res.string.font_size_small), - NORMAL(1.0f, 1, Res.string.font_size_normal), - LARGE(1.15f, 2, Res.string.font_size_large), - HUGE(1.3f, 3, Res.string.font_size_huge), + SMALL(0.85f, 0), + NORMAL(1.0f, 1), + LARGE(1.15f, 2), + HUGE(1.3f, 3), } fun parseFontSizeType(screenCode: Int): FontSizeType = @@ -178,28 +144,25 @@ fun parseFontSizeType(screenCode: Int): FontSizeType = enum class ConnectivityType( val prefCode: Boolean?, val screenCode: Int, - val resourceId: StringResource, ) { - ALWAYS(null, 0, Res.string.connectivity_type_always), - WIFI_ONLY(true, 1, Res.string.connectivity_type_unmetered_wifi_only), - NEVER(false, 2, Res.string.connectivity_type_never), + ALWAYS(null, 0), + WIFI_ONLY(true, 1), + NEVER(false, 2), } enum class FeatureSetType( val screenCode: Int, - val resourceId: StringResource, ) { - COMPLETE(0, Res.string.ui_feature_set_type_complete), - SIMPLIFIED(1, Res.string.ui_feature_set_type_simplified), - PERFORMANCE(2, Res.string.ui_feature_set_type_performance), + COMPLETE(0), + SIMPLIFIED(1), + PERFORMANCE(2), } enum class ProfileGalleryType( val screenCode: Int, - val resourceId: StringResource, ) { - CLASSIC(0, Res.string.gallery_type_classic), - MODERN(1, Res.string.gallery_type_modern), + CLASSIC(0), + MODERN(1), } fun parseConnectivityType(code: Boolean?): ConnectivityType = @@ -236,10 +199,9 @@ fun parseGalleryType(screenCode: Int): ProfileGalleryType = enum class BooleanType( val prefCode: Boolean?, val screenCode: Int, - val reourceId: StringResource, ) { - ALWAYS(null, 0, Res.string.connectivity_type_always), - NEVER(false, 1, Res.string.connectivity_type_never), + ALWAYS(null, 0), + NEVER(false, 1), } fun parseBooleanType(code: Boolean?): BooleanType = @@ -259,11 +221,10 @@ fun parseBooleanType(screenCode: Int): BooleanType = enum class WarningType( val prefCode: Boolean?, val screenCode: Int, - val resourceId: StringResource, ) { - WARN(null, 0, Res.string.content_warning_see_warnings_option), - SHOW(true, 1, Res.string.content_warning_show_all_sensitive_content_option), - HIDE(false, 2, Res.string.content_warning_hide_all_sensitive_content_option), + WARN(null, 0), + SHOW(true, 1), + HIDE(false, 2), } fun parseWarningType(screenCode: Int): WarningType = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettingsFlow.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/UiSettingsFlow.kt similarity index 99% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettingsFlow.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/UiSettingsFlow.kt index d2528689c2..6a0870cfa8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/UiSettingsFlow.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/UiSettingsFlow.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model +package com.vitorpamplona.amethyst.commons.model import androidx.compose.runtime.Stable import kotlinx.coroutines.flow.Flow diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStore.kt new file mode 100644 index 0000000000..c1606b0440 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStore.kt @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataMigration +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.MutablePreferences +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringPreferencesKey +import com.vitorpamplona.amethyst.commons.model.AccentColorType +import com.vitorpamplona.amethyst.commons.model.BooleanType +import com.vitorpamplona.amethyst.commons.model.ConnectivityType +import com.vitorpamplona.amethyst.commons.model.FeatureSetType +import com.vitorpamplona.amethyst.commons.model.FontFamilyType +import com.vitorpamplona.amethyst.commons.model.FontSizeType +import com.vitorpamplona.amethyst.commons.model.ProfileGalleryType +import com.vitorpamplona.amethyst.commons.model.ThemeType +import com.vitorpamplona.amethyst.commons.model.UiSettings +import com.vitorpamplona.quartz.utils.Log +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.withContext +import kotlin.coroutines.cancellation.CancellationException + +/** + * The app-wide UI settings — theme, language, what loads on cellular, which + * profile and home tabs are shown. + * + * Lives on the [AppPreferenceStores.SHARED_SETTINGS] file under the `ui.` key + * prefix, one key per setting rather than a single blob: a DataStore read is + * whole-file anyway, but individual keys mean a setting added later does not + * invalidate the ones already stored. + * + * Headless on purpose. Applying a theme or a locale is platform work — on + * Android it is `UiModeManager` and `AppCompatDelegate`, which have no desktop + * equivalent — so that half stays in each front end and only the persistence + * is shared. + * + * @param loadLegacy reads the single `shared_settings` JSON blob these settings + * used to live in. Injected because the legacy file is Android's, and this + * store is not. Front ends without one pass nothing. + */ +class UiSettingsStore( + private val store: DataStore, + private val loadLegacy: suspend () -> UiSettings? = { null }, +) { + /** + * Reads every setting, falling back to the legacy blob if the store itself + * cannot be read. + * + * Returns null when neither can be read, which the caller shows as "still + * loading" rather than as defaults — writing defaults over an unreadable + * store would make a transient failure permanent on the next save. + */ + suspend fun load(): UiSettings? = + try { + read(store.data.first()) + } catch (e: Exception) { + if (e is CancellationException) throw e + Log.e("UiSettingsStore") { "Error reading DataStore preferences: ${e.message}" } + + try { + loadLegacy()?.also { save(it) } + } catch (e: Exception) { + if (e is CancellationException) throw e + null + } + } + + suspend fun save(settings: UiSettings) { + try { + store.edit { it.write(settings) } + } catch (e: Exception) { + if (e is CancellationException) throw e + Log.e("UiSettingsStore") { "Error saving DataStore preferences: ${e.message}" } + } + } + + companion object { + // loads faster when individualized + val UI_THEME = stringPreferencesKey("ui.theme") + val UI_LANGUAGE = stringPreferencesKey("ui.language") + val UI_SHOW_IMAGES = stringPreferencesKey("ui.show_images") + val UI_START_PLAYBACK = stringPreferencesKey("ui.start_playback") + val UI_PLAY_VIDEOS = stringPreferencesKey("ui.play_videos") + val UI_SHOW_URL_PREVIEW = stringPreferencesKey("ui.show_url_preview") + val UI_HIDE_NAVIGATION_BARS = stringPreferencesKey("ui.hide_navigation_bars") + val UI_SHOW_PROFILE_PICTURES = stringPreferencesKey("ui.show_profile_pictures") + val UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR = booleanPreferencesKey("ui.dont_show_push_notification_selector") + val UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS = booleanPreferencesKey("ui.dont_ask_for_notification_permissions") + val UI_FEATURE_SET = stringPreferencesKey("ui.feature_set") + val UI_GALLERY_SET = stringPreferencesKey("ui.gallery_set") + val UI_PROPOSE_AI_IMPROVEMENTS = stringPreferencesKey("ui.propose_ai_improvements") + val UI_USE_TRACKED_BROADCASTS = stringPreferencesKey("ui.use_tracked_broadcasts") + val UI_AUTOMATICALLY_CREATE_DRAFTS = stringPreferencesKey("ui.automatically_create_drafts") + val UI_SHOW_HOME_NEW_THREADS_TAB = booleanPreferencesKey("ui.show_home_new_threads_tab") + val UI_SHOW_HOME_CONVERSATIONS_TAB = booleanPreferencesKey("ui.show_home_conversations_tab") + val UI_SHOW_HOME_EVERYTHING_TAB = booleanPreferencesKey("ui.show_home_everything_tab") + val UI_SHOW_PROFILE_BADGES = booleanPreferencesKey("ui.show_profile_badges") + val UI_SHOW_PROFILE_APP_RECOMMENDATIONS = booleanPreferencesKey("ui.show_profile_app_recommendations") + val UI_SHOW_PROFILE_ZAP_RECEIVED_FEED = booleanPreferencesKey("ui.show_profile_zap_received_feed") + val UI_SHOW_PROFILE_FOLLOWERS_FEED = booleanPreferencesKey("ui.show_profile_followers_feed") + val UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING = booleanPreferencesKey("ui.dont_show_onchain_public_warning") + val UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT = stringPreferencesKey("ui.suggest_workouts_from_health_connect") + val UI_ACCENT_COLOR = stringPreferencesKey("ui.accent_color") + val UI_FONT_FAMILY = stringPreferencesKey("ui.font_family") + val UI_FONT_SIZE = stringPreferencesKey("ui.font_size") + val UI_COMPOSE_SIGNATURE = stringPreferencesKey("ui.compose_signature") + val UI_SHOW_ONCHAIN_WALLET = booleanPreferencesKey("ui.show_onchain_wallet") + val UI_SHOW_PAYTO_ZAP_CHIP = booleanPreferencesKey("ui.show_payto_zap_chip") + + /** + * Every setting's default matches what the old `getBoolean(key, default)` + * call returned for a missing key. Several of them are `true`, so reading + * a default of `false` here would silently turn features off for every + * install that never touched them. + */ + fun read(preferences: Preferences): UiSettings { + val featureSet = preferences[UI_FEATURE_SET]?.let { FeatureSetType.valueOf(it) } ?: FeatureSetType.SIMPLIFIED + + return UiSettings( + theme = preferences[UI_THEME]?.let { ThemeType.valueOf(it) } ?: ThemeType.SYSTEM, + preferredLanguage = preferences[UI_LANGUAGE]?.ifBlank { null }, + automaticallyShowImages = preferences[UI_SHOW_IMAGES]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, + automaticallyStartPlayback = preferences[UI_START_PLAYBACK]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, + automaticallyPlayVideos = preferences[UI_PLAY_VIDEOS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, + automaticallyShowUrlPreview = preferences[UI_SHOW_URL_PREVIEW]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, + automaticallyHideNavigationBars = preferences[UI_HIDE_NAVIGATION_BARS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, + automaticallyShowProfilePictures = preferences[UI_SHOW_PROFILE_PICTURES]?.let { ConnectivityType.valueOf(it) } ?: ConnectivityType.ALWAYS, + dontShowPushNotificationSelector = preferences[UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR] ?: false, + dontAskForNotificationPermissions = preferences[UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS] ?: false, + featureSet = featureSet, + gallerySet = preferences[UI_GALLERY_SET]?.let { ProfileGalleryType.valueOf(it) } ?: ProfileGalleryType.CLASSIC, + automaticallyProposeAiImprovements = preferences[UI_PROPOSE_AI_IMPROVEMENTS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, + useTrackedBroadcasts = + preferences[UI_USE_TRACKED_BROADCASTS]?.let { BooleanType.valueOf(it) } + ?: if (featureSet == FeatureSetType.COMPLETE) BooleanType.ALWAYS else BooleanType.NEVER, + automaticallyCreateDrafts = preferences[UI_AUTOMATICALLY_CREATE_DRAFTS]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, + showHomeNewThreadsTab = preferences[UI_SHOW_HOME_NEW_THREADS_TAB] ?: true, + showHomeConversationsTab = preferences[UI_SHOW_HOME_CONVERSATIONS_TAB] ?: true, + showHomeEverythingTab = preferences[UI_SHOW_HOME_EVERYTHING_TAB] ?: false, + showProfileBadges = preferences[UI_SHOW_PROFILE_BADGES] ?: true, + showProfileAppRecommendations = preferences[UI_SHOW_PROFILE_APP_RECOMMENDATIONS] ?: true, + showProfileZapReceivedFeed = preferences[UI_SHOW_PROFILE_ZAP_RECEIVED_FEED] ?: true, + showProfileFollowersFeed = preferences[UI_SHOW_PROFILE_FOLLOWERS_FEED] ?: true, + dontShowOnchainPublicWarning = preferences[UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING] ?: false, + suggestWorkoutsFromHealthConnect = + preferences[UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT]?.let { BooleanType.valueOf(it) } ?: BooleanType.ALWAYS, + accentColor = preferences[UI_ACCENT_COLOR]?.let { AccentColorType.valueOf(it) } ?: AccentColorType.PURPLE, + fontFamily = preferences[UI_FONT_FAMILY]?.let { FontFamilyType.valueOf(it) } ?: FontFamilyType.SYSTEM, + fontSize = preferences[UI_FONT_SIZE]?.let { FontSizeType.valueOf(it) } ?: FontSizeType.NORMAL, + composeSignature = preferences[UI_COMPOSE_SIGNATURE] ?: "", + showOnchainWallet = preferences[UI_SHOW_ONCHAIN_WALLET] ?: true, + showPayToZapChip = preferences[UI_SHOW_PAYTO_ZAP_CHIP] ?: true, + ) + } + + /** + * Writes every UI setting into [this]. + * + * Shared by [save] and by the one-shot copy out of the old + * `shared_settings` blob, so the two cannot come to disagree about + * which keys a complete set of UI settings has. + */ + fun MutablePreferences.write(sharedSettings: UiSettings) { + val preferences = this + preferences[UI_THEME] = sharedSettings.theme.name + preferences[UI_LANGUAGE] = sharedSettings.preferredLanguage ?: "" + preferences[UI_SHOW_IMAGES] = sharedSettings.automaticallyShowImages.name + preferences[UI_START_PLAYBACK] = sharedSettings.automaticallyStartPlayback.name + preferences[UI_PLAY_VIDEOS] = sharedSettings.automaticallyPlayVideos.name + preferences[UI_SHOW_URL_PREVIEW] = sharedSettings.automaticallyShowUrlPreview.name + preferences[UI_HIDE_NAVIGATION_BARS] = sharedSettings.automaticallyHideNavigationBars.name + preferences[UI_SHOW_PROFILE_PICTURES] = sharedSettings.automaticallyShowProfilePictures.name + preferences[UI_DONT_SHOW_PUSH_NOTIFICATION_SELECTOR] = sharedSettings.dontShowPushNotificationSelector + preferences[UI_DONT_ASK_FOR_NOTIFICATION_PERMISSIONS] = sharedSettings.dontAskForNotificationPermissions + preferences[UI_FEATURE_SET] = sharedSettings.featureSet.name + preferences[UI_GALLERY_SET] = sharedSettings.gallerySet.name + preferences[UI_PROPOSE_AI_IMPROVEMENTS] = sharedSettings.automaticallyProposeAiImprovements.name + preferences[UI_USE_TRACKED_BROADCASTS] = sharedSettings.useTrackedBroadcasts.name + preferences[UI_AUTOMATICALLY_CREATE_DRAFTS] = sharedSettings.automaticallyCreateDrafts.name + preferences[UI_SHOW_HOME_NEW_THREADS_TAB] = sharedSettings.showHomeNewThreadsTab + preferences[UI_SHOW_HOME_CONVERSATIONS_TAB] = sharedSettings.showHomeConversationsTab + preferences[UI_SHOW_HOME_EVERYTHING_TAB] = sharedSettings.showHomeEverythingTab + preferences[UI_SHOW_PROFILE_BADGES] = sharedSettings.showProfileBadges + preferences[UI_SHOW_PROFILE_APP_RECOMMENDATIONS] = sharedSettings.showProfileAppRecommendations + preferences[UI_SHOW_PROFILE_ZAP_RECEIVED_FEED] = sharedSettings.showProfileZapReceivedFeed + preferences[UI_SHOW_PROFILE_FOLLOWERS_FEED] = sharedSettings.showProfileFollowersFeed + preferences[UI_DONT_SHOW_ONCHAIN_PUBLIC_WARNING] = sharedSettings.dontShowOnchainPublicWarning + preferences[UI_SUGGEST_WORKOUTS_FROM_HEALTH_CONNECT] = sharedSettings.suggestWorkoutsFromHealthConnect.name + preferences[UI_ACCENT_COLOR] = sharedSettings.accentColor.name + preferences[UI_FONT_FAMILY] = sharedSettings.fontFamily.name + preferences[UI_FONT_SIZE] = sharedSettings.fontSize.name + preferences[UI_COMPOSE_SIGNATURE] = sharedSettings.composeSignature + preferences[UI_SHOW_ONCHAIN_WALLET] = sharedSettings.showOnchainWallet + preferences[UI_SHOW_PAYTO_ZAP_CHIP] = sharedSettings.showPayToZapChip + } + + /** + * The one-shot copy out of the single `shared_settings` JSON blob these + * settings used to be kept as, in the global encrypted file. + * + * Guarded, and it has to be. Unlike the per-account migrations, this + * store has been the real home of these settings for a while, so most + * installs already have a populated one — and copying an old blob over + * it would undo every UI change the user has made since. [UI_THEME] is + * the test: [write] sets every key unconditionally and is the only + * writer, so its absence means this store has never been saved, which + * is exactly the install whose settings are still only in the legacy + * file. + * + * Must be handed to the store at construction, so every consumer of the + * shared file gets it no matter which one opens the file first. + */ + fun migrations(loadLegacy: suspend () -> UiSettings?): List> = + listOf( + CopyOnceMigration("migrated.sharedSettings") { out -> + if (out[UI_THEME] == null) { + withContext(Dispatchers.IO) { + loadLegacy()?.let { out.write(it) } + } + } + }, + ) + } +} diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/UiSettingsLabels.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/UiSettingsLabels.kt new file mode 100644 index 0000000000..247c0c8ebc --- /dev/null +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/UiSettingsLabels.kt @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.ui.settings + +import com.vitorpamplona.amethyst.commons.model.AccentColorType +import com.vitorpamplona.amethyst.commons.model.FontSizeType +import com.vitorpamplona.amethyst.commons.model.ProfileGalleryType +import com.vitorpamplona.amethyst.commons.model.ThemeType +import com.vitorpamplona.amethyst.commons.model.WarningType +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.accent_color_blue +import com.vitorpamplona.amethyst.commons.resources.accent_color_green +import com.vitorpamplona.amethyst.commons.resources.accent_color_orange +import com.vitorpamplona.amethyst.commons.resources.accent_color_pink +import com.vitorpamplona.amethyst.commons.resources.accent_color_purple +import com.vitorpamplona.amethyst.commons.resources.accent_color_red +import com.vitorpamplona.amethyst.commons.resources.content_warning_hide_all_sensitive_content_option +import com.vitorpamplona.amethyst.commons.resources.content_warning_see_warnings_option +import com.vitorpamplona.amethyst.commons.resources.content_warning_show_all_sensitive_content_option +import com.vitorpamplona.amethyst.commons.resources.dark +import com.vitorpamplona.amethyst.commons.resources.font_size_huge +import com.vitorpamplona.amethyst.commons.resources.font_size_large +import com.vitorpamplona.amethyst.commons.resources.font_size_normal +import com.vitorpamplona.amethyst.commons.resources.font_size_small +import com.vitorpamplona.amethyst.commons.resources.gallery_type_classic +import com.vitorpamplona.amethyst.commons.resources.gallery_type_modern +import com.vitorpamplona.amethyst.commons.resources.light +import com.vitorpamplona.amethyst.commons.resources.system +import org.jetbrains.compose.resources.StringResource + +/** + * The display label for each UI-settings enum. + * + * These used to be a constructor argument on the enums themselves, which pinned + * `UiSettings` to `commonsUI` — a [StringResource] comes from the generated `Res` + * class, and `commons` cannot see it. The settings are plain data that the CLI and + * any headless front end may read, so the data moved to `commons/model` and the + * labels stayed here, following the same extension-property shape the Tor settings + * already use (`ui.tor.resourceId`). + * + * Each `when` is exhaustive over its enum, so a new constant is a compile error + * here rather than a missing label at runtime — the same guarantee the constructor + * argument gave. + * + * Only the enums something actually labels are here. `ConnectivityType`, + * `FeatureSetType` and `FontFamilyType` carried a `resourceId` that nothing read — + * their pickers are segmented rows and use the narrower `shortLabelRes` helpers in + * `AppSettingsScreen` instead — and `BooleanType`'s was misspelled `reourceId`, + * which is how it went unnoticed. They are dropped rather than carried over; the + * strings they pointed at are still used by those short labels. + */ +val ThemeType.resourceId: StringResource + get() = + when (this) { + ThemeType.SYSTEM -> Res.string.system + ThemeType.LIGHT -> Res.string.light + ThemeType.DARK -> Res.string.dark + } + +val AccentColorType.resourceId: StringResource + get() = + when (this) { + AccentColorType.PURPLE -> Res.string.accent_color_purple + AccentColorType.BLUE -> Res.string.accent_color_blue + AccentColorType.GREEN -> Res.string.accent_color_green + AccentColorType.ORANGE -> Res.string.accent_color_orange + AccentColorType.RED -> Res.string.accent_color_red + AccentColorType.PINK -> Res.string.accent_color_pink + } + +val FontSizeType.resourceId: StringResource + get() = + when (this) { + FontSizeType.SMALL -> Res.string.font_size_small + FontSizeType.NORMAL -> Res.string.font_size_normal + FontSizeType.LARGE -> Res.string.font_size_large + FontSizeType.HUGE -> Res.string.font_size_huge + } + +val ProfileGalleryType.resourceId: StringResource + get() = + when (this) { + ProfileGalleryType.CLASSIC -> Res.string.gallery_type_classic + ProfileGalleryType.MODERN -> Res.string.gallery_type_modern + } + +val WarningType.resourceId: StringResource + get() = + when (this) { + WarningType.WARN -> Res.string.content_warning_see_warnings_option + WarningType.SHOW -> Res.string.content_warning_show_all_sensitive_content_option + WarningType.HIDE -> Res.string.content_warning_hide_all_sensitive_content_option + } From 5c4a345dd0deaed99725122f43f51c9d828694d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 13:08:05 +0000 Subject: [PATCH 21/57] refactor: move the shared_settings file off the Context delegate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last Context-bound piece of the preference layer. Eight stores share `shared_settings` — UI, Tor, Namecoin, OTS, the three Buzz stores and the drawer collapse state — and all eight reached it through `Context.preferencesDataStore`, which exists only on Android and only from a Context. They now go through AppPreferenceStores, which takes the root directory as a parameter, so the file is addressable from a desktop or CLI front end too. The paths are unchanged: AppPreferenceStores.file reproduces `filesDir/datastore/.preferences_pb`, which is exactly what the delegate resolved to, so nothing migrates and a rollback finds its data where it left it. AppPreferenceStoresTest already pins that shape. Done in one commit on purpose. DataStore keeps a process-wide registry keyed by file path and throws on a second live store for the same path, so a half-migrated state is a crash rather than a degradation — there is no safe intermediate commit here. AppPreferenceStores gains a per-file `migrations` parameter, matching AccountPreferenceStores. The shared_settings copy has to hang off the file rather than off the UI store: DataStore runs a file's migrations once, when that file is first opened, and which of the eight stores opens it first is a race. TorSharedPreferences takes a DataStore instead of a Context. It keeps its TorSettingsFlow/TorPreferencesPort dependencies in amethyst.ui.tor, so the class itself cannot move to commons yet — this is only the file provider. UISharedPreferences.kt is renamed UiSharedPreferences.kt: with the delegate gone the file holds a single class, and ktlint's filename rule wants the match. Tests: UiSettingsStoreTest covers the defaults an untouched install reads (several are `true`, and reading `false` would turn those features off for everyone who never opened Settings), the round trip, the blank-language to null mapping, and the migration guard. The guard is driven against the DataMigration directly rather than through two DataStores over one file, because that second store is the crash above rather than a test. Two things the tests pinned down that were easy to get wrong: reading an empty store is not the same as constructing UiSettings(), because useTrackedBroadcasts follows the feature set and an unset feature set reads SIMPLIFIED, which means NEVER while the data class default says ALWAYS. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 57 ++++- .../model/preferences/TorSharedPreferences.kt | 27 +-- ...dPreferences.kt => UiSharedPreferences.kt} | 22 +- .../model/preferences/AppPreferenceStores.kt | 10 + .../model/preferences/UiSettingsStoreTest.kt | 207 ++++++++++++++++++ 5 files changed, 279 insertions(+), 44 deletions(-) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/{UISharedPreferences.kt => UiSharedPreferences.kt} (89%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStoreTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 781ac1b91d..cef5a1c1d0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -33,12 +33,14 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.BitcoinExplorerEndpoint import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.IncomingOtsEventVerifier import com.vitorpamplona.amethyst.commons.model.nip03Timestamp.TorAwareOkHttpOtsResolverBuilder +import com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores import com.vitorpamplona.amethyst.commons.model.preferences.BuzzAttestationStore import com.vitorpamplona.amethyst.commons.model.preferences.BuzzChannelStarStore import com.vitorpamplona.amethyst.commons.model.preferences.BuzzWorkspaceStore import com.vitorpamplona.amethyst.commons.model.preferences.NamecoinSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.OtsSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.RelayGroupDeletionStore +import com.vitorpamplona.amethyst.commons.model.preferences.UiSettingsStore import com.vitorpamplona.amethyst.commons.napplet.permissions.NappletPermissionLedger import com.vitorpamplona.amethyst.commons.relayClient.BlockedRelayFilteringClient import com.vitorpamplona.amethyst.commons.relayClient.diagnostics.BootRelayDiagnostics @@ -71,7 +73,6 @@ import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.model.preferences.DrawerSectionCollapsePreferences import com.vitorpamplona.amethyst.model.preferences.TorSharedPreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences -import com.vitorpamplona.amethyst.model.preferences.sharedPreferencesDataStore import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.model.torState.AccountsTorStateConnector import com.vitorpamplona.amethyst.model.torState.TorRelayState @@ -198,6 +199,7 @@ import kotlinx.coroutines.flow.transform import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import okio.Path.Companion.toOkioPath import java.io.File class AppModules( @@ -229,19 +231,50 @@ class AppModules( private val _trimLevelEvents = MutableSharedFlow(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) val trimLevelEvents = _trimLevelEvents.asSharedFlow() + /** + * The app-wide DataStore files — the ones that belong to the install rather + * than to an account. [AccountPreferenceStores] is the same idea keyed by + * npub. + * + * This replaces the `Context.preferencesDataStore` delegate these stores + * used to share. Same paths — `AppPreferenceStores.file` reproduces + * `filesDir/datastore/.preferences_pb` exactly — so nothing migrates + * and a rollback finds its data where it left it. What it buys is that the + * stores themselves live in `commonMain`, where a desktop or CLI front end + * can say where its data lives instead of needing a `Context`. + * + * The shared_settings migration is attached here, to the file, because + * eight stores share it and DataStore runs a file's migrations once, on + * whichever store opens it first. + */ + val appStores by lazy { + AppPreferenceStores( + rootFilesDir = { appContext.filesDir.toOkioPath() }, + migrations = { name -> + when (name) { + AppPreferenceStores.SHARED_SETTINGS -> UiSettingsStore.migrations { LocalPreferences.loadSharedSettings() } + else -> emptyList() + } + }, + ) + } + + /** The file UI, Tor, Namecoin, OTS and the Buzz stores all share. */ + val sharedSettingsStore get() = appStores.sharedSettings() + // Pre-load both preference DataStores in parallel on IO threads. // Both constructors use runBlocking internally, so starting them concurrently // reduces total blocking time from (torPrefs + uiPrefs) to ~max(torPrefs, uiPrefs). private val uiPrefsDeferred = applicationIOScope.async { - val prefs = UiSharedPreferences.uiPreferences(appContext) ?: UiSettings() - UiSharedPreferences(prefs, appContext, applicationIOScope) + val prefs = UiSharedPreferences.uiPreferences(sharedSettingsStore) ?: UiSettings() + UiSharedPreferences(prefs, sharedSettingsStore, appContext, applicationIOScope) } private val torPrefsDeferred = applicationIOScope.async { - val prefs = TorSharedPreferences.torPreferences(appContext) ?: TorSettings() - TorSharedPreferences(prefs, appContext, applicationIOScope) + val prefs = TorSharedPreferences.torPreferences(sharedSettingsStore) ?: TorSettings() + TorSharedPreferences(prefs, sharedSettingsStore, applicationIOScope) } // Blocking load of UI Preferences to avoid theme/language blinking @@ -259,7 +292,7 @@ class AppModules( // Namecoin ElectrumX server preferences (global, like Tor settings) val namecoinPrefs by lazy { Log.d("AppModules", "NamecoinSettingsStore Init") - NamecoinSettingsStore(appContext.sharedPreferencesDataStore, applicationIOScope) + NamecoinSettingsStore(sharedSettingsStore, applicationIOScope) } // OTS blockchain explorer preferences (global, like Tor settings) @@ -270,7 +303,7 @@ class AppModules( // in commonMain, which has no runBlocking to hide it behind. val otsPrefs by lazy { Log.d("AppModules", "OtsSettingsStore Init") - val store = appContext.sharedPreferencesDataStore + val store = sharedSettingsStore OtsSettingsStore(store, runBlocking { OtsSettingsStore.load(store) }) } @@ -315,12 +348,12 @@ class AppModules( // deleted channel stays hidden across a restart even if the host relay re-announces a stale // kind-44100 for it (device-global; a delete is authoritative and terminal for everyone). val relayGroupDeletionPrefs = - RelayGroupDeletionStore(appContext.sharedPreferencesDataStore, applicationIOScope) + RelayGroupDeletionStore(sharedSettingsStore, applicationIOScope) // Restore + persist which drawer section headings the user has folded away, so the side menu // opens the way they left it (device-global: a collapsed heading is a per-device view choice, // not an account setting worth syncing, unlike the hidden rows beside it in the drawer). - val drawerSectionCollapsePrefs = DrawerSectionCollapsePreferences(appContext.sharedPreferencesDataStore, applicationIOScope) + val drawerSectionCollapsePrefs = DrawerSectionCollapsePreferences(sharedSettingsStore, applicationIOScope) // Service that will run at all times to receive events from Pokey val pokeyReceiver = PokeyReceiver() @@ -976,11 +1009,11 @@ class AppModules( // start — Buzz membership is server-side) and the starred channels. Per account: the // joined set makes a relay first-party for NIP-42, and a star is personal. startBuzzPersistence = { account -> - BuzzWorkspaceStore(appContext.sharedPreferencesDataStore, account.scope, account.pubKey, account.buzzWorkspaces) - BuzzChannelStarStore(appContext.sharedPreferencesDataStore, account.scope, account.pubKey, account.buzzChannelStars) + BuzzWorkspaceStore(sharedSettingsStore, account.scope, account.pubKey, account.buzzWorkspaces) + BuzzChannelStarStore(sharedSettingsStore, account.scope, account.pubKey, account.buzzChannelStars) // Eager like the rest, so a held NIP-OA attestation is loaded before this account's // first Buzz-relay AUTH rather than after it. - BuzzAttestationStore(appContext.sharedPreferencesDataStore, account.scope, account.pubKey, account.buzzAttestation) + BuzzAttestationStore(sharedSettingsStore, account.scope, account.pubKey, account.buzzAttestation) }, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt index 900cc3e78f..5c4b054edd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt @@ -20,8 +20,9 @@ */ package com.vitorpamplona.amethyst.model.preferences -import android.content.Context import androidx.compose.runtime.Stable +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.intPreferencesKey @@ -48,7 +49,7 @@ import kotlin.coroutines.cancellation.CancellationException @Stable class TorSharedPreferences( prefs: TorSettings, - val context: Context, + val store: DataStore, val scope: CoroutineScope, ) : TorPreferencesPort { // Tor Preferences. Makes sure to wait for it to avoid connecting with random IPs @@ -63,7 +64,7 @@ class TorSharedPreferences( .debounce(1000) .distinctUntilChanged() .onEach { - save(it, context) + save(it, store) }.flowOn(Dispatchers.IO) .stateIn( scope, @@ -71,9 +72,9 @@ class TorSharedPreferences( value.toSettings(), ) - override suspend fun loadLastBypassApprovalMs(): Long = TorSharedPreferences.loadLastBypassApprovalMs(context) + override suspend fun loadLastBypassApprovalMs(): Long = TorSharedPreferences.loadLastBypassApprovalMs(store) - override suspend fun saveLastBypassApprovalMs(value: Long) = TorSharedPreferences.saveLastBypassApprovalMs(value, context) + override suspend fun saveLastBypassApprovalMs(value: Long) = TorSharedPreferences.saveLastBypassApprovalMs(value, store) companion object { // loads faster when individualized @@ -92,10 +93,10 @@ class TorSharedPreferences( val NIP05_VERIFICATIONS_VIA_TOR_KEY = booleanPreferencesKey("tor.nip05VerificationsViaTor") val MEDIA_UPLOADS_VIA_TOR_KEY = booleanPreferencesKey("tor.mediaUploadsViaTor") - suspend fun torPreferences(context: Context): TorSettings? = + suspend fun torPreferences(store: DataStore): TorSettings? = try { // Get the preference flow and take the first value. - val preferences = context.sharedPreferencesDataStore.data.first() + val preferences = store.data.first() TorSettings( torType = preferences[TOR_TYPE_KEY]?.let { TorType.valueOf(it) } ?: TorType.INTERNAL, externalSocksPort = preferences[EXTERNAL_SOCKS_PORT_KEY] ?: 9050, @@ -120,10 +121,10 @@ class TorSharedPreferences( suspend fun save( torSettings: TorSettings, - context: Context, + store: DataStore, ) { try { - context.sharedPreferencesDataStore.edit { preferences -> + store.edit { preferences -> preferences[TOR_TYPE_KEY] = torSettings.torType.name preferences[EXTERNAL_SOCKS_PORT_KEY] = torSettings.externalSocksPort preferences[ONION_RELAYS_VIA_TOR_KEY] = torSettings.onionRelaysViaTor @@ -145,9 +146,9 @@ class TorSharedPreferences( } } - suspend fun loadLastBypassApprovalMs(context: Context): Long = + suspend fun loadLastBypassApprovalMs(store: DataStore): Long = try { - context.sharedPreferencesDataStore.data.first()[LAST_BYPASS_APPROVAL_MS_KEY] ?: 0L + store.data.first()[LAST_BYPASS_APPROVAL_MS_KEY] ?: 0L } catch (e: Exception) { if (e is CancellationException) throw e Log.e("SharedPreferences") { "Error reading lastBypassApprovalMs: ${e.message}" } @@ -156,10 +157,10 @@ class TorSharedPreferences( suspend fun saveLastBypassApprovalMs( value: Long, - context: Context, + store: DataStore, ) { try { - context.sharedPreferencesDataStore.edit { prefs -> + store.edit { prefs -> prefs[LAST_BYPASS_APPROVAL_MS_KEY] = value } } catch (e: Exception) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UiSharedPreferences.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UiSharedPreferences.kt index fe4df20db7..273445a3fb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UISharedPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/UiSharedPreferences.kt @@ -29,8 +29,6 @@ import androidx.core.content.getSystemService import androidx.core.os.LocaleListCompat import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences -import androidx.datastore.preferences.preferencesDataStore -import com.vitorpamplona.amethyst.LocalPreferences import com.vitorpamplona.amethyst.commons.model.ThemeType import com.vitorpamplona.amethyst.commons.model.UiSettings import com.vitorpamplona.amethyst.commons.model.UiSettingsFlow @@ -48,21 +46,6 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.withContext import kotlin.coroutines.cancellation.CancellationException -/** - * The file UI, Tor, Namecoin, OTS and the Buzz stores all share, each under its - * own key prefix. - * - * The migration is attached here, at the file, rather than inside - * [UiSettingsStore]: whichever of those stores is constructed first is the one - * that opens the file, and DataStore runs a file's migrations once, on that - * first open. Hanging it off the UI store alone would make the copy depend on - * load order. - */ -val Context.sharedPreferencesDataStore: DataStore by preferencesDataStore( - name = "shared_settings", - produceMigrations = { UiSettingsStore.migrations { LocalPreferences.loadSharedSettings() } }, -) - /** * The Android half of the UI settings: the flows the app observes, and the two * platform side effects that a theme or language change has to perform. @@ -74,10 +57,11 @@ val Context.sharedPreferencesDataStore: DataStore by preferencesDat @Stable class UiSharedPreferences( prefs: UiSettings, + dataStore: DataStore, val context: Context, val scope: CoroutineScope, ) { - private val store = UiSettingsStore(context.sharedPreferencesDataStore) { LocalPreferences.loadSharedSettings() } + private val store = UiSettingsStore(dataStore) // UI Preferences. Makes sure to wait for it to avoid blinking themes and language preferences val value = UiSettingsFlow.build(prefs) @@ -197,6 +181,6 @@ class UiSharedPreferences( ) companion object { - suspend fun uiPreferences(context: Context): UiSettings? = UiSettingsStore(context.sharedPreferencesDataStore) { LocalPreferences.loadSharedSettings() }.load() + suspend fun uiPreferences(dataStore: DataStore): UiSettings? = UiSettingsStore(dataStore).load() } } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt index c1f7bd5c5b..a49447d3cb 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.commons.model.preferences +import androidx.datastore.core.DataMigration import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences @@ -54,9 +55,17 @@ import okio.Path * holder opens the file it was already using, so nothing has to be migrated * and a rollback finds its data where it left it. Changing [file]'s shape * would silently orphan every existing install's settings. + * + * @param migrations the migrations to attach to a file, by name. Taken here + * rather than at [getDataStore] because DataStore runs a file's migrations + * once, when that file is first opened — and several stores share + * [SHARED_SETTINGS], so which one opens it is a race. Wiring the migrations + * to the file rather than to a caller is what makes the copy happen no + * matter who wins. */ class AppPreferenceStores( val rootFilesDir: () -> Path, + private val migrations: (String) -> List> = { emptyList() }, ) { companion object { /** @@ -96,6 +105,7 @@ class AppPreferenceStores( scope, PreferenceDataStoreFactory.createWithPath( scope = scope, + migrations = migrations(name), produceFile = { file(name) }, ), ) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStoreTest.kt new file mode 100644 index 0000000000..efefb1eecb --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/UiSettingsStoreTest.kt @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.mutablePreferencesOf +import com.vitorpamplona.amethyst.commons.model.AccentColorType +import com.vitorpamplona.amethyst.commons.model.BooleanType +import com.vitorpamplona.amethyst.commons.model.ConnectivityType +import com.vitorpamplona.amethyst.commons.model.FeatureSetType +import com.vitorpamplona.amethyst.commons.model.FontSizeType +import com.vitorpamplona.amethyst.commons.model.ThemeType +import com.vitorpamplona.amethyst.commons.model.UiSettings +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class UiSettingsStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private fun stores(migrations: (String) -> List> = { emptyList() }) = AppPreferenceStores(rootFilesDir = { folder.root.toOkioPath() }, migrations = migrations) + + private fun rawStore(name: String): DataStore = + PreferenceDataStoreFactory.createWithPath( + produceFile = { folder.root.toOkioPath() / "$name.preferences_pb" }, + ) + + /** + * An account that never opened Settings has no stored value for anything, + * so every default here is what that install gets forever. Several of them + * are `true` — reading `false` would quietly turn those features off for + * everyone who never touched them. + */ + @Test + fun anEmptyStoreReadsTheSameDefaultsSharedPreferencesDid() = + runTest { + val settings = UiSettingsStore(rawStore("empty")).load()!! + + assertEquals(ThemeType.SYSTEM, settings.theme) + assertNull(settings.preferredLanguage) + assertEquals(ConnectivityType.ALWAYS, settings.automaticallyShowImages) + assertEquals(FeatureSetType.SIMPLIFIED, settings.featureSet) + assertEquals(AccentColorType.PURPLE, settings.accentColor) + assertEquals(FontSizeType.NORMAL, settings.fontSize) + assertEquals("", settings.composeSignature) + + // Not a constant, and not the data class default either: UiSettings() + // says ALWAYS, but a store with no feature set reads SIMPLIFIED, and + // SIMPLIFIED means NEVER. Reading an empty store is therefore not the + // same as constructing UiSettings() — pinned here because the two look + // interchangeable at a call site. + assertEquals(BooleanType.NEVER, settings.useTrackedBroadcasts) + + // the ones that default on + assertTrue(settings.showHomeNewThreadsTab) + assertTrue(settings.showHomeConversationsTab) + assertTrue(settings.showProfileBadges) + assertTrue(settings.showProfileAppRecommendations) + assertTrue(settings.showProfileZapReceivedFeed) + assertTrue(settings.showProfileFollowersFeed) + assertTrue(settings.showOnchainWallet) + assertTrue(settings.showPayToZapChip) + + // and the ones that default off + assertFalse(settings.showHomeEverythingTab) + assertFalse(settings.dontShowPushNotificationSelector) + assertFalse(settings.dontAskForNotificationPermissions) + assertFalse(settings.dontShowOnchainPublicWarning) + } + + /** + * `useTrackedBroadcasts` is the one default that is not a constant: it + * follows the feature set when it has never been set explicitly, and an + * explicit value wins over that. + */ + @Test + fun trackedBroadcastsFollowsTheFeatureSetUntilItIsSetExplicitly() = + runTest { + val complete = rawStore("complete") + complete.edit { it[UiSettingsStore.UI_FEATURE_SET] = FeatureSetType.COMPLETE.name } + assertEquals(BooleanType.ALWAYS, UiSettingsStore(complete).load()!!.useTrackedBroadcasts) + + val simplified = rawStore("simplified") + simplified.edit { it[UiSettingsStore.UI_FEATURE_SET] = FeatureSetType.SIMPLIFIED.name } + assertEquals(BooleanType.NEVER, UiSettingsStore(simplified).load()!!.useTrackedBroadcasts) + + val explicit = rawStore("explicit") + explicit.edit { + it[UiSettingsStore.UI_FEATURE_SET] = FeatureSetType.SIMPLIFIED.name + it[UiSettingsStore.UI_USE_TRACKED_BROADCASTS] = BooleanType.ALWAYS.name + } + assertEquals(BooleanType.ALWAYS, UiSettingsStore(explicit).load()!!.useTrackedBroadcasts) + } + + @Test + fun everySettingSurvivesARoundTrip() = + runTest { + val store = UiSettingsStore(rawStore("roundtrip")) + val settings = + UiSettings( + theme = ThemeType.DARK, + preferredLanguage = "pt-BR", + automaticallyShowImages = ConnectivityType.WIFI_ONLY, + automaticallyPlayVideos = BooleanType.NEVER, + featureSet = FeatureSetType.COMPLETE, + accentColor = AccentColorType.GREEN, + fontSize = FontSizeType.HUGE, + composeSignature = "— sent from Amethyst", + showHomeEverythingTab = true, + showProfileBadges = false, + showOnchainWallet = false, + showPayToZapChip = false, + ) + + store.save(settings) + + assertEquals(settings, store.load()) + } + + /** + * A blank language is stored as "" (the key is written unconditionally) and + * has to read back as null, or "no preference" turns into a locale tag the + * `LocaleListCompat` call cannot parse. + */ + @Test + fun aBlankLanguageReadsBackAsNoPreference() = + runTest { + val store = UiSettingsStore(rawStore("blank")) + store.save(UiSettings(preferredLanguage = null)) + + assertNull(store.load()!!.preferredLanguage) + } + + /** + * The copy out of the old blob must not run on an install that already has + * these settings here — that would undo every change made since this store + * took over. `ui.theme` is the test, because [UiSettingsStore.write] sets + * every key and is the only writer. + * + * Driven against the [androidx.datastore.core.DataMigration] directly rather + * than through two DataStores over one file: DataStore keeps a process-wide + * registry keyed by path and refuses the second one, so "reopen it and look" + * is a crash, not a test. + */ + @Test + fun theLegacyCopyRunsOnlyWhenTheStoreHasNeverBeenSaved() = + runTest { + val legacy = UiSettings(theme = ThemeType.LIGHT, composeSignature = "from the old blob") + val migration = UiSettingsStore.migrations { legacy }.single() + + // A store nothing has written: the copy lands. + val fresh = emptyPreferences() + assertTrue(migration.shouldMigrate(fresh)) + assertEquals(legacy, UiSettingsStore.read(migration.migrate(fresh))) + + // A store this app has already saved to: the copy must leave it alone. + val mine = UiSettings(theme = ThemeType.DARK, composeSignature = "mine") + val used = mutablePreferencesOf().apply { with(UiSettingsStore) { write(mine) } }.toPreferences() + + val after = migration.migrate(used) + assertEquals(mine, UiSettingsStore.read(after)) + + // ...and having run once, it never runs again. + assertFalse(migration.shouldMigrate(after)) + } + + /** No legacy reader (desktop, CLI) is not an error — it just means no copy. */ + @Test + fun aFrontEndWithoutALegacyFileGetsDefaults() = + runTest { + val subject = stores { UiSettingsStore.migrations { null } } + + assertEquals( + UiSettings(useTrackedBroadcasts = BooleanType.NEVER), + UiSettingsStore(subject.sharedSettings()).load(), + ) + } +} From 14aa3334066b7f3ec56b47600b7f75ff78636852 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 13:35:59 +0000 Subject: [PATCH 22/57] refactor: move the Tor settings store and flow into commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same split as the UI settings, and most of it was already done: the Tor model (TorSettings, TorType, TorPresetType, the presets) has lived in commons/tor for a while, with the StringResource labels left behind in amethyst. What was still Android-only was everything around it. - commons/tor: TorSettingsFlow and TorPreferencesPort, both of which only ever needed kotlinx flows and the commons model. The port moves because the store that satisfies it is now shared, and a desktop or CLI manager needs the same slice. - commons/model/preferences/TorSettingsStore: the former TorSharedPreferences, renamed now that it is neither Android-specific nor SharedPreferences. It already took a DataStore rather than a Context after the shared_settings move, so nothing about its persistence changed. - commonsUI/ui/settings/TorSettingsLabels: TorType.resourceId, TorPresetType.resourceId and .explainerId, beside the UI settings labels. This empties amethyst/ui/tor/TorSettings.kt, which was by then a file of re-export comments and a `private const val RE_EXPORTS = 0` placeholder, so it goes. amethyst keeps the genuinely platform-bound half: TorService, ArtiNative, TorBackend, the manager and the dialogs. Tests: TorSettingsStoreTest pins the defaults an untouched install reads (onion, DM and new relays on; everything else off), the round trip, the key names, and that the bypass-approval timestamp survives a settings save — it is dialog bookkeeping rather than a user setting, so it has its own key and must not be cleared by one. It also pins that an unreadable torType makes the whole read return null rather than throw, which the caller turns into defaults. That is existing behaviour, not new, but it means one bad enum value costs every Tor setting rather than one, and it was worth writing down. amethyst's TorSettingsTest is deleted: it was 305 lines testing commons functions from the Android module, duplicating commons/tor/TorSettingsTest. The six cases it had that the commons copy lacked (preset monotonicity, whichPreset ignoring torType/port, equality for distinctUntilChanged) are ported across, so coverage goes up while 34 tests move off the Android job onto the multiplatform one. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 8 +- .../RoleBasedHttpClientBuilder.kt | 2 +- .../amethyst/model/torState/TorRelayState.kt | 2 +- .../ui/screen/loggedIn/AccountViewModel.kt | 2 +- .../loggedIn/privacy/PrivacyOptionsScreen.kt | 8 +- .../loggedIn/settings/OtsSettingsScreen.kt | 2 +- .../ui/screen/loggedOff/TorSettingsSetup.kt | 2 +- .../ui/screen/loggedOff/login/LoginScreen.kt | 2 +- .../screen/loggedOff/login/LoginViewModel.kt | 2 +- .../screen/loggedOff/signup/SignUpScreen.kt | 2 +- .../loggedOff/signup/SignUpViewModel.kt | 2 +- .../amethyst/ui/tor/TorManager.kt | 1 + .../amethyst/ui/tor/TorSettingsDialog.kt | 2 + .../amethyst/ui/tor/TorManagerTest.kt | 1 + .../amethyst/ui/tor/TorSettingsTest.kt | 305 ------------------ .../model/preferences/TorSettingsStore.kt | 21 +- .../commons}/tor/TorPreferencesPort.kt | 12 +- .../amethyst/commons}/tor/TorSettingsFlow.kt | 4 +- .../amethyst/commons/tor/TorSettingsTest.kt | 56 ++++ .../model/preferences/TorSettingsStoreTest.kt | 156 +++++++++ .../commons/ui/settings/TorSettingsLabels.kt | 18 +- 21 files changed, 262 insertions(+), 348 deletions(-) delete mode 100644 amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsTest.kt rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStore.kt (92%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/ui => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/tor/TorPreferencesPort.kt (75%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/ui => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/tor/TorSettingsFlow.kt (97%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStoreTest.kt rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/TorSettingsLabels.kt (88%) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index cef5a1c1d0..6c3fde8ac3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -40,6 +40,7 @@ import com.vitorpamplona.amethyst.commons.model.preferences.BuzzWorkspaceStore import com.vitorpamplona.amethyst.commons.model.preferences.NamecoinSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.OtsSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.RelayGroupDeletionStore +import com.vitorpamplona.amethyst.commons.model.preferences.TorSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.UiSettingsStore import com.vitorpamplona.amethyst.commons.napplet.permissions.NappletPermissionLedger import com.vitorpamplona.amethyst.commons.relayClient.BlockedRelayFilteringClient @@ -71,7 +72,6 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.model.preferences.DrawerSectionCollapsePreferences -import com.vitorpamplona.amethyst.model.preferences.TorSharedPreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.model.torState.AccountsTorStateConnector @@ -273,8 +273,8 @@ class AppModules( private val torPrefsDeferred = applicationIOScope.async { - val prefs = TorSharedPreferences.torPreferences(sharedSettingsStore) ?: TorSettings() - TorSharedPreferences(prefs, sharedSettingsStore, applicationIOScope) + val prefs = TorSettingsStore.torPreferences(sharedSettingsStore) ?: TorSettings() + TorSettingsStore(prefs, sharedSettingsStore, applicationIOScope) } // Blocking load of UI Preferences to avoid theme/language blinking @@ -285,7 +285,7 @@ class AppModules( // Blocking load of Tor Settings to avoid connection leaks val torPrefs by lazy { - Log.d("AppModules", "TorSharedPreferences Init") + Log.d("AppModules", "TorSettingsStore Init") runBlocking { torPrefsDeferred.await() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/privacyOptions/RoleBasedHttpClientBuilder.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/privacyOptions/RoleBasedHttpClientBuilder.kt index e2cdd4c805..278443ed5e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/privacyOptions/RoleBasedHttpClientBuilder.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/privacyOptions/RoleBasedHttpClientBuilder.kt @@ -23,10 +23,10 @@ package com.vitorpamplona.amethyst.model.privacyOptions import com.vitorpamplona.amethyst.commons.service.http.DualHttpClientManager import com.vitorpamplona.amethyst.commons.service.http.IRoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.commons.service.http.ProxiedSocketFactory +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.amethyst.service.resourceusage.HttpUsageMeter import com.vitorpamplona.amethyst.service.resourceusage.UsageKeys -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import okhttp3.OkHttpClient import java.net.InetSocketAddress diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt index b2d4c32286..589fe2ebf7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt @@ -25,8 +25,8 @@ import com.vitorpamplona.amethyst.commons.service.http.DualHttpClientManager import com.vitorpamplona.amethyst.commons.tor.RelayClassification import com.vitorpamplona.amethyst.commons.tor.TorRelayEvaluation import com.vitorpamplona.amethyst.commons.tor.TorRelaySettings +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.tor.TorType -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers 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 23ac016ee0..34f8d28ea3 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 @@ -102,6 +102,7 @@ import com.vitorpamplona.amethyst.commons.service.broadcast.BroadcastTracker import com.vitorpamplona.amethyst.commons.service.http.EmptyRoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.commons.service.http.IRoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.commons.service.pow.PoWCategory +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.amethyst.commons.ui.components.UrlPreviewState import com.vitorpamplona.amethyst.commons.ui.loadStringRes @@ -143,7 +144,6 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.CombinedZap import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.NOTIFICATION_LAST_READ_KEY import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.eventsync.EventSync import com.vitorpamplona.amethyst.ui.screen.loggedIn.wallet.ReloadMintRequest -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import com.vitorpamplona.quartz.experimental.clink.debits.DebitResponse import com.vitorpamplona.quartz.experimental.clink.pointers.NDebit import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt index da8585ea2e..8b580ee3d3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt @@ -89,6 +89,7 @@ import com.vitorpamplona.amethyst.commons.resources.tor_use_videos_explainer import com.vitorpamplona.amethyst.commons.resources.use_internal_tor import com.vitorpamplona.amethyst.commons.resources.use_internal_tor_explainer import com.vitorpamplona.amethyst.commons.tor.TorPresetType +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.amethyst.commons.tor.torDefaultPreset import com.vitorpamplona.amethyst.commons.tor.torFullyPrivate @@ -100,6 +101,8 @@ import com.vitorpamplona.amethyst.commons.ui.components.TitleExplainer import com.vitorpamplona.amethyst.commons.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton +import com.vitorpamplona.amethyst.commons.ui.settings.explainerId +import com.vitorpamplona.amethyst.commons.ui.settings.resourceId import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SegmentedChoiceTile @@ -109,9 +112,6 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsDivider import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsSection import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsSwitchTile import com.vitorpamplona.amethyst.ui.stringRes -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow -import com.vitorpamplona.amethyst.ui.tor.explainerId -import com.vitorpamplona.amethyst.ui.tor.resourceId import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.MutableStateFlow import org.jetbrains.compose.resources.StringResource @@ -136,7 +136,7 @@ fun PrivacyOptionsScreen( } // Every control writes straight to [TorSettingsFlow] via `tryEmit`; a debounced collector in -// TorSharedPreferences persists the change automatically, so this screen has no Save/Cancel — the +// TorSettingsStore persists the change automatically, so this screen has no Save/Cancel — the // back arrow is the only chrome and the state is already saved by the time the user leaves. @Composable fun PrivacyOptionsContent( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt index 97ee6ae701..3b452871b4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/OtsSettingsScreen.kt @@ -37,11 +37,11 @@ import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.preferences.OtsSettingsStore import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.ots_explorer_settings +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/TorSettingsSetup.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/TorSettingsSetup.kt index a455d3881d..aab022ad56 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/TorSettingsSetup.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/TorSettingsSetup.kt @@ -34,10 +34,10 @@ import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.connect_via_tor1 import com.vitorpamplona.amethyst.commons.resources.connect_via_tor2 +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.ui.components.appendLink import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.ui.tor.ConnectTorDialog -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow @Composable fun TorSettingsSetup( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt index 79f0338488..24ecb4cd05 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginScreen.kt @@ -79,6 +79,7 @@ import com.vitorpamplona.amethyst.commons.resources.hide_password import com.vitorpamplona.amethyst.commons.resources.ncryptsec_password import com.vitorpamplona.amethyst.commons.resources.show_password import com.vitorpamplona.amethyst.commons.resources.temporary_account +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.Size10dp import com.vitorpamplona.amethyst.commons.ui.theme.Size20dp @@ -89,7 +90,6 @@ import com.vitorpamplona.amethyst.ui.insets.imePaddingSafe import com.vitorpamplona.amethyst.ui.screen.AccountSessionManager import com.vitorpamplona.amethyst.ui.screen.loggedOff.TorSettingsSetup import com.vitorpamplona.amethyst.ui.screen.loggedOff.legal.TermsGate -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import com.vitorpamplona.quartz.nip55AndroidSigner.client.isExternalSignerInstalled import kotlinx.coroutines.delay import kotlinx.coroutines.launch diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginViewModel.kt index 5b3af89c9a..38e6c7ea99 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/login/LoginViewModel.kt @@ -36,8 +36,8 @@ import com.vitorpamplona.amethyst.commons.resources.login_bunker_not_supported import com.vitorpamplona.amethyst.commons.resources.login_nostrconnect_not_supported import com.vitorpamplona.amethyst.commons.resources.password_is_required import com.vitorpamplona.amethyst.commons.resources.sign_request_rejected_description +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.ui.screen.AccountSessionManager -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow @Stable class LoginViewModel : ViewModel() { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt index b579310fd6..86bcbb03aa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpScreen.kt @@ -59,6 +59,7 @@ import com.vitorpamplona.amethyst.commons.resources.app_logo import com.vitorpamplona.amethyst.commons.resources.how_should_we_call_you import com.vitorpamplona.amethyst.commons.resources.my_awesome_name import com.vitorpamplona.amethyst.commons.resources.welcome +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.Size10dp import com.vitorpamplona.amethyst.commons.ui.theme.Size20dp @@ -70,7 +71,6 @@ import com.vitorpamplona.amethyst.ui.screen.AccountSessionManager import com.vitorpamplona.amethyst.ui.screen.loggedOff.TorSettingsSetup import com.vitorpamplona.amethyst.ui.screen.loggedOff.legal.TermsGate import com.vitorpamplona.amethyst.ui.screen.loggedOff.login.LoginErrorManager -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import kotlinx.coroutines.launch @Preview(device = "spec:width=2160px,height=2340px,dpi=440") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpViewModel.kt index c076422ea3..42307cb17b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedOff/signup/SignUpViewModel.kt @@ -29,9 +29,9 @@ import androidx.lifecycle.ViewModel import com.vitorpamplona.amethyst.BuildConfig import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.name_is_required +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.ui.screen.AccountSessionManager import com.vitorpamplona.amethyst.ui.screen.loggedOff.login.LoginErrorManager -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow @Stable class SignUpViewModel : ViewModel() { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt index fd6449d309..a0b41a4aca 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorManager.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.ui.tor +import com.vitorpamplona.amethyst.commons.tor.TorPreferencesPort import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineDispatcher diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt index 8214177c36..f3ccdd3c6f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt @@ -84,6 +84,8 @@ import com.vitorpamplona.amethyst.commons.tor.parseTorPresetType import com.vitorpamplona.amethyst.commons.tor.parseTorType import com.vitorpamplona.amethyst.commons.ui.components.TitleExplainer import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.SavingTopBar +import com.vitorpamplona.amethyst.commons.ui.settings.explainerId +import com.vitorpamplona.amethyst.commons.ui.settings.resourceId import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.Size10dp import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorManagerTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorManagerTest.kt index a6ea38384c..5b472c33fe 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorManagerTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorManagerTest.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.ui.tor +import com.vitorpamplona.amethyst.commons.tor.TorPreferencesPort import com.vitorpamplona.amethyst.commons.tor.TorType import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.awaitCancellation diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsTest.kt deleted file mode 100644 index d7361f9602..0000000000 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsTest.kt +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.tor - -import com.vitorpamplona.amethyst.commons.tor.TorPresetType -import com.vitorpamplona.amethyst.commons.tor.TorSettings -import com.vitorpamplona.amethyst.commons.tor.TorType -import com.vitorpamplona.amethyst.commons.tor.isPreset -import com.vitorpamplona.amethyst.commons.tor.parseTorPresetType -import com.vitorpamplona.amethyst.commons.tor.parseTorType -import com.vitorpamplona.amethyst.commons.tor.torDefaultPreset -import com.vitorpamplona.amethyst.commons.tor.torFullyPrivate -import com.vitorpamplona.amethyst.commons.tor.torOnlyWhenNeededPreset -import com.vitorpamplona.amethyst.commons.tor.torSmallPayloadsPreset -import com.vitorpamplona.amethyst.commons.tor.whichPreset -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -class TorSettingsTest { - // --- parseTorType --- - - @Test - fun parseTorType_code0_returnsOff() { - assertEquals(TorType.OFF, parseTorType(0)) - } - - @Test - fun parseTorType_code1_returnsInternal() { - assertEquals(TorType.INTERNAL, parseTorType(1)) - } - - @Test - fun parseTorType_code2_returnsExternal() { - assertEquals(TorType.EXTERNAL, parseTorType(2)) - } - - @Test - fun parseTorType_null_defaultsToInternal() { - assertEquals(TorType.INTERNAL, parseTorType(null)) - } - - @Test - fun parseTorType_unknownCode_defaultsToInternal() { - assertEquals(TorType.INTERNAL, parseTorType(99)) - } - - @Test - fun parseTorType_negativeCode_defaultsToInternal() { - assertEquals(TorType.INTERNAL, parseTorType(-1)) - } - - // --- TorType screenCode consistency --- - - @Test - fun torType_screenCodes_areUnique() { - val codes = TorType.entries.map { it.screenCode } - assertEquals(codes.size, codes.toSet().size) - } - - @Test - fun torType_allValues_roundTripViaParse() { - TorType.entries.forEach { type -> - assertEquals(type, parseTorType(type.screenCode)) - } - } - - // --- parseTorPresetType --- - - @Test - fun parseTorPresetType_code0_returnsOnlyWhenNeeded() { - assertEquals(TorPresetType.ONLY_WHEN_NEEDED, parseTorPresetType(0)) - } - - @Test - fun parseTorPresetType_code1_returnsDefault() { - assertEquals(TorPresetType.DEFAULT, parseTorPresetType(1)) - } - - @Test - fun parseTorPresetType_code2_returnsSmallPayloads() { - assertEquals(TorPresetType.SMALL_PAYLOADS, parseTorPresetType(2)) - } - - @Test - fun parseTorPresetType_code3_returnsFullPrivacy() { - assertEquals(TorPresetType.FULL_PRIVACY, parseTorPresetType(3)) - } - - @Test - fun parseTorPresetType_unknownCode_defaultsToCustom() { - assertEquals(TorPresetType.CUSTOM, parseTorPresetType(99)) - } - - @Test - fun parseTorPresetType_null_defaultsToCustom() { - assertEquals(TorPresetType.CUSTOM, parseTorPresetType(null)) - } - - @Test - fun torPresetType_screenCodes_areUnique() { - val codes = TorPresetType.entries.map { it.screenCode } - assertEquals(codes.size, codes.toSet().size) - } - - // --- Preset definitions --- - - @Test - fun onlyWhenNeededPreset_onlyOnionEnabled() { - assertTrue(torOnlyWhenNeededPreset.onionRelaysViaTor) - assertFalse(torOnlyWhenNeededPreset.dmRelaysViaTor) - assertFalse(torOnlyWhenNeededPreset.newRelaysViaTor) - assertFalse(torOnlyWhenNeededPreset.trustedRelaysViaTor) - assertFalse(torOnlyWhenNeededPreset.urlPreviewsViaTor) - assertFalse(torOnlyWhenNeededPreset.profilePicsViaTor) - assertFalse(torOnlyWhenNeededPreset.imagesViaTor) - assertFalse(torOnlyWhenNeededPreset.videosViaTor) - assertFalse(torOnlyWhenNeededPreset.moneyOperationsViaTor) - assertFalse(torOnlyWhenNeededPreset.nip05VerificationsViaTor) - assertFalse(torOnlyWhenNeededPreset.mediaUploadsViaTor) - } - - @Test - fun defaultPreset_onionDmNewEnabled() { - assertTrue(torDefaultPreset.onionRelaysViaTor) - assertTrue(torDefaultPreset.dmRelaysViaTor) - assertTrue(torDefaultPreset.newRelaysViaTor) - assertFalse(torDefaultPreset.trustedRelaysViaTor) - assertFalse(torDefaultPreset.urlPreviewsViaTor) - assertFalse(torDefaultPreset.imagesViaTor) - assertFalse(torDefaultPreset.videosViaTor) - assertFalse(torDefaultPreset.moneyOperationsViaTor) - assertFalse(torDefaultPreset.nip05VerificationsViaTor) - assertFalse(torDefaultPreset.mediaUploadsViaTor) - } - - @Test - fun smallPayloadsPreset_addsPreviewsNip05Money() { - assertTrue(torSmallPayloadsPreset.onionRelaysViaTor) - assertTrue(torSmallPayloadsPreset.dmRelaysViaTor) - assertTrue(torSmallPayloadsPreset.newRelaysViaTor) - assertTrue(torSmallPayloadsPreset.trustedRelaysViaTor) - assertTrue(torSmallPayloadsPreset.urlPreviewsViaTor) - assertTrue(torSmallPayloadsPreset.profilePicsViaTor) - assertFalse(torSmallPayloadsPreset.imagesViaTor) - assertFalse(torSmallPayloadsPreset.videosViaTor) - assertTrue(torSmallPayloadsPreset.moneyOperationsViaTor) - assertTrue(torSmallPayloadsPreset.nip05VerificationsViaTor) - assertFalse(torSmallPayloadsPreset.mediaUploadsViaTor) - } - - @Test - fun fullPrivacyPreset_allEnabled() { - assertTrue(torFullyPrivate.onionRelaysViaTor) - assertTrue(torFullyPrivate.dmRelaysViaTor) - assertTrue(torFullyPrivate.newRelaysViaTor) - assertTrue(torFullyPrivate.trustedRelaysViaTor) - assertTrue(torFullyPrivate.urlPreviewsViaTor) - assertTrue(torFullyPrivate.profilePicsViaTor) - assertTrue(torFullyPrivate.imagesViaTor) - assertTrue(torFullyPrivate.videosViaTor) - assertTrue(torFullyPrivate.moneyOperationsViaTor) - assertTrue(torFullyPrivate.nip05VerificationsViaTor) - assertTrue(torFullyPrivate.mediaUploadsViaTor) - } - - // --- Preset hierarchy: each level is a superset of the previous --- - - @Test - fun presets_areIncreasing_defaultSupersetOfOnlyWhenNeeded() { - // Default enables DM + new relays on top of onlyWhenNeeded - assertTrue(torDefaultPreset.dmRelaysViaTor) - assertTrue(torDefaultPreset.newRelaysViaTor) - assertFalse(torOnlyWhenNeededPreset.dmRelaysViaTor) - assertFalse(torOnlyWhenNeededPreset.newRelaysViaTor) - } - - @Test - fun presets_areIncreasing_fullPrivacySupersetOfSmallPayloads() { - // Full privacy adds images, videos, media uploads - assertTrue(torFullyPrivate.imagesViaTor) - assertTrue(torFullyPrivate.videosViaTor) - assertTrue(torFullyPrivate.mediaUploadsViaTor) - assertFalse(torSmallPayloadsPreset.imagesViaTor) - assertFalse(torSmallPayloadsPreset.videosViaTor) - assertFalse(torSmallPayloadsPreset.mediaUploadsViaTor) - } - - // --- whichPreset --- - - @Test - fun whichPreset_matchesOnlyWhenNeeded() { - assertEquals(TorPresetType.ONLY_WHEN_NEEDED, whichPreset(torOnlyWhenNeededPreset)) - } - - @Test - fun whichPreset_matchesDefault() { - assertEquals(TorPresetType.DEFAULT, whichPreset(torDefaultPreset)) - } - - @Test - fun whichPreset_matchesSmallPayloads() { - assertEquals(TorPresetType.SMALL_PAYLOADS, whichPreset(torSmallPayloadsPreset)) - } - - @Test - fun whichPreset_matchesFullPrivacy() { - assertEquals(TorPresetType.FULL_PRIVACY, whichPreset(torFullyPrivate)) - } - - @Test - fun whichPreset_returnsCustomForMixedSettings() { - val mixed = - TorSettings( - onionRelaysViaTor = true, - dmRelaysViaTor = true, - newRelaysViaTor = false, // differs from DEFAULT - trustedRelaysViaTor = true, // differs from DEFAULT - ) - assertEquals(TorPresetType.CUSTOM, whichPreset(mixed)) - } - - @Test - fun whichPreset_ignoresProfilePicsInComparison() { - // profilePicsViaTor is commented out in isPreset() - val withProfilePics = torDefaultPreset.copy(profilePicsViaTor = true) - assertEquals(TorPresetType.DEFAULT, whichPreset(withProfilePics)) - } - - @Test - fun whichPreset_ignoresTorTypeAndPort() { - // whichPreset only compares boolean flags, not torType/port - val withExternal = torDefaultPreset.copy(torType = TorType.EXTERNAL, externalSocksPort = 1234) - assertEquals(TorPresetType.DEFAULT, whichPreset(withExternal)) - } - - // --- isPreset --- - - @Test - fun isPreset_exactMatch_returnsTrue() { - assertTrue(isPreset(torFullyPrivate, torFullyPrivate)) - } - - @Test - fun isPreset_differentFlag_returnsFalse() { - val modified = torFullyPrivate.copy(imagesViaTor = false) - assertFalse(isPreset(modified, torFullyPrivate)) - } - - @Test - fun isPreset_torTypeDifference_ignored() { - val withOff = torDefaultPreset.copy(torType = TorType.OFF) - assertTrue(isPreset(withOff, torDefaultPreset)) - } - - // --- TorSettings data class --- - - @Test - fun torSettings_defaultValues() { - val defaults = TorSettings() - assertEquals(TorType.INTERNAL, defaults.torType) - assertEquals(9050, defaults.externalSocksPort) - assertTrue(defaults.onionRelaysViaTor) - assertTrue(defaults.dmRelaysViaTor) - assertTrue(defaults.newRelaysViaTor) - assertFalse(defaults.trustedRelaysViaTor) - } - - @Test - fun torSettings_equality_worksForDistinctUntilChanged() { - val a = TorSettings(torType = TorType.INTERNAL, externalSocksPort = 9050) - val b = TorSettings(torType = TorType.INTERNAL, externalSocksPort = 9050) - assertEquals(a, b) - assertEquals(a.hashCode(), b.hashCode()) - } - - @Test - fun torSettings_copy_changesOneField() { - val original = TorSettings() - val modified = original.copy(torType = TorType.OFF) - assertEquals(TorType.OFF, modified.torType) - assertEquals(original.externalSocksPort, modified.externalSocksPort) - assertNotEquals(original, modified) - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStore.kt similarity index 92% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStore.kt index 5c4b054edd..45c654835e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/TorSharedPreferences.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStore.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import androidx.compose.runtime.Stable import androidx.datastore.core.DataStore @@ -28,14 +28,15 @@ import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.intPreferencesKey import androidx.datastore.preferences.core.longPreferencesKey import androidx.datastore.preferences.core.stringPreferencesKey +import com.vitorpamplona.amethyst.commons.tor.TorPreferencesPort import com.vitorpamplona.amethyst.commons.tor.TorSettings +import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.tor.TorType -import com.vitorpamplona.amethyst.ui.tor.TorPreferencesPort -import com.vitorpamplona.amethyst.ui.tor.TorSettingsFlow import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.IO import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.debounce @@ -47,7 +48,7 @@ import kotlinx.coroutines.flow.stateIn import kotlin.coroutines.cancellation.CancellationException @Stable -class TorSharedPreferences( +class TorSettingsStore( prefs: TorSettings, val store: DataStore, val scope: CoroutineScope, @@ -72,9 +73,9 @@ class TorSharedPreferences( value.toSettings(), ) - override suspend fun loadLastBypassApprovalMs(): Long = TorSharedPreferences.loadLastBypassApprovalMs(store) + override suspend fun loadLastBypassApprovalMs(): Long = loadLastBypassApprovalMs(store) - override suspend fun saveLastBypassApprovalMs(value: Long) = TorSharedPreferences.saveLastBypassApprovalMs(value, store) + override suspend fun saveLastBypassApprovalMs(value: Long) = saveLastBypassApprovalMs(value, store) companion object { // loads faster when individualized @@ -115,7 +116,7 @@ class TorSharedPreferences( } catch (e: Exception) { if (e is CancellationException) throw e // Log any errors that occur while reading the DataStore. - Log.e("SharedPreferences") { "Error reading DataStore preferences: ${e.message}" } + Log.e("TorSettingsStore") { "Error reading DataStore preferences: ${e.message}" } null } @@ -142,7 +143,7 @@ class TorSharedPreferences( } catch (e: Exception) { if (e is CancellationException) throw e // Log any errors that occur while reading the DataStore. - Log.e("SharedPreferences") { "Error saving DataStore preferences: ${e.message}" } + Log.e("TorSettingsStore") { "Error saving DataStore preferences: ${e.message}" } } } @@ -151,7 +152,7 @@ class TorSharedPreferences( store.data.first()[LAST_BYPASS_APPROVAL_MS_KEY] ?: 0L } catch (e: Exception) { if (e is CancellationException) throw e - Log.e("SharedPreferences") { "Error reading lastBypassApprovalMs: ${e.message}" } + Log.e("TorSettingsStore") { "Error reading lastBypassApprovalMs: ${e.message}" } 0L } @@ -165,7 +166,7 @@ class TorSharedPreferences( } } catch (e: Exception) { if (e is CancellationException) throw e - Log.e("SharedPreferences") { "Error saving lastBypassApprovalMs: ${e.message}" } + Log.e("TorSettingsStore") { "Error saving lastBypassApprovalMs: ${e.message}" } } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorPreferencesPort.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/tor/TorPreferencesPort.kt similarity index 75% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorPreferencesPort.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/tor/TorPreferencesPort.kt index 3188f15f81..3710aec24e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorPreferencesPort.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/tor/TorPreferencesPort.kt @@ -18,15 +18,17 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.tor +package com.vitorpamplona.amethyst.commons.tor -import com.vitorpamplona.amethyst.commons.tor.TorType import kotlinx.coroutines.flow.StateFlow /** - * The slice of `TorSharedPreferences` that [TorManager] depends on. Extracted so the - * manager can be unit-tested without an Android `Context` (and without DataStore). - * Production wires `TorSharedPreferences`; tests wire an in-memory fake. + * The slice of `TorSettingsStore` that each front end's Tor manager depends on. + * + * Extracted so a manager can be unit-tested without a real store behind it: + * production wires `TorSettingsStore`, tests wire an in-memory fake. It lives + * here rather than beside Android's `TorManager` because the store that + * satisfies it is shared, and a desktop or CLI manager needs the same slice. */ interface TorPreferencesPort { val torType: StateFlow diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/tor/TorSettingsFlow.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/tor/TorSettingsFlow.kt index 89f297fedc..e7d3e43769 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsFlow.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/tor/TorSettingsFlow.kt @@ -18,11 +18,9 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.tor +package com.vitorpamplona.amethyst.commons.tor import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.tor.TorSettings -import com.vitorpamplona.amethyst.commons.tor.TorType import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/tor/TorSettingsTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/tor/TorSettingsTest.kt index 1dfb214a3b..a96731c21f 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/tor/TorSettingsTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/tor/TorSettingsTest.kt @@ -179,4 +179,60 @@ class TorSettingsTest { assertEquals(TorType.OFF, modified.torType) assertNotEquals(original, modified) } + + @Test + fun isPreset_torTypeDifference_ignored() { + val withOff = torDefaultPreset.copy(torType = TorType.OFF) + assertTrue(isPreset(withOff, torDefaultPreset)) + } + + @Test + fun presets_areIncreasing_defaultSupersetOfOnlyWhenNeeded() { + // Default enables DM + new relays on top of onlyWhenNeeded + assertTrue(torDefaultPreset.dmRelaysViaTor) + assertTrue(torDefaultPreset.newRelaysViaTor) + assertFalse(torOnlyWhenNeededPreset.dmRelaysViaTor) + assertFalse(torOnlyWhenNeededPreset.newRelaysViaTor) + } + + @Test + fun presets_areIncreasing_fullPrivacySupersetOfSmallPayloads() { + // Full privacy adds images, videos, media uploads + assertTrue(torFullyPrivate.imagesViaTor) + assertTrue(torFullyPrivate.videosViaTor) + assertTrue(torFullyPrivate.mediaUploadsViaTor) + assertFalse(torSmallPayloadsPreset.imagesViaTor) + assertFalse(torSmallPayloadsPreset.videosViaTor) + assertFalse(torSmallPayloadsPreset.mediaUploadsViaTor) + } + + @Test + fun smallPayloadsPreset_addsPreviewsNip05Money() { + assertTrue(torSmallPayloadsPreset.onionRelaysViaTor) + assertTrue(torSmallPayloadsPreset.dmRelaysViaTor) + assertTrue(torSmallPayloadsPreset.newRelaysViaTor) + assertTrue(torSmallPayloadsPreset.trustedRelaysViaTor) + assertTrue(torSmallPayloadsPreset.urlPreviewsViaTor) + assertTrue(torSmallPayloadsPreset.profilePicsViaTor) + assertFalse(torSmallPayloadsPreset.imagesViaTor) + assertFalse(torSmallPayloadsPreset.videosViaTor) + assertTrue(torSmallPayloadsPreset.moneyOperationsViaTor) + assertTrue(torSmallPayloadsPreset.nip05VerificationsViaTor) + assertFalse(torSmallPayloadsPreset.mediaUploadsViaTor) + } + + @Test + fun torSettings_equality_worksForDistinctUntilChanged() { + val a = TorSettings(torType = TorType.INTERNAL, externalSocksPort = 9050) + val b = TorSettings(torType = TorType.INTERNAL, externalSocksPort = 9050) + assertEquals(a, b) + assertEquals(a.hashCode(), b.hashCode()) + } + + @Test + fun whichPreset_ignoresTorTypeAndPort() { + // whichPreset only compares boolean flags, not torType/port + val withExternal = torDefaultPreset.copy(torType = TorType.EXTERNAL, externalSocksPort = 1234) + assertEquals(TorPresetType.DEFAULT, whichPreset(withExternal)) + } } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStoreTest.kt new file mode 100644 index 0000000000..ecf403972d --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TorSettingsStoreTest.kt @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.preferences + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import com.vitorpamplona.amethyst.commons.tor.TorSettings +import com.vitorpamplona.amethyst.commons.tor.TorType +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class TorSettingsStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private fun rawStore(name: String): DataStore = + PreferenceDataStoreFactory.createWithPath( + produceFile = { folder.root.toOkioPath() / "$name.preferences_pb" }, + ) + + /** + * These defaults decide what an install that never opened the privacy screen + * sends over Tor, so getting one wrong is a privacy regression in one + * direction and a connectivity regression in the other. + * + * Three are on — onion, DM and new relays — and the rest are off. Note that + * the desktop front end's own `DesktopTorPreferences` reads most of these as + * `true` instead; the two have never agreed, and this pins the Android + * behaviour that the shared store inherits. + */ + @Test + fun anEmptyStoreReadsTheDefaultsTheAndroidStoreAlwaysHad() = + runTest { + val settings = TorSettingsStore.torPreferences(rawStore("empty"))!! + + assertEquals(TorType.INTERNAL, settings.torType) + assertEquals(9050, settings.externalSocksPort) + + assertTrue(settings.onionRelaysViaTor) + assertTrue(settings.dmRelaysViaTor) + assertTrue(settings.newRelaysViaTor) + + assertFalse(settings.trustedRelaysViaTor) + assertFalse(settings.urlPreviewsViaTor) + assertFalse(settings.profilePicsViaTor) + assertFalse(settings.imagesViaTor) + assertFalse(settings.videosViaTor) + assertFalse(settings.moneyOperationsViaTor) + assertFalse(settings.nip05VerificationsViaTor) + assertFalse(settings.mediaUploadsViaTor) + } + + /** The data class and the store must agree, or "unset" and "default" drift apart. */ + @Test + fun theEmptyStoreMatchesTheDataClassDefaults() = + runTest { + assertEquals(TorSettings(), TorSettingsStore.torPreferences(rawStore("match"))) + } + + @Test + fun everySettingSurvivesARoundTrip() = + runTest { + val store = rawStore("roundtrip") + val settings = + TorSettings( + torType = TorType.EXTERNAL, + externalSocksPort = 9150, + onionRelaysViaTor = false, + dmRelaysViaTor = false, + newRelaysViaTor = false, + trustedRelaysViaTor = true, + urlPreviewsViaTor = true, + profilePicsViaTor = true, + imagesViaTor = true, + videosViaTor = true, + moneyOperationsViaTor = true, + nip05VerificationsViaTor = true, + mediaUploadsViaTor = true, + ) + + TorSettingsStore.save(settings, store) + + assertEquals(settings, TorSettingsStore.torPreferences(store)) + } + + /** + * The bypass timestamp is deliberately not part of [TorSettings] — it is + * bookkeeping for the connection-failure dialog, not a user setting — so it + * has its own pair of accessors and its own key. + */ + @Test + fun theBypassApprovalTimestampIsStoredApartFromTheSettings() = + runTest { + val store = rawStore("bypass") + + assertEquals(0L, TorSettingsStore.loadLastBypassApprovalMs(store)) + + TorSettingsStore.saveLastBypassApprovalMs(1_700_000_000_000L, store) + assertEquals(1_700_000_000_000L, TorSettingsStore.loadLastBypassApprovalMs(store)) + + // and a settings save must not clear it + TorSettingsStore.save(TorSettings(torType = TorType.OFF), store) + assertEquals(1_700_000_000_000L, TorSettingsStore.loadLastBypassApprovalMs(store)) + } + + /** + * An unreadable enum name must not take the whole settings object down with + * it — a store written by a newer build that added a TorType would otherwise + * strand the user with no Tor settings at all. + */ + @Test + fun anUnknownTorTypeFallsBackRatherThanThrowing() = + runTest { + val store = rawStore("garbage") + store.edit { it[TorSettingsStore.TOR_TYPE_KEY] = "SOMETHING_NEWER" } + + assertNull(TorSettingsStore.torPreferences(store)) + } + + /** The keys are the ones the Android store has always written. */ + @Test + fun theKeyNamesAreUnchanged() { + assertEquals("tor.torType", TorSettingsStore.TOR_TYPE_KEY.name) + assertEquals("tor.externalSocksPort", TorSettingsStore.EXTERNAL_SOCKS_PORT_KEY.name) + assertEquals("tor.lastBypassApprovalMs", TorSettingsStore.LAST_BYPASS_APPROVAL_MS_KEY.name) + assertEquals("tor.onionRelaysViaTor", TorSettingsStore.ONION_RELAYS_VIA_TOR_KEY.name) + assertEquals("tor.mediaUploadsViaTor", TorSettingsStore.MEDIA_UPLOADS_VIA_TOR_KEY.name) + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/TorSettingsLabels.kt similarity index 88% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/TorSettingsLabels.kt index 4443d4bbdc..ce050893d7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettings.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/settings/TorSettingsLabels.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.tor +package com.vitorpamplona.amethyst.commons.ui.settings import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.tor_custom @@ -38,12 +38,15 @@ import com.vitorpamplona.amethyst.commons.tor.TorPresetType import com.vitorpamplona.amethyst.commons.tor.TorType import org.jetbrains.compose.resources.StringResource -// Re-export shared types so existing Android imports continue to work -// The canonical types now live in commons/commonMain -@Suppress("unused") -private const val RE_EXPORTS = 0 - -// Catalog keys for TorType (shared types live in commons/commonMain) +/** + * The display labels for the Tor settings enums. + * + * Same split as the UI settings labels beside this file: the data ([TorType], [TorPresetType], + * [com.vitorpamplona.amethyst.commons.tor.TorSettings]) is in `commons`, where + * the CLI and any headless front end can read it, and the [StringResource]s are + * here because they come from the generated `Res` class that only `commonsUI` + * has. + */ val TorType.resourceId: StringResource get() = when (this) { @@ -52,7 +55,6 @@ val TorType.resourceId: StringResource TorType.EXTERNAL -> Res.string.tor_external } -// Catalog keys for TorPresetType val TorPresetType.resourceId: StringResource get() = when (this) { From edc12df63a21c6caa18baf3b89aa0c6c53438238 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 14:24:16 +0000 Subject: [PATCH 23/57] refactor: move the search history and NIP-46 client stores into commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both were already DataStore-backed and already implemented a commons interface; what kept them in amethyst was that each kept its own `ConcurrentHashMap>` registry, keyed by absolute path, to satisfy DataStore's one-instance-per-file rule. That is a third registry alongside AppPreferenceStores and AccountPreferenceStores, and `java.util.concurrent` does not belong in commonMain either. They now take the DataStore instead of a directory, so the caller's holder is the single registry. Paths are unchanged — AppPreferenceStores.file produces the same `datastore/.preferences_pb` these built by hand. DataStoreNip46ClientStore also dropped `java.security.MessageDigest` for quartz's KMP sha256. That digest feeds a stored key, so getting it wrong would not fail loudly — it would orphan every NIP-46 client a user has authorized. Hex.encode masks to 0xFF and emits lower case, which is what `"%02x".format(byte)` did, and DataStoreNip46ClientStoreTest pins three coordinates against SHA-256 prefixes computed outside this codebase so the equivalence is checked rather than argued. Renamed its `store` property to `dataStore` while moving it: the class had both a `store` property and a `store(coordinate, info)` method, and `store.edit { }` inside `fun store()` reads as a recursive call at a glance. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 4 +- .../ui/screen/loggedIn/search/SearchScreen.kt | 5 +- .../nip46/DataStoreNip46ClientStore.kt | 47 ++++------ .../search}/DataStoreSearchHistoryStorage.kt | 36 ++----- .../nip46/DataStoreNip46ClientStoreTest.kt | 93 +++++++++++++++++++ 5 files changed, 127 insertions(+), 58 deletions(-) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/connectedApps/nip46/DataStoreNip46ClientStore.kt (77%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search}/DataStoreSearchHistoryStorage.kt (54%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/nip46/DataStoreNip46ClientStoreTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 6c3fde8ac3..fdcc03588f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -27,6 +27,7 @@ import android.os.SystemClock import androidx.security.crypto.EncryptedSharedPreferences import coil3.disk.DiskCache import coil3.memory.MemoryCache +import com.vitorpamplona.amethyst.commons.connectedApps.nip46.DataStoreNip46ClientStore import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.UiSettings import com.vitorpamplona.amethyst.commons.model.cache.LocalCache @@ -67,7 +68,6 @@ import com.vitorpamplona.amethyst.commons.service.pow.PoWPolicy import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue import com.vitorpamplona.amethyst.commons.tor.TorSettings import com.vitorpamplona.amethyst.connectedApps.DataStoreNostrSignerPermissionStore -import com.vitorpamplona.amethyst.connectedApps.nip46.DataStoreNip46ClientStore import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever @@ -873,7 +873,7 @@ class AppModules( val signerPermissionStore by lazy { DataStoreNostrSignerPermissionStore(appContext) } // Display + relay info for connected NIP-46 remote-signer clients. - val nip46ClientStore by lazy { DataStoreNip46ClientStore(appContext) } + val nip46ClientStore by lazy { DataStoreNip46ClientStore(appStores.getDataStore(DataStoreNip46ClientStore.FILE_NAME)) } // Authenticates with relays. val authCoordinator = AuthCoordinator(client, applicationIOScope) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt index 46072a6f17..24082d100f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/search/SearchScreen.kt @@ -73,7 +73,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.text.style.TextAlign @@ -111,6 +110,7 @@ import com.vitorpamplona.amethyst.commons.resources.search_source_relays import com.vitorpamplona.amethyst.commons.resources.search_type_to_begin import com.vitorpamplona.amethyst.commons.resources.search_type_to_begin_explainer import com.vitorpamplona.amethyst.commons.resources.search_waiting_on_relays +import com.vitorpamplona.amethyst.commons.search.DataStoreSearchHistoryStorage import com.vitorpamplona.amethyst.commons.search.QuerySerializer import com.vitorpamplona.amethyst.commons.search.SearchScope import com.vitorpamplona.amethyst.commons.search.SearchSortOrder @@ -133,7 +133,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size5dp import com.vitorpamplona.amethyst.commons.ui.theme.StdTopPadding import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.model.nip11RelayInfo.loadRelayInfo -import com.vitorpamplona.amethyst.model.preferences.DataStoreSearchHistoryStorage import com.vitorpamplona.amethyst.service.location.CachedReversedGeoLocations import com.vitorpamplona.amethyst.service.relayClient.searchCommand.TextSearchDataSourceSubscription import com.vitorpamplona.amethyst.ui.components.namecoin.NamecoinResolutionRow @@ -167,7 +166,7 @@ fun SearchScreen( accountViewModel: AccountViewModel, nav: INav, ) { - val historyStorage = LocalContext.current.let { context -> remember(context) { DataStoreSearchHistoryStorage(context) } } + val historyStorage = remember { DataStoreSearchHistoryStorage(Amethyst.instance.appStores.getDataStore(DataStoreSearchHistoryStorage.FILE_NAME)) } val searchBarViewModel: SearchBarViewModel = viewModel( // Keyed on the seed: navigating from one screen's search button to another's has to diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/connectedApps/nip46/DataStoreNip46ClientStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/nip46/DataStoreNip46ClientStore.kt similarity index 77% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/connectedApps/nip46/DataStoreNip46ClientStore.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/nip46/DataStoreNip46ClientStore.kt index eaa68c4031..c3ffec1b38 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/connectedApps/nip46/DataStoreNip46ClientStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/nip46/DataStoreNip46ClientStore.kt @@ -18,20 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.connectedApps.nip46 +package com.vitorpamplona.amethyst.commons.connectedApps.nip46 -import android.content.Context import androidx.datastore.core.DataStore -import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import com.vitorpamplona.amethyst.commons.connectedApps.nip46.Nip46ClientInfo -import com.vitorpamplona.amethyst.commons.connectedApps.nip46.Nip46ClientStore +import com.vitorpamplona.quartz.nip01Core.core.toHexKey +import com.vitorpamplona.quartz.utils.sha256.sha256 import kotlinx.coroutines.flow.first -import java.io.File -import java.security.MessageDigest -import java.util.concurrent.ConcurrentHashMap /** * Single-file DataStore-backed [Nip46ClientStore]. Every connected client's @@ -41,14 +36,10 @@ import java.util.concurrent.ConcurrentHashMap * individually so no serialization library is needed; [relays] is newline-joined. */ class DataStoreNip46ClientStore( - private val filesDir: File, + private val dataStore: DataStore, ) : Nip46ClientStore { - constructor(context: Context) : this(context.applicationContext.filesDir) - - private val store: DataStore get() = dataStoreFor(File(filesDir, "datastore/nip46_clients.preferences_pb")) - override suspend fun load(coordinate: String): Nip46ClientInfo? { - val prefs = store.data.first() + val prefs = dataStore.data.first() if (prefs[coordKey(coordinate)] == null) return null return Nip46ClientInfo( name = prefs[nameKey(coordinate)], @@ -62,7 +53,7 @@ class DataStoreNip46ClientStore( coordinate: String, info: Nip46ClientInfo, ) { - store.edit { prefs -> + dataStore.edit { prefs -> prefs[coordKey(coordinate)] = coordinate info.name?.let { prefs[nameKey(coordinate)] = it } ?: prefs.remove(nameKey(coordinate)) info.url?.let { prefs[urlKey(coordinate)] = it } ?: prefs.remove(urlKey(coordinate)) @@ -72,7 +63,7 @@ class DataStoreNip46ClientStore( } override suspend fun remove(coordinate: String) { - store.edit { prefs -> + dataStore.edit { prefs -> prefs.remove(coordKey(coordinate)) prefs.remove(nameKey(coordinate)) prefs.remove(urlKey(coordinate)) @@ -82,7 +73,7 @@ class DataStoreNip46ClientStore( } override suspend fun all(): Map { - val prefs = store.data.first() + val prefs = dataStore.data.first() val result = mutableMapOf() for ((key, value) in prefs.asMap()) { if (!key.name.startsWith(COORD_PREFIX)) continue @@ -111,18 +102,20 @@ class DataStoreNip46ClientStore( private fun relaysKey(coordinate: String) = stringPreferencesKey("relays:${hash(coordinate)}") companion object { - private val stores = ConcurrentHashMap>() - - private fun dataStoreFor(file: File): DataStore = - stores.computeIfAbsent(file.absolutePath) { - PreferenceDataStoreFactory.create(produceFile = { file }) - } + const val FILE_NAME = "nip46_clients" private const val COORD_PREFIX = "coord:" - private fun hash(coordinate: String): String { - val digest = MessageDigest.getInstance("SHA-256").digest(coordinate.toByteArray()) - return digest.take(8).joinToString("") { "%02x".format(it) } - } + /** + * The first 8 bytes of the coordinate's SHA-256, lower-case hex. + * + * This is a stored key, so it must keep producing exactly what + * `MessageDigest.getInstance("SHA-256")` plus `"%02x".format(byte)` did + * on Android — a different digest here would orphan every client a user + * has already authorized rather than fail loudly. + * `DataStoreNip46ClientStoreTest` pins three coordinates against hashes + * computed outside this codebase. + */ + internal fun hash(coordinate: String): String = sha256(coordinate.encodeToByteArray()).copyOfRange(0, 8).toHexKey() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DataStoreSearchHistoryStorage.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/DataStoreSearchHistoryStorage.kt similarity index 54% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DataStoreSearchHistoryStorage.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/DataStoreSearchHistoryStorage.kt index 6820899ad4..80f9de7353 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DataStoreSearchHistoryStorage.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/DataStoreSearchHistoryStorage.kt @@ -18,38 +18,27 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.search -import android.content.Context import androidx.datastore.core.DataStore -import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import com.vitorpamplona.amethyst.commons.search.SearchHistoryStorage import kotlinx.coroutines.flow.first -import java.io.File -import java.util.concurrent.ConcurrentHashMap /** - * Where Android keeps the search history: one `datastore/search_history.preferences_pb` file. + * [SearchHistoryStorage] on a DataStore of its own — `search_history` under the + * front end's datastore directory. * - * The history itself — what it holds, how much of it, in what order — is - * [com.vitorpamplona.amethyst.commons.search.SearchHistory] in commons, shared with Desktop. This - * is only the two strings and the file they live in. - * - * Device-global rather than per-account, like the drawer's collapse state beside it: what you - * searched for is a property of this phone, and it is never published to a relay. + * Takes the store rather than a directory: the search screen is rebuilt per + * seeded query, and DataStore refuses a second live instance on a path that + * already has one, so who owns the instance matters. Handing it in means the + * caller's store holder is the single registry rather than this class keeping a + * private one of its own. */ class DataStoreSearchHistoryStorage( - private val filesDir: File, + private val store: DataStore, ) : SearchHistoryStorage { - constructor(context: Context) : this(context.applicationContext.filesDir) - - // DataStore v1 throws if two instances are ever active on the same file, and the search screen - // is rebuilt per seeded query, so the store is shared per absolute path across the process. - private val store: DataStore get() = dataStoreFor(File(filesDir, "datastore/search_history.preferences_pb")) - override suspend fun read(key: String): String? = store.data.first()[stringPreferencesKey(key)] override suspend fun write( @@ -62,11 +51,6 @@ class DataStoreSearchHistoryStorage( } companion object { - private val stores = ConcurrentHashMap>() - - private fun dataStoreFor(file: File): DataStore = - stores.computeIfAbsent(file.absolutePath) { - PreferenceDataStoreFactory.create(produceFile = { file }) - } + const val FILE_NAME = "search_history" } } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/nip46/DataStoreNip46ClientStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/nip46/DataStoreNip46ClientStoreTest.kt new file mode 100644 index 0000000000..c98604a1cc --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/nip46/DataStoreNip46ClientStoreTest.kt @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.connectedApps.nip46 + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class DataStoreNip46ClientStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private fun store(name: String): DataStore = + PreferenceDataStoreFactory.createWithPath( + produceFile = { folder.root.toOkioPath() / "$name.preferences_pb" }, + ) + + /** + * The coordinate hash is a stored key, so it has to keep producing exactly + * what the Android implementation did — `MessageDigest.getInstance("SHA-256")` + * truncated to 8 bytes and formatted with `"%02x"`. A different digest would + * not fail; it would quietly orphan every client the user has authorized. + * + * The expected values are SHA-256 prefixes computed outside this codebase, so + * this is a cross-check rather than a restatement of the implementation. + */ + @Test + fun theCoordinateHashMatchesTheAndroidImplementation() { + assertEquals("12bafbcaa8bb08b6", DataStoreNip46ClientStore.hash("31990:abc:def")) + assertEquals("12f134c5dae480dc", DataStoreNip46ClientStore.hash("wss://relay.example.com")) + assertEquals("e3b0c44298fc1c14", DataStoreNip46ClientStore.hash("")) + } + + /** 16 lower-case hex characters, always — it is half a key name. */ + @Test + fun theHashIsAlwaysSixteenLowerCaseHexChars() { + listOf("a", "a longer coordinate with spaces", "ünïcödé", "31990:".repeat(50)).forEach { + val h = DataStoreNip46ClientStore.hash(it) + assertEquals("wrong length for '$it'", 16, h.length) + assertEquals("not lower-case hex for '$it'", h, h.lowercase().filter { c -> c in "0123456789abcdef" }) + } + } + + @Test + fun aStoredClientComesBack() = + runTest { + val subject = DataStoreNip46ClientStore(store("clients")) + val coordinate = "31990:pubkeyhex:handler" + + assertNull(subject.load(coordinate)) + + subject.store( + coordinate, + Nip46ClientInfo(name = "Test App", url = "https://x", image = "https://x/y.png", relays = setOf("wss://a", "wss://b")), + ) + + val loaded = subject.load(coordinate)!! + assertEquals("Test App", loaded.name) + assertEquals("https://x", loaded.url) + assertEquals("https://x/y.png", loaded.image) + assertEquals(setOf("wss://a", "wss://b"), loaded.relays) + + assertEquals(mapOf(coordinate to loaded), subject.all()) + + subject.remove(coordinate) + assertNull(subject.load(coordinate)) + } +} From ffc574d9e66f36d00ef613bb0ba99ba6efefcc4f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 14:31:20 +0000 Subject: [PATCH 24/57] refactor: move the signer permission store into commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last of the app-wide DataStore stores that still needed a Context. Unlike the others it is one file per app rather than one file, `nsp_`, and `allPolicies` enumerated that directory with `File.listFiles` — which is why it could not simply take a DataStore. AppPreferenceStores grows a `names(prefix)` built on the existing `platformFileSystem` expect/actual, so the enumeration is shared rather than JVM-only, and the store takes the holder instead of a directory. That also retires its private LargeCache of stores by path: the holder is now the only registry, which is the point, since DataStore refuses a second live instance on a path and a second registry is exactly how that happens. `java.security.MessageDigest` gives way to quartz's KMP sha256 here too, and the stakes are higher than for the NIP-46 store: this hash is half the *file name*, so a mismatch does not throw, it just never opens the old file again and every permission the user granted that app is silently gone. DataStoreNostrSignerPermissionStoreTest pins three coordinates against SHA-256 prefixes computed outside this codebase, and separately pins that `names("nsp_")` sees only the signer files — shared_settings and search_history live in that same directory — and returns empty rather than throwing when nothing has been written yet. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 4 +- .../DataStoreNostrSignerPermissionStore.kt | 50 +++++------- .../model/preferences/AppPreferenceStores.kt | 28 ++++++- ...DataStoreNostrSignerPermissionStoreTest.kt | 78 +++++++++++++++++++ 4 files changed, 128 insertions(+), 32 deletions(-) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/connectedApps/DataStoreNostrSignerPermissionStore.kt (82%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStoreTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index fdcc03588f..7f388ce450 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -27,6 +27,7 @@ import android.os.SystemClock import androidx.security.crypto.EncryptedSharedPreferences import coil3.disk.DiskCache import coil3.memory.MemoryCache +import com.vitorpamplona.amethyst.commons.connectedApps.DataStoreNostrSignerPermissionStore import com.vitorpamplona.amethyst.commons.connectedApps.nip46.DataStoreNip46ClientStore import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.UiSettings @@ -67,7 +68,6 @@ import com.vitorpamplona.amethyst.commons.service.lnurl.OkHttpLnurlEndpointResol import com.vitorpamplona.amethyst.commons.service.pow.PoWPolicy import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue import com.vitorpamplona.amethyst.commons.tor.TorSettings -import com.vitorpamplona.amethyst.connectedApps.DataStoreNostrSignerPermissionStore import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever @@ -870,7 +870,7 @@ class AppModules( // carry their owning account (`nip46::`) and whose sessions run for a specific // account rather than the active one. The napplet path namespaces its own coordinate the same way // (see NappletBroker.signerCoordinateFor) instead. - val signerPermissionStore by lazy { DataStoreNostrSignerPermissionStore(appContext) } + val signerPermissionStore by lazy { DataStoreNostrSignerPermissionStore(appStores) } // Display + relay info for connected NIP-46 remote-signer clients. val nip46ClientStore by lazy { DataStoreNip46ClientStore(appStores.getDataStore(DataStoreNip46ClientStore.FILE_NAME)) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/connectedApps/DataStoreNostrSignerPermissionStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStore.kt similarity index 82% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/connectedApps/DataStoreNostrSignerPermissionStore.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStore.kt index ec38b703b8..60bf4f7ffe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/connectedApps/DataStoreNostrSignerPermissionStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStore.kt @@ -18,11 +18,9 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.connectedApps +package com.vitorpamplona.amethyst.commons.connectedApps -import android.content.Context import androidx.datastore.core.DataStore -import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey @@ -30,12 +28,12 @@ import com.vitorpamplona.amethyst.commons.connectedApps.signers.AppSignerPolicy import com.vitorpamplona.amethyst.commons.connectedApps.signers.NostrOpDecision import com.vitorpamplona.amethyst.commons.connectedApps.signers.NostrSignerOp import com.vitorpamplona.amethyst.commons.connectedApps.signers.NostrSignerPermissionStore -import com.vitorpamplona.quartz.utils.cache.LargeCache +import com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores +import com.vitorpamplona.quartz.nip01Core.core.toHexKey +import com.vitorpamplona.quartz.utils.sha256.sha256 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first import kotlinx.coroutines.withContext -import java.io.File -import java.security.MessageDigest /** * Per-coordinate DataStore-backed [NostrSignerPermissionStore]. One small `.preferences_pb` @@ -46,18 +44,9 @@ import java.security.MessageDigest * reverse-map file → coordinate without scanning the filesystem. */ class DataStoreNostrSignerPermissionStore( - private val filesDir: File, + private val stores: AppPreferenceStores, ) : NostrSignerPermissionStore { - constructor(context: Context) : this(context.applicationContext.filesDir) - - private val cache = LargeCache>() - - private fun storeFor(coordinate: String): DataStore { - val file = File(filesDir, "datastore/nsp_${hash(coordinate)}.preferences_pb") - return cache.getOrCreate(file.absolutePath) { - PreferenceDataStoreFactory.create(produceFile = { file }) - } - } + private fun storeFor(coordinate: String): DataStore = stores.getDataStore(nameFor(coordinate)) override suspend fun loadPolicy(coordinate: String): AppSignerPolicy? { val raw = storeFor(coordinate).data.first()[KEY_POLICY] ?: return null @@ -108,15 +97,9 @@ class DataStoreNostrSignerPermissionStore( // Enumerates the datastore directory + reads each file — blocking disk IO, so keep it off the // caller's thread (callers invoke this from Compose LaunchedEffects on the main dispatcher). withContext(Dispatchers.IO) { - val dir = File(filesDir, "datastore") - if (!dir.exists()) return@withContext emptyMap() val result = mutableMapOf() - for (file in dir.listFiles { f -> f.name.startsWith("nsp_") } ?: emptyArray()) { - val ds = - cache.getOrCreate(file.absolutePath) { - PreferenceDataStoreFactory.create(produceFile = { file }) - } - val coordinate = ds.data.first()[KEY_COORDINATE] ?: continue + for (name in stores.names(NAME_PREFIX)) { + val coordinate = stores.getDataStore(name).data.first()[KEY_COORDINATE] ?: continue val policy = loadPolicy(coordinate) ?: continue result[coordinate] = policy } @@ -188,9 +171,18 @@ class DataStoreNostrSignerPermissionStore( private const val OP_PREFIX = "op:" private const val OP_EXPIRY_SUFFIX = ":exp" - private fun hash(coordinate: String): String { - val digest = MessageDigest.getInstance("SHA-256").digest(coordinate.toByteArray()) - return digest.take(8).joinToString("") { "%02x".format(it) } - } + internal const val NAME_PREFIX = "nsp_" + + /** + * The per-app store's file name. + * + * The hash is part of the file name, so it must keep producing exactly + * what `MessageDigest.getInstance("SHA-256")` plus `"%02x".format(byte)` + * did on Android — a different digest orphans the file rather than + * failing, and with it every permission the user has granted that app. + * Pinned in DataStoreNostrSignerPermissionStoreTest against hashes + * computed outside this codebase. + */ + internal fun nameFor(coordinate: String): String = NAME_PREFIX + sha256(coordinate.encodeToByteArray()).copyOfRange(0, 8).toHexKey() } } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt index a49447d3cb..edf30e73e8 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt @@ -24,6 +24,7 @@ import androidx.datastore.core.DataMigration import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences +import com.vitorpamplona.amethyst.commons.util.platformFileSystem import com.vitorpamplona.quartz.utils.cache.LargeCache import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -77,6 +78,8 @@ class AppPreferenceStores( * a whole-file read. */ const val SHARED_SETTINGS = "shared_settings" + + private const val SUFFIX = ".preferences_pb" } /** @@ -95,7 +98,7 @@ class AppPreferenceStores( private val storeCache = LargeCache() - fun file(name: String): Path = rootFilesDir() / "datastore" / "$name.preferences_pb" + fun file(name: String): Path = rootFilesDir() / "datastore" / "$name$SUFFIX" fun getDataStore(name: String): DataStore = storeCache @@ -113,4 +116,27 @@ class AppPreferenceStores( /** The file UI, Tor, OTS, Namecoin and friends share. */ fun sharedSettings(): DataStore = getDataStore(SHARED_SETTINGS) + + /** + * The names of stores already on disk whose name starts with [prefix]. + * + * For the store families that are one file per key rather than one file — + * the signer permissions keep an `nsp_` file per app — where the only + * way to enumerate what exists is to look. Reads the directory, so callers + * keep it off the main thread. + * + * Returns names in the form [getDataStore] takes, with the directory and + * the `.preferences_pb` suffix stripped, and an empty list when nothing has + * been written yet. + */ + fun names(prefix: String): List { + val dir = rootFilesDir() / "datastore" + if (!platformFileSystem.exists(dir)) return emptyList() + + return platformFileSystem + .list(dir) + .map { it.name } + .filter { it.startsWith(prefix) && it.endsWith(SUFFIX) } + .map { it.removeSuffix(SUFFIX) } + } } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStoreTest.kt new file mode 100644 index 0000000000..bb6135bf88 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStoreTest.kt @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.connectedApps + +import androidx.datastore.preferences.core.booleanPreferencesKey +import androidx.datastore.preferences.core.edit +import com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class DataStoreNostrSignerPermissionStoreTest { + @get:Rule + val folder = TemporaryFolder() + + private fun stores() = AppPreferenceStores(rootFilesDir = { folder.root.toOkioPath() }) + + /** + * The hash is half the file name, so it has to keep producing exactly what + * `MessageDigest.getInstance("SHA-256")` truncated to 8 bytes and formatted + * with `"%02x"` produced on Android. Get it wrong and the old file is simply + * never opened again — every permission the user granted that app is gone, + * silently. The expected values are SHA-256 prefixes computed outside this + * codebase. + */ + @Test + fun theFileNameMatchesTheAndroidImplementation() { + assertEquals("nsp_12bafbcaa8bb08b6", DataStoreNostrSignerPermissionStore.nameFor("31990:abc:def")) + assertEquals("nsp_12f134c5dae480dc", DataStoreNostrSignerPermissionStore.nameFor("wss://relay.example.com")) + assertEquals("nsp_e3b0c44298fc1c14", DataStoreNostrSignerPermissionStore.nameFor("")) + } + + /** + * allPolicies enumerates the datastore directory, which used to be + * `File.listFiles` and is now AppPreferenceStores.names. It must see only + * the signer files — the shared settings and every other store live in the + * same directory. + */ + @Test + fun namesSeesOnlyTheSignerFilesAndSurvivesAnEmptyDirectory() = + runTest { + val subject = stores() + + assertTrue("nothing written yet", subject.names("nsp_").isEmpty()) + + // a read does not create the file, only a write does + listOf("shared_settings", "search_history", "nsp_deadbeefdeadbeef", "nsp_0011223344556677").forEach { + subject.getDataStore(it).edit { prefs -> prefs[booleanPreferencesKey("touch")] = true } + } + + assertEquals( + listOf("nsp_0011223344556677", "nsp_deadbeefdeadbeef"), + subject.names("nsp_").sorted(), + ) + } +} From aeb1e483c8a55fa82974108fa850aa3cfce491f1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 14:42:14 +0000 Subject: [PATCH 25/57] refactor: move the relay-auth permission store into commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per-account rather than app-wide: its file lives in that account's own directory, `accounts//datastore/relay_auth.preferences_pb`, so a DENY for one account cannot leak into another. That shape is why this one could not just take a directory and be done. buildAccount runs again for the same account on re-login and on cache races, and DataStore throws if a second instance is ever live on a file that already has one — the store used to guard that itself with a private ConcurrentHashMap keyed by absolute path. AccountCacheState now keeps one AppPreferenceStores per account directory instead, so the guarantee holds for any per-account store added there later rather than only this one, and commons keeps a single registry type instead of three ad-hoc ones. Its `java.security.MessageDigest` goes the same way as the other two, and carries the same risk: the hash is the stored key for every ALLOW/DENY, so a mismatch would not throw, it would quietly drop every decision the user has made. Pinned against SHA-256 prefixes computed outside this codebase. The store's 10 round-trip tests move to commons with it, off the Android unit-test job and onto the multiplatform one. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../model/accountsCache/AccountCacheState.kt | 27 ++++++++- .../DataStoreRelayAuthPermissionStore.kt | 58 +++++++++---------- .../DataStoreRelayAuthPermissionStoreTest.kt | 31 +++++++--- 3 files changed, 75 insertions(+), 41 deletions(-) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayauth}/DataStoreRelayAuthPermissionStore.kt (80%) rename {amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model => commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayauth}/DataStoreRelayAuthPermissionStoreTest.kt (83%) 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 62672c0ce9..2c347c81c7 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 @@ -30,7 +30,9 @@ import com.vitorpamplona.amethyst.commons.marmot.InMemoryMlsGroupStateStore import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.marmot.AndroidIngestDedupStore import com.vitorpamplona.amethyst.commons.model.marmot.AndroidPushStateStore +import com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores import com.vitorpamplona.amethyst.commons.relayClient.nip47WalletConnect.NWCPaymentFilterAssembler +import com.vitorpamplona.amethyst.commons.relayauth.DataStoreRelayAuthPermissionStore import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.AccountSettings @@ -39,7 +41,6 @@ import com.vitorpamplona.amethyst.model.marmot.AndroidMarmotMessageStore import com.vitorpamplona.amethyst.model.marmot.AndroidMlsGroupStateStore import com.vitorpamplona.amethyst.model.marmot.AndroidPublishObligationStore import com.vitorpamplona.amethyst.service.location.LocationState -import com.vitorpamplona.amethyst.service.relayClient.authCommand.model.DataStoreRelayAuthPermissionStore import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient @@ -49,6 +50,7 @@ import com.vitorpamplona.quartz.nip03Timestamp.OtsResolver import com.vitorpamplona.quartz.nip55AndroidSigner.client.NostrSignerExternal import com.vitorpamplona.quartz.nip89AppHandlers.clientTag.NostrSignerWithClientTag import com.vitorpamplona.quartz.utils.Log +import com.vitorpamplona.quartz.utils.cache.LargeCache import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -57,6 +59,7 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update +import okio.Path.Companion.toOkioPath import java.io.File class AccountCacheState( @@ -89,6 +92,23 @@ class AccountCacheState( /** Guards [loadAccount]'s check-then-create so concurrent callers can't build twin Accounts. */ private val loadLock = Any() + /** + * One [AppPreferenceStores] per account directory, kept for the life of the + * process. + * + * [buildAccount] runs again for the same account on re-login and on cache + * races, and DataStore throws if a second instance is ever live on a file + * that already has one. Caching the holder — rather than the store — keeps + * that guarantee for every per-account store that gets added here later, + * not just the relay-auth one. + */ + private val accountStoreHolders = LargeCache() + + private fun storesFor(accountDir: File): AppPreferenceStores = + accountStoreHolders.getOrCreate(accountDir.absolutePath) { + AppPreferenceStores(rootFilesDir = { accountDir.toOkioPath() }) + } + fun removeAccount(pubkey: HexKey) { accounts.update { existingAccounts -> val oldValue = existingAccounts[pubkey] @@ -310,7 +330,10 @@ class AccountCacheState( // Per-account NIP-42 ALLOW/DENY overrides live in this account's own dir, so a DENY for one // account never leaks into another (the store used to be a single app-wide file). - val relayAuthPermissionStore = DataStoreRelayAuthPermissionStore(accountDir) + val relayAuthPermissionStore = + DataStoreRelayAuthPermissionStore( + storesFor(accountDir).getDataStore(DataStoreRelayAuthPermissionStore.FILE_NAME), + ) return Account( settings = accountSettings, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/DataStoreRelayAuthPermissionStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayauth/DataStoreRelayAuthPermissionStore.kt similarity index 80% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/DataStoreRelayAuthPermissionStore.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayauth/DataStoreRelayAuthPermissionStore.kt index fe2e79fffd..20cd1aaca0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/DataStoreRelayAuthPermissionStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayauth/DataStoreRelayAuthPermissionStore.kt @@ -18,39 +18,34 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.relayClient.authCommand.model +package com.vitorpamplona.amethyst.commons.relayauth -import android.content.Context import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.MutablePreferences -import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import com.vitorpamplona.amethyst.commons.relayauth.AuthPurposeKind -import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthDecision -import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthPermissionStore +import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.utils.TimeUtils +import com.vitorpamplona.quartz.utils.sha256.sha256 import kotlinx.coroutines.flow.first -import java.io.File -import java.security.MessageDigest -import java.util.concurrent.ConcurrentHashMap /** - * Single-file DataStore-backed [RelayAuthPermissionStore]. All per-relay ALLOW/DENY overrides - * live in one `datastore/relay_auth.preferences_pb` file; a SHA-256 prefix of the URL is the - * key so the URL itself is safe in the file (stored separately for reverse-lookup in [allDecisions]). + * Per-account NIP-42 ALLOW/DENY overrides, in one `relay_auth` store inside that + * account's own directory so a DENY for one account never leaks into another. + * + * A SHA-256 prefix of the relay URL is the key, so the URL itself is not a key + * in the file; it is stored separately under its own prefix for the reverse + * lookup [allDecisions] needs. + * + * Takes the store rather than the directory. DataStore throws if two instances + * are ever live on one file, and an account can be built more than once in a + * process (re-login, cache races), so the caller has to hand in a store it + * keeps — see AccountCacheState, which caches one holder per account. */ class DataStoreRelayAuthPermissionStore( - private val filesDir: File, + private val store: DataStore, ) : RelayAuthPermissionStore { - constructor(context: Context) : this(context.applicationContext.filesDir) - - // DataStore v1 throws if two instances are ever active on the same file. loadAccount can build - // this store more than once for the same account (re-login, cache races), so the underlying - // DataStore is shared per absolute file path across the process instead of created per instance. - private val store: DataStore get() = dataStoreFor(File(filesDir, "datastore/relay_auth.preferences_pb")) - override suspend fun loadDecision(relayUrl: String): RelayAuthDecision? { val raw = store.data.first()[decisionKey(relayUrl)] ?: return null return runCatching { RelayAuthDecision.valueOf(raw) }.getOrNull() @@ -198,14 +193,7 @@ class DataStoreRelayAuthPermissionStore( private fun lastUsedKey(relayUrl: String) = stringPreferencesKey("$LAST_USED_PREFIX${hash(relayUrl)}") companion object { - // One DataStore per file path, process-wide. computeIfAbsent runs the factory at most once - // per path, so concurrent constructions for the same account share a single active DataStore. - private val stores = ConcurrentHashMap>() - - private fun dataStoreFor(file: File): DataStore = - stores.computeIfAbsent(file.absolutePath) { - PreferenceDataStoreFactory.create(produceFile = { file }) - } + const val FILE_NAME = "relay_auth" private const val DECISION_PREFIX = "allow:" private const val URL_PREFIX = "url:" @@ -220,9 +208,15 @@ class DataStoreRelayAuthPermissionStore( /** Minimum seconds between last-used refreshes when no new counterparty appears. */ private const val LAST_USED_REFRESH_SECS = 300L - private fun hash(relayUrl: String): String { - val digest = MessageDigest.getInstance("SHA-256").digest(relayUrl.toByteArray()) - return digest.take(8).joinToString("") { "%02x".format(it) } - } + /** + * The first 8 bytes of the URL's SHA-256, lower-case hex. + * + * A stored key, so it has to keep producing exactly what + * `MessageDigest.getInstance("SHA-256")` plus `"%02x".format(byte)` did + * on Android: a different digest silently drops every decision the user + * has made rather than failing. Pinned in + * DataStoreRelayAuthPermissionStoreTest. + */ + internal fun hash(relayUrl: String): String = sha256(relayUrl.encodeToByteArray()).copyOfRange(0, 8).toHexKey() } } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/DataStoreRelayAuthPermissionStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayauth/DataStoreRelayAuthPermissionStoreTest.kt similarity index 83% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/DataStoreRelayAuthPermissionStoreTest.kt rename to commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayauth/DataStoreRelayAuthPermissionStoreTest.kt index a67cc661a2..9cdb366b08 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/authCommand/model/DataStoreRelayAuthPermissionStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayauth/DataStoreRelayAuthPermissionStoreTest.kt @@ -18,11 +18,11 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.relayClient.authCommand.model +package com.vitorpamplona.amethyst.commons.relayauth -import com.vitorpamplona.amethyst.commons.relayauth.AuthPurposeKind -import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthDecision +import com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores import kotlinx.coroutines.runBlocking +import okio.Path.Companion.toOkioPath import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNull @@ -33,14 +33,31 @@ import org.junit.rules.TemporaryFolder /** * Round-trip tests for the DataStore-backed relay-auth permission store. Backed by a real - * PreferenceDataStore on a per-test temp directory (the store takes a plain filesDir), so it runs - * on the JVM without Robolectric. A fresh directory per test dodges DataStore's per-file - * single-instance guard. + * PreferenceDataStore on a per-test temp directory, so it runs on the JVM without Robolectric. + * A fresh directory per test dodges DataStore's per-file single-instance guard. */ class DataStoreRelayAuthPermissionStoreTest { @get:Rule val tmp = TemporaryFolder() - private fun newStore() = DataStoreRelayAuthPermissionStore(tmp.newFolder()) + private fun newStore() = + DataStoreRelayAuthPermissionStore( + AppPreferenceStores(rootFilesDir = { tmp.newFolder().toOkioPath() }) + .getDataStore(DataStoreRelayAuthPermissionStore.FILE_NAME), + ) + + /** + * The relay-URL hash is a stored key, so it must keep producing exactly what + * `MessageDigest.getInstance("SHA-256")` truncated to 8 bytes and formatted + * with `"%02x"` produced on Android. A different digest would not throw — it + * would silently drop every ALLOW/DENY the user has ever set. Expected values + * are SHA-256 prefixes computed outside this codebase. + */ + @Test + fun theRelayHashMatchesTheAndroidImplementation() { + assertEquals("88b21471340e72df", DataStoreRelayAuthPermissionStore.hash("wss://auth.relay.test")) + assertEquals("2535089fcc9a2cf1", DataStoreRelayAuthPermissionStore.hash("wss://other.relay.test")) + assertEquals("e3b0c44298fc1c14", DataStoreRelayAuthPermissionStore.hash("")) + } private val relay = "wss://auth.relay.test" private val other = "wss://other.relay.test" From e1fa25ca72528d74c4889b5db1bed8e525a0d15f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 14:52:25 +0000 Subject: [PATCH 26/57] refactor: route the roster and Cashu counter stores through AppPreferenceStores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neither needed a Context — both already built a DataStore directly on a path under `filesDir/datastore`, which is the same directory the holder owns. Building one by hand there is how a second live instance on a file happens, so they now ask the holder for it. The Cashu store is one file per account, so its `cashu_prefs_` copy could not stay attached to the store: DataStore runs a file's migrations when that file is first opened, and the holder is what opens it. AppModules selects the migration by file name instead — shared_settings takes the UI copy, `cashu_` takes that account's counter copy. That makes per-name selection load-bearing, so AppPreferenceStoresTest now pins it: the name reaches the chooser, two accounts get their own migration, and a file with no migration is left alone. A holder that ignored the name would copy one account's NUT-13 counters into another's, and a counter that moves backwards makes the mint reply `outputs already signed` — real ecash, stranded. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../vitorpamplona/amethyst/AccountRoster.kt | 14 ++++---- .../com/vitorpamplona/amethyst/AppModules.kt | 8 +++-- .../model/nip60Cashu/CashuPreferences.kt | 26 ++++++++------ .../preferences/AppPreferenceStoresTest.kt | 36 +++++++++++++++++++ 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt index e0a79dcd66..012bd535b9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountRoster.kt @@ -20,12 +20,9 @@ */ package com.vitorpamplona.amethyst -import androidx.datastore.preferences.core.PreferenceDataStoreFactory import com.vitorpamplona.amethyst.commons.model.preferences.AccountRosterStore import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.utils.Log -import okio.Path.Companion.toOkioPath -import java.io.File /** * The slice of the roster store this needs. @@ -169,17 +166,18 @@ class AccountRoster( } val accountRoster: AccountRoster by lazy { - val context = Amethyst.instance.appContext AccountRoster( EncryptedRosterStorage( AccountRosterStore( - PreferenceDataStoreFactory.createWithPath( - scope = Amethyst.instance.applicationIOScope, - produceFile = { File(context.filesDir, "datastore/roster.preferences_pb").toOkioPath() }, - ), + // Through the holder rather than a DataStore built here: it is the + // one registry that knows which files already have a live store, + // and `roster` sits in the same directory as every other one. + Amethyst.instance.appStores.getDataStore(ROSTER_FILE_NAME), SecretEncryption(), Amethyst.instance.applicationIOScope, ), ), ) } + +private const val ROSTER_FILE_NAME = "roster" diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 7f388ce450..4ef11c6fbd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -71,6 +71,7 @@ import com.vitorpamplona.amethyst.commons.tor.TorSettings import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever +import com.vitorpamplona.amethyst.model.nip60Cashu.CashuPreferences import com.vitorpamplona.amethyst.model.preferences.DrawerSectionCollapsePreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder @@ -251,8 +252,11 @@ class AppModules( AppPreferenceStores( rootFilesDir = { appContext.filesDir.toOkioPath() }, migrations = { name -> - when (name) { - AppPreferenceStores.SHARED_SETTINGS -> UiSettingsStore.migrations { LocalPreferences.loadSharedSettings() } + when { + name == AppPreferenceStores.SHARED_SETTINGS -> UiSettingsStore.migrations { LocalPreferences.loadSharedSettings() } + // One file per account, so the migration is per name rather than a constant. + name.startsWith(CashuPreferences.FILE_PREFIX) -> + listOf(CashuPreferences.legacyMigration(appContext, name.removePrefix(CashuPreferences.FILE_PREFIX))) else -> emptyList() } }, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt index 08f3b96ada..e856c3fe07 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuPreferences.kt @@ -21,15 +21,12 @@ package com.vitorpamplona.amethyst.model.nip60Cashu import android.content.Context -import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.longPreferencesKey import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.cashu.CashuKeysetCounterStore import com.vitorpamplona.amethyst.commons.cashu.DataStoreCashuCounterStore import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration import com.vitorpamplona.quartz.utils.cache.LargeCache -import okio.Path.Companion.toOkioPath -import java.io.File /** * Android's per-account NUT-13 counter store: the shared @@ -51,6 +48,11 @@ import java.io.File object CashuPreferences { private const val LEGACY_FILE_PREFIX = "cashu_prefs_" + /** The store file name for [npub], as AppPreferenceStores takes it. */ + const val FILE_PREFIX = "cashu_" + + fun fileName(npub: String) = FILE_PREFIX + npub + private val stores = LargeCache() /** @@ -60,16 +62,18 @@ object CashuPreferences { */ fun forAccount(npub: String): CashuKeysetCounterStore = stores.getOrCreate(npub) { - val context = Amethyst.instance.appContext - DataStoreCashuCounterStore( - PreferenceDataStoreFactory.createWithPath( - migrations = listOf(legacyMigration(context, npub)), - produceFile = { File(context.filesDir, "datastore/cashu_$npub.preferences_pb").toOkioPath() }, - ), - ) + DataStoreCashuCounterStore(Amethyst.instance.appStores.getDataStore(fileName(npub))) } - private fun legacyMigration( + /** + * The copy out of `cashu_prefs_`, wired to the file by AppModules + * rather than attached here. + * + * DataStore runs a file's migrations when that file is first opened, and + * the holder is what opens it, so the migration has to be registered with + * the holder or it would never run. + */ + fun legacyMigration( context: Context, npub: String, ) = CopyOnceMigration("migrated.cashuCounters") { out -> diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt index 3c8106602f..a71c28cd60 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt @@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runTest import okio.Path.Companion.toOkioPath import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull import org.junit.Assert.assertSame import org.junit.Assert.assertTrue import org.junit.Rule @@ -85,4 +86,39 @@ class AppPreferenceStoresTest { val expected = java.io.File(folder.root, "datastore/shared_settings.preferences_pb") assertTrue(expected.absolutePath, expected.exists()) } + + /** + * Migrations are chosen per file name, and the name reaches the chooser. + * + * Both users of this depend on it: shared_settings takes the UI copy, and + * the Cashu counters take a different migration per account because they + * are one file per npub. A holder that ignored the name, or applied one + * file's migration to another, would copy an account's counters into + * someone else's — and a counter that moves backwards costs real ecash. + */ + @Test + fun migrationsAreChosenPerFileNameAndTheNameIsPassedThrough() = + runTest { + val asked = mutableListOf() + val marker = stringPreferencesKey("from") + + val subject = + AppPreferenceStores( + rootFilesDir = { folder.root.toOkioPath() }, + migrations = { name -> + asked += name + if (name.startsWith("cashu_")) { + listOf(CopyOnceMigration("migrated.$name") { out -> out[marker] = name }) + } else { + emptyList() + } + }, + ) + + assertEquals("cashu_npubA", subject.getDataStore("cashu_npubA").data.first()[marker]) + assertEquals("cashu_npubB", subject.getDataStore("cashu_npubB").data.first()[marker]) + assertNull("a file with no migration must stay untouched", subject.sharedSettings().data.first()[marker]) + + assertTrue("cashu_npubA" in asked && "cashu_npubB" in asked && "shared_settings" in asked) + } } From deed14258668494db61dbd5251a7abeb3a88981a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 15:06:31 +0000 Subject: [PATCH 27/57] refactor: move the drawer collapse store into commons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last of the Context-bound preference stores. It already took a DataStore; what held it in amethyst was DrawerSectionId, which sat in DrawerSections.kt alongside the drawer's actual layout — `Res` strings, MaterialSymbols, android.os.Build. The enum and its name codec move to commons/model/navigation, next to NavBarItem, which the codec's own KDoc already said it mirrors. The layout stays where it is; only the 32 lines that were pure data moved. Its 9 tests move to commons with it. Also adds the `kotlinx.coroutines.IO` import the signer permission store needed. The JVM compile does not need it — Dispatchers.IO is a JVM property — so this only surfaced in compileCommonMainKotlinMetadata, which is the check that speaks for iOS. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 2 +- .../ui/navigation/drawer/DrawerContent.kt | 1 + .../ui/navigation/drawer/DrawerSections.kt | 34 +----------- .../loggedIn/settings/DrawerSettingsScreen.kt | 2 +- .../navigation/DrawerItemVisibilityTest.kt | 2 +- .../amethyst/navigation/DrawerSectionsTest.kt | 6 +-- .../DataStoreNostrSignerPermissionStore.kt | 1 + .../model/navigation/DrawerSectionId.kt | 54 +++++++++++++++++++ .../DrawerSectionCollapsePreferences.kt | 8 +-- .../DrawerSectionCollapsePreferencesTest.kt | 4 +- 10 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/navigation/DrawerSectionId.kt rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/model/preferences/DrawerSectionCollapsePreferences.kt (94%) rename {amethyst/src/test/java/com/vitorpamplona/amethyst => commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons}/model/preferences/DrawerSectionCollapsePreferencesTest.kt (97%) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 4ef11c6fbd..4b9342dc5f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -39,6 +39,7 @@ import com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores import com.vitorpamplona.amethyst.commons.model.preferences.BuzzAttestationStore import com.vitorpamplona.amethyst.commons.model.preferences.BuzzChannelStarStore import com.vitorpamplona.amethyst.commons.model.preferences.BuzzWorkspaceStore +import com.vitorpamplona.amethyst.commons.model.preferences.DrawerSectionCollapsePreferences import com.vitorpamplona.amethyst.commons.model.preferences.NamecoinSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.OtsSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.RelayGroupDeletionStore @@ -72,7 +73,6 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.model.nip60Cashu.CashuPreferences -import com.vitorpamplona.amethyst.model.preferences.DrawerSectionCollapsePreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.model.torState.AccountsTorStateConnector diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt index 77cf8b53a3..a48060d964 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt @@ -95,6 +95,7 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.ImmutableListOfLists import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.model.navigation.DrawerSectionId import com.vitorpamplona.amethyst.commons.model.navigation.NavBarItem import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerSections.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerSections.kt index 378e698010..34f372180d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerSections.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerSections.kt @@ -25,8 +25,8 @@ import androidx.compose.runtime.Immutable import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.navigation.DrawerItemVisibility +import com.vitorpamplona.amethyst.commons.model.navigation.DrawerSectionId import com.vitorpamplona.amethyst.commons.model.navigation.NavBarItem -import com.vitorpamplona.amethyst.commons.model.navigation.navBarItemsFromNames import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.drawer_section_create import com.vitorpamplona.amethyst.commons.resources.drawer_section_feeds @@ -69,38 +69,6 @@ data class DrawerSection( * copied — a `DrawerSections.map { it.copy(...) }` would silently defeat an `===` check, with no * compile error and nothing to fail a test. */ -enum class DrawerSectionId { - YOU, - NAVIGATE, - FEEDS, - - /** Composer entry points. Carries no catalog destinations, so nothing in it is configurable. */ - CREATE, - - /** Also renders the relay-status row, which isn't a catalog destination (it shows a live counter). */ - SYSTEM, -} - -private val DrawerSectionIdsByName = DrawerSectionId.entries.associateBy { it.name } - -/** - * Parses the persisted names of the headings the user has collapsed, silently dropping any this - * build doesn't know. Mirrors [com.vitorpamplona.amethyst.commons.model.navigation.navBarItemsFromNames]: - * names rather than ordinals, so reordering this enum renames nothing by accident, and a value left - * by a build with one more section costs that heading rather than the whole read. - * - * The stored set holds the **collapsed** headings rather than the expanded ones, for the same reason - * [DrawerItemVisibility] stores the hidden rows: a heading nobody has ever collapsed simply isn't in - * the set, so a section added in a later release opens expanded for everyone with no migration. - */ -fun drawerSectionIdsFromNames(names: Collection): Set = names.mapNotNullTo(mutableSetOf()) { DrawerSectionIdsByName[it] } - -/** - * The inverse of [drawerSectionIdsFromNames]. Unlike the NavBarItem codec this returns an unsorted - * Set rather than a sorted List: the destination is a DataStore string set, whose equality is - * already order-independent, so there is no serialized form to keep deterministic. - */ -fun Set.toNames(): Set = mapTo(mutableSetOf()) { it.name } private val DrawerNavigateItems: List = listOf( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/DrawerSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/DrawerSettingsScreen.kt index 10e0797d53..51d376c0bc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/DrawerSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/DrawerSettingsScreen.kt @@ -45,6 +45,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.model.navigation.DrawerSectionId import com.vitorpamplona.amethyst.commons.model.navigation.MandatoryDrawerItems import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.drawer_settings @@ -65,7 +66,6 @@ import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow import com.vitorpamplona.amethyst.ui.navigation.bottombars.NavBarCatalog import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSection -import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSectionId import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSectionVisibility import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSections import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerItemVisibilityTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerItemVisibilityTest.kt index 693f3c0d26..11ecb7f0f8 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerItemVisibilityTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerItemVisibilityTest.kt @@ -21,8 +21,8 @@ package com.vitorpamplona.amethyst.navigation import com.vitorpamplona.amethyst.commons.model.navigation.DrawerItemVisibility +import com.vitorpamplona.amethyst.commons.model.navigation.DrawerSectionId import com.vitorpamplona.amethyst.commons.model.navigation.NavBarItem -import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSectionId import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSectionVisibility import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSections import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.DrawerSettingsState diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerSectionsTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerSectionsTest.kt index b61e2d5e1f..49b0ed57b0 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerSectionsTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/navigation/DrawerSectionsTest.kt @@ -20,13 +20,13 @@ */ package com.vitorpamplona.amethyst.navigation +import com.vitorpamplona.amethyst.commons.model.navigation.DrawerSectionId import com.vitorpamplona.amethyst.commons.model.navigation.MandatoryDrawerItems +import com.vitorpamplona.amethyst.commons.model.navigation.drawerSectionIdsFromNames +import com.vitorpamplona.amethyst.commons.model.navigation.toNames import com.vitorpamplona.amethyst.ui.navigation.bottombars.NavBarCatalog -import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSectionId import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSections import com.vitorpamplona.amethyst.ui.navigation.drawer.SdkGatedDrawerItems -import com.vitorpamplona.amethyst.ui.navigation.drawer.drawerSectionIdsFromNames -import com.vitorpamplona.amethyst.ui.navigation.drawer.toNames import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStore.kt index 60bf4f7ffe..0efbba4b5e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/DataStoreNostrSignerPermissionStore.kt @@ -32,6 +32,7 @@ import com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.utils.sha256.sha256 import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO import kotlinx.coroutines.flow.first import kotlinx.coroutines.withContext diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/navigation/DrawerSectionId.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/navigation/DrawerSectionId.kt new file mode 100644 index 0000000000..cdb41678a5 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/navigation/DrawerSectionId.kt @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.model.navigation + +enum class DrawerSectionId { + YOU, + NAVIGATE, + FEEDS, + + /** Composer entry points. Carries no catalog destinations, so nothing in it is configurable. */ + CREATE, + + /** Also renders the relay-status row, which isn't a catalog destination (it shows a live counter). */ + SYSTEM, +} + +private val DrawerSectionIdsByName = DrawerSectionId.entries.associateBy { it.name } + +/** + * Parses the persisted names of the headings the user has collapsed, silently dropping any this + * build doesn't know. Mirrors [com.vitorpamplona.amethyst.commons.model.navigation.navBarItemsFromNames]: + * names rather than ordinals, so reordering this enum renames nothing by accident, and a value left + * by a build with one more section costs that heading rather than the whole read. + * + * The stored set holds the **collapsed** headings rather than the expanded ones, for the same reason + * [DrawerItemVisibility] stores the hidden rows: a heading nobody has ever collapsed simply isn't in + * the set, so a section added in a later release opens expanded for everyone with no migration. + */ +fun drawerSectionIdsFromNames(names: Collection): Set = names.mapNotNullTo(mutableSetOf()) { DrawerSectionIdsByName[it] } + +/** + * The inverse of [drawerSectionIdsFromNames]. Unlike the NavBarItem codec this returns an unsorted + * Set rather than a sorted List: the destination is a DataStore string set, whose equality is + * already order-independent, so there is no serialized form to keep deterministic. + */ +fun Set.toNames(): Set = mapTo(mutableSetOf()) { it.name } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferences.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferences.kt similarity index 94% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferences.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferences.kt index c29ae2cf13..6e7f5fd745 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferences.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferences.kt @@ -18,16 +18,16 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import androidx.compose.runtime.Stable import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringSetPreferencesKey -import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSectionId -import com.vitorpamplona.amethyst.ui.navigation.drawer.drawerSectionIdsFromNames -import com.vitorpamplona.amethyst.ui.navigation.drawer.toNames +import com.vitorpamplona.amethyst.commons.model.navigation.DrawerSectionId +import com.vitorpamplona.amethyst.commons.model.navigation.drawerSectionIdsFromNames +import com.vitorpamplona.amethyst.commons.model.navigation.toNames import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferencesTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferencesTest.kt similarity index 97% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferencesTest.kt rename to commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferencesTest.kt index d7c4aa0d4f..d453b47ee7 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/preferences/DrawerSectionCollapsePreferencesTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferencesTest.kt @@ -18,12 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.preferences +package com.vitorpamplona.amethyst.commons.model.preferences import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.PreferenceDataStoreFactory import androidx.datastore.preferences.core.Preferences -import com.vitorpamplona.amethyst.ui.navigation.drawer.DrawerSectionId +import com.vitorpamplona.amethyst.commons.model.navigation.DrawerSectionId import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.cancel From cdb4f1f76e32c194309b8fc2b26e001885bfcc01 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 15:39:35 +0000 Subject: [PATCH 28/57] ci: cap Gradle memory on the Android job; add AppPreferenceStores.release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two small things. **The Android job's memory.** gradle.properties asks for -Xmx6g (Gradle) plus -Xmx8g and 2g metaspace (Kotlin daemon). That is roughly 16GB of ceiling on a 16GB ubuntu-latest runner, before the launcher JVM, Lint's fork and the KSP workers are counted, and no CI job overrides it. test-and-build-android is the only job that comes near that ceiling — two lint variants, two flavours of unit tests, assembleBenchmark — and it is the only job that has died: five times, each one mid-compile or mid-lint rather than at a random moment, reported as "the runner has received a shutdown signal". That is what the Linux OOM killer taking the runner agent looks like from the outside, and it is the same configuration, on the same 16GB size, that repeatedly killed the Gradle daemon in the container this branch was developed in. Capped to 4g apiece for this job only, so local builds on bigger machines keep their headroom. 4g was verified to complete lintFdroidBenchmark and both unit-test tasks; it trades some build time for a job that finishes. This corrects an earlier guess of mine, posted on the PR, that `concurrency: cancel-in-progress` was behind these. It is not: a concurrency cancel ends with conclusion `cancelled`, and these are `failure`. The cancelled runs on main are a separate and expected effect of merging quickly. **AppPreferenceStores.release.** There was no way to let go of a store, so "write the file, reopen it, check what is on disk" was impossible — which is why the migration-guard test had to be driven against the DataMigration directly rather than through a real reopen. Mirrors AccountPreferenceStores.removeAccount, including the join: cancel() only asks, and DataStore's registry entry survives until the owning job actually completes. That detail produced "there are multiple DataStores active for the same file" twice in this codebase already. Production has no reason to call it; these stores live as long as the process. Two tests now use it, and the second is the one that was missing: a migration runs when the file is first opened and does NOT run again when a later instance opens the same file — the copy-once guarantee the Cashu counter and UI settings copies both rest on, checked the way it actually happens at runtime. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .github/workflows/build.yml | 16 +++++ .../model/preferences/AppPreferenceStores.kt | 29 ++++++++++ .../preferences/AppPreferenceStoresTest.kt | 58 +++++++++++++++++++ 3 files changed, 103 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17a402ae78..faf7452235 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -380,9 +380,25 @@ jobs: # variants are compile-equivalent for unit-test purposes; running all six # adds ~5× the kotlinc work without catching new defects on PRs. Push to # main still gets the full test matrix via the production-build path. + # Memory caps, CI-only. gradle.properties asks for -Xmx6g (Gradle) plus + # -Xmx8g and 2g metaspace (Kotlin daemon), which is ~16GB of ceiling on a + # 16GB ubuntu-latest runner before the launcher JVM, Lint's fork and the + # KSP workers are counted. Every other job stays well under it; this one + # runs two lint variants, two flavours of unit tests and + # assembleBenchmark, and it is the only job that has died — five times, + # each mid-compile or mid-lint, reported as "the runner has received a + # shutdown signal", which is what the Linux OOM killer taking the runner + # agent looks like from the outside. + # + # Overridden here rather than in gradle.properties so local builds on + # bigger machines keep the headroom. 4g apiece was verified to complete + # lintFdroidBenchmark and both unit-test tasks; it trades some build time + # for a job that finishes. - name: Test + Build Android (gradle) run: | ./gradlew \ + -Dorg.gradle.jvmargs="-Xmx4g -Dfile.encoding=UTF-8" \ + -Dkotlin.daemon.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=1g" \ :amethyst:lintFdroidBenchmark \ :amethyst:lintPlayBenchmark \ :quartz:jvmTest \ diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt index edf30e73e8..a188cb3719 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStores.kt @@ -30,6 +30,8 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.job import okio.Path /** @@ -117,6 +119,33 @@ class AppPreferenceStores( /** The file UI, Tor, OTS, Namecoin and friends share. */ fun sharedSettings(): DataStore = getDataStore(SHARED_SETTINGS) + /** + * Releases the store for [name], so the file can be opened again. + * + * DataStore keeps a process-wide registry keyed by path and refuses a second + * live instance, and `cancel()` only *asks* a scope to stop — the registry + * entry survives until the owning job actually completes, which is why this + * joins. Getting that wrong produced "there are multiple DataStores active + * for the same file" twice in this codebase already. + * + * Production has no reason to call this: these stores live as long as the + * process. It exists so a test can write a file, let go of it, and reopen it + * to check what is actually on disk — the one thing that was impossible + * before, and the reason the migration-guard test had to be driven against + * the DataMigration directly instead. + * + * Returns false if nothing was open under that name. + */ + suspend fun release(name: String): Boolean { + val entry = storeCache.get(name) ?: return false + + entry.scope.cancel() + entry.scope.coroutineContext.job + .join() + storeCache.remove(name) + return true + } + /** * The names of stores already on disk whose name starts with [prefix]. * diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt index a71c28cd60..59dfcefb7a 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AppPreferenceStoresTest.kt @@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.test.runTest import okio.Path.Companion.toOkioPath import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse import org.junit.Assert.assertNull import org.junit.Assert.assertSame import org.junit.Assert.assertTrue @@ -121,4 +122,61 @@ class AppPreferenceStoresTest { assertTrue("cashu_npubA" in asked && "cashu_npubB" in asked && "shared_settings" in asked) } + + /** + * Releasing a store lets the same file be opened again. + * + * DataStore's registry is keyed by path and `cancel()` only asks, so this is + * only safe because [AppPreferenceStores.release] joins the scope's job. + * Without the join this test is exactly the "multiple DataStores active for + * the same file" crash. + */ + @Test + fun aReleasedStoreCanBeReopenedAndStillHasItsData() = + runTest { + val key = stringPreferencesKey("k") + val subject = stores() + + subject.getDataStore("reopen").edit { it[key] = "written once" } + + assertTrue("something was open", subject.release("reopen")) + assertFalse("and now nothing is", subject.release("reopen")) + + // a genuinely new instance over the same file + val reopened = subject.getDataStore("reopen") + assertEquals("written once", reopened.data.first()[key]) + } + + /** + * The guard the Cashu and UI copies both rest on, now checked the way it + * actually happens at runtime: the migration runs when the file is first + * opened, and must not run again when a later instance opens the same file. + */ + @Test + fun aMigrationRunsOnceEvenAcrossAReopen() = + runTest { + val marker = stringPreferencesKey("copied") + var runs = 0 + + val subject = + AppPreferenceStores( + rootFilesDir = { folder.root.toOkioPath() }, + migrations = { + listOf( + CopyOnceMigration("migrated.once") { out -> + runs++ + out[marker] = "run $runs" + }, + ) + }, + ) + + assertEquals("run 1", subject.getDataStore("once").data.first()[marker]) + assertEquals(1, runs) + + subject.release("once") + + assertEquals("still the first copy", "run 1", subject.getDataStore("once").data.first()[marker]) + assertEquals("the migration must not run a second time", 1, runs) + } } From c47b9e50a8cea7b9fbfaaf198f68c9882dd0d57e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 15:54:28 +0000 Subject: [PATCH 29/57] fix: join cancelled scopes in the store tests before reopening the file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `:commons:jvmTest` failed on CI with IllegalStateException from DataStore's FileStorage — "multiple DataStores active for the same file" — in TopNavFollowListStoreTest.migrationDoesNotClobberLaterEdits. It has passed locally every time, including under this branch's own verification. It is a race, not a change in behaviour. The test cancels the scope owning one DataStore and immediately opens another on the same file, and `cancel()` only *asks*: DataStore's registry keeps the entry until the owning job actually completes. On an idle machine the cancellation wins; on a loaded runner it does not. The same shape was in two more tests that also reopen a file right after cancelling — EncryptedDataStoreTest and DrawerSectionCollapsePreferences- Test — so all three are fixed rather than just the one that happened to fire. On a real dispatcher the fix is `job.join()`; on a test dispatcher it is `advanceUntilIdle()`, which is the same guarantee. LegacyKeyTableTest already joined. This is the third time this exact rule has cost something in this codebase: twice in production code (AccountPreferenceStores.removeAccount, and the per-account holder in AccountCacheState) and now in the tests. AppPreferenceStores.release, added in the previous commit, exists to give tests one correct way to do it. Verified by rerunning the three classes three times under saturating CPU load, which is the condition that makes the cancellation lose. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../preferences/DrawerSectionCollapsePreferencesTest.kt | 4 ++++ .../commons/model/preferences/EncryptedDataStoreTest.kt | 2 ++ .../commons/model/preferences/TopNavFollowListStoreTest.kt | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferencesTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferencesTest.kt index d453b47ee7..83bfc0a5b9 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferencesTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/DrawerSectionCollapsePreferencesTest.kt @@ -59,7 +59,11 @@ class DrawerSectionCollapsePreferencesTest { advanceUntilIdle() prefs.taps() advanceUntilIdle() + // On the test dispatcher advanceUntilIdle is the join: cancel() only + // asks, and the next session() opens the same file, which DataStore + // refuses while the previous instance is still winding down. scope.cancel() + advanceUntilIdle() return prefs.flow.value } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt index 97c2b6ec3a..07b4a055f4 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/EncryptedDataStoreTest.kt @@ -27,6 +27,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel +import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest import okio.Path.Companion.toOkioPath import org.junit.Assert.assertEquals @@ -158,6 +159,7 @@ class EncryptedDataStoreTest { ) subject.save(key, "a real value") scope.cancel() + scope.coroutineContext.job.join() // Truncate the store so opening it fails rather than reading empty. dataFile.writeBytes(byteArrayOf(0x01, 0x02, 0x03)) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt index 1a08dc1eb7..f0fa524877 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/TopNavFollowListStoreTest.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel +import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest import okio.Path.Companion.toOkioPath import org.junit.Assert.assertEquals @@ -206,7 +207,12 @@ class TopNavFollowListStoreTest { ), ) } finally { + // cancel() only asks. DataStore's registry keeps the entry until + // the owning job actually completes, so without this join the + // next open of the same file races it — which is what failed on + // a loaded CI runner while passing locally every time. scope.cancel() + scope.coroutineContext.job.join() } } From d1995108233bd5b5895640cb5a1493c9495e4e5e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 17:20:39 +0000 Subject: [PATCH 30/57] style: sort the relocated Tor label imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fallout from moving TorSettingsLabels into commons/tor during the main reconciliation. The import paths were rewritten in place, which left `commons.tor.explainerId` and `commons.tor.resourceId` sitting where the old `commons.ui.settings.*` lines had been — after the `commons.ui.*` block rather than with their own package. Spotless sorts them back. No behaviour change; the same extensions were already resolving. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt | 4 ++-- .../com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt index c607da873a..5ecce348ac 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/privacy/PrivacyOptionsScreen.kt @@ -91,6 +91,8 @@ import com.vitorpamplona.amethyst.commons.resources.use_internal_tor_explainer import com.vitorpamplona.amethyst.commons.tor.TorPresetType import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow import com.vitorpamplona.amethyst.commons.tor.TorType +import com.vitorpamplona.amethyst.commons.tor.explainerId +import com.vitorpamplona.amethyst.commons.tor.resourceId import com.vitorpamplona.amethyst.commons.tor.torDefaultPreset import com.vitorpamplona.amethyst.commons.tor.torFullyPrivate import com.vitorpamplona.amethyst.commons.tor.torOnlyWhenNeededPreset @@ -101,8 +103,6 @@ import com.vitorpamplona.amethyst.commons.ui.components.TitleExplainer import com.vitorpamplona.amethyst.commons.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton -import com.vitorpamplona.amethyst.commons.tor.explainerId -import com.vitorpamplona.amethyst.commons.tor.resourceId import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SegmentedChoiceTile diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt index 161362b619..415d54252d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/tor/TorSettingsDialog.kt @@ -80,12 +80,12 @@ import com.vitorpamplona.amethyst.commons.resources.use_internal_tor_explainer import com.vitorpamplona.amethyst.commons.tor.TorPresetType import com.vitorpamplona.amethyst.commons.tor.TorSettings import com.vitorpamplona.amethyst.commons.tor.TorType +import com.vitorpamplona.amethyst.commons.tor.explainerId import com.vitorpamplona.amethyst.commons.tor.parseTorPresetType import com.vitorpamplona.amethyst.commons.tor.parseTorType +import com.vitorpamplona.amethyst.commons.tor.resourceId import com.vitorpamplona.amethyst.commons.ui.components.TitleExplainer import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.SavingTopBar -import com.vitorpamplona.amethyst.commons.tor.explainerId -import com.vitorpamplona.amethyst.commons.tor.resourceId import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.Size10dp import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn From ea459bc51e503e3a3a52a19d44c3d1b1287f4c95 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 17:22:12 +0000 Subject: [PATCH 31/57] ci: cut only the Kotlin daemon heap, not Gradle's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correcting cdb4f1f7, which capped both to 4g and traded one OOM for another. The diagnosis was right: test-and-build-android was dying of memory. gradle.properties asks for -Xmx6g (Gradle) plus -Xmx8g and 2g metaspace (Kotlin daemon), roughly 16GB of ceiling on a 16GB runner, and that job is the only one heavy enough to reach it. Capping both did stop the runner deaths — the job ran 61 minutes and reached R8 and lint, where it used to die at 11 to 14 minutes during compile. But it then failed with java.lang.OutOfMemoryError: Java heap space in minifyPlayBenchmarkWithR8 and lintAnalyzePlayBenchmark. Both draw on the Gradle daemon's heap, and 4g is not enough for them on this app. 6g always was — they never OOMed in the five earlier runs; the system did. So the cut belongs entirely on the Kotlin daemon: 8g + 2g metaspace down to 4g + 1g, Gradle left at its 6g default. Total ceiling ~11GB instead of ~16GB, which leaves the runner headroom without starving R8. Confirmation signals stay falsifiable: if the runner dies early again, the ceiling is still too high; if R8 or lint OOM again, 6g is not enough either and the job needs splitting rather than tuning. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .github/workflows/build.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index faf7452235..1a123e7e16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -380,24 +380,25 @@ jobs: # variants are compile-equivalent for unit-test purposes; running all six # adds ~5× the kotlinc work without catching new defects on PRs. Push to # main still gets the full test matrix via the production-build path. - # Memory caps, CI-only. gradle.properties asks for -Xmx6g (Gradle) plus - # -Xmx8g and 2g metaspace (Kotlin daemon), which is ~16GB of ceiling on a - # 16GB ubuntu-latest runner before the launcher JVM, Lint's fork and the - # KSP workers are counted. Every other job stays well under it; this one - # runs two lint variants, two flavours of unit tests and - # assembleBenchmark, and it is the only job that has died — five times, - # each mid-compile or mid-lint, reported as "the runner has received a - # shutdown signal", which is what the Linux OOM killer taking the runner - # agent looks like from the outside. + # Memory, CI-only. gradle.properties asks for -Xmx6g (Gradle) plus -Xmx8g + # and 2g metaspace (Kotlin daemon) — about 16GB of ceiling on a 16GB + # ubuntu-latest runner, before the launcher JVM, Lint's fork and the KSP + # workers. This job is the only one heavy enough to reach it, and it died + # five times mid-compile with "the runner has received a shutdown signal", + # which is the OOM killer taking the runner agent. + # + # Only the Kotlin daemon is cut. An earlier attempt capped BOTH to 4g and + # traded one OOM for another: the runner survived and the job ran to + # completion, but R8 and lintAnalyze then failed with + # "java.lang.OutOfMemoryError: Java heap space" — they draw on the Gradle + # daemon's heap, and 4g is not enough for them on this app. 6g always was, + # so it stays; 8g + 2g for kotlinc is the part that did not fit. # # Overridden here rather than in gradle.properties so local builds on - # bigger machines keep the headroom. 4g apiece was verified to complete - # lintFdroidBenchmark and both unit-test tasks; it trades some build time - # for a job that finishes. + # bigger machines keep the headroom. - name: Test + Build Android (gradle) run: | ./gradlew \ - -Dorg.gradle.jvmargs="-Xmx4g -Dfile.encoding=UTF-8" \ -Dkotlin.daemon.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=1g" \ :amethyst:lintFdroidBenchmark \ :amethyst:lintPlayBenchmark \ From 2539e5103521014d7dae61205f491a7c6e3d3744 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 22:42:22 +0000 Subject: [PATCH 32/57] refactor: take the last nine DataStores off the Context delegate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every other store in the app now opens through AppPreferenceStores; these nine were still on androidx's `Context.preferencesDataStore`, which is the pattern the rest of this branch removed. They are the stores behind the napplet sandbox, the in-app browser, favorites, chess dismissals and the two calendar-reminder files. The names are unchanged, and that is the whole safety argument. The holder reproduces `filesDir/datastore/.preferences_pb`, which is exactly what the delegate resolved to, so every one of these opens the file it was already using: nothing migrates, and a rollback finds its data where it left it. A typo in one of these strings would silently orphan that store's data rather than fail, so they were copied across verbatim. The calendar migrations moved with their files. DataStore runs a file's migrations once, when that file is first opened, so they have to be attached to the file by the holder rather than by whichever caller happens to open it first — the same reason shared_settings' migration lives there. Two shapes changed rather than being mechanically translated: - The registries' `Context` receiver is gone. These stores are app-scoped now, so a receiver the body ignores would claim a dependency that is not real. The `appContext ?: return` guards stay: they mean "init() has run", which is still true and still worth keeping. - DataStoreNappletStorage and DataStoreNappletPermissionStore lose their Context secondary constructors instead of keeping an unused parameter. Both call sites pass the store directly. On the process boundary, since Amethyst.instance is deliberately unset in the `:napplet` sandbox and reaching it there throws: all four components declared `android:process=":napplet"` are napplethost.* classes from the :nappletHost module, NappletBrokerService declares no process and so runs in main, and onCreate's sandbox early-return precedes the one WebAppNetworkRegistry.init() call. All nine stores are main-process only. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 14 +++- .../favorites/BrowserHistoryRegistry.kt | 20 +++-- .../favorites/FavoriteAppsRegistry.kt | 24 ++++-- .../DataStoreNappletPermissionStore.kt | 7 -- .../napplet/DataStoreNappletStorage.kt | 7 -- .../amethyst/napplet/NappletBrokerService.kt | 2 +- .../napplet/NappletNetworkRegistry.kt | 20 +++-- .../amethyst/napplet/WebAppNetworkRegistry.kt | 21 ++++-- .../calendar/CalendarReminderStores.kt | 74 ++++++++++--------- .../calendar/CalendarReminderWorker.kt | 4 +- .../CalendarReminderSettingsScreen.kt | 2 +- .../loggedIn/chess/ChessDismissedGamesData.kt | 8 +- .../loggedIn/chess/ChessViewModelNew.kt | 2 +- 13 files changed, 124 insertions(+), 81 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 431f57e5c3..26697a4fcb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -79,8 +79,12 @@ import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilde import com.vitorpamplona.amethyst.model.torState.AccountsTorStateConnector import com.vitorpamplona.amethyst.model.torState.TorRelayState import com.vitorpamplona.amethyst.napplet.DataStoreNappletPermissionStore +import com.vitorpamplona.amethyst.service.calendar.CALENDAR_REMINDER_LOG_STORE +import com.vitorpamplona.amethyst.service.calendar.CALENDAR_REMINDER_SETTINGS_STORE import com.vitorpamplona.amethyst.service.calendar.CalendarReminderWorker +import com.vitorpamplona.amethyst.service.calendar.calendarReminderLogMigrations import com.vitorpamplona.amethyst.service.calendar.calendarReminderSettings +import com.vitorpamplona.amethyst.service.calendar.calendarReminderSettingsMigrations import com.vitorpamplona.amethyst.service.cast.CastRegistry import com.vitorpamplona.amethyst.service.connectivity.ConnectivityManager import com.vitorpamplona.amethyst.service.crashreports.CrashReportCache @@ -257,6 +261,8 @@ class AppModules( // One file per account, so the migration is per name rather than a constant. name.startsWith(CashuPreferences.FILE_PREFIX) -> listOf(CashuPreferences.legacyMigration(appContext, name.removePrefix(CashuPreferences.FILE_PREFIX))) + name == CALENDAR_REMINDER_SETTINGS_STORE -> calendarReminderSettingsMigrations(appContext) + name == CALENDAR_REMINDER_LOG_STORE -> calendarReminderLogMigrations(appContext) else -> emptyList() } }, @@ -855,8 +861,10 @@ class AppModules( */ val nappletAccountScope: () -> String = { sessionManager.loggedInAccount()?.pubKey ?: "" } - // Singleton stores for napplet permissions — DataStore v1 enforces one instance per file. - val nappletPermissionStore by lazy { DataStoreNappletPermissionStore(appContext, nappletAccountScope) } + // Singleton stores for napplet permissions. The holder is what enforces + // DataStore's one-instance-per-file rule now; this stays a lazy val so the + // ledger below and the broker share one object. + val nappletPermissionStore by lazy { DataStoreNappletPermissionStore(appStores.getDataStore("napplet_permissions"), nappletAccountScope) } /** * The one napplet permission ledger for the main process. Its persistent half is just the store @@ -1347,7 +1355,7 @@ class AppModules( Filter(kinds = listOf(CalendarDateSlotEvent.KIND, CalendarTimeSlotEvent.KIND)), ).conflate() .collect { - if (appContext.calendarReminderSettings().load().enabled && + if (calendarReminderSettings().load().enabled && CalendarReminderWorker.couldStillFire(CalendarReminderWorker.acceptedRsvpsInCache(), TimeUtils.now()) ) { CalendarReminderWorker.schedule(appContext) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserHistoryRegistry.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserHistoryRegistry.kt index 5564139886..e9988b23e7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserHistoryRegistry.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserHistoryRegistry.kt @@ -21,9 +21,11 @@ package com.vitorpamplona.amethyst.favorites import android.content.Context +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import androidx.datastore.preferences.preferencesDataStore +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.browser.OmniboxInput import com.vitorpamplona.quartz.nip01Core.core.JsonMapper import com.vitorpamplona.quartz.utils.Log @@ -37,7 +39,15 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import kotlinx.serialization.Serializable -private val Context.browserHistoryDataStore by preferencesDataStore(name = "browser_history") +/** + * The browser-history file, on the app-wide holder rather than a `Context` delegate. + * Same path the delegate resolved to, so nothing migrates. + * + * Main process only: [Amethyst.instance] is deliberately unset in the + * `:napplet` sandbox. + */ +private val browserHistoryDataStore: DataStore + get() = Amethyst.instance.appStores.getDataStore("browser_history") /** * One device-local visited site, keyed by full [url]. [visitCount]/[lastVisitedAt] drive frecency ranking @@ -83,7 +93,7 @@ object BrowserHistoryRegistry { val ctx = context.applicationContext appContext = ctx scope.launch { - val json = ctx.browserHistoryDataStore.data.first()[KEY] + val json = browserHistoryDataStore.data.first()[KEY] val loaded = if (json != null) decode(json) else emptyList() // Merge disk under anything already recorded this session (session wins, newest-first). update { current -> dedupeNewestFirst(current + loaded) } @@ -136,9 +146,9 @@ object BrowserHistoryRegistry { } private fun persist(json: String) { - val ctx = appContext ?: return + appContext ?: return scope.launch { - ctx.browserHistoryDataStore.edit { it[KEY] = json } + browserHistoryDataStore.edit { it[KEY] = json } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppsRegistry.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppsRegistry.kt index 99e36cf19b..ad9d03d325 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppsRegistry.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppsRegistry.kt @@ -21,9 +21,11 @@ package com.vitorpamplona.amethyst.favorites import android.content.Context +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import androidx.datastore.preferences.preferencesDataStore +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp import com.vitorpamplona.quartz.nip01Core.core.JsonMapper import com.vitorpamplona.quartz.utils.Log @@ -38,7 +40,15 @@ import kotlinx.coroutines.launch import kotlinx.serialization.Serializable import java.util.concurrent.ConcurrentHashMap -private val Context.favoriteAppsDataStore by preferencesDataStore(name = "favorite_apps") +/** + * The favorite-apps file, on the app-wide holder rather than a `Context` delegate. + * Same path the delegate resolved to, so nothing migrates. + * + * Main process only: [Amethyst.instance] is deliberately unset in the + * `:napplet` sandbox. + */ +private val favoriteAppsDataStore: DataStore + get() = Amethyst.instance.appStores.getDataStore("favorite_apps") /** * The user's device-local list of [FavoriteApp]s — the single source of truth shared by the bottom @@ -81,7 +91,7 @@ object FavoriteAppsRegistry { val ctx = context.applicationContext appContext = ctx scope.launch { - val prefs = ctx.favoriteAppsDataStore.data.first() + val prefs = favoriteAppsDataStore.data.first() val loaded = prefs[KEY]?.let { decode(it) } ?: emptyList() // Don't clobber adds made in this session before hydration finished, and don't resurrect // anything the user removed in that same window. @@ -139,16 +149,16 @@ object FavoriteAppsRegistry { } private fun persist(json: String) { - val ctx = appContext ?: return + appContext ?: return scope.launch { - ctx.favoriteAppsDataStore.edit { it[KEY] = json } + favoriteAppsDataStore.edit { it[KEY] = json } } } private fun persistManifests(json: String) { - val ctx = appContext ?: return + appContext ?: return scope.launch { - ctx.favoriteAppsDataStore.edit { it[MANIFESTS_KEY] = json } + favoriteAppsDataStore.edit { it[MANIFESTS_KEY] = json } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletPermissionStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletPermissionStore.kt index 073d458f83..7550c41334 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletPermissionStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletPermissionStore.kt @@ -20,19 +20,15 @@ */ package com.vitorpamplona.amethyst.napplet -import android.content.Context import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import androidx.datastore.preferences.preferencesDataStore import com.vitorpamplona.amethyst.commons.napplet.NappletCapability import com.vitorpamplona.amethyst.commons.napplet.permissions.GrantState import com.vitorpamplona.amethyst.commons.napplet.permissions.NappletPermissionStore import kotlinx.coroutines.flow.first -private val Context.nappletPermissionsDataStore by preferencesDataStore(name = "napplet_permissions") - /** * Persists the standing napplet grants ([GrantState.ALLOW_ALWAYS] / [GrantState.DENY]) in a * dedicated DataStore. Keyed by `"\u0000"` so a coordinate's grants can @@ -43,9 +39,6 @@ class DataStoreNappletPermissionStore( private val dataStore: DataStore, private val accountPubKey: () -> String, ) : NappletPermissionStore { - constructor(context: Context, accountPubKey: () -> String) : - this(context.applicationContext.nappletPermissionsDataStore, accountPubKey) - /** * Grants belong to one account. [accountPubKey] is read at call time, so an account switch moves * every read and write to that account's namespace with no rebuild — a grant made by one account diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletStorage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletStorage.kt index 14d3499371..4c3141b6e4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletStorage.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/DataStoreNappletStorage.kt @@ -20,17 +20,13 @@ */ package com.vitorpamplona.amethyst.napplet -import android.content.Context import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import androidx.datastore.preferences.preferencesDataStore import com.vitorpamplona.amethyst.commons.napplet.NappletStorage import kotlinx.coroutines.flow.first -private val Context.nappletStorageDataStore by preferencesDataStore(name = "napplet_storage") - /** * DataStore-backed [NappletStorage]. Every key is prefixed with the **active account** and then the * applet's coordinate, so one napplet's keys can never collide with another's, one account's data is @@ -44,9 +40,6 @@ class DataStoreNappletStorage( private val dataStore: DataStore, private val accountPubKey: () -> String, ) : NappletStorage { - constructor(context: Context, accountPubKey: () -> String) : - this(context.applicationContext.nappletStorageDataStore, accountPubKey) - override suspend fun get( coordinate: String, key: String, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt index de5815af52..7f98885be1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt @@ -90,7 +90,7 @@ class NappletBrokerService : Service() { private val signerLedger by lazy { NostrSignerPermissionLedger(Amethyst.instance.signerPermissionStore) } // Per-applet sandboxed key-value store (namespaced by account + coordinate inside the impl). - private val storage by lazy { DataStoreNappletStorage(applicationContext, Amethyst.instance.nappletAccountScope) } + private val storage by lazy { DataStoreNappletStorage(Amethyst.instance.appStores.getDataStore("napplet_storage"), Amethyst.instance.nappletAccountScope) } private val incoming by lazy { Messenger(Handler(Looper.getMainLooper(), ::handleMessage)) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletNetworkRegistry.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletNetworkRegistry.kt index 3dc4e46da8..1e95e1fb02 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletNetworkRegistry.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletNetworkRegistry.kt @@ -21,9 +21,11 @@ package com.vitorpamplona.amethyst.napplet import android.content.Context +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import androidx.datastore.preferences.preferencesDataStore +import com.vitorpamplona.amethyst.Amethyst import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -32,7 +34,15 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import java.util.concurrent.ConcurrentHashMap -private val Context.nappletNetworkDataStore by preferencesDataStore(name = "napplet_network") +/** + * The per-napplet routing file, on the app-wide holder rather than a `Context` delegate. + * Same path the delegate resolved to, so nothing migrates. + * + * Main process only: [Amethyst.instance] is deliberately unset in the + * `:napplet` sandbox. + */ +private val nappletNetworkDataStore: DataStore + get() = Amethyst.instance.appStores.getDataStore("napplet_network") /** * Per-nSite network-routing preference: whether a site's traffic goes through **Tor** (the default) @@ -69,7 +79,7 @@ object NappletNetworkRegistry { appContext = ctx hydration = scope.launch { - ctx.nappletNetworkDataStore.data.first().asMap().forEach { (key, value) -> + nappletNetworkDataStore.data.first().asMap().forEach { (key, value) -> // putIfAbsent: never clobber a choice made in this session before hydration finished. modes.putIfAbsent(key.name, value != OPEN_WEB) } @@ -95,9 +105,9 @@ object NappletNetworkRegistry { useTor: Boolean, ) { modes[coordinate] = useTor - val ctx = appContext ?: return + appContext ?: return scope.launch { - ctx.nappletNetworkDataStore.edit { it[stringPreferencesKey(coordinate)] = if (useTor) TOR else OPEN_WEB } + nappletNetworkDataStore.edit { it[stringPreferencesKey(coordinate)] = if (useTor) TOR else OPEN_WEB } } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/WebAppNetworkRegistry.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/WebAppNetworkRegistry.kt index 2038417d1a..a274fb036c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/WebAppNetworkRegistry.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/WebAppNetworkRegistry.kt @@ -22,9 +22,11 @@ package com.vitorpamplona.amethyst.napplet import android.content.Context import androidx.core.net.toUri +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import androidx.datastore.preferences.preferencesDataStore +import com.vitorpamplona.amethyst.Amethyst import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -33,7 +35,16 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import java.util.concurrent.ConcurrentHashMap -private val Context.webUrlNetworkDataStore by preferencesDataStore(name = "weburl_network") +/** + * The per-site routing file, on the app-wide holder rather than a `Context` + * delegate. Same path the delegate resolved to, so nothing migrates. + * + * Main process only: [Amethyst.instance] is deliberately unset in the + * `:napplet` sandbox, and this registry is only touched from the browser + * chrome that runs in the main process. + */ +private val webUrlNetworkDataStore: DataStore + get() = Amethyst.instance.appStores.getDataStore("weburl_network") /** * Per-web-client network-routing preference: whether a favorited URL / browsed site routes through @@ -67,7 +78,7 @@ object WebAppNetworkRegistry { appContext = ctx hydration = scope.launch { - ctx.webUrlNetworkDataStore.data.first().asMap().forEach { (key, value) -> + webUrlNetworkDataStore.data.first().asMap().forEach { (key, value) -> // putIfAbsent: never clobber a choice made in this session before hydration finished. modes.putIfAbsent(key.name, value != OPEN_WEB) } @@ -98,9 +109,9 @@ object WebAppNetworkRegistry { ) { val host = hostKeyOf(url) modes[host] = useTor - val ctx = appContext ?: return + appContext ?: return scope.launch { - ctx.webUrlNetworkDataStore.edit { it[stringPreferencesKey(host)] = if (useTor) TOR else OPEN_WEB } + webUrlNetworkDataStore.edit { it[stringPreferencesKey(host)] = if (useTor) TOR else OPEN_WEB } } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt index e7105b31b8..e430a79bc0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderStores.kt @@ -21,9 +21,11 @@ package com.vitorpamplona.amethyst.service.calendar import android.content.Context +import androidx.datastore.core.DataMigration +import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.intPreferencesKey -import androidx.datastore.preferences.preferencesDataStore +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.preferences.CalendarReminderLogStore import com.vitorpamplona.amethyst.commons.model.preferences.CalendarReminderSettings import com.vitorpamplona.amethyst.commons.model.preferences.CalendarReminderSettingsStore @@ -34,43 +36,47 @@ import com.vitorpamplona.amethyst.commons.model.preferences.CopyOnceMigration * * The store classes live in commons; only the file location and the one-off * lift out of the legacy SharedPreferences are Android's business. + * + * Both files sit on `AppPreferenceStores` rather than a `Context` delegate. + * The names below are the delegate's names, and the holder reproduces the path + * it resolved to, so nothing migrates. The migrations move with them: DataStore + * runs a file's migrations once, when that file is first opened, so they have + * to be attached to the file by the holder rather than by whoever opens it. */ private const val LEGACY_SETTINGS_FILE = "amethyst_calendar_reminder_prefs" private const val LEGACY_LOG_FILE = "amethyst_calendar_reminders" -private val Context.calendarReminderSettingsData by preferencesDataStore( - name = "calendar_reminder_settings", - produceMigrations = { context -> - listOf( - CopyOnceMigration("migrated.calendarReminderSettings") { out -> - val legacy = context.getSharedPreferences(LEGACY_SETTINGS_FILE, Context.MODE_PRIVATE) - if (legacy.contains("enabled")) { - out[booleanPreferencesKey("enabled")] = legacy.getBoolean("enabled", CalendarReminderSettings.DEFAULT_ENABLED) - } - if (legacy.contains("lead_minutes")) { - out[intPreferencesKey("lead_minutes")] = legacy.getInt("lead_minutes", CalendarReminderSettings.DEFAULT_LEAD_MINUTES) - } - }, - ) - }, -) +/** Store (and file) names, as [Amethyst.appStores] keys them. */ +const val CALENDAR_REMINDER_SETTINGS_STORE = "calendar_reminder_settings" +const val CALENDAR_REMINDER_LOG_STORE = "calendar_reminder_log" -private val Context.calendarReminderLogData by preferencesDataStore( - name = "calendar_reminder_log", - produceMigrations = { context -> - listOf( - CopyOnceMigration("migrated.calendarReminderLog") { out -> - val legacy = context.getSharedPreferences(LEGACY_LOG_FILE, Context.MODE_PRIVATE) - // Values are the event-start times the reminders fired for; anything - // else in the file is not ours and is left behind. - legacy.all.forEach { (key, value) -> - if (value is Long) out[CalendarReminderLogStore.keyFor(key.removePrefix("notified:"))] = value - } - }, - ) - }, -) +/** The one-off copy of the reminder settings out of the legacy prefs file. */ +fun calendarReminderSettingsMigrations(context: Context): List> = + listOf( + CopyOnceMigration("migrated.calendarReminderSettings") { out -> + val legacy = context.getSharedPreferences(LEGACY_SETTINGS_FILE, Context.MODE_PRIVATE) + if (legacy.contains("enabled")) { + out[booleanPreferencesKey("enabled")] = legacy.getBoolean("enabled", CalendarReminderSettings.DEFAULT_ENABLED) + } + if (legacy.contains("lead_minutes")) { + out[intPreferencesKey("lead_minutes")] = legacy.getInt("lead_minutes", CalendarReminderSettings.DEFAULT_LEAD_MINUTES) + } + }, + ) -fun Context.calendarReminderSettings() = CalendarReminderSettingsStore(calendarReminderSettingsData) +/** The one-off copy of the fired-reminder log out of the legacy prefs file. */ +fun calendarReminderLogMigrations(context: Context): List> = + listOf( + CopyOnceMigration("migrated.calendarReminderLog") { out -> + val legacy = context.getSharedPreferences(LEGACY_LOG_FILE, Context.MODE_PRIVATE) + // Values are the event-start times the reminders fired for; anything + // else in the file is not ours and is left behind. + legacy.all.forEach { (key, value) -> + if (value is Long) out[CalendarReminderLogStore.keyFor(key.removePrefix("notified:"))] = value + } + }, + ) -fun Context.calendarReminderLog() = CalendarReminderLogStore(calendarReminderLogData) +fun calendarReminderSettings() = CalendarReminderSettingsStore(Amethyst.instance.appStores.getDataStore(CALENDAR_REMINDER_SETTINGS_STORE)) + +fun calendarReminderLog() = CalendarReminderLogStore(Amethyst.instance.appStores.getDataStore(CALENDAR_REMINDER_LOG_STORE)) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt index 40e1134f8d..b3f34ae3ce 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/calendar/CalendarReminderWorker.kt @@ -65,7 +65,7 @@ class CalendarReminderWorker( ) : CoroutineWorker(appContext, params) { override suspend fun doWork(): Result { runCatching { Amethyst.instance.resourceUsage.add(UsageKeys.workerRuns("calendarReminder"), 1) } - val settings = applicationContext.calendarReminderSettings().load() + val settings = calendarReminderSettings().load() if (!settings.enabled) { Log.d(TAG) { "Reminders disabled; ending periodic chain." } // The settings toggle re-schedules on enable; no reason to keep @@ -75,7 +75,7 @@ class CalendarReminderWorker( } val now = TimeUtils.now() val windowEnd = now + settings.leadMinutes * 60L - val store = applicationContext.calendarReminderLog() + val store = calendarReminderLog() // Walk every kind-31925 RSVP authored by an account on this device. We don't have a // multi-account "all logged-in pubkeys" view here, so we accept any RSVP that's diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt index ce1888a33d..1115110ab4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarReminderSettingsScreen.kt @@ -68,7 +68,7 @@ import kotlinx.coroutines.launch fun CalendarReminderSettingsScreen(nav: INav) { val context = LocalContext.current val scope = rememberCoroutineScope() - val store = remember(context) { context.calendarReminderSettings() } + val store = remember { calendarReminderSettings() } // DataStore reads are suspend, so the first frame renders the defaults and // the stored values arrive right after. Collecting the flow rather than diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt index dc63800518..a0cba559e4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessDismissedGamesData.kt @@ -20,8 +20,9 @@ */ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chess -import android.content.Context -import androidx.datastore.preferences.preferencesDataStore +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import com.vitorpamplona.amethyst.Amethyst /** * Where Android keeps the dismissed-chess-games store. @@ -31,4 +32,5 @@ import androidx.datastore.preferences.preferencesDataStore * data over is not worth the code. Anyone who had dismissed a game sees it once * more and dismisses it again. */ -internal val Context.chessDismissedGamesData by preferencesDataStore(name = "chess_dismissed_games_v2") +internal val chessDismissedGamesData: DataStore + get() = Amethyst.instance.appStores.getDataStore("chess_dismissed_games_v2") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt index ae46d80463..9bd3819de4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chess/ChessViewModelNew.kt @@ -61,7 +61,7 @@ class ChessViewModelNew( private val publisher = AndroidChessPublisher(account) private val fetcher = AndroidRelayFetcher(account) private val metadataProvider = AndroidMetadataProvider() - private val dismissedStorage = ChessDismissedGamesStore(application.chessDismissedGamesData) + private val dismissedStorage = ChessDismissedGamesStore(chessDismissedGamesData) // Shared business logic (creates its own ChessLobbyState internally) private val logic = From 04ef41281aa38356d4f60690d679ee5d1601bfde Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 22:53:59 +0000 Subject: [PATCH 33/57] refactor: move the location-chat identity into the encrypted DataStore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GeohashChatIdentityState was the last thing in the app still reading and writing EncryptedSharedPreferences outside the four deliberate mirrors. It kept two keys — the seed its per-geohash throwaway keys derive from, and the handle the user posts under — and neither was covered by the 112-key migration, because neither is in PrefKeys: they are private constants in the state object, so LegacyKeyCoverageTest, which reflects over PrefKeys, structurally could not see them. They were also in a file nothing else uses. The writer passed `signer.pubKey`, which is hex, where every other caller passes an npub, so the identity lived in `secret_keeper_` while the account's own secrets live in `secret_keeper_`. That makes it an orphan rather than a hazard: LegacyPreferenceCleanup enumerates and deletes the npub file, so it never saw these keys, and deleting that file could not have lost them. It also means nothing will ever clean the hex file up on its own. So: read the hex file once, copy into the account's npub-keyed encrypted DataStore, prefer the new store on read, and keep mirroring the legacy write until the legacy writes are retired app-wide — the same terms as AccountSecrets. GeohashIdentitySecrets is its own group with its own migrated marker, and that is load-bearing rather than tidy. Every account save mirrors a whole AccountSecrets built field by field from AccountSettings, which does not hold these — they belong to the state object. Folded into that group, each save would write null over them, and the group save uses putOrRemove, so null removes: the seed would disappear on the next unrelated save and every geohash identity the user has would silently change. Its own marker for the same reason the group is separate — the two migrate out of different files, so neither marker can speak for the other. The keys are deliberately NOT added to LegacyAccountSecretNames.all. That set is what the cleanup gate treats as claimed in the npub file, and these never appear in it; listing them would be inert and would suggest the gate handles them. Shape changes this forced: nickname() and keyPair() are suspend (every call site was already inside withContext(Dispatchers.IO)); setNickname stays fire-and-forget on the account scope, as the SharedPreferences edit {} it replaces already was; and seed creation moved from synchronized to a Mutex, because the store reads it guards are suspending and two racers minting different seeds would strand one caller's identities. Tests: seven, covering the round trip, a seed with no handle, an empty identity still counting as migrated, the two markers staying independent in both directions, and anAccountSaveLeavesTheGeohashIdentityAlone — which pins the wipe this design exists to prevent. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/AccountSecretsStore.kt | 41 ++++++ .../vitorpamplona/amethyst/model/Account.kt | 2 +- .../model/GeohashChatIdentityState.kt | 123 ++++++++++++------ .../model/preferences/AccountSecrets.kt | 65 +++++++++ .../AccountSecretsEncryptedStores.kt | 33 +++++ .../preferences/AccountSecretsStoreTest.kt | 90 +++++++++++++ 6 files changed, 311 insertions(+), 43 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt index e60aaa48cf..ee32dde855 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecretsEncryptedStores +import com.vitorpamplona.amethyst.commons.model.preferences.GeohashIdentitySecrets import com.vitorpamplona.quartz.utils.Log import okio.Path.Companion.toOkioPath @@ -98,6 +99,46 @@ class AccountSecretsStore( */ suspend fun stored(npub: String): AccountSecrets? = stores.loadSecrets(npub) + // ── the location-chat identity ──────────────────────────────────── + + /** + * The account's location-chat identity, migrating out of the legacy file on + * first use, on the same terms as [read]. + * + * @param legacy what `secret_keeper_` holds. Note the *hex*: this + * group's legacy file is keyed by the signer's pubkey rather than the npub + * every other group uses, so the caller opens a different file for it. + */ + suspend fun readGeohashIdentity( + npub: String, + legacy: GeohashIdentitySecrets, + ): GeohashIdentitySecrets { + val stored = + try { + stores.loadGeohashIdentity(npub) + } catch (e: Exception) { + Log.w(TAG, "Could not read the location-chat identity for $npub; using the legacy file", e) + return legacy + } + + if (stored != null) return stored + + mirrorGeohashIdentity(npub, legacy) + return legacy + } + + /** Mirrors a save into the new store. The legacy write stays where it is. */ + suspend fun mirrorGeohashIdentity( + npub: String, + value: GeohashIdentitySecrets, + ) { + try { + stores.saveGeohashIdentity(npub, value) + } catch (e: Exception) { + Log.w(TAG, "Could not write the location-chat identity for $npub to the current store", e) + } + } + suspend fun delete(npub: String) { try { stores.removeAccount(npub) 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 f99574df02..385a1e6389 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -759,7 +759,7 @@ class Account( val geohashList = GeohashListState(signer, cache, geohashListDecryptionCache, scope, settings) // Anonymous, per-geohash throwaway identities for Bitchat-interoperable location chats. - val geohashIdentity = GeohashChatIdentityState(signer) + val geohashIdentity = GeohashChatIdentityState(signer, scope) val muteListDecryptionCache = MuteListDecryptionCache(signer) val muteList = MuteListState(signer, cache, muteListDecryptionCache, scope, settings) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt index 9517a3b62b..699fbb9f37 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt @@ -22,13 +22,23 @@ package com.vitorpamplona.amethyst.model import androidx.core.content.edit import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.LegacySharedPreferences +import com.vitorpamplona.amethyst.accountSecretsStore +import com.vitorpamplona.amethyst.commons.model.preferences.GeohashIdentitySecrets +import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyGeohashIdentity import com.vitorpamplona.quartz.experimental.bitchat.identity.GeohashKeyDerivation import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal +import com.vitorpamplona.quartz.nip19Bech32.toNpub import com.vitorpamplona.quartz.utils.RandomInstance +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import java.util.concurrent.ConcurrentHashMap /** * The account's anonymous, per-geohash chat identities. @@ -52,68 +62,97 @@ import com.vitorpamplona.quartz.utils.RandomInstance */ class GeohashChatIdentityState( private val signer: NostrSigner, + private val scope: CoroutineScope, ) { - private val lock = Any() - private val cache = HashMap() + /** + * Guards seed creation as well as the key cache: two callers racing into + * [deviceSeed] must not mint two different seeds, or the loser's cells get + * identities the next launch cannot reproduce. A [Mutex] rather than + * `synchronized`, because the store reads it protects are suspending. + */ + private val mutex = Mutex() + private val cache = ConcurrentHashMap() - @Volatile private var cachedDeviceSeed: ByteArray? = null + /** + * The npub the current store is keyed by. + * + * The legacy file is keyed by the pubkey *hex* — the old code passed + * `signer.pubKey` where every other caller passes an npub, so the identity + * lived in `secret_keeper_`, a different file from the account's own + * `secret_keeper_`. The copy below reads that file and writes the + * npub-keyed store, which is what folds this orphan back in with the rest. + */ + private val npub by lazy { signer.pubKey.hexToByteArray().toNpub() } - @Volatile private var cachedNickname: String? = null + @Volatile private var loaded: GeohashIdentitySecrets? = null + + /** What `secret_keeper_` holds. Touches disk; callers are off the main thread. */ + private fun legacy(): GeohashIdentitySecrets = readLegacyGeohashIdentity(LegacySharedPreferences(Amethyst.instance.encryptedStorage(signer.pubKey))) + + /** The stored identity, copying it out of the legacy file the first time. */ + private suspend fun current(): GeohashIdentitySecrets { + loaded?.let { return it } + return accountSecretsStore.readGeohashIdentity(npub, legacy()).also { loaded = it } + } + + private suspend fun persist(value: GeohashIdentitySecrets) { + loaded = value + accountSecretsStore.mirrorGeohashIdentity(npub, value) + } /** * The user's display handle for location chats: a single global nickname, persisted per account. * Bitchat carries this as the per-message `["n", …]` tag rather than a kind-0 profile, and kind-20000 * messages are ephemeral (relays needn't store them), so the only durable home for it is the device. - * Kept in this account's encrypted storage, so it survives restarts and switches with the account. - * Empty string means "no nickname set". Reads touch disk on first call — invoke off the main thread. + * Empty string means "no nickname set". */ - fun nickname(): String { - cachedNickname?.let { return it } - synchronized(lock) { - cachedNickname?.let { return it } - val value = Amethyst.instance.encryptedStorage(signer.pubKey).getString(PREF_NICKNAME, "") ?: "" - cachedNickname = value - return value - } - } + suspend fun nickname(): String = current().nickname ?: "" - /** Persists the global location-chat nickname (trimmed) for this account. */ + /** + * Persists the global location-chat nickname (trimmed) for this account. + * + * Fire-and-forget on the account scope, which is what the SharedPreferences + * `edit {}` this replaced already did — the caller is a click handler on the + * main thread and the write is not something it waits for. + */ fun setNickname(value: String) { val trimmed = value.trim() - synchronized(lock) { - cachedNickname = trimmed + scope.launch { + persist(current().copy(nickname = trimmed)) + // Mirrored, not moved: the legacy file stays readable until the + // legacy writes are retired app-wide, so a rollback keeps the handle. Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_NICKNAME, trimmed) } } } - /** The Nostr key pair to use inside [geohash]. Derivation is cheap but cached; call off the main thread. */ - fun keyPair(geohash: String): KeyPair = - synchronized(lock) { - cache.getOrPut(geohash) { GeohashKeyDerivation.deriveKeyPair(seed(), geohash) } - } + /** The Nostr key pair to use inside [geohash]. Derivation is cheap but cached. */ + suspend fun keyPair(geohash: String): KeyPair { + cache[geohash]?.let { return it } - private fun seed(): ByteArray = accountPrivKey()?.let { GeohashKeyDerivation.accountSeed(it) } ?: deviceSeed() + return mutex.withLock { + cache[geohash] ?: GeohashKeyDerivation.deriveKeyPair(seed(), geohash).also { cache[geohash] = it } + } + } + + /** Call under [mutex]. */ + private suspend fun seed(): ByteArray = accountPrivKey()?.let { GeohashKeyDerivation.accountSeed(it) } ?: deviceSeed() private fun accountPrivKey(): ByteArray? = (signer as? NostrSignerInternal)?.keyPair?.privKey - /** Random per-account seed, used only when the account key is unreachable (bunker / external signer). */ - private fun deviceSeed(): ByteArray { - cachedDeviceSeed?.let { return it } - synchronized(lock) { - cachedDeviceSeed?.let { return it } - val prefs = Amethyst.instance.encryptedStorage(signer.pubKey) - val existing = prefs.getString(PREF_KEY, null) - val seed = - if (existing != null && existing.length == GeohashKeyDerivation.SEED_SIZE * 2) { - existing.hexToByteArray() - } else { - val fresh = RandomInstance.bytes(GeohashKeyDerivation.SEED_SIZE) - prefs.edit { putString(PREF_KEY, fresh.toHexKey()) } - fresh - } - cachedDeviceSeed = seed - return seed - } + /** + * Random per-account seed, used only when the account key is unreachable (bunker / external signer). + * + * Call under [mutex]: minting a second seed for an account that already has + * one would change every throwaway identity it has ever used. + */ + private suspend fun deviceSeed(): ByteArray { + val stored = current().deviceSeed + if (stored != null && stored.length == GeohashKeyDerivation.SEED_SIZE * 2) return stored.hexToByteArray() + + val fresh = RandomInstance.bytes(GeohashKeyDerivation.SEED_SIZE) + persist(current().copy(deviceSeed = fresh.toHexKey())) + Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_KEY, fresh.toHexKey()) } + return fresh } companion object { diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt index 7a18508ff1..46769ead3d 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecrets.kt @@ -102,6 +102,22 @@ object LegacyAccountSecretNames { /** The private key, which lives in its own store rather than in [AccountSecrets]. */ const val NOSTR_PRIVKEY = "nostr_privkey" + /** + * The location-chat identity, which is [GeohashIdentitySecrets] rather than + * part of [AccountSecrets] — see that class for why it is its own group. + * + * These two sit in `secret_keeper_`, not `secret_keeper_`: + * the writer passed `signer.pubKey`, which is hex, where every other caller + * passes an npub. They are therefore in a *different file* from everything + * else named here, which is why they are deliberately **not** in [all]: + * [all] is what `LegacyPreferenceCleanup` treats as claimed in the npub + * file, and these never appear in it. That file's deletion cannot lose + * them, and cannot clean them up either — retiring the hex file is its own + * job, once these writes stop. + */ + const val GEOHASH_DEVICE_SEED = "geohash_chat_device_seed" + const val GEOHASH_NICKNAME = "geohash_chat_nickname" + val all = setOf( NIP46_SIGNER_ENABLED, @@ -135,3 +151,52 @@ fun readLegacyAccountSecrets(source: LegacyPreferenceSource) = legacyDefaultNwcWalletId = source.getString(LegacyAccountSecretNames.DEFAULT_NWC_WALLET_ID), legacyZapPaymentRequestServer = source.getString(LegacyAccountSecretNames.ZAP_PAYMENT_REQUEST_SERVER), ) + +/** + * The account's location-chat identity: the seed its per-geohash throwaway keys + * come from, and the handle it posts under. + * + * # Why this is not two more fields on [AccountSecrets] + * + * Every account save mirrors a whole [AccountSecrets], built field by field from + * `AccountSettings` — which does not hold these, because they are owned by + * `GeohashChatIdentityState` rather than by the settings object. Folding them in + * would make each save write null over them, and the group save uses + * `putOrRemove`, so null *deletes*. The seed would vanish on the next unrelated + * save and every geohash identity the user has would silently change. A separate + * group with its own save path cannot be wiped by a save that does not know + * about it. + * + * # Why encrypted + * + * The whole point of the seed is that the identities derived from it are + * unlinkable to the npub. Anyone who can read it can link every cell the user + * has ever posted in, to each other and to the device, which is exactly what the + * feature exists to prevent. It was in an encrypted file before; it stays in one. + */ +data class GeohashIdentitySecrets( + val deviceSeed: String? = null, + val nickname: String? = null, +) + +/** Keys for [GeohashIdentitySecrets] inside an [EncryptedDataStore]. */ +internal object GeohashIdentityKeys { + val deviceSeed = stringPreferencesKey(LegacyAccountSecretNames.GEOHASH_DEVICE_SEED) + val nickname = stringPreferencesKey(LegacyAccountSecretNames.GEOHASH_NICKNAME) + + /** Records that the one-off copy out of the legacy file has run for this account. */ + val migrated = stringPreferencesKey("migrated.geohashIdentity") +} + +/** + * The location-chat identity as the legacy file holds it. + * + * Both absent is a real answer — an account that never opened a location chat — + * and is why the caller compares against [GeohashIdentitySecrets] rather than + * treating null as "not migrated". + */ +fun readLegacyGeohashIdentity(source: LegacyPreferenceSource) = + GeohashIdentitySecrets( + deviceSeed = source.getString(LegacyAccountSecretNames.GEOHASH_DEVICE_SEED), + nickname = source.getString(LegacyAccountSecretNames.GEOHASH_NICKNAME), + ) diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt index 082c14fd06..90d4a323e3 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsEncryptedStores.kt @@ -182,6 +182,39 @@ class AccountSecretsEncryptedStores( } } + // ── the location-chat identity ──────────────────────────────────── + + /** + * Reads [GeohashIdentitySecrets], or null when this account has not been + * copied out of the legacy encrypted file yet. + * + * Its own marker, not [AccountSecretKeys.migrated]: the two groups migrate + * from *different files* (this one from `secret_keeper_`, the + * secrets from `secret_keeper_`), so one marker cannot speak for both. + */ + suspend fun loadGeohashIdentity(npub: String): GeohashIdentitySecrets? { + val stored = getDataStore(npub).snapshot() + if (stored[GeohashIdentityKeys.migrated] == null) return null + + return GeohashIdentitySecrets( + deviceSeed = stored[GeohashIdentityKeys.deviceSeed], + nickname = stored[GeohashIdentityKeys.nickname], + ) + } + + /** Writes the group and its marker as one edit, for the reasons [saveSecrets] gives. */ + suspend fun saveGeohashIdentity( + npub: String, + value: GeohashIdentitySecrets, + ) { + getDataStore(npub).edit { + putOrRemove(GeohashIdentityKeys.deviceSeed, value.deviceSeed) + putOrRemove(GeohashIdentityKeys.nickname, value.nickname) + + put(GeohashIdentityKeys.migrated, "true") + } + } + private fun decodeSet(raw: String?): Set = raw ?.split(AccountSecretKeys.SET_SEPARATOR) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt index 32962ebd25..fc22b515a1 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt @@ -206,4 +206,94 @@ class AccountSecretsStoreTest { assertEquals(filled, subject.loadSecrets(npub)) } + // ── the location-chat identity ──────────────────────────────────── + + @Test + fun anUnmigratedGeohashIdentityReadsAsNull() = + runTest { + assertNull(stores().loadGeohashIdentity(npub)) + } + + @Test + fun theGeohashIdentityRoundTrips() = + runTest { + val subject = stores() + val value = GeohashIdentitySecrets(deviceSeed = "a".repeat(64), nickname = "vitor") + + subject.saveGeohashIdentity(npub, value) + + assertEquals(value, subject.loadGeohashIdentity(npub)) + } + + /** + * An account that opened a location chat under a bunker signer has a seed but + * never set a handle. Absent must come back absent rather than as "". + */ + @Test + fun aSeedWithNoNicknameRoundTrips() = + runTest { + val subject = stores() + val value = GeohashIdentitySecrets(deviceSeed = "b".repeat(64), nickname = null) + + subject.saveGeohashIdentity(npub, value) + + assertEquals(value, subject.loadGeohashIdentity(npub)) + } + + /** An account that holds neither key still counts as migrated, or the copy runs forever. */ + @Test + fun anEmptyGeohashIdentityStillCountsAsMigrated() = + runTest { + val subject = stores() + + subject.saveGeohashIdentity(npub, GeohashIdentitySecrets()) + + assertEquals(GeohashIdentitySecrets(), subject.loadGeohashIdentity(npub)) + } + + /** + * The two groups migrate out of *different* legacy files — the secrets from + * `secret_keeper_`, the identity from `secret_keeper_` — + * so neither marker may stand in for the other. Saving one must leave the + * other reading as not-yet-copied. + */ + @Test + fun theTwoGroupsMigrateIndependently() = + runTest { + val subject = stores() + + subject.saveSecrets(npub, filled) + + assertNull("saving the secrets must not mark the identity migrated", subject.loadGeohashIdentity(npub)) + } + + @Test + fun savingTheIdentityDoesNotMarkTheSecretsMigrated() = + runTest { + val subject = stores() + + subject.saveGeohashIdentity(npub, GeohashIdentitySecrets(deviceSeed = "c".repeat(64))) + + assertNull(subject.loadSecrets(npub)) + } + + /** + * The seed must survive an unrelated account save. This is the whole reason + * the identity is its own group: every save mirrors a full AccountSecrets + * built from AccountSettings, which does not hold the seed, and the group + * save removes keys whose value is null. Folded into that group, the seed + * would be deleted here — and every geohash identity the user has would + * silently change. + */ + @Test + fun anAccountSaveLeavesTheGeohashIdentityAlone() = + runTest { + val subject = stores() + val identity = GeohashIdentitySecrets(deviceSeed = "d".repeat(64), nickname = "vitor") + subject.saveGeohashIdentity(npub, identity) + + subject.saveSecrets(npub, filled) + + assertEquals(identity, subject.loadGeohashIdentity(npub)) + } } From 48bb8d37e345d400a70fb32683e4e704c936f76c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 23:33:23 +0000 Subject: [PATCH 34/57] ci: cut the Android job's worker concurrency, not more heap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test-and-build-android died again with "the runner has received a shutdown signal" — the OOM killer taking the runner agent, about 20 minutes in, with every task up to that point green. No test failed and nothing failed to compile. The previous fix is not wrong, it was validated on the easy case. ea459bc5 changed only this file, so the run restored main's Gradle cache and rebuilt almost nothing; it passed in 54 minutes and I read that as confirmation. The first PR run since that touches `commons` invalidated the cache — this job's own comment above notes a quartz/commons change does exactly that and costs 2-3x — rebuilt from cold, and died the same way. Cold is the case the 4g cap had never actually faced. So the lever is concurrency rather than ceilings. Those heap numbers are per-JVM limits; what tips a 16GB runner over is how many heavy JVMs are resident at once, and Gradle defaults max-workers to the core count with org.gradle.parallel on. The log shows the peak: R8 and both lintAnalyze tasks behind it, a cold compileFdroidDebugKotlin, and a forked test JVM starting, alongside the 6g Gradle and 4g Kotlin daemons. --max-workers=3, not 2. This job is mostly a chain of single-task module compiles, so it loses little real parallelism, and halving it risks the timeout on a cold run instead — the cap goes to 120 for that reason, which costs nothing on runs that finish early. Dropping the Kotlin daemon further was the obvious alternative and is the wrong one: cdb4f1f7 already lost that trade, starving R8 and lintAnalyze into "java.lang.OutOfMemoryError: Java heap space". If this still dies early, the job is simply too big for one 16GB runner and the answer is splitting lint out into its own job — not another number. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .github/workflows/build.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a123e7e16..72b2548016 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -347,7 +347,7 @@ jobs: # workflow, which puts this one past the cap and gets it killed mid-step # with no test report. Raising the cap costs nothing on runs that finish # early — `timeout-minutes` bounds a job, it does not reserve the time. - timeout-minutes: 90 + timeout-minutes: 120 steps: - name: Checkout code uses: actions/checkout@v7 @@ -396,10 +396,31 @@ jobs: # # Overridden here rather than in gradle.properties so local builds on # bigger machines keep the headroom. + # + # `--max-workers` is the second half, and it is about concurrency rather + # than ceilings. The heap numbers above are per-JVM limits; what actually + # tips a 16GB runner over is how many heavy JVMs are live at once. Gradle + # defaults max-workers to the core count (4 on ubuntu-latest) and + # org.gradle.parallel is on, so a cold run can have several kotlinc + # workers, a lint fork and a forked test JVM resident alongside the two + # daemons. + # + # Cold is the case that matters. The 4g cap was first validated on a run + # that only changed this file, so it restored main's Gradle cache and + # built almost nothing; the next PR run that touched `commons` + # invalidated that cache, rebuilt from cold, and died the same way at + # ~20 minutes. Fewer workers is what makes the cold path fit — dropping + # heap further would start starving R8 again, which is the trade the + # previous attempt already lost. + # + # 3 rather than 2: this job is mostly a chain of single-task module + # compiles, so the parallelism it loses is small, and halving it risks + # the timeout on a cold run. The cap goes to 120 for the same reason. - name: Test + Build Android (gradle) run: | ./gradlew \ -Dkotlin.daemon.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=1g" \ + --max-workers=3 \ :amethyst:lintFdroidBenchmark \ :amethyst:lintPlayBenchmark \ :quartz:jvmTest \ From e619fdcb410678f594cbcf3f3cba8d5c9a1d8964 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 14:10:26 +0000 Subject: [PATCH 35/57] fix: make the location-chat identity migration finish on its own MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two gaps left by 04ef4128, both of which would have surfaced as a half-finished release at the flag flip rather than as a failure now. The mirror ignored the retirement switch. LEGACY_WRITES_RETIRED was private to LocalPreferences, so GeohashChatIdentityState could not read it and wrote to its legacy file unconditionally. Flipping the flag would have retired the four documented mirrors and left this one running. It is `internal` now and both of that class's legacy writes are gated on it, so the flip is one switch that stops everything. Nothing would ever have deleted the identity's legacy file. It is `secret_keeper_`, not `secret_keeper_` — the writer passed signer.pubKey where every other caller passes an npub — and the cleanup enumerates npub-keyed files. It would have sat on disk holding a seed after every other legacy file was gone. LegacyAccountFiles.delete now clears and unlinks both, and verify() refuses while the hex file holds an identity the current store does not. That check reads geohashSource(), the hex file. An earlier version of it read the npub file and was reverted for being unable to fire; this is the corrected form, and it is paired with actually deleting the file it guards. The copy also had to stop being lazy, and that is the part that would have bitten users rather than the release. It ran only from GeohashChatIdentityState, so only for someone who opened a location chat. Combined with the new gate that is worse than the orphan it replaced: a user with an identity who never opens another location chat would never be copied, and their legacy files could then never be deleted at all. It now runs on the first account load after the upgrade, beside the cleanup call and before it, so every existing install converges whether or not location chat is ever touched again. It sits next to legacyCleanup rather than inside the loader because innerLoadCurrentAccountFromEncryptedStorage is at the JVM's 64KB method limit — AccountStoreData's KDoc already records that every suspend call in there costs a coroutine state, and adding one broke the build with "Method too large". Outside the lock, once per load, is also where it belongs: this is migration housekeeping, not part of building AccountSettings. Tests: four on the gate (an uncopied identity blocks deletion, a copied one does not, an account that never opened a location chat is not held hostage, and both files go together) and one on idempotence, which the copy now needs because it runs on every load. The plan doc is updated to match: the group and its two quirks, deletion covering both files, the fourth condition, the flip stopping this mirror too, and a device-pass step for the seed — the one migrated value whose loss is silent rather than visible. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- ...2026-09-23-encrypted-storage-retirement.md | 41 +++++++-- .../amethyst/AccountSecretsStore.kt | 8 ++ .../amethyst/LegacyPreferenceCleanup.kt | 54 ++++++++++++ .../amethyst/LocalPreferences.kt | 68 +++++++++++++- .../model/GeohashChatIdentityState.kt | 11 ++- .../amethyst/LegacyPreferenceCleanupTest.kt | 88 +++++++++++++++++++ .../preferences/AccountSecretsStoreTest.kt | 21 +++++ 7 files changed, 278 insertions(+), 13 deletions(-) diff --git a/amethyst/plans/2026-09-23-encrypted-storage-retirement.md b/amethyst/plans/2026-09-23-encrypted-storage-retirement.md index ceb220068c..b2eccd2986 100644 --- a/amethyst/plans/2026-09-23-encrypted-storage-retirement.md +++ b/amethyst/plans/2026-09-23-encrypted-storage-retirement.md @@ -42,10 +42,20 @@ to none of those fails that test at the commit that adds it. | NIP-46 material, wallets, payment source | the account's encrypted DataStore | **kept** | | current account, saved accounts | the encrypted roster store | **kept** | | UI settings (`shared_settings`) | `UiSharedPreferences`' own DataStore | none left | +| location-chat identity — seed, nickname | the account's encrypted DataStore, as its own `GeohashIdentitySecrets` group | **kept** | -The three stores that still mirror are the ones whose loss is not an -annoyance: an account that cannot be listed, signed with, or paid from. They -keep the rollback window open until the device pass below has happened. +The stores that still mirror are the ones whose loss is not an annoyance: an +account that cannot be listed, signed with, or paid from. They keep the +rollback window open until the device pass below has happened. + +The location-chat identity is the odd one, in two ways worth knowing before +step 4. It is its **own** group rather than fields on `AccountSecrets`: every +account save mirrors a whole `AccountSecrets` built from `AccountSettings`, +which does not hold these, and that group save removes keys whose value is +null — folded in, the seed would be deleted by the next unrelated save and +every geohash identity the user has would silently change. And its legacy home +is a **different file**, `secret_keeper_`, because its writer +passed `signer.pubKey` where every other caller passes an npub. The UI settings copy is **guarded** where the others are not. That store has been the real home of these settings for a while, so most installs already @@ -69,7 +79,11 @@ cleanup treat any *other* unclaimed key as a reason to keep the file. ## Deleting a legacy file `LegacyPreferenceCleanup` runs after every successful account load and deletes -that account's file only when it can prove nothing would be lost: +that account's files — `secret_keeper_` **and** the location-chat +identity's `secret_keeper_` — only when it can prove nothing would +be lost. Both, because nothing else would ever remove the second one: the +cleanup enumerates npub-keyed files, so left out of this it would sit on disk +holding a seed forever. 1. **Every key in the file is accounted for** — claimed by a table, one of the secrets, or on the accepted list. Driven from the file's own keys, not from @@ -83,9 +97,14 @@ that account's file only when it can prove nothing would be lost: 3. **The secrets and the private key read back identical** from the current stores. Those *are* still dual-written, so the stronger question is available and is asked. -4. A store that cannot be read is a reason, never a pass. +4. **The location-chat identity has been copied**, when its file holds one. + Read from the hex-keyed file, not the npub one — these two keys were never + in that one, so a check pointed at it would never fire. An account that + never opened a location chat holds neither key, which is a real answer and + must not hold the file hostage. +5. A store that cannot be read is a reason, never a pass. -It refuses today, and says so, because of the fifth condition: +It refuses today, and says so, because of the last condition: `LEGACY_WRITES_RETIRED` is false. While the app still mirrors into the file, deleting it achieves nothing — the next save recreates it — and would look like it had worked. @@ -97,7 +116,10 @@ like it had worked. 3. Do the device pass below. 4. Flip `LEGACY_WRITES_RETIRED` and drop the legacy writes for the identity, key, secret and roster stores. This ends the rollback window, so it is a - release of its own. + release of its own. The flag is `internal`, not private, so the + location-chat mirror in `GeohashChatIdentityState` reads the same switch — + flipping it stops that write too, and the cleanup then removes both of the + account's legacy files. One flip, nothing left behind. 5. Keep the reader, and `androidx.security.crypto`, indefinitely. ## Verification this needs and has not had @@ -110,6 +132,9 @@ the one irreversible step in the whole series. On a real device, before step 4 ships: upgrade an install holding accounts and confirm they all list; open one and sign; force-stop and relaunch; add and remove an account; pair a NIP-46 signer; pay from a wallet; check the -key-backup nudge stays dismissed; confirm UI settings survive the upgrade. +key-backup nudge stays dismissed; confirm UI settings survive the upgrade; +open a location chat under a bunker or external signer and confirm the +throwaway identity and nickname are the same ones as before the upgrade — the +seed is the one migrated value whose loss is silent rather than visible. Then let the cleanup run with the flag flipped, and confirm the files are gone and everything above still holds on the next cold start. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt index ee32dde855..2e73084664 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt @@ -127,6 +127,14 @@ class AccountSecretsStore( return legacy } + /** + * What the current store holds for the location-chat identity, with no + * fallback to the legacy file — the same distinction [stored] draws, and + * for the same reader: [LegacyPreferenceCleanup] has to tell "migrated" + * from "falling back and looking migrated". + */ + suspend fun storedGeohashIdentity(npub: String): GeohashIdentitySecrets? = stores.loadGeohashIdentity(npub) + /** Mirrors a save into the new store. The legacy write stays where it is. */ suspend fun mirrorGeohashIdentity( npub: String, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt index 9872ab3ac8..7a271b02ee 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanup.kt @@ -25,6 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.preferences.AccountIdentityStore import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets import com.vitorpamplona.amethyst.commons.model.preferences.DialogDismissalStore import com.vitorpamplona.amethyst.commons.model.preferences.FeedVisibilityStore +import com.vitorpamplona.amethyst.commons.model.preferences.GeohashIdentitySecrets import com.vitorpamplona.amethyst.commons.model.preferences.LatestEventCacheStore import com.vitorpamplona.amethyst.commons.model.preferences.LegacyAccountSecretNames import com.vitorpamplona.amethyst.commons.model.preferences.LegacyKeyTable @@ -33,6 +34,7 @@ import com.vitorpamplona.amethyst.commons.model.preferences.NotificationPrefsSto import com.vitorpamplona.amethyst.commons.model.preferences.RelayAuthStore import com.vitorpamplona.amethyst.commons.model.preferences.TopNavFollowListStore import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettingsStore +import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyGeohashIdentity import com.vitorpamplona.quartz.utils.Log /** @@ -100,6 +102,17 @@ sealed interface LegacyCleanupResult { interface LegacyAccountFiles { fun source(npub: String): LegacyPreferenceSource + /** + * The account's OTHER legacy file: the location-chat identity, which lives + * in `secret_keeper_` rather than `secret_keeper_` + * because that is the key its writer passed. + * + * Separate from [source] because [delete] removes both, and a check that + * read the npub file for these keys would never find them — they are not + * in it. That mistake was made once already. + */ + fun geohashSource(npub: String): LegacyPreferenceSource + fun exists(npub: String): Boolean /** Returns false when there was nothing to delete. */ @@ -113,6 +126,14 @@ interface MigratedSecrets { /** Null only when the account genuinely has no private key. Throws when the store is unreadable. */ suspend fun privateKey(npub: String): String? + + /** + * The location-chat identity, or null when it has not been copied across. + * + * Its own question because it migrates out of its own file: [AccountSecrets] + * being present says nothing about whether this was carried over. + */ + suspend fun geohashIdentity(npub: String): GeohashIdentitySecrets? } /** @@ -255,9 +276,42 @@ class LegacyPreferenceCleanup( } } + reasons += geohashMismatches(npub) + return reasons } + /** + * Whether deleting this account's `secret_keeper_` file would + * lose its location-chat identity. + * + * Read from [LegacyAccountFiles.geohashSource], not from the npub file the + * rest of [verify] walks: these two keys were never in that one. An account + * that never opened a location chat holds neither, and needs no copy. + */ + private suspend fun geohashMismatches(npub: String): List { + val legacy = + try { + readLegacyGeohashIdentity(files.geohashSource(npub)) + } catch (e: Exception) { + Log.w(TAG, "Could not read the location-chat identity file for $npub", e) + return listOf("the location-chat identity file could not be read") + } + + if (legacy == GeohashIdentitySecrets()) return emptyList() + + return try { + if (secrets.geohashIdentity(npub) == null) { + listOf("the location-chat identity has not been copied across") + } else { + emptyList() + } + } catch (e: Exception) { + Log.w(TAG, "Could not read the location-chat identity store for $npub", e) + listOf("the location-chat identity store could not be read") + } + } + /** * Deletes the account's legacy file if — and only if — [verify] comes back * empty and the app has stopped writing to it. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 430f20be37..c797fcd434 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -57,6 +57,7 @@ import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettings import com.vitorpamplona.amethyst.commons.model.preferences.UploadSettingsStore import com.vitorpamplona.amethyst.commons.model.preferences.orIfUnusable import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyAccountSecrets +import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyGeohashIdentity import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayauth.RelayAuthPolicy import com.vitorpamplona.amethyst.model.AccountSettings @@ -78,6 +79,7 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip19Bech32.bech32.bechToBytes import com.vitorpamplona.quartz.nip19Bech32.toNpub import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent @@ -325,8 +327,14 @@ object LocalPreferences { * Flipping this is a release of its own, and it ends the rollback window. * It waits on the device pass in * `amethyst/plans/2026-09-23-encrypted-storage-retirement.md`. + * + * `internal` rather than private because the mirror is not all in this + * file: [com.vitorpamplona.amethyst.model.GeohashChatIdentityState] writes + * the location-chat identity into its own legacy file and reads this to + * know when to stop. Private, it would have kept writing after the flip + * and the switch would only half work. */ - private const val LEGACY_WRITES_RETIRED = false + internal const val LEGACY_WRITES_RETIRED = false private val legacyCleanup: LegacyPreferenceCleanup by lazy { LegacyPreferenceCleanup( @@ -338,12 +346,25 @@ object LocalPreferences { override fun exists(npub: String) = legacyAccountFile(npub).exists() + override fun geohashSource(npub: String) = LegacySharedPreferences(encryptedPreferences(geohashLegacyKey(npub))) + override suspend fun delete(npub: String): Boolean { // Clear before unlinking, as deleteAccount does: the live // SharedPreferences still holds the values in memory and // would write them straight back out. encryptedPreferences(npub).edit(commit = true) { clear() } - return legacyAccountFile(npub).delete() + val removedAccountFile = legacyAccountFile(npub).delete() + + // The location-chat identity is in a SECOND file, keyed by the + // pubkey hex rather than the npub, because that is the key its + // writer passed. Nothing else would ever remove it, so it is + // deleted here with the account's own file rather than left as + // an orphan holding a seed forever. + val hex = geohashLegacyKey(npub) + encryptedPreferences(hex).edit(commit = true) { clear() } + legacyAccountFile(hex).delete() + + return removedAccountFile } }, currentStore = { npub -> accountStores.getDataStore(npub).data.first() }, @@ -352,6 +373,8 @@ object LocalPreferences { override suspend fun secrets(npub: String) = accountSecretsStore.stored(npub) override suspend fun privateKey(npub: String) = accountKeyStore.stored(npub) + + override suspend fun geohashIdentity(npub: String) = accountSecretsStore.storedGeohashIdentity(npub) }, legacyWritesRetired = LEGACY_WRITES_RETIRED, ) @@ -368,6 +391,37 @@ object LocalPreferences { return File(prefsDirPath, "$name.xml") } + /** + * The key the location-chat identity's legacy file is named by. + * + * [GeohashChatIdentityState] passed `signer.pubKey` — hex — where every + * other caller of [encryptedPreferences] passes an npub, so that material + * sits in `secret_keeper_`, a different file from the account's own + * `secret_keeper_`. Converting here keeps that quirk in one place. + */ + private fun geohashLegacyKey(npub: String): String = npub.bechToBytes("npub").toHexKey() + + /** + * Copies the location-chat identity out of `secret_keeper_` on + * the first load after the upgrade. + * + * Eager, not lazy. [GeohashChatIdentityState] also copies on first use, but + * only a user who opens a location chat ever reaches it — and the cleanup + * refuses to delete an account's legacy files while that file still holds + * an identity the current store does not. Left to the lazy path alone, a + * user who never opens another location chat would keep both files + * forever, which is the opposite of what the migration is for. + * + * Idempotent: the store's marker makes every run after the first a no-op, + * so re-running it on each load cannot overwrite a later edit. + */ + private suspend fun copyGeohashIdentity(npub: String) { + accountSecretsStore.readGeohashIdentity( + npub = npub, + legacy = readLegacyGeohashIdentity(LegacySharedPreferences(encryptedPreferences(geohashLegacyKey(npub)))), + ) + } + /** * Everything the account's DataStore holds, read in one hop. * @@ -1031,7 +1085,15 @@ object LocalPreferences { // while `mutex` serialises every account load — under the lock, each // account on a multi-account cold start would wait for the previous // one's full cleanup pass. Nothing here feeds the load. - if (loadedHere) legacyCleanup.deleteIfVerified(npub) + if (loadedHere) { + // Before the cleanup, which refuses to delete this account's files + // while the location-chat identity has not been copied. Here rather + // than inside the loader for the reason [AccountStoreData] gives: + // that method is at the JVM's 64KB limit and one more suspend call + // inside it does not fit. + copyGeohashIdentity(npub) + legacyCleanup.deleteIfVerified(npub) + } accountSettings } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt index 699fbb9f37..21c011e8d6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt @@ -23,6 +23,7 @@ package com.vitorpamplona.amethyst.model import androidx.core.content.edit import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.LegacySharedPreferences +import com.vitorpamplona.amethyst.LocalPreferences import com.vitorpamplona.amethyst.accountSecretsStore import com.vitorpamplona.amethyst.commons.model.preferences.GeohashIdentitySecrets import com.vitorpamplona.amethyst.commons.model.preferences.readLegacyGeohashIdentity @@ -121,7 +122,11 @@ class GeohashChatIdentityState( persist(current().copy(nickname = trimmed)) // Mirrored, not moved: the legacy file stays readable until the // legacy writes are retired app-wide, so a rollback keeps the handle. - Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_NICKNAME, trimmed) } + // Gated on the same switch as every other mirror — otherwise flipping + // it would retire the documented four and leave this one writing. + if (!LocalPreferences.LEGACY_WRITES_RETIRED) { + Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_NICKNAME, trimmed) } + } } } @@ -151,7 +156,9 @@ class GeohashChatIdentityState( val fresh = RandomInstance.bytes(GeohashKeyDerivation.SEED_SIZE) persist(current().copy(deviceSeed = fresh.toHexKey())) - Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_KEY, fresh.toHexKey()) } + if (!LocalPreferences.LEGACY_WRITES_RETIRED) { + Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_KEY, fresh.toHexKey()) } + } return fresh } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt index 18bad7f959..e4cc8f3ebc 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt @@ -26,6 +26,7 @@ import androidx.datastore.preferences.core.emptyPreferences import androidx.datastore.preferences.core.mutablePreferencesOf import androidx.datastore.preferences.core.stringPreferencesKey import com.vitorpamplona.amethyst.commons.model.preferences.AccountSecrets +import com.vitorpamplona.amethyst.commons.model.preferences.GeohashIdentitySecrets import com.vitorpamplona.amethyst.commons.model.preferences.LegacyBooleanKey import com.vitorpamplona.amethyst.commons.model.preferences.LegacyKeyTable import com.vitorpamplona.amethyst.commons.model.preferences.LegacyPreferenceSource @@ -52,18 +53,26 @@ private class MapSource( private class FakeFiles( private val values: Map, + private val geohashValues: Map = emptyMap(), ) : LegacyAccountFiles { var deleted = false private set + /** The `secret_keeper_` file goes with the account's own. */ + var deletedGeohash = false + private set + var present = true override fun source(npub: String) = MapSource(values) + override fun geohashSource(npub: String) = MapSource(geohashValues) + override fun exists(npub: String) = present override suspend fun delete(npub: String): Boolean { deleted = true + deletedGeohash = true present = false return true } @@ -73,6 +82,7 @@ private class FakeSecrets( private val stored: AccountSecrets? = AccountSecrets(), private val key: String? = null, private val throws: Boolean = false, + private val geohash: GeohashIdentitySecrets? = GeohashIdentitySecrets(), ) : MigratedSecrets { override suspend fun secrets(npub: String): AccountSecrets? { if (throws) throw IllegalStateException("keystore unavailable") @@ -83,6 +93,11 @@ private class FakeSecrets( if (throws) throw IllegalStateException("keystore unavailable") return key } + + override suspend fun geohashIdentity(npub: String): GeohashIdentitySecrets? { + if (throws) throw IllegalStateException("keystore unavailable") + return geohash + } } /** @@ -307,4 +322,77 @@ class LegacyPreferenceCleanupTest { subject.verify(NPUB), ) } + // ── the location-chat identity's own legacy file ────────────────── + + /** + * The seed is in `secret_keeper_`, and [delete] removes that + * file too. So the gate has to refuse while it holds something the current + * store does not — otherwise every geohash identity the account has would + * change on the next launch. + */ + @Test + fun anUncopiedLocationChatIdentityBlocksDeletion() = + runTest { + val (files, subject) = + cleanup( + values = emptyMap(), + files = FakeFiles(emptyMap(), mapOf("geohash_chat_device_seed" to "a".repeat(64))), + secrets = FakeSecrets(geohash = null), + ) + + val result = subject.deleteIfVerified(NPUB) + + assertTrue(result is LegacyCleanupResult.Kept) + assertTrue( + "was ${(result as LegacyCleanupResult.Kept).reasons}", + result.reasons.any { it.contains("location-chat identity") }, + ) + assertTrue(!files.deleted) + } + + /** Copied across: nothing to lose, so it must not block. */ + @Test + fun aCopiedLocationChatIdentityDoesNotBlockDeletion() = + runTest { + val (files, subject) = + cleanup( + values = emptyMap(), + files = FakeFiles(emptyMap(), mapOf("geohash_chat_device_seed" to "a".repeat(64))), + secrets = FakeSecrets(geohash = GeohashIdentitySecrets(deviceSeed = "a".repeat(64))), + ) + + assertEquals(LegacyCleanupResult.Deleted, subject.deleteIfVerified(NPUB)) + assertTrue(files.deleted) + } + + /** + * An account that never opened a location chat holds neither key. That is a + * real answer, not "not migrated", and must not hold the file hostage. + */ + @Test + fun anAccountWithNoLocationChatIdentityIsNotBlocked() = + runTest { + val (files, subject) = + cleanup( + values = emptyMap(), + files = FakeFiles(emptyMap(), emptyMap()), + secrets = FakeSecrets(geohash = null), + ) + + assertEquals(LegacyCleanupResult.Deleted, subject.deleteIfVerified(NPUB)) + assertTrue(files.deleted) + } + + /** + * Both files go, or the hex one is an orphan nothing will ever remove — + * the whole reason it is wired into this gate. + */ + @Test + fun deletingTheAccountFileAlsoRemovesTheLocationChatFile() = + runTest { + val (files, subject) = cleanup(values = emptyMap()) + + assertEquals(LegacyCleanupResult.Deleted, subject.deleteIfVerified(NPUB)) + assertTrue("the hex-keyed file must be deleted with the account's own", files.deletedGeohash) + } } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt index fc22b515a1..5685c6c603 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/preferences/AccountSecretsStoreTest.kt @@ -296,4 +296,25 @@ class AccountSecretsStoreTest { assertEquals(identity, subject.loadGeohashIdentity(npub)) } + + /** + * The copy has to be idempotent, because the loader now runs it on every + * account load rather than only when a location chat is opened. A second + * run must not overwrite what the user has changed since the first. + */ + @Test + fun recopyingDoesNotClobberALaterEdit() = + runTest { + val subject = stores() + subject.saveGeohashIdentity(npub, GeohashIdentitySecrets(deviceSeed = "a".repeat(64), nickname = "old")) + + // What a fresh load would find in the legacy file: the pre-migration value. + val stored = subject.loadGeohashIdentity(npub) + assertEquals("old", stored?.nickname) + + subject.saveGeohashIdentity(npub, GeohashIdentitySecrets(deviceSeed = "a".repeat(64), nickname = "new")) + + assertEquals("new", subject.loadGeohashIdentity(npub)?.nickname) + assertEquals("a".repeat(64), subject.loadGeohashIdentity(npub)?.deviceSeed) + } } From 0bbe5054dcc29ba887e77ca04245c9e86318d6e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 17:01:15 +0000 Subject: [PATCH 36/57] fix: close five review findings in the location-chat migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A /code-review pass over this session's commits found five, all in the geohash work and all in code that had already gone green in CI — the tests I wrote exercised the cleanup gate's decision logic against fakes, not the file lifecycle, which is where every one of these lived. Two of them together defeated the previous commit entirely. It added the hex-keyed file to the cleanup so nothing would be orphaned; in practice the next account load recreated the file and the gate then declined to look at it again, leaving the same orphan plus extra work per launch. 1. setNickname read-modify-wrote outside the mutex. Racing the first seed mint it persisted the nickname over a null deviceSeed, and the group save removes null keys, so the seed vanished and every per-cell identity used in that session became unreproducible. It is under the lock now, where deviceSeed() already was. current() and persist() are marked lock-required and deliberately do not self-lock: Mutex is not reentrant and keyPair() is already holding it when it reaches them. 2. readGeohashIdentity took the legacy value eagerly, so every account load opened secret_keeper_. Opening an EncryptedSharedPreferences writes its Tink keyset, which means the open CREATES the file: on the load after the cleanup deleted it, the file came straight back, for good. It also cost a Keystore-backed open per account on every cold start. The parameter is a suspend lambda now, called only when the store has nothing. 3. deleteAccount never touched the hex file, so the anonymous device seed outlived the account that owned it and returned if the same npub was re-added. For an identity whose whole purpose is to be unlinkable, that is the wrong direction. Both call sites now share deleteGeohashLegacyFile. 4. The copy was the only legacy step on the account-load path without a try/catch. An EncryptedSharedPreferences that cannot be opened would have failed the whole load, and with it the per-account loops in the notification consumers. 5. deleteIfVerified gated on the npub file alone, so once that was gone the hex file was unreachable and could never be removed. exists() is either file now. Tests: the gate still runs when only the location-chat file is left, and FakeFiles tracks the two files separately — modelling them behind one flag is what let finding 5 hide. That change also exposed anAccountWithNoLegacyFileIsAlreadyDone, which cleared one file and meant "neither"; it clears both now, which is what its name always claimed. Not pinned, and worth saying: finding 2's laziness has no unit test. The lambda lives in AccountSecretsStore, which takes the concrete AccountSecretsEncryptedStores rather than an interface, so it cannot be faked the way AccountKeyStore takes a FakeVault. A test was written and deleted for re-asserting existing coverage while looking like it covered the fix. Extracting a narrow interface there would close it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/AccountSecretsStore.kt | 21 ++++--- .../amethyst/LocalPreferences.kt | 59 ++++++++++++++----- .../model/GeohashChatIdentityState.kt | 41 +++++++++---- .../amethyst/LegacyPreferenceCleanupTest.kt | 37 +++++++++++- 4 files changed, 123 insertions(+), 35 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt index 2e73084664..aaf46b8726 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AccountSecretsStore.kt @@ -105,26 +105,33 @@ class AccountSecretsStore( * The account's location-chat identity, migrating out of the legacy file on * first use, on the same terms as [read]. * - * @param legacy what `secret_keeper_` holds. Note the *hex*: this - * group's legacy file is keyed by the signer's pubkey rather than the npub - * every other group uses, so the caller opens a different file for it. + * @param legacy opens and reads `secret_keeper_`. Note the + * *hex*: this group's legacy file is keyed by the signer's pubkey rather + * than the npub every other group uses, so it is a different file. + * + * A lambda, not a value, because opening that file **creates** it — an + * `EncryptedSharedPreferences` writes its Tink keyset on construction. An + * eager read would resurrect the file on the load after the cleanup + * deleted it, and would cost a Keystore-backed open per account on every + * cold start. Called only when the store has nothing yet. */ suspend fun readGeohashIdentity( npub: String, - legacy: GeohashIdentitySecrets, + legacy: suspend () -> GeohashIdentitySecrets, ): GeohashIdentitySecrets { val stored = try { stores.loadGeohashIdentity(npub) } catch (e: Exception) { Log.w(TAG, "Could not read the location-chat identity for $npub; using the legacy file", e) - return legacy + return legacy() } if (stored != null) return stored - mirrorGeohashIdentity(npub, legacy) - return legacy + val fromLegacy = legacy() + mirrorGeohashIdentity(npub, fromLegacy) + return fromLegacy } /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index c797fcd434..f0c6f739d0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -344,7 +344,9 @@ object LocalPreferences { object : LegacyAccountFiles { override fun source(npub: String) = legacySource(npub) - override fun exists(npub: String) = legacyAccountFile(npub).exists() + // Either file: once the npub one is gone, the hex one still + // has to be reachable or it can never be removed. + override fun exists(npub: String) = legacyAccountFile(npub).exists() || legacyAccountFile(geohashLegacyKey(npub)).exists() override fun geohashSource(npub: String) = LegacySharedPreferences(encryptedPreferences(geohashLegacyKey(npub))) @@ -357,14 +359,12 @@ object LocalPreferences { // The location-chat identity is in a SECOND file, keyed by the // pubkey hex rather than the npub, because that is the key its - // writer passed. Nothing else would ever remove it, so it is - // deleted here with the account's own file rather than left as - // an orphan holding a seed forever. - val hex = geohashLegacyKey(npub) - encryptedPreferences(hex).edit(commit = true) { clear() } - legacyAccountFile(hex).delete() + // writer passed. Nothing else would ever remove it, so it goes + // with the account's own file rather than being left as an + // orphan holding a seed forever. + val removedGeohashFile = deleteGeohashLegacyFile(npub) - return removedAccountFile + return removedAccountFile || removedGeohashFile } }, currentStore = { npub -> accountStores.getDataStore(npub).data.first() }, @@ -401,6 +401,19 @@ object LocalPreferences { */ private fun geohashLegacyKey(npub: String): String = npub.bechToBytes("npub").toHexKey() + /** + * Clears and unlinks `secret_keeper_`. + * + * Clear before unlinking, as everything else here does: the live + * SharedPreferences still holds the values in memory and would write them + * straight back out. + */ + private fun deleteGeohashLegacyFile(npub: String): Boolean { + val hex = geohashLegacyKey(npub) + encryptedPreferences(hex).edit(commit = true) { clear() } + return legacyAccountFile(hex).delete() + } + /** * Copies the location-chat identity out of `secret_keeper_` on * the first load after the upgrade. @@ -412,14 +425,17 @@ object LocalPreferences { * user who never opens another location chat would keep both files * forever, which is the opposite of what the migration is for. * - * Idempotent: the store's marker makes every run after the first a no-op, - * so re-running it on each load cannot overwrite a later edit. + * Idempotent, and cheap after the first run: the store's marker short-circuits + * it, so re-running on each load cannot overwrite a later edit and — because + * the legacy read is a lambda — does not open `secret_keeper_` + * either. That matters beyond speed: opening an `EncryptedSharedPreferences` + * writes its Tink keyset, so an eager read would recreate the file on the + * load right after the cleanup deleted it, permanently. */ private suspend fun copyGeohashIdentity(npub: String) { - accountSecretsStore.readGeohashIdentity( - npub = npub, - legacy = readLegacyGeohashIdentity(LegacySharedPreferences(encryptedPreferences(geohashLegacyKey(npub)))), - ) + accountSecretsStore.readGeohashIdentity(npub) { + readLegacyGeohashIdentity(LegacySharedPreferences(encryptedPreferences(geohashLegacyKey(npub)))) + } } /** @@ -686,6 +702,11 @@ object LocalPreferences { // would resurrect the deleted settings from this cache. mutex.withLock { cachedAccounts.remove(accountInfo.npub) } encryptedPreferences(accountInfo.npub).edit(commit = true) { clear() } + // The location-chat identity's own file, keyed by pubkey hex. Without + // this the anonymous device seed outlives the account that owned it + // and comes back if the same npub is re-added — the opposite of what + // an unlinkable per-cell identity is for. + deleteGeohashLegacyFile(accountInfo.npub) accountKeyStore.delete(accountInfo.npub) accountSecretsStore.delete(accountInfo.npub) // The account's plain DataStore, which deleteUserPreferenceFile cannot @@ -1091,7 +1112,15 @@ object LocalPreferences { // than inside the loader for the reason [AccountStoreData] gives: // that method is at the JVM's 64KB limit and one more suspend call // inside it does not fit. - copyGeohashIdentity(npub) + // Never fatal, like every other legacy step here: this runs on + // the account-load path, and an EncryptedSharedPreferences that + // cannot be opened must not take the whole load — and with it the + // per-account loops in the notification consumers — down with it. + try { + copyGeohashIdentity(npub) + } catch (e: Exception) { + Log.w("LocalPreferences", "Could not copy the location-chat identity for $npub", e) + } legacyCleanup.deleteIfVerified(npub) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt index 21c011e8d6..e45bc638b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/GeohashChatIdentityState.kt @@ -87,15 +87,27 @@ class GeohashChatIdentityState( @Volatile private var loaded: GeohashIdentitySecrets? = null - /** What `secret_keeper_` holds. Touches disk; callers are off the main thread. */ + /** + * What `secret_keeper_` holds. + * + * Only called when the store has nothing yet: opening this file creates it, + * so reading it unconditionally would resurrect it after the cleanup has + * deleted it. Touches disk; callers are off the main thread. + */ private fun legacy(): GeohashIdentitySecrets = readLegacyGeohashIdentity(LegacySharedPreferences(Amethyst.instance.encryptedStorage(signer.pubKey))) - /** The stored identity, copying it out of the legacy file the first time. */ + /** + * The stored identity, copying it out of the legacy file the first time. + * + * **Call under [mutex].** Not self-locking, because [keyPair] already holds + * the lock when it reaches here and [Mutex] is not reentrant. + */ private suspend fun current(): GeohashIdentitySecrets { loaded?.let { return it } - return accountSecretsStore.readGeohashIdentity(npub, legacy()).also { loaded = it } + return accountSecretsStore.readGeohashIdentity(npub) { legacy() }.also { loaded = it } } + /** Call under [mutex], for the reason [current] gives. */ private suspend fun persist(value: GeohashIdentitySecrets) { loaded = value accountSecretsStore.mirrorGeohashIdentity(npub, value) @@ -107,7 +119,7 @@ class GeohashChatIdentityState( * messages are ephemeral (relays needn't store them), so the only durable home for it is the device. * Empty string means "no nickname set". */ - suspend fun nickname(): String = current().nickname ?: "" + suspend fun nickname(): String = mutex.withLock { current().nickname ?: "" } /** * Persists the global location-chat nickname (trimmed) for this account. @@ -119,13 +131,20 @@ class GeohashChatIdentityState( fun setNickname(value: String) { val trimmed = value.trim() scope.launch { - persist(current().copy(nickname = trimmed)) - // Mirrored, not moved: the legacy file stays readable until the - // legacy writes are retired app-wide, so a rollback keeps the handle. - // Gated on the same switch as every other mirror — otherwise flipping - // it would retire the documented four and leave this one writing. - if (!LocalPreferences.LEGACY_WRITES_RETIRED) { - Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_NICKNAME, trimmed) } + // Under the lock: this is a read-modify-write of the same group + // deviceSeed() writes. Racing the first seed mint, an unlocked copy + // would persist the nickname over a null deviceSeed, putOrRemove + // would delete the seed, and every per-cell identity minted that + // session would be unreproducible on the next launch. + mutex.withLock { + persist(current().copy(nickname = trimmed)) + // Mirrored, not moved: the legacy file stays readable until the + // legacy writes are retired app-wide, so a rollback keeps the handle. + // Gated on the same switch as every other mirror — otherwise flipping + // it would retire the documented four and leave this one writing. + if (!LocalPreferences.LEGACY_WRITES_RETIRED) { + Amethyst.instance.encryptedStorage(signer.pubKey).edit { putString(PREF_NICKNAME, trimmed) } + } } } } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt index e4cc8f3ebc..ddb6ca0aa0 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/LegacyPreferenceCleanupTest.kt @@ -64,16 +64,23 @@ private class FakeFiles( var present = true + /** + * Tracked apart from [present]: the two are different files, and the gate + * has to stay reachable while only one of them is left. + */ + var geohashPresent = true + override fun source(npub: String) = MapSource(values) override fun geohashSource(npub: String) = MapSource(geohashValues) - override fun exists(npub: String) = present + override fun exists(npub: String) = present || geohashPresent override suspend fun delete(npub: String): Boolean { deleted = true deletedGeohash = true present = false + geohashPresent = false return true } } @@ -292,10 +299,15 @@ class LegacyPreferenceCleanupTest { assertTrue(!files.deleted) } + /** Neither file — the account's own nor the location-chat one. */ @Test fun anAccountWithNoLegacyFileIsAlreadyDone() = runTest { - val files = FakeFiles(emptyMap()).also { it.present = false } + val files = + FakeFiles(emptyMap()).also { + it.present = false + it.geohashPresent = false + } val (_, subject) = cleanup(emptyMap(), files = files) assertEquals(LegacyCleanupResult.NothingToDelete, subject.deleteIfVerified(NPUB)) @@ -395,4 +407,25 @@ class LegacyPreferenceCleanupTest { assertEquals(LegacyCleanupResult.Deleted, subject.deleteIfVerified(NPUB)) assertTrue("the hex-keyed file must be deleted with the account's own", files.deletedGeohash) } + + /** + * Once the npub file is gone, the hex-keyed one is all that is left — and + * it still has to be removable. Gating on the account file alone returned + * NothingToDelete and stranded it forever. + */ + @Test + fun theGateStillRunsWhenOnlyTheLocationChatFileIsLeft() = + runTest { + val files = FakeFiles(emptyMap(), mapOf("geohash_chat_nickname" to "vitor")) + files.present = false + val (_, subject) = + cleanup( + values = emptyMap(), + files = files, + secrets = FakeSecrets(geohash = GeohashIdentitySecrets(nickname = "vitor")), + ) + + assertEquals(LegacyCleanupResult.Deleted, subject.deleteIfVerified(NPUB)) + assertTrue(files.deletedGeohash) + } } From f0c6695521d239e16286ee8c06dff07b9cde864f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Sep 2026 19:37:22 +0000 Subject: [PATCH 37/57] refactor(commons): move the favorites and browser-history registries out of the app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FavoriteAppsRegistry and BrowserHistoryRegistry were the two stores that 2539e510 repointed at AppPreferenceStores without relocating. That commit's scope was removing the Context.preferencesDataStore delegates, so these kept sitting in amethyst/ — by inertia, not because anything platform-specific held them there. Nothing in either was Android. The one real tie was that they reached out for their store: private val favoriteAppsDataStore: DataStore get() = Amethyst.instance.appStores.getDataStore("favorite_apps") Every store that already lives in commons takes its DataStore instead, for the reason DataStoreSearchHistoryStorage documents: DataStore refuses a second live instance on a path that already has one, so the caller's holder has to stay the single registry. Both are classes taking (store, scope) now, and the Android side does the binding in AppModules from appStores.getDataStore(FILE_NAME) and applicationIOScope. File names are unchanged, so nothing migrates. The Context parameter turned out to be dead. It was written once in init() and then only read as `appContext ?: return` — a has-init-run gate that happened to be typed Context?, never used as a Context. It is a Boolean now. The other platform call, System.currentTimeMillis() in record(), is TimeUtils.nowMillis(). ConcurrentHashMap.newKeySet() becomes commons' ConcurrentSet, which exists for exactly this (lock-striped on JVM, lock-guarded on iOS). BrowserHistoryRegistry's `hydrated` flag is gone: it was assigned and never read, unlike FavoriteAppsRegistry's, which gates the removal tombstones. The point of the move is that the disk lifecycle is now testable — as objects reaching into a singleton these had no unit coverage at all. 14 new tests, the ones worth naming being the two sides of the hydration window: a favorite removed after init() but before the merge lands must not be resurrected by it, and an add made in that same window must not be dropped by it. Both are driven on the test scheduler, so the window is a state the test controls rather than races. Also pinned: nothing is written before init() (without that gate a write in the window flushes a partial list over the stored one), a corrupt file hydrates empty, the history cap at 500, and that a blank title on a revisit does not overwrite the name the user recognises. Writing those tests surfaced the single-instance rule the hard way: the first restart tests opened a second DataStore on a live path and read an empty store, which looks exactly like data loss. Each test session now owns its Job and is cancelled before the next opens — the same rule production follows by keeping one instance per file. Verified: :commons:jvmTest, :commons:verifyKmpPurity, :commons:compileCommonMainKotlinMetadata, :amethyst:compilePlayDebugKotlin. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/Amethyst.kt | 6 +- .../com/vitorpamplona/amethyst/AppModules.kt | 12 + .../amethyst/favorites/FavoriteAppLauncher.kt | 2 +- .../amethyst/napplet/NappletBrokerService.kt | 16 +- .../ui/navigation/bottombars/AppBottomBar.kt | 5 +- .../bottombars/AppNavigationRail.kt | 5 +- .../screen/loggedIn/browser/BrowserScreen.kt | 24 +- .../screen/loggedIn/browser/WebAppScreen.kt | 10 +- .../embed/EmbeddedTabPreloadSweeper.kt | 6 +- .../embed/FavoriteAppManifestPreloader.kt | 9 +- .../loggedIn/favorites/FavoriteAppsScreen.kt | 7 +- .../favorites/FavoriteToggleButton.kt | 9 +- .../loggedIn/favorites/NostrAppScreen.kt | 11 +- .../settings/BottomBarSettingsScreen.kt | 8 +- .../browser}/BrowserHistoryRegistry.kt | 80 +++--- .../favorites/FavoriteAppsRegistry.kt | 117 ++++----- .../browser/BrowserHistoryRegistryTest.kt | 218 +++++++++++++++ .../favorites/FavoriteAppsRegistryTest.kt | 248 ++++++++++++++++++ 18 files changed, 636 insertions(+), 157 deletions(-) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/favorites => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser}/BrowserHistoryRegistry.kt (69%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/favorites/FavoriteAppsRegistry.kt (69%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserHistoryRegistryTest.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/favorites/FavoriteAppsRegistryTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt index c3445013ca..7266fdc6cc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt @@ -25,9 +25,7 @@ import android.content.ComponentCallbacks2 import android.os.Build import com.vitorpamplona.amethyst.commons.service.http.HttpClientEnvironment import com.vitorpamplona.amethyst.commons.service.http.MediaCallEventListener -import com.vitorpamplona.amethyst.favorites.BrowserHistoryRegistry import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.napplet.WebAppNetworkRegistry import com.vitorpamplona.amethyst.service.logging.Logging import com.vitorpamplona.amethyst.service.nests.AppForegroundRecycleHook @@ -143,10 +141,10 @@ class Amethyst : Application() { WorkerThreadPriorityGovernor.start(this) // Hydrate the device-local favorite-apps list (main process only; the sandbox never reads it). - FavoriteAppsRegistry.init(this) + instance.favoriteApps.init() // Hydrate the device-local browser visit history (main process only; feeds the omnibox suggestions). - BrowserHistoryRegistry.init(this) + instance.browserHistory.init() // Index device-local captured favicons (main process only; decorates favorites + suggestions). BrowserIconRegistry.init(this) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 26697a4fcb..2bfc9ff3be 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -27,8 +27,10 @@ import android.os.SystemClock import androidx.security.crypto.EncryptedSharedPreferences import coil3.disk.DiskCache import coil3.memory.MemoryCache +import com.vitorpamplona.amethyst.commons.browser.BrowserHistoryRegistry import com.vitorpamplona.amethyst.commons.connectedApps.DataStoreNostrSignerPermissionStore import com.vitorpamplona.amethyst.commons.connectedApps.nip46.DataStoreNip46ClientStore +import com.vitorpamplona.amethyst.commons.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.UiSettings import com.vitorpamplona.amethyst.commons.model.cache.LocalCache @@ -887,6 +889,16 @@ class AppModules( // Display + relay info for connected NIP-46 remote-signer clients. val nip46ClientStore by lazy { DataStoreNip46ClientStore(appStores.getDataStore(DataStoreNip46ClientStore.FILE_NAME)) } + // The device-local favorite-apps list behind the bottom bar, the Favorite Apps grid and the + // browser launcher, plus the browser's visit history behind the omnibox suggestions. Both live in + // commons and take their store and scope from here — that is the whole of their Android binding. + // + // Main process only: the keyless `:napplet` sandbox never builds AppModules, so it never builds + // these either. One instance each, so DataStore only ever sees one live reader per file. + val favoriteApps by lazy { FavoriteAppsRegistry(appStores.getDataStore(FavoriteAppsRegistry.FILE_NAME), applicationIOScope) } + + val browserHistory by lazy { BrowserHistoryRegistry(appStores.getDataStore(BrowserHistoryRegistry.FILE_NAME), applicationIOScope) } + // Authenticates with relays. val authCoordinator = AuthCoordinator(client, applicationIOScope) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt index cd6fb36b17..45cfd84f05 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppLauncher.kt @@ -97,7 +97,7 @@ object FavoriteAppLauncher { if (nightMask == Configuration.UI_MODE_NIGHT_YES) "DARK" else "LIGHT" } } - val isFavorite = FavoriteAppsRegistry.isFavorite("url:$url") + val isFavorite = Amethyst.instance.favoriteApps.isFavorite("url:$url") val intent = NappletBrowserActivity .intent( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt index 7f98885be1..c6badf72e0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt @@ -42,9 +42,7 @@ import com.vitorpamplona.amethyst.commons.napplet.NappletIdentityWatch import com.vitorpamplona.amethyst.commons.napplet.NappletRequestRouter import com.vitorpamplona.amethyst.commons.napplet.protocol.NappletProtocolJson import com.vitorpamplona.amethyst.commons.napplet.protocol.NappletResponse -import com.vitorpamplona.amethyst.favorites.BrowserHistoryRegistry import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.napplet.gateways.AccountNappletGateways import com.vitorpamplona.amethyst.napplethost.NappletIpc @@ -203,8 +201,9 @@ class NappletBrokerService : Service() { if (msg.what == NappletIpc.MSG_RECORD_HISTORY) { val data = msg.data ?: return true val url = data.getString(NappletIpc.KEY_HISTORY_URL)?.takeIf { it.isNotBlank() } ?: return true - BrowserHistoryRegistry.init(applicationContext) - BrowserHistoryRegistry.record(url, data.getString(NappletIpc.KEY_HISTORY_TITLE).orEmpty()) + val history = Amethyst.instance.browserHistory + history.init() + history.record(url, data.getString(NappletIpc.KEY_HISTORY_TITLE).orEmpty()) return true } @@ -223,12 +222,13 @@ class NappletBrokerService : Service() { val data = msg.data ?: return true val url = data.getString(NappletIpc.KEY_FAVORITE_URL)?.takeIf { it.isNotBlank() } ?: return true val label = data.getString(NappletIpc.KEY_FAVORITE_LABEL).orEmpty().ifBlank { url } - FavoriteAppsRegistry.init(applicationContext) + val favorites = Amethyst.instance.favoriteApps + favorites.init() val id = "url:$url" - if (FavoriteAppsRegistry.isFavorite(id)) { - FavoriteAppsRegistry.remove(id) + if (favorites.isFavorite(id)) { + favorites.remove(id) } else { - FavoriteAppsRegistry.add(FavoriteApp.WebApp(url, label, System.currentTimeMillis())) + favorites.add(FavoriteApp.WebApp(url, label, System.currentTimeMillis())) } return true } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt index 42c7f91d64..14d81fdaee 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt @@ -43,6 +43,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.browser.OmniboxInput import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp import com.vitorpamplona.amethyst.commons.favorites.FavoriteAppIcon @@ -60,7 +61,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size25Modifier import com.vitorpamplona.amethyst.commons.ui.theme.Size27Modifier import com.vitorpamplona.amethyst.commons.ui.theme.onSurface65 import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.favorites.rememberNappletIconModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -112,7 +112,8 @@ fun AppBottomBar( // Favorite entries in the unified list resolve to a live favorite for their icon/label and to an // embedded-tab route. Both kinds embed in-process (WebApp → browser surface, NostrApp → napplet // surface), so such a tab swaps in place rather than launching an activity from the bottom row. - val favorites by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val favorites by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() val isKeyboardState by keyboardAsState() if (isKeyboardState == KeyboardState.Closed) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppNavigationRail.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppNavigationRail.kt index b51d1059b5..30dddb074a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppNavigationRail.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppNavigationRail.kt @@ -36,9 +36,9 @@ import androidx.navigation.NavDestination import androidx.navigation.NavDestination.Companion.hasRoute import androidx.navigation.NavHostController import androidx.navigation.compose.currentBackStackEntryAsState +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.navigation.BottomBarEntry import com.vitorpamplona.amethyst.commons.model.navigation.Route -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.ui.navigation.navs.Nav import com.vitorpamplona.amethyst.ui.navigation.routes.getRouteWithArguments import com.vitorpamplona.amethyst.ui.navigation.topbars.LoggedInUserPictureDrawer @@ -58,7 +58,8 @@ fun AppNavigationRail( ) { val items by accountViewModel.account.settings.syncedSettings.navigation.bottomBarItems .collectAsStateWithLifecycle() - val favorites by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val favorites by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() val favoritesById = remember(favorites) { favorites.associateBy { it.id } } val reselectCoordinator = LocalTabReselectCoordinator.current diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt index 06f038fb22..d4e10ff587 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt @@ -75,6 +75,7 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import coil3.compose.AsyncImage import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.browser.BrowserHistoryEntry import com.vitorpamplona.amethyst.commons.browser.DefaultWebClients import com.vitorpamplona.amethyst.commons.browser.OmniboxInput import com.vitorpamplona.amethyst.commons.browser.OmniboxSuggestions @@ -101,11 +102,8 @@ import com.vitorpamplona.amethyst.commons.resources.favorite_app_remove import com.vitorpamplona.amethyst.commons.resources.favorite_app_still_loading import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.note.ArrowBackIcon -import com.vitorpamplona.amethyst.favorites.BrowserHistoryEntry -import com.vitorpamplona.amethyst.favorites.BrowserHistoryRegistry import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.favorites.FavoriteAppLauncher -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.favorites.PreloadFavoriteNostrApps import com.vitorpamplona.amethyst.favorites.rememberNappletIconModel import com.vitorpamplona.amethyst.ui.navigation.bottombars.AppBottomBar @@ -154,8 +152,10 @@ private fun BrowserLauncher( ) { val context = LocalContext.current val appStillLoadingStr = stringRes(Res.string.favorite_app_still_loading) - val apps by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() - val history by BrowserHistoryRegistry.history.collectAsStateWithLifecycle() + val apps by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() + val history by Amethyst.instance.browserHistory.history + .collectAsStateWithLifecycle() val iconKeys by BrowserIconRegistry.keys.collectAsStateWithLifecycle() // Fetch favorited nsite/napplet manifests up front so tapping one launches immediately instead of @@ -235,10 +235,10 @@ private fun BrowserLauncher( label: String, ) { val id = "url:$url" - if (FavoriteAppsRegistry.isFavorite(id)) { - FavoriteAppsRegistry.remove(id) + if (Amethyst.instance.favoriteApps.isFavorite(id)) { + Amethyst.instance.favoriteApps.remove(id) } else { - FavoriteAppsRegistry.add(FavoriteApp.WebApp(url, label.ifBlank { OmniboxInput.hostOf(url) ?: url }, System.currentTimeMillis())) + Amethyst.instance.favoriteApps.add(FavoriteApp.WebApp(url, label.ifBlank { OmniboxInput.hostOf(url) ?: url }, System.currentTimeMillis())) } } @@ -290,7 +290,7 @@ private fun BrowserLauncher( historyUrls = historyUrls, onOpen = { open(it.url) }, onToggleFavorite = { toggleFavorite(it.url, it.label) }, - onRemoveFromHistory = { BrowserHistoryRegistry.remove(it) }, + onRemoveFromHistory = { Amethyst.instance.browserHistory.remove(it) }, modifier = contentModifier, ) else -> { @@ -306,11 +306,11 @@ private fun BrowserLauncher( nsites = followedNsites, napplets = followedNapplets, onOpenApp = { FavoriteAppLauncher.launch(context, it, appStillLoadingStr) }, - onRemoveApp = { FavoriteAppsRegistry.remove(it.id) }, - onAddApp = { FavoriteAppsRegistry.add(it) }, + onRemoveApp = { Amethyst.instance.favoriteApps.remove(it.id) }, + onAddApp = { Amethyst.instance.favoriteApps.add(it) }, onOpenUrl = { open(it) }, onToggleRecentFavorite = { entry -> toggleFavorite(entry.url, entry.title.ifBlank { entry.host }) }, - onRemoveRecent = { BrowserHistoryRegistry.remove(it) }, + onRemoveRecent = { Amethyst.instance.browserHistory.remove(it) }, modifier = contentModifier, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/WebAppScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/WebAppScreen.kt index 8d0c221e5a..424c15c1bc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/WebAppScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/WebAppScreen.kt @@ -54,7 +54,6 @@ import com.vitorpamplona.amethyst.commons.resources.browser_unsupported import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.favorites.FavoriteAppLauncher -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.napplet.WebAppNetworkRegistry import com.vitorpamplona.amethyst.ui.navigation.bottombars.AppBottomBar import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -110,7 +109,8 @@ private fun EmbeddedWebAppTab( // can opt one out and it must stick). Only meaningful when Tor is actually available. var torOn by remember { mutableStateOf(proxyAvailable && WebAppNetworkRegistry.useTor(url)) } - val apps by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val apps by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() val isFavorite = remember(apps, currentUrl) { apps.any { it is FavoriteApp.WebApp && it.url == currentUrl } } val backgroundColor = MaterialTheme.colorScheme.background.toArgb() @@ -147,10 +147,10 @@ private fun EmbeddedWebAppTab( isFavorite = isFavorite, onFavorite = { val favId = "url:$currentUrl" - if (FavoriteAppsRegistry.isFavorite(favId)) { - FavoriteAppsRegistry.remove(favId) + if (Amethyst.instance.favoriteApps.isFavorite(favId)) { + Amethyst.instance.favoriteApps.remove(favId) } else { - FavoriteAppsRegistry.add(FavoriteApp.WebApp(currentUrl, hostLabel(currentUrl), System.currentTimeMillis())) + Amethyst.instance.favoriteApps.add(FavoriteApp.WebApp(currentUrl, hostLabel(currentUrl), System.currentTimeMillis())) } }, // NIP-07 grants for a plain web client are keyed per visited origin as `browser:` diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabPreloadSweeper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabPreloadSweeper.kt index 48c143ee19..8c68f970f1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabPreloadSweeper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/EmbeddedTabPreloadSweeper.kt @@ -23,8 +23,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.embed import android.content.Context import android.os.Build import androidx.annotation.RequiresApi +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.navigation.favoriteIds -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.napplet.NappletNetworkRegistry import com.vitorpamplona.amethyst.napplet.WebAppNetworkRegistry import kotlinx.coroutines.CoroutineScope @@ -113,7 +113,9 @@ object EmbeddedTabPreloadSweeper { NappletNetworkRegistry.awaitReady() var attempt = 0 while (isActive) { - val byId = FavoriteAppsRegistry.favorites.value.associateBy { it.id } + val byId = + Amethyst.instance.favoriteApps.favorites.value + .associateBy { it.id } var stillPending = false for (id in favoriteIds) { val app = byId[id] ?: continue diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/FavoriteAppManifestPreloader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/FavoriteAppManifestPreloader.kt index b38eee524f..9edabf3bdb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/FavoriteAppManifestPreloader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/embed/FavoriteAppManifestPreloader.kt @@ -26,9 +26,9 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.remember import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp import com.vitorpamplona.amethyst.commons.model.cache.LocalCache -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNote import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Event @@ -60,7 +60,8 @@ private const val MANIFEST_OFFLINE_FALLBACK_MS = 2_000L */ @Composable fun FavoriteAppManifestPreloader(accountViewModel: AccountViewModel) { - val favorites by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val favorites by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() val coordinates = remember(favorites) { favorites.filterIsInstance().map { it.coordinate } @@ -91,7 +92,7 @@ private fun WatchFavoriteManifest( LaunchedEffect(event?.id) { val resolved = event ?: return@LaunchedEffect withContext(Dispatchers.IO) { - FavoriteAppsRegistry.cacheManifest(coordinate, resolved.toJson()) + Amethyst.instance.favoriteApps.cacheManifest(coordinate, resolved.toJson()) } } @@ -103,7 +104,7 @@ private fun WatchFavoriteManifest( delay(MANIFEST_OFFLINE_FALLBACK_MS) if (LocalCache.getAddressableNoteIfExists(coordinate)?.event != null) return@LaunchedEffect withContext(Dispatchers.IO) { - val cached = FavoriteAppsRegistry.cachedManifest(coordinate) ?: return@withContext + val cached = Amethyst.instance.favoriteApps.cachedManifest(coordinate) ?: return@withContext Event.fromJsonOrNull(cached)?.let { LocalCache.justConsume(it, null, false) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt index b29f7462c2..c4e69e44f4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt @@ -59,6 +59,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.browser.OmniboxInput import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp import com.vitorpamplona.amethyst.commons.favorites.FavoriteAppIcon @@ -74,7 +75,6 @@ import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.favorites.FavoriteAppLauncher -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.favorites.PreloadFavoriteNostrApps import com.vitorpamplona.amethyst.favorites.rememberNappletIconModel import com.vitorpamplona.amethyst.ui.navigation.bottombars.AppBottomBar @@ -94,7 +94,8 @@ fun FavoriteAppsScreen( ) { val appStillLoadingStr = stringRes(Res.string.favorite_app_still_loading) val context = LocalContext.current - val apps by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val apps by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() // Fetch favorited nsite/napplet manifests up front so a tap launches immediately instead of showing // "isn't loaded yet" until the user happens to visit the nsite/napplet feed. @@ -126,7 +127,7 @@ fun FavoriteAppsScreen( FavoriteAppsGrid( apps = apps, onOpen = { FavoriteAppLauncher.launch(context, it, appStillLoadingStr) }, - onRemove = { FavoriteAppsRegistry.remove(it.id) }, + onRemove = { Amethyst.instance.favoriteApps.remove(it.id) }, modifier = Modifier .fillMaxSize() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteToggleButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteToggleButton.kt index b85cf1126c..0afea73440 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteToggleButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteToggleButton.kt @@ -27,6 +27,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols @@ -34,7 +35,6 @@ import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.favorite_app_add import com.vitorpamplona.amethyst.commons.resources.favorite_app_remove import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry /** * A star toggle that pins/unpins an nsite or napplet (a [FavoriteApp.NostrApp]) by its addressable @@ -47,16 +47,17 @@ fun FavoriteToggleButton( label: String, iconUrl: String? = null, ) { - val apps by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val apps by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() val id = "nostr:$coordinate" val isFavorite = remember(apps, id) { apps.any { it.id == id } } IconButton( onClick = { if (isFavorite) { - FavoriteAppsRegistry.remove(id) + Amethyst.instance.favoriteApps.remove(id) } else { - FavoriteAppsRegistry.add(FavoriteApp.NostrApp(coordinate, label, System.currentTimeMillis(), iconUrl)) + Amethyst.instance.favoriteApps.add(FavoriteApp.NostrApp(coordinate, label, System.currentTimeMillis(), iconUrl)) } }, ) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/NostrAppScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/NostrAppScreen.kt index 1067fce67e..552dfc6441 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/NostrAppScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/NostrAppScreen.kt @@ -54,6 +54,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.navigation.favoriteIds @@ -72,7 +73,6 @@ import com.vitorpamplona.amethyst.commons.resources.favorite_notice_uploaded import com.vitorpamplona.amethyst.commons.ui.loadStringRes import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.favorites.FavoriteAppLauncher -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.napplethost.HostProfile import com.vitorpamplona.amethyst.napplethost.NappletEmbedContract import com.vitorpamplona.amethyst.napplethost.NappletHostContract @@ -147,7 +147,8 @@ private fun EmbeddedNostrAppTab( var canGoBack by remember { mutableStateOf(false) } var showAccess by remember { mutableStateOf(false) } - val apps by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val apps by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() val isFavorite = remember(apps, coordinate) { apps.any { it.id == "nostr:$coordinate" } } val controller = @@ -182,10 +183,10 @@ private fun EmbeddedNostrAppTab( isFavorite = isFavorite, onFavorite = { val favId = "nostr:$coordinate" - if (FavoriteAppsRegistry.isFavorite(favId)) { - FavoriteAppsRegistry.remove(favId) + if (Amethyst.instance.favoriteApps.isFavorite(favId)) { + Amethyst.instance.favoriteApps.remove(favId) } else { - FavoriteAppsRegistry.add(FavoriteApp.NostrApp(coordinate, title, System.currentTimeMillis())) + Amethyst.instance.favoriteApps.add(FavoriteApp.NostrApp(coordinate, title, System.currentTimeMillis())) } }, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt index d2d91c37a6..38b405e133 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/BottomBarSettingsScreen.kt @@ -67,6 +67,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp import com.vitorpamplona.amethyst.commons.favorites.FavoriteAppIcon import com.vitorpamplona.amethyst.commons.icons.symbols.Icon @@ -92,7 +93,6 @@ import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton import com.vitorpamplona.amethyst.commons.ui.theme.Size22Modifier import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow -import com.vitorpamplona.amethyst.favorites.FavoriteAppsRegistry import com.vitorpamplona.amethyst.ui.navigation.bottombars.BottomBarCategories import com.vitorpamplona.amethyst.ui.navigation.bottombars.GroupEntryAvatar import com.vitorpamplona.amethyst.ui.navigation.bottombars.GroupEntryDisplay @@ -498,7 +498,8 @@ private fun PickerChildren( ) { when (item) { NavBarItem.BROWSER -> { - val favorites by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val favorites by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() if (favorites.isEmpty()) { EmptyChildHint(Res.string.bottom_bar_settings_no_favorites) } else { @@ -817,7 +818,8 @@ private fun rememberPinnedVisual( PinnedVisual.Glyph(def?.icon ?: MaterialSymbols.Apps, def?.let { stringRes(it.labelRes) } ?: "") } is BottomBarEntry.Favorite -> { - val favorites by FavoriteAppsRegistry.favorites.collectAsStateWithLifecycle() + val favorites by Amethyst.instance.favoriteApps.favorites + .collectAsStateWithLifecycle() val app = favorites.firstOrNull { it.id == entry.favoriteId } if (app != null) PinnedVisual.Favorite(app) else PinnedVisual.Glyph(MaterialSymbols.Public, "") } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserHistoryRegistry.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserHistoryRegistry.kt similarity index 69% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserHistoryRegistry.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserHistoryRegistry.kt index e9988b23e7..3d4f010948 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserHistoryRegistry.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserHistoryRegistry.kt @@ -18,36 +18,23 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.favorites +package com.vitorpamplona.amethyst.commons.browser -import android.content.Context import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import com.vitorpamplona.amethyst.Amethyst -import com.vitorpamplona.amethyst.commons.browser.OmniboxInput import com.vitorpamplona.quartz.nip01Core.core.JsonMapper import com.vitorpamplona.quartz.utils.Log +import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import kotlinx.serialization.Serializable - -/** - * The browser-history file, on the app-wide holder rather than a `Context` delegate. - * Same path the delegate resolved to, so nothing migrates. - * - * Main process only: [Amethyst.instance] is deliberately unset in the - * `:napplet` sandbox. - */ -private val browserHistoryDataStore: DataStore - get() = Amethyst.instance.appStores.getDataStore("browser_history") +import kotlin.concurrent.Volatile /** * One device-local visited site, keyed by full [url]. [visitCount]/[lastVisitedAt] drive frecency ranking @@ -65,39 +52,40 @@ data class BrowserHistoryEntry( /** * The browser's visit history — the data behind the omnibox suggestions, alongside the user's favorites. * - * **Only pages that actually loaded land here.** [record] is called from the `:napplet` browser host - * (relayed over IPC through `NappletBrokerService`) on a *successful* main-frame page-finish — never from - * the address bar as the user types — so misspelled/never-resolved hosts never pollute the list. Bounded - * to [MAX_ENTRIES] most-recent entries. + * **Only pages that actually loaded land here.** [record] is meant to be called on a *successful* + * main-frame page-finish — never from the address bar as the user types — so misspelled/never-resolved + * hosts never pollute the list. Bounded to [MAX_ENTRIES] most-recent entries. On Android the call is + * relayed from the `:napplet` browser host over IPC through `NappletBrokerService`. * - * Lives only in the **main process** (the launcher/omnibox consume it; the keyless `:napplet` sandbox - * never reads it). Same shape as [FavoriteAppsRegistry]: an authoritative in-memory [StateFlow] for - * synchronous Compose reads, with write-through persistence to a DataStore on a background scope. + * Same shape as [com.vitorpamplona.amethyst.commons.favorites.FavoriteAppsRegistry]: an authoritative + * in-memory [StateFlow] for synchronous Compose reads, write-through persistence to [store] on [scope], + * and the [DataStore] handed in rather than reached for, so the caller's store holder stays the single + * registry and nothing here depends on a front end. + * + * One instance per process. On Android the launcher/omnibox in the **main** process own it; the keyless + * `:napplet` sandbox never builds one. */ -object BrowserHistoryRegistry { - private val KEY = stringPreferencesKey("history") - private const val MAX_ENTRIES = 500 - +class BrowserHistoryRegistry( + private val store: DataStore, + private val scope: CoroutineScope, +) { private val _history = MutableStateFlow>(emptyList()) val history: StateFlow> = _history.asStateFlow() - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + // Gates persistence until init() has been called: writing before hydration has been scheduled + // would flush a partial list over the stored one. Set synchronously in init(), so the merge it + // launches still persists whatever the session recorded in the meantime. + @Volatile private var started = false - @Volatile private var appContext: Context? = null - - @Volatile private var hydrated = false - - /** Binds the app context and hydrates the on-disk list into [history]. Idempotent. */ - fun init(context: Context) { - if (appContext != null) return - val ctx = context.applicationContext - appContext = ctx + /** Hydrates the on-disk list into [history]. Idempotent. */ + fun init() { + if (started) return + started = true scope.launch { - val json = browserHistoryDataStore.data.first()[KEY] + val json = store.data.first()[KEY] val loaded = if (json != null) decode(json) else emptyList() // Merge disk under anything already recorded this session (session wins, newest-first). update { current -> dedupeNewestFirst(current + loaded) } - hydrated = true } } @@ -110,7 +98,7 @@ object BrowserHistoryRegistry { title: String, ) { val host = OmniboxInput.hostOf(url) ?: url - val now = System.currentTimeMillis() + val now = TimeUtils.nowMillis() update { current -> val existing = current.firstOrNull { it.url == url } val entry = @@ -146,9 +134,9 @@ object BrowserHistoryRegistry { } private fun persist(json: String) { - appContext ?: return + if (!started) return scope.launch { - browserHistoryDataStore.edit { it[KEY] = json } + store.edit { it[KEY] = json } } } @@ -161,4 +149,12 @@ object BrowserHistoryRegistry { Log.w("BrowserHistoryRegistry", "Failed to decode history", e) emptyList() } + + companion object { + /** Same file the `Context.preferencesDataStore("browser_history")` delegate resolved to. */ + const val FILE_NAME = "browser_history" + + private val KEY = stringPreferencesKey("history") + private const val MAX_ENTRIES = 500 + } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppsRegistry.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/favorites/FavoriteAppsRegistry.kt similarity index 69% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppsRegistry.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/favorites/FavoriteAppsRegistry.kt index ad9d03d325..74c1480770 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/FavoriteAppsRegistry.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/favorites/FavoriteAppsRegistry.kt @@ -18,89 +18,77 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.favorites +package com.vitorpamplona.amethyst.commons.favorites -import android.content.Context import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringPreferencesKey -import com.vitorpamplona.amethyst.Amethyst -import com.vitorpamplona.amethyst.commons.favorites.FavoriteApp +import com.vitorpamplona.amethyst.commons.util.ConcurrentSet import com.vitorpamplona.quartz.nip01Core.core.JsonMapper import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import kotlinx.serialization.Serializable -import java.util.concurrent.ConcurrentHashMap - -/** - * The favorite-apps file, on the app-wide holder rather than a `Context` delegate. - * Same path the delegate resolved to, so nothing migrates. - * - * Main process only: [Amethyst.instance] is deliberately unset in the - * `:napplet` sandbox. - */ -private val favoriteAppsDataStore: DataStore - get() = Amethyst.instance.appStores.getDataStore("favorite_apps") +import kotlin.concurrent.Volatile /** * The user's device-local list of [FavoriteApp]s — the single source of truth shared by the bottom * bar, the Favorite Apps grid, and the browser launcher. Ordered (the user can reorder); de-duplicated * by [FavoriteApp.id]. * - * Lives only in the **main process** (the launcher/UI consume it); the keyless `:napplet` sandbox never - * touches it. An in-memory [StateFlow] is authoritative for the session so Compose can observe it - * synchronously, with write-through persistence to a DataStore on a background scope. The list is - * stored as a single JSON array under one key (small, bounded, hand-curated data — no need for one key - * per entry). + * An in-memory [StateFlow] is authoritative for the session so Compose can observe it synchronously, + * with write-through persistence to [store] on [scope]. The list is stored as a single JSON array + * under one key (small, bounded, hand-curated data — no need for one key per entry). + * + * Takes its [DataStore] rather than reaching for one, for the same reason + * `DataStoreSearchHistoryStorage` does: DataStore refuses a second live instance on a path that + * already has one, so the caller's store holder stays the single registry. That is also what keeps + * this class off any one front end — the Android app builds it in `AppModules` from + * `appStores.getDataStore(FILE_NAME)`, and nothing here knows about `Context` or the app singleton. + * + * One instance per process. On Android the launcher/UI in the **main** process own it; the keyless + * `:napplet` sandbox never builds one. */ -object FavoriteAppsRegistry { - private val KEY = stringPreferencesKey("favorites") - - // Raw manifest event JSON for each favorited [FavoriteApp.NostrApp], keyed by its addressable - // coordinate. Cached so a pinned nsite/napplet resolves instantly on the next cold start — and - // offline — instead of waiting on a relay round-trip the way a [FavoriteApp.WebApp]'s URL never - // has to. The relay subscription that warms these favorites keeps the cache fresh. - private val MANIFESTS_KEY = stringPreferencesKey("manifests") - +class FavoriteAppsRegistry( + private val store: DataStore, + private val scope: CoroutineScope, +) { private val _favorites = MutableStateFlow>(emptyList()) val favorites: StateFlow> = _favorites.asStateFlow() private val manifestCache = MutableStateFlow>(emptyMap()) - private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) + // Gates persistence until init() has been called: writing before hydration has been scheduled + // would flush a partial list over the stored one. Set synchronously in init(), so the merge it + // launches still persists whatever the session added in the meantime. + @Volatile private var started = false - @Volatile private var appContext: Context? = null - - // Hydration runs async on a background scope, so the user can add/remove before the disk list - // merges in. [removedBeforeHydration] tombstones any id removed in that window, so the merge can't + // Hydration runs async on [scope], so the user can add/remove before the disk list merges in. + // [removedBeforeHydration] tombstones any id removed in that window, so the merge can't // resurrect a just-deleted favorite from disk. @Volatile private var hydrated = false - private val removedBeforeHydration = ConcurrentHashMap.newKeySet() + private val removedBeforeHydration = ConcurrentSet() - /** Binds the app context and hydrates the on-disk list into [favorites]. Idempotent. */ - fun init(context: Context) { - if (appContext != null) return - val ctx = context.applicationContext - appContext = ctx + /** Hydrates the on-disk list into [favorites]. Idempotent. */ + fun init() { + if (started) return + started = true scope.launch { - val prefs = favoriteAppsDataStore.data.first() + val prefs = store.data.first() val loaded = prefs[KEY]?.let { decode(it) } ?: emptyList() // Don't clobber adds made in this session before hydration finished, and don't resurrect // anything the user removed in that same window. - update { current -> (loaded.filterNot { it.id in removedBeforeHydration } + current).distinctBy { it.id } } + update { current -> (loaded.filterNot { removedBeforeHydration.contains(it.id) } + current).distinctBy { it.id } } // Same race rules for the manifest cache: a cacheManifest() in this session wins over the // disk copy, and a manifest whose favorite was removed pre-hydration must not come back. val loadedManifests = prefs[MANIFESTS_KEY]?.let { decodeManifests(it) } ?: emptyMap() - updateManifests { current -> loadedManifests.filterKeys { "nostr:$it" !in removedBeforeHydration } + current } + updateManifests { current -> loadedManifests.filterKeys { !removedBeforeHydration.contains("nostr:$it") } + current } hydrated = true removedBeforeHydration.clear() @@ -138,27 +126,23 @@ object FavoriteAppsRegistry { val next = transform(_favorites.value) if (next == _favorites.value) return _favorites.value = next - persist(encode(next)) + persist(KEY, encode(next)) } private inline fun updateManifests(transform: (Map) -> Map) { val next = transform(manifestCache.value) if (next == manifestCache.value) return manifestCache.value = next - persistManifests(encodeManifests(next)) + persist(MANIFESTS_KEY, encodeManifests(next)) } - private fun persist(json: String) { - appContext ?: return + private fun persist( + key: Preferences.Key, + json: String, + ) { + if (!started) return scope.launch { - favoriteAppsDataStore.edit { it[KEY] = json } - } - } - - private fun persistManifests(json: String) { - appContext ?: return - scope.launch { - favoriteAppsDataStore.edit { it[MANIFESTS_KEY] = json } + store.edit { it[key] = json } } } @@ -199,9 +183,6 @@ object FavoriteAppsRegistry { emptyList() } - private const val TYPE_NOSTR = "nostr" - private const val TYPE_URL = "url" - // --- Manifest cache persistence ------------------------------------------------------------- // Stored as a flat list of (coordinate, json) records under one key — same single-key, hand-curated // shape as the favorites list, so we never serialize a raw polymorphic map. @@ -221,4 +202,20 @@ object FavoriteAppsRegistry { Log.w("FavoriteAppsRegistry", "Failed to decode favorite manifests", e) emptyMap() } + + companion object { + /** Same file the `Context.preferencesDataStore("favorite_apps")` delegate resolved to. */ + const val FILE_NAME = "favorite_apps" + + private val KEY = stringPreferencesKey("favorites") + + // Raw manifest event JSON for each favorited [FavoriteApp.NostrApp], keyed by its addressable + // coordinate. Cached so a pinned nsite/napplet resolves instantly on the next cold start — and + // offline — instead of waiting on a relay round-trip the way a [FavoriteApp.WebApp]'s URL never + // has to. The relay subscription that warms these favorites keeps the cache fresh. + private val MANIFESTS_KEY = stringPreferencesKey("manifests") + + private const val TYPE_NOSTR = "nostr" + private const val TYPE_URL = "url" + } } diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserHistoryRegistryTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserHistoryRegistryTest.kt new file mode 100644 index 0000000000..108389ccfb --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserHistoryRegistryTest.kt @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.browser + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.cancel +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * The visit history's ranking inputs and its bound, neither of which had coverage while this was an + * Android-side `object`. The omnibox ranks on [BrowserHistoryEntry.visitCount] and + * [BrowserHistoryEntry.lastVisitedAt], so a bump that does not bump is a silently wrong suggestion + * order rather than a crash. + */ +class BrowserHistoryRegistryTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun newFile() = File(folder.root, "browser_history_${seq++}.preferences_pb") + + private fun store( + scope: CoroutineScope, + file: File, + ): DataStore = PreferenceDataStoreFactory.createWithPath(scope = scope, produceFile = { file.toOkioPath() }) + + /** + * One app "session" over [file]. Each gets its own [Job] so the DataStore it opened is released + * when the session is cancelled: DataStore refuses a second live instance on a path that already + * has one, which is exactly why production keeps a single instance per file in the store holder. + * A restart test that skipped this would read an empty store and look like data loss. + */ + private fun TestScope.session(file: File): Pair { + val scope = CoroutineScope(coroutineContext + Job()) + return BrowserHistoryRegistry(store(scope, file), scope) to scope + } + + /** A revisit is a bump, not a second row — this is what makes frecency mean anything. */ + @Test + fun revisitingAUrlBumpsTheCountInsteadOfAddingARow() = + runTest { + val (registry, _) = session(newFile()) + registry.init() + advanceUntilIdle() + + registry.record("https://example.com/a", "A") + registry.record("https://example.com/a", "A again") + + assertEquals("one row for one url", 1, registry.history.value.size) + assertEquals( + "visit count bumped", + 2, + registry.history.value + .single() + .visitCount, + ) + assertEquals( + "title refreshed", + "A again", + registry.history.value + .single() + .title, + ) + } + + /** A page that finishes loading with no must not blank out the name the user recognises. */ + @Test + fun aBlankTitleOnARevisitKeepsTheOldOne() = + runTest { + val (registry, _) = session(newFile()) + registry.init() + advanceUntilIdle() + + registry.record("https://example.com/a", "Real Title") + registry.record("https://example.com/a", " ") + + assertEquals( + "the blank did not overwrite it", + "Real Title", + registry.history.value + .single() + .title, + ) + } + + /** Most recent first, because that is the order the omnibox shows them in. */ + @Test + fun theMostRecentVisitLeads() = + runTest { + val (registry, _) = session(newFile()) + registry.init() + advanceUntilIdle() + + registry.record("https://first.example", "First") + registry.record("https://second.example", "Second") + + assertEquals( + "newest at the front", + listOf("https://second.example", "https://first.example"), + registry.history.value.map { it.url }, + ) + } + + /** The bound is what stops an unbounded JSON blob being rewritten on every page load. */ + @Test + fun historyIsCappedAtFiveHundredEntries() = + runTest { + val (registry, _) = session(newFile()) + registry.init() + advanceUntilIdle() + + repeat(505) { registry.record("https://example.com/page$it", "Page $it") } + + assertEquals("capped", 500, registry.history.value.size) + assertEquals( + "and it is the oldest that fell off", + "https://example.com/page504", + registry.history.value + .first() + .url, + ) + assertTrue("page0 is gone", registry.history.value.none { it.url == "https://example.com/page0" }) + } + + @Test + fun historySurvivesARestart() = + runTest { + val file = newFile() + + val (first, firstScope) = session(file) + first.init() + advanceUntilIdle() + first.record("https://example.com/a", "A") + advanceUntilIdle() + firstScope.cancel() + + val (second, _) = session(file) + second.init() + advanceUntilIdle() + + assertEquals("hydrated from disk", listOf("https://example.com/a"), second.history.value.map { it.url }) + assertEquals( + "with its count", + 1, + second.history.value + .single() + .visitCount, + ) + } + + /** Clearing is a privacy action: it has to reach disk, not just the in-memory flow. */ + @Test + fun clearingEmptiesTheStoredHistoryToo() = + runTest { + val file = newFile() + + val (first, firstScope) = session(file) + first.init() + advanceUntilIdle() + first.record("https://example.com/a", "A") + advanceUntilIdle() + first.clear() + advanceUntilIdle() + firstScope.cancel() + + val (second, _) = session(file) + second.init() + advanceUntilIdle() + + assertTrue("nothing came back", second.history.value.isEmpty()) + } + + @Test + fun removingOneUrlLeavesTheRest() = + runTest { + val (registry, _) = session(newFile()) + registry.init() + advanceUntilIdle() + + registry.record("https://keep.example", "Keep") + registry.record("https://drop.example", "Drop") + registry.remove("https://drop.example") + + assertEquals("only the one", listOf("https://keep.example"), registry.history.value.map { it.url }) + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/favorites/FavoriteAppsRegistryTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/favorites/FavoriteAppsRegistryTest.kt new file mode 100644 index 0000000000..1d4e8f52d1 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/favorites/FavoriteAppsRegistryTest.kt @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.favorites + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringPreferencesKey +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.cancel +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * The registry's disk lifecycle, which had no coverage while it was an Android-side `object` reaching + * into `Amethyst.instance` for its store. Taking the [DataStore] as a constructor argument is what + * makes these reachable. + * + * Every test drives the registry on the test scheduler, so "hydration has not finished yet" is a state + * the test controls rather than races: [advanceUntilIdle] is the only thing that lets the coroutine + * [FavoriteAppsRegistry.init] launches actually run. + */ +class FavoriteAppsRegistryTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun newFile() = File(folder.root, "favorite_apps_${seq++}.preferences_pb") + + private fun store( + scope: CoroutineScope, + file: File, + ): DataStore<Preferences> = PreferenceDataStoreFactory.createWithPath(scope = scope, produceFile = { file.toOkioPath() }) + + /** + * One app "session" over [file]. Each gets its own [Job] so the DataStore it opened is released + * when the session is cancelled: DataStore refuses a second live instance on a path that already + * has one, which is exactly why production keeps a single instance per file in the store holder. + * A restart test that skipped this would read an empty store and look like data loss. + */ + private fun TestScope.session(file: File): Pair<FavoriteAppsRegistry, CoroutineScope> { + val scope = CoroutineScope(coroutineContext + Job()) + return FavoriteAppsRegistry(store(scope, file), scope) to scope + } + + private fun web( + url: String, + label: String = url, + ) = FavoriteApp.WebApp(url, label, addedAt = 1L) + + /** What the user actually notices: a favorite added in one session is there in the next. */ + @Test + fun aFavoriteSurvivesARestart() = + runTest { + val file = newFile() + + val (first, firstScope) = session(file) + first.init() + advanceUntilIdle() + first.add(web("https://example.com")) + advanceUntilIdle() + firstScope.cancel() + + val (second, _) = session(file) + second.init() + advanceUntilIdle() + + assertEquals( + "the favorite written by the first session is what the second one hydrates", + listOf("url:https://example.com"), + second.favorites.value.map { it.id }, + ) + } + + /** + * The tombstone. Removing between init() and the merge landing must win, or the disk copy + * resurrects a favorite the user just deleted — and then persists it again. + */ + @Test + fun hydrationDoesNotResurrectAFavoriteRemovedBeforeItFinished() = + runTest { + val file = newFile() + + val (seeded, seededScope) = session(file) + seeded.init() + advanceUntilIdle() + seeded.add(web("https://gone.example")) + seeded.add(web("https://kept.example")) + advanceUntilIdle() + seededScope.cancel() + + val (reopened, _) = session(file) + reopened.init() + // Still inside the window: init() launched the merge but nothing has run it yet. + reopened.remove("url:https://gone.example") + advanceUntilIdle() + + assertEquals( + "the removal beat the merge and must survive it", + listOf("url:https://kept.example"), + reopened.favorites.value.map { it.id }, + ) + } + + /** The other side of the same window: an add made before the merge must not be dropped by it. */ + @Test + fun hydrationKeepsAnAddMadeBeforeItFinished() = + runTest { + val file = newFile() + + val (seeded, seededScope) = session(file) + seeded.init() + advanceUntilIdle() + seeded.add(web("https://ondisk.example")) + advanceUntilIdle() + seededScope.cancel() + + val (reopened, _) = session(file) + reopened.init() + reopened.add(web("https://thissession.example")) + advanceUntilIdle() + + assertEquals( + "both the disk copy and the pre-merge add are present", + setOf("url:https://ondisk.example", "url:https://thissession.example"), + reopened.favorites.value + .map { it.id } + .toSet(), + ) + } + + /** + * Persistence is gated on init(). Without the gate a write in that window flushes a list that has + * not merged with disk yet, which is the stored list being replaced by a partial one. + */ + @Test + fun nothingIsWrittenBeforeInit() = + runTest { + val file = newFile() + + val (registry, writerScope) = session(file) + registry.add(web("https://notpersisted.example")) + advanceUntilIdle() + + assertEquals( + "the add is live in memory", + listOf("url:https://notpersisted.example"), + registry.favorites.value.map { it.id }, + ) + writerScope.cancel() + advanceUntilIdle() + val readerScope = CoroutineScope(coroutineContext + Job()) + assertNull( + "but nothing reached disk, because init() never ran", + store(readerScope, file).data.first()[stringPreferencesKey("favorites")], + ) + readerScope.cancel() + } + + /** A favorite's cached manifest must not outlive the favorite. */ + @Test + fun removingANostrFavoriteDropsItsCachedManifest() = + runTest { + val (registry, _) = session(newFile()) + registry.init() + advanceUntilIdle() + + val coordinate = "31990:pubkey:slug" + registry.add(FavoriteApp.NostrApp(coordinate, "An App", addedAt = 1L)) + registry.cacheManifest(coordinate, """{"kind":31990}""") + assertEquals("cached while favorited", """{"kind":31990}""", registry.cachedManifest(coordinate)) + + registry.remove("nostr:$coordinate") + advanceUntilIdle() + + assertNull("and gone with the favorite", registry.cachedManifest(coordinate)) + } + + /** Garbage on disk must degrade to an empty list, never take the launcher down with it. */ + @Test + fun aCorruptStoredListHydratesAsEmpty() = + runTest { + val file = newFile() + val seedScope = CoroutineScope(coroutineContext + Job()) + store(seedScope, file).edit { it[stringPreferencesKey("favorites")] = "}not json[" } + advanceUntilIdle() + seedScope.cancel() + advanceUntilIdle() + + val (registry, _) = session(file) + registry.init() + advanceUntilIdle() + + assertTrue("decode failed softly", registry.favorites.value.isEmpty()) + } + + /** Ids are the identity: adding the same app twice is a no-op, not a duplicate row. */ + @Test + fun addingTheSameAppTwiceKeepsOneEntry() = + runTest { + val (registry, _) = session(newFile()) + registry.init() + advanceUntilIdle() + + registry.add(web("https://example.com", "First")) + registry.add(web("https://example.com", "Second")) + + assertEquals("de-duplicated by id", 1, registry.favorites.value.size) + assertEquals( + "and the first one won", + "First", + registry.favorites.value + .single() + .label, + ) + } +} From 2cd6569fe97a8b09032e58e993be3beea0ca620d Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Fri, 25 Sep 2026 20:04:34 +0000 Subject: [PATCH 38/57] refactor(commons): move the browser favicon registry out of the app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BrowserIconRegistry was the third of the trio flagged as still sitting in amethyst/, and the only one with a real platform tie: unlike the other two, its Context was not dead — it supplied filesDir for the icon directory. It is a small tie, and commons already has the shape for it. AppPreferenceStores takes `rootFilesDir: () -> Path`, so this takes `iconDir: () -> Path` and goes through commons' platformFileSystem (the expect/actual that exists because okio declares FileSystem.SYSTEM per platform). The Android app passes `{ appContext.filesDir.toOkioPath() / BrowserIconRegistry.DIR }`, which is the same filesDir/browser_icons the object used, so stored favicons are found where they were left. No bitmaps are involved anywhere — it has always been ByteArray in, `file://` string out. One behaviour change, deliberate: the startup scan now merges into `keys` instead of assigning it. A record() that landed while the scan was in flight had already written its file and added its key, and the wholesale assignment dropped it — the icon sat on disk unshown until the next launch. Not pinned by a test, and that is on purpose: making the scan finish after a concurrent record is not something I can force deterministically, so any test I wrote would pass with or without the change and would only look like coverage. 8 new tests for what is deterministic: a recorded icon reaches disk with the bytes given and is announced, icons already on disk are indexed by init(), an unknown host has no model (iconModelFor is read from composition, so it answers from `keys` rather than touching the filesystem), a missing icon directory is created rather than dropping the icon, blank hosts and empty byte arrays are ignored, and hosts are sanitized into one flat filename both when storing and when looking up — "Example.COM:8080/../etc" cannot escape the directory. Writing them repeated the lesson from f0c66955 in a new form: with the registry's scope set to runTest's backgroundScope, none of the launched disk work ran under advanceUntilIdle and every assertion failed as though the code did nothing. Same `coroutineContext + Job()` session idiom as the other two suites now. Three call sites used it as a method reference (`::iconModelFor`), which has no trailing dot and so was missed by the first pass over the callers — caught by the compiler, not by grep. Verified: :commons:jvmTest, :commons:verifyKmpPurity, :commons:compileCommonMainKotlinMetadata, :amethyst:compilePlayDebugKotlin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/Amethyst.kt | 3 +- .../com/vitorpamplona/amethyst/AppModules.kt | 7 + .../amethyst/favorites/BrowserIconRegistry.kt | 124 ----------- .../amethyst/favorites/NappletFavoriteIcon.kt | 7 +- .../amethyst/napplet/NappletBrokerService.kt | 6 +- .../amethyst/napplet/NappletConsentSummary.kt | 4 +- .../amethyst/napplet/NostrSignerOpLabels.kt | 6 +- .../ui/navigation/bottombars/AppBottomBar.kt | 6 +- .../screen/loggedIn/browser/BrowserScreen.kt | 8 +- .../loggedIn/favorites/FavoriteAppsScreen.kt | 6 +- .../napplets/ConnectedAppDetailScreen.kt | 3 +- .../commons/browser/BrowserIconRegistry.kt | 141 +++++++++++++ .../browser/BrowserIconRegistryTest.kt | 197 ++++++++++++++++++ 13 files changed, 369 insertions(+), 149 deletions(-) delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserIconRegistry.kt create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistryTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt index 7266fdc6cc..5715d4e98b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/Amethyst.kt @@ -25,7 +25,6 @@ import android.content.ComponentCallbacks2 import android.os.Build import com.vitorpamplona.amethyst.commons.service.http.HttpClientEnvironment import com.vitorpamplona.amethyst.commons.service.http.MediaCallEventListener -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.napplet.WebAppNetworkRegistry import com.vitorpamplona.amethyst.service.logging.Logging import com.vitorpamplona.amethyst.service.nests.AppForegroundRecycleHook @@ -147,7 +146,7 @@ class Amethyst : Application() { instance.browserHistory.init() // Index device-local captured favicons (main process only; decorates favorites + suggestions). - BrowserIconRegistry.init(this) + instance.browserIcons.init() // Warm the global-settings prefs off-main so the first (deliberately synchronous) read of // them does not hit disk on the main thread. See LocalPreferences.warmGlobalSettings. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 2bfc9ff3be..8c98c1f1b4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -28,6 +28,7 @@ import androidx.security.crypto.EncryptedSharedPreferences import coil3.disk.DiskCache import coil3.memory.MemoryCache import com.vitorpamplona.amethyst.commons.browser.BrowserHistoryRegistry +import com.vitorpamplona.amethyst.commons.browser.BrowserIconRegistry import com.vitorpamplona.amethyst.commons.connectedApps.DataStoreNostrSignerPermissionStore import com.vitorpamplona.amethyst.commons.connectedApps.nip46.DataStoreNip46ClientStore import com.vitorpamplona.amethyst.commons.favorites.FavoriteAppsRegistry @@ -899,6 +900,12 @@ class AppModules( val browserHistory by lazy { BrowserHistoryRegistry(appStores.getDataStore(BrowserHistoryRegistry.FILE_NAME), applicationIOScope) } + // Favicons captured by the browser host, one PNG per host. Not a DataStore — it takes the directory + // to keep them in, the same way AppPreferenceStores takes rootFilesDir. + val browserIcons by lazy { + BrowserIconRegistry({ appContext.filesDir.toOkioPath() / BrowserIconRegistry.DIR }, applicationIOScope) + } + // Authenticates with relays. val authCoordinator = AuthCoordinator(client, applicationIOScope) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserIconRegistry.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserIconRegistry.kt deleted file mode 100644 index f2d37b5453..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/BrowserIconRegistry.kt +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.favorites - -import android.content.Context -import com.vitorpamplona.quartz.utils.Log -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.update -import kotlinx.coroutines.launch -import java.io.File - -/** - * Device-local favicon store for browsed sites, keyed by host. Favicons are **captured from the WebView - * that already loaded the page** in the keyless `:napplet` browser host (where they ride the page's own — - * Tor-routed — network path) and relayed here as PNG bytes over IPC; this is the privacy-preserving - * alternative to the main app fetching `host/favicon.ico` itself, which would bypass Tor and leak the - * visit. Used to decorate favorite cards and omnibox suggestion rows. - * - * Lives only in the **main process**. Bytes are persisted as one small PNG per host under - * `filesDir/browser_icons`; the deterministic path means the only in-memory state is [keys] — the set of - * hosts that currently have an icon — which exists purely to drive Compose recomposition (and to keep - * `File.exists()` disk checks out of composition). - */ -object BrowserIconRegistry { - private const val DIR = "browser_icons" - - private val _keys = MutableStateFlow<Set<String>>(emptySet()) - - /** Sanitized host keys that currently have a stored icon. Observe to recompose when an icon arrives. */ - val keys: StateFlow<Set<String>> = _keys.asStateFlow() - - @Volatile private var iconDir: File? = null - - // Disk work runs here, never on the caller's thread. Both entry points are reached from threads - // that must not block: init() from app startup and record() from the broker's IPC handler, which - // is the main looper — StrictMode flagged the write, and a slow filesystem would have stalled the - // UI while a favicon was saved. - private val io = CoroutineScope(SupervisorJob() + Dispatchers.IO) - - /** - * Binds the app context and indexes already-stored icons. Idempotent. - * - * [iconDir] is published synchronously so [iconModelFor] and [record] work immediately; only the - * directory scan is deferred. Until it lands [keys] is empty, so an icon simply renders its - * placeholder for one frame and then recomposes — [keys] is a StateFlow precisely so that arrival - * drives recomposition. - */ - fun init(context: Context) { - if (iconDir != null) return - val dir = File(context.applicationContext.filesDir, DIR) - iconDir = dir - io.launch { - dir.mkdirs() - _keys.value = dir.listFiles()?.mapNotNull { it.name.removeSuffix(PNG).takeIf { n -> n.isNotBlank() } }?.toSet() ?: emptySet() - } - } - - /** Persists [bytes] as the favicon for [host] and marks it available. Called from the broker on IPC. */ - fun record( - host: String, - bytes: ByteArray, - ) { - val dir = iconDir ?: return - if (host.isBlank() || bytes.isEmpty()) return - val key = sanitize(host) - // Fire-and-forget: a favicon is a decoration, and the IPC handler must not wait on disk. - // [keys] updates only after the bytes are actually on disk, so a reader can never be told an - // icon exists before the file backing it does. - io.launch { - try { - dir.mkdirs() - File(dir, key + PNG).writeBytes(bytes) - _keys.update { it + key } - } catch (e: Exception) { - Log.w("BrowserIconRegistry", "Failed to store favicon for $host", e) - } - } - } - - /** - * A Coil model (`file://…`) for [host]'s favicon, or null when none is stored. Reads [keys] so callers - * that observe the flow recompose as icons arrive — pass [keys]'s value as a `remember` key. - */ - fun iconModelFor(host: String): String? { - val dir = iconDir ?: return null - val key = sanitize(host) - if (key !in _keys.value) return null - return "file://" + File(dir, key + PNG).absolutePath - } - - // Hosts map to a flat, filesystem-safe filename. Collisions (two hosts → one key) only mean a shared - // icon file, which is harmless for a decoration. - private fun sanitize(host: String): String = - host - .lowercase() - .map { if (it.isLetterOrDigit() || it == '.' || it == '-') it else '_' } - .joinToString("") - .take(120) - - private const val PNG = ".png" -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/NappletFavoriteIcon.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/NappletFavoriteIcon.kt index 330f648f09..f6b1e609e7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/NappletFavoriteIcon.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/favorites/NappletFavoriteIcon.kt @@ -111,7 +111,7 @@ private fun resolveIconBlob(event: Event?): IconBlob? = /** * A Coil model (`file://…`) for the cached favicon of [url]'s host, or null when no favicon - * has been captured yet. The favicon is stored by [BrowserIconRegistry] at browse time (the + * has been captured yet. The favicon is stored by [com.vitorpamplona.amethyst.commons.browser.BrowserIconRegistry] at browse time (the * WebView captures it in the sandboxed `:napplet` process); this composable just reads the cache. * * Early-returns null when [url] is blank or has no parseable host — this early return is stable @@ -121,8 +121,9 @@ private fun resolveIconBlob(event: Event?): IconBlob? = @Composable fun rememberWebAppIconModel(url: String): String? { val host = remember(url) { OmniboxInput.hostOf(url) } ?: return null - val iconKeys by BrowserIconRegistry.keys.collectAsStateWithLifecycle() - return remember(host, iconKeys) { BrowserIconRegistry.iconModelFor(host) } + val iconKeys by Amethyst.instance.browserIcons.keys + .collectAsStateWithLifecycle() + return remember(host, iconKeys) { Amethyst.instance.browserIcons.iconModelFor(host) } } /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt index c6badf72e0..3340367115 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletBrokerService.kt @@ -42,7 +42,6 @@ import com.vitorpamplona.amethyst.commons.napplet.NappletIdentityWatch import com.vitorpamplona.amethyst.commons.napplet.NappletRequestRouter import com.vitorpamplona.amethyst.commons.napplet.protocol.NappletProtocolJson import com.vitorpamplona.amethyst.commons.napplet.protocol.NappletResponse -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.napplet.gateways.AccountNappletGateways import com.vitorpamplona.amethyst.napplethost.NappletIpc @@ -212,8 +211,9 @@ class NappletBrokerService : Service() { val data = msg.data ?: return true val host = data.getString(NappletIpc.KEY_ICON_HOST)?.takeIf { it.isNotBlank() } ?: return true val bytes = data.getByteArray(NappletIpc.KEY_ICON_BYTES) ?: return true - BrowserIconRegistry.init(applicationContext) - BrowserIconRegistry.record(host, bytes) + val icons = Amethyst.instance.browserIcons + icons.init() + icons.record(host, bytes) return true } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt index 500b133ef6..3c0d13871e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.napplet import android.content.Context +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.browser.OmniboxInput import com.vitorpamplona.amethyst.commons.napplet.NappletCapability import com.vitorpamplona.amethyst.commons.napplet.NappletIdentity @@ -62,7 +63,6 @@ import com.vitorpamplona.amethyst.commons.resources.napplet_consent_upload import com.vitorpamplona.amethyst.commons.resources.napplet_fallback_title import com.vitorpamplona.amethyst.commons.ui.loadPluralStringRes import com.vitorpamplona.amethyst.commons.ui.loadStringRes -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.lightning.LnInvoiceUtil import com.vitorpamplona.quartz.nip01Core.core.fastForEach @@ -95,7 +95,7 @@ class NappletConsentSummary( val (title, iconUrl) = if (identity.authorPubKey == "browser") { val host = OmniboxInput.hostOf(identity.identifier) ?: identity.identifier - host to BrowserIconRegistry.iconModelFor(host) + host to Amethyst.instance.browserIcons.iconModelFor(host) } else { resolveNappletMeta(identity.authorPubKey, identity.identifier, untitled) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NostrSignerOpLabels.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NostrSignerOpLabels.kt index ce636d427a..9ff3361771 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NostrSignerOpLabels.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NostrSignerOpLabels.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.napplet import android.content.Context +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.browser.OmniboxInput import com.vitorpamplona.amethyst.commons.connectedApps.signers.NostrSignerOp import com.vitorpamplona.amethyst.commons.model.cache.LocalCache @@ -39,7 +40,6 @@ import com.vitorpamplona.amethyst.commons.resources.nip46_signer_allow_always_fo import com.vitorpamplona.amethyst.commons.ui.loadStringRes import com.vitorpamplona.amethyst.connectedApps.consent.SignerConnectInfo import com.vitorpamplona.amethyst.connectedApps.consent.SignerConsentInfo -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.kindNameFor import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey @@ -83,7 +83,7 @@ suspend fun buildSignerConsentInfo( val (title, iconUrl) = if (identity.authorPubKey == "browser") { val host = OmniboxInput.hostOf(identity.identifier) ?: identity.identifier - host to BrowserIconRegistry.iconModelFor(host) + host to Amethyst.instance.browserIcons.iconModelFor(host) } else { resolveNappletMeta(identity.authorPubKey, identity.identifier, untitled) } @@ -183,7 +183,7 @@ suspend fun buildConnectInfo( val (title, iconUrl) = if (identity.authorPubKey == "browser") { val host = OmniboxInput.hostOf(identity.identifier) ?: identity.identifier - host to BrowserIconRegistry.iconModelFor(host) + host to Amethyst.instance.browserIcons.iconModelFor(host) } else { resolveNappletMeta(identity.authorPubKey, identity.identifier, untitled) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt index 14d81fdaee..c91ee5a633 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/bottombars/AppBottomBar.kt @@ -60,7 +60,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size10Modifier import com.vitorpamplona.amethyst.commons.ui.theme.Size25Modifier import com.vitorpamplona.amethyst.commons.ui.theme.Size27Modifier import com.vitorpamplona.amethyst.commons.ui.theme.onSurface65 -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.favorites.rememberNappletIconModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -132,9 +131,10 @@ internal fun rememberFavoriteIconModel(fav: FavoriteApp): Any? = when (fav) { is FavoriteApp.WebApp -> { // Captured favicons, keyed so the icon appears once the site's capture lands. - val iconKeys by BrowserIconRegistry.keys.collectAsStateWithLifecycle() + val iconKeys by Amethyst.instance.browserIcons.keys + .collectAsStateWithLifecycle() remember(fav, iconKeys) { - OmniboxInput.hostOf(fav.url)?.let(BrowserIconRegistry::iconModelFor) + OmniboxInput.hostOf(fav.url)?.let(Amethyst.instance.browserIcons::iconModelFor) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt index d4e10ff587..cc5430711b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/browser/BrowserScreen.kt @@ -102,7 +102,6 @@ import com.vitorpamplona.amethyst.commons.resources.favorite_app_remove import com.vitorpamplona.amethyst.commons.resources.favorite_app_still_loading import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.note.ArrowBackIcon -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.favorites.FavoriteAppLauncher import com.vitorpamplona.amethyst.favorites.PreloadFavoriteNostrApps import com.vitorpamplona.amethyst.favorites.rememberNappletIconModel @@ -156,7 +155,8 @@ private fun BrowserLauncher( .collectAsStateWithLifecycle() val history by Amethyst.instance.browserHistory.history .collectAsStateWithLifecycle() - val iconKeys by BrowserIconRegistry.keys.collectAsStateWithLifecycle() + val iconKeys by Amethyst.instance.browserIcons.keys + .collectAsStateWithLifecycle() // Fetch favorited nsite/napplet manifests up front so tapping one launches immediately instead of // showing "isn't loaded yet" until the user happens to visit the nsite/napplet feed. @@ -571,7 +571,7 @@ private fun SuggestedRow( onClick: () -> Unit, onAddFavorite: () -> Unit, ) { - val iconModel = remember(entry, iconKeys) { OmniboxInput.hostOf(entry.app.url)?.let(BrowserIconRegistry::iconModelFor) } + val iconModel = remember(entry, iconKeys) { OmniboxInput.hostOf(entry.app.url)?.let(Amethyst.instance.browserIcons::iconModelFor) } Row( modifier = Modifier @@ -798,7 +798,7 @@ private fun SiteIcon( iconKeys: Set<String>, modifier: Modifier = Modifier, ) { - val model = remember(host, iconKeys) { BrowserIconRegistry.iconModelFor(host) } + val model = remember(host, iconKeys) { Amethyst.instance.browserIcons.iconModelFor(host) } val symbol = if (isFavorite) MaterialSymbols.Star else MaterialSymbols.Public val tint = MaterialTheme.colorScheme.onSurfaceVariant if (model == null) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt index c4e69e44f4..f3e9e9f896 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/favorites/FavoriteAppsScreen.kt @@ -73,7 +73,6 @@ import com.vitorpamplona.amethyst.commons.resources.favorite_apps import com.vitorpamplona.amethyst.commons.resources.favorite_apps_empty import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.favorites.FavoriteAppLauncher import com.vitorpamplona.amethyst.favorites.PreloadFavoriteNostrApps import com.vitorpamplona.amethyst.favorites.rememberNappletIconModel @@ -190,12 +189,13 @@ internal fun FavoriteAppCell( // For a plain web favorite, prefer the favicon captured when its site was opened; an nsite/napplet uses // the verified icon blob bundled in its own content. Observing the key set recomputes the model as a // captured favicon arrives. - val iconKeys by BrowserIconRegistry.keys.collectAsStateWithLifecycle() + val iconKeys by Amethyst.instance.browserIcons.keys + .collectAsStateWithLifecycle() val faviconModel = when (app) { is FavoriteApp.WebApp -> remember(app, iconKeys) { - OmniboxInput.hostOf(app.url)?.let(BrowserIconRegistry::iconModelFor) + OmniboxInput.hostOf(app.url)?.let(Amethyst.instance.browserIcons::iconModelFor) } is FavoriteApp.NostrApp -> rememberNappletIconModel(app.coordinate) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/ConnectedAppDetailScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/ConnectedAppDetailScreen.kt index ed86de0cb2..9e7491a45d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/ConnectedAppDetailScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/napplets/ConnectedAppDetailScreen.kt @@ -110,7 +110,6 @@ import com.vitorpamplona.amethyst.commons.resources.nip46_signer_reconnecting import com.vitorpamplona.amethyst.commons.resources.nip46_signer_remote_app import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton -import com.vitorpamplona.amethyst.favorites.BrowserIconRegistry import com.vitorpamplona.amethyst.favorites.rememberManifestIconModel import com.vitorpamplona.amethyst.favorites.rememberWebAppIconModel import com.vitorpamplona.amethyst.napplet.NappletBrokerService @@ -790,7 +789,7 @@ private suspend fun loadDetailState( val (title, iconUrl) = if (author == "browser") { val host = OmniboxInput.hostOf(identifier) ?: identifier - host to BrowserIconRegistry.iconModelFor(host) + host to Amethyst.instance.browserIcons.iconModelFor(host) } else { resolveNappletMeta(author, identifier, untitled) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt new file mode 100644 index 0000000000..f7f6c4bb69 --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.browser + +import com.vitorpamplona.amethyst.commons.util.platformFileSystem +import com.vitorpamplona.quartz.utils.Log +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch +import okio.Path +import kotlin.concurrent.Volatile + +/** + * Device-local favicon store for browsed sites, keyed by host. Favicons are **captured from the WebView + * that already loaded the page** — on Android, in the keyless `:napplet` browser host, where they ride the + * page's own (Tor-routed) network path — and handed here as PNG bytes; this is the privacy-preserving + * alternative to the app fetching `host/favicon.ico` itself, which would bypass Tor and leak the visit. + * Used to decorate favorite cards and omnibox suggestion rows. + * + * Bytes are persisted as one small PNG per host under [iconDir], so the only in-memory state is [keys] — + * the set of hosts that currently have an icon — which exists purely to drive Compose recomposition (and + * to keep filesystem existence checks out of composition). + * + * [iconDir] is a function rather than a path for the same reason [com.vitorpamplona.amethyst.commons.model.preferences.AppPreferenceStores] + * takes `rootFilesDir`: the front end owns where its files live, and resolving it lazily keeps this class + * free of any platform's notion of an app directory. The Android app passes + * `{ appContext.filesDir.toOkioPath() / DIR }`. + * + * One instance per process. On Android the launcher/UI in the **main** process own it; the keyless + * `:napplet` sandbox never builds one and relays captured bytes over IPC instead. + */ +class BrowserIconRegistry( + private val iconDir: () -> Path, + private val scope: CoroutineScope, +) { + private val _keys = MutableStateFlow<Set<String>>(emptySet()) + + /** Sanitized host keys that currently have a stored icon. Observe to recompose when an icon arrives. */ + val keys: StateFlow<Set<String>> = _keys.asStateFlow() + + @Volatile private var started = false + + /** + * Indexes already-stored icons. Idempotent. + * + * Only the directory scan is deferred; [iconModelFor] and [record] resolve [iconDir] themselves and + * work immediately. Until the scan lands [keys] is empty, so an icon renders its placeholder for one + * frame and then recomposes — [keys] is a StateFlow precisely so that arrival drives recomposition. + */ + fun init() { + if (started) return + started = true + scope.launch { + try { + val dir = iconDir() + platformFileSystem.createDirectories(dir) + val scanned = + platformFileSystem + .list(dir) + .mapNotNull { it.name.removeSuffix(PNG).takeIf { name -> name.isNotBlank() } } + .toSet() + // Merged rather than assigned: a record() that lands while the scan is in flight has + // already written its file and added its key, and overwriting the set wholesale would + // drop it — the icon would sit on disk unshown until the next launch. + _keys.update { it + scanned } + } catch (e: Exception) { + Log.w("BrowserIconRegistry", "Failed to index stored favicons", e) + } + } + } + + /** Persists [bytes] as the favicon for [host] and marks it available. */ + fun record( + host: String, + bytes: ByteArray, + ) { + if (host.isBlank() || bytes.isEmpty()) return + val key = sanitize(host) + // Fire-and-forget: a favicon is a decoration, and the caller (on Android, the broker's IPC + // handler, which runs on the main looper) must not wait on disk. + // [keys] updates only after the bytes are actually on disk, so a reader can never be told an + // icon exists before the file backing it does. + scope.launch { + try { + val dir = iconDir() + platformFileSystem.createDirectories(dir) + platformFileSystem.write(dir / (key + PNG)) { write(bytes) } + _keys.update { it + key } + } catch (e: Exception) { + Log.w("BrowserIconRegistry", "Failed to store favicon for $host", e) + } + } + } + + /** + * A Coil model (`file://…`) for [host]'s favicon, or null when none is stored. Reads [keys] so callers + * that observe the flow recompose as icons arrive — pass [keys]'s value as a `remember` key. + */ + fun iconModelFor(host: String): String? { + val key = sanitize(host) + if (key !in _keys.value) return null + return "file://" + (iconDir() / (key + PNG)) + } + + companion object { + /** Same directory the Android registry used: `filesDir/browser_icons`. */ + const val DIR = "browser_icons" + + private const val PNG = ".png" + + // Hosts map to a flat, filesystem-safe filename. Collisions (two hosts → one key) only mean a + // shared icon file, which is harmless for a decoration. + private fun sanitize(host: String): String = + host + .lowercase() + .map { if (it.isLetterOrDigit() || it == '.' || it == '-') it else '_' } + .joinToString("") + .take(120) + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistryTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistryTest.kt new file mode 100644 index 0000000000..1e5593e921 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistryTest.kt @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.browser + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.runTest +import okio.Path.Companion.toOkioPath +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * The favicon store's disk behaviour. Untestable while it was an Android `object` taking a `Context` + * for its `filesDir`; taking `iconDir: () -> Path` is what opens it up. + */ +class BrowserIconRegistryTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + private fun newDir(): File = folder.newFolder("icons_${seq++}") + + private val png = byteArrayOf(0x89.toByte(), 0x50, 0x4E, 0x47) + + /** One app "session" over [dir], on the test scheduler so [advanceUntilIdle] drives its disk work. */ + private fun TestScope.registryOver(dir: File) = BrowserIconRegistry({ dir.toOkioPath() }, CoroutineScope(coroutineContext + Job())) + + @Test + fun aRecordedIconBecomesAvailableAndReachesDisk() = + runTest { + val dir = newDir() + val registry = registryOver(dir) + registry.init() + advanceUntilIdle() + + registry.record("example.com", png) + advanceUntilIdle() + + assertEquals("the host is announced", setOf("example.com"), registry.keys.value) + assertEquals( + "and the model points at the file", + "file://" + File(dir, "example.com.png").absolutePath, + registry.iconModelFor("example.com"), + ) + assertTrue("which exists", File(dir, "example.com.png").exists()) + assertEquals("with the bytes given", png.toList(), File(dir, "example.com.png").readBytes().toList()) + } + + /** A cold start has to find what earlier sessions stored, or every icon redownloads on first paint. */ + @Test + fun iconsAlreadyOnDiskAreIndexedByInit() = + runTest { + val dir = newDir() + File(dir, "already.example.png").writeBytes(png) + + val registry = registryOver(dir) + assertTrue("nothing is known before init", registry.keys.value.isEmpty()) + + registry.init() + advanceUntilIdle() + + assertEquals("the stored icon is indexed", setOf("already.example"), registry.keys.value) + } + + /** + * [BrowserIconRegistry.iconModelFor] is read from composition, so it must answer from [keys] rather + * than touch the filesystem — a host with no icon is null, not a path to a file that is not there. + */ + @Test + fun aHostWithNoStoredIconHasNoModel() = + runTest { + val registry = registryOver(newDir()) + registry.init() + advanceUntilIdle() + + assertNull(registry.iconModelFor("never-visited.example")) + } + + /** Host keys become one flat filename, so a port or an uppercase host cannot escape the directory. */ + @Test + fun hostsAreSanitizedIntoASingleFlatFilename() = + runTest { + val dir = newDir() + val registry = registryOver(dir) + registry.init() + advanceUntilIdle() + + registry.record("Example.COM:8080/../etc", png) + advanceUntilIdle() + + assertEquals( + "lowercased, and everything but letters/digits/dot/dash replaced", + setOf("example.com_8080_.._etc"), + registry.keys.value, + ) + assertEquals( + "one file, directly in the icon dir", + listOf("example.com_8080_.._etc.png"), + dir.listFiles()?.map { it.name }, + ) + } + + /** Lookups are sanitized the same way, so the caller passes the raw host and still finds it. */ + @Test + fun aLookupSanitizesTheHostTheSameWay() = + runTest { + val dir = newDir() + val registry = registryOver(dir) + registry.init() + advanceUntilIdle() + + registry.record("Example.COM", png) + advanceUntilIdle() + + assertEquals( + "the raw host resolves to the sanitized file", + "file://" + File(dir, "example.com.png").absolutePath, + registry.iconModelFor("Example.COM"), + ) + } + + @Test + fun aBlankHostOrEmptyBytesAreIgnored() = + runTest { + val dir = newDir() + val registry = registryOver(dir) + registry.init() + advanceUntilIdle() + + registry.record(" ", png) + registry.record("example.com", ByteArray(0)) + advanceUntilIdle() + + assertTrue("nothing announced", registry.keys.value.isEmpty()) + assertEquals("nothing written", emptyList<String>(), dir.listFiles()?.map { it.name }) + } + + @Test + fun aRecordedIconSurvivesARestart() = + runTest { + val dir = newDir() + + val first = registryOver(dir) + first.init() + advanceUntilIdle() + first.record("example.com", png) + advanceUntilIdle() + + val second = registryOver(dir) + second.init() + advanceUntilIdle() + + assertEquals("indexed again from disk", setOf("example.com"), second.keys.value) + } + + /** The icon dir need not exist yet: a first run must create it rather than drop the icon. */ + @Test + fun aMissingIconDirectoryIsCreated() = + runTest { + val dir = File(folder.root, "not_yet_${seq++}") + val registry = registryOver(dir) + registry.init() + advanceUntilIdle() + + registry.record("example.com", png) + advanceUntilIdle() + + assertTrue("the directory was created", dir.isDirectory) + assertEquals("and the icon landed in it", setOf("example.com"), registry.keys.value) + } +} From f5fc432e950d9e05c650a5c2cd32e3aee05e495a Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Fri, 25 Sep 2026 21:05:27 +0000 Subject: [PATCH 39/57] refactor(commons): move the marmot encrypted stores and the NIP-11 / online caches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two clusters from the survey of what was left in amethyst/, both cases of code that was shared-layer already and just happened to live in the app. The four Marmot stores go to commons/jvmAndroid/marmot, next to the EncryptedAppendLog they were already built on. Nothing in them was Android despite the prefix: no android.* import, no Context, just (rootDir: File, encryption: SecretEncryption) and the quartz interfaces. One call site, AccountCacheState. The KDoc lines claiming "Android implementation" and "AES/GCM via Android KeyStore" are reworded: SecretEncryption is expect/actual, AndroidKeyStore on Android and a key file on desktop, so the old wording is now only half true. Commons already referred to two of them by name in its own KDoc; those references are updated. They are Encrypted* rather than File*, and that is not cosmetic. cli/stores already declares FileMlsGroupStateStore, FileMarmotMessageStore, FileKeyPackageBundleStore and FilePublishObligationStore — deliberately UNENCRYPTED test-harness stores, in a module that depends on commons. Two same-named classes with opposite encryption semantics, one import away from each other, is how MLS state ends up written in plaintext. Encrypted* is also what these actually are, and reads correctly next to EncryptedAppendLog. Nip11CachedRetriever + Nip11Retriever + RetrieveResult go to commons/relays/nip11, and OnlineChecker to commons/service. RetrieveResult had to travel: the cache is typed on it and commons cannot import from amethyst. Nip11RetrieverTest travels too — it sat in the same package and used the class with no import line. LoadRelayInfo and RelaySupportsNip stay behind; both reach Amethyst.instance. android.util.LruCache -> androidx.collection.LruCache is not the pure import swap it looks like, and the compiler said so: androidx bounds V to Any, while android.util.LruCache is a Java platform type that accepted LruCache<NormalizedRelayUrl, RetrieveResult?>. Checked all four put() sites first — every one stores a concrete RetrieveResult, so the nullable argument never meant anything and get() still returns null on a miss, which is what the readers already branch on. Dropping it is behaviour-preserving. NotifyCoordinator does NOT move despite being grouped with the other two: android.util.LruCache really is its only platform import, but it takes accountForPubkey: (HexKey) -> Account?, and Account lives in amethyst/model. It needs that abstraction, not an import swap. 17 new tests. OnlineChecker's predicates decide whether the UI shows a player or an offline placeholder, so the five-minute TTL is pinned in both directions — a stale online entry must stop reading online, and a stale offline one must stop suppressing retries — along with resetIfOfflineToRetry dropping only failures, since evicting good entries would refetch every URL that already worked. Its suspend probe is left alone: it needs a real OkHttp round trip and commons has no MockWebServer, so there is no honest way to drive it. Same reason Nip11CachedRetriever gets nothing new here; its fetch and error-caching paths are all network. The Marmot tests cover what restart depends on: group state, sender ratchet and message log surviving a new store over the same directory, deletes removing both the state and the listing, and two account directories not seeing each other. Writing them found validation I had not noticed reading the code — group ids must be hex, which is a path-traversal guard — after a first pass using readable labels failed every test on it. That guard is pinned now too: "../escape" and friends are rejected rather than resolved to a path. Verified: :commons:jvmTest (2549, 0 failures), :amethyst:testPlayDebugUnitTest, :cli:compileKotlin, :commons:verifyKmpPurity, :commons:compileCommonMainKotlinMetadata, :amethyst:compilePlayDebugKotlin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../com/vitorpamplona/amethyst/AppModules.kt | 2 +- .../model/accountsCache/AccountCacheState.kt | 26 +-- .../model/nip11RelayInfo/LoadRelayInfo.kt | 1 + .../ui/screen/loggedIn/AccountViewModel.kt | 2 +- .../LiveActivityChannelScreen.kt | 2 +- .../DiscoverLiveFeedFilter.kt | 2 +- .../ui/screen/loggedIn/home/HomeScreen.kt | 2 +- .../loggedIn/home/live/LiveStatusIndicator.kt | 2 +- .../livestreams/dal/LiveStreamsFeedFilter.kt | 2 +- .../common/BasicRelaySetupInfoClickableRow.kt | 2 +- .../common/BasicRelaySetupInfoDialog.kt | 2 +- .../relays/common/RelayUrlEditField.kt | 2 +- .../relays/common/ShowRelaySuggestionList.kt | 2 +- .../relays/vanish/RequestToVanishScreen.kt | 2 +- .../marmot/InMemoryMlsGroupStateStore.kt | 2 +- .../commons/marmot/EncryptedAppendLog.kt | 2 +- .../marmot/EncryptedKeyPackageBundleStore.kt | 14 +- .../marmot/EncryptedMarmotMessageStore.kt | 12 +- .../marmot/EncryptedMlsGroupStateStore.kt | 14 +- .../marmot/EncryptedPublishObligationStore.kt | 8 +- .../relays/nip11}/Nip11CachedRetriever.kt | 11 +- .../commons/relays/nip11}/Nip11Retriever.kt | 2 +- .../commons/relays/nip11}/RetrieveResult.kt | 2 +- .../amethyst/commons}/service/OnlineCheck.kt | 4 +- .../marmot/EncryptedMarmotStoresTest.kt | 184 ++++++++++++++++++ .../relays/nip11}/Nip11RetrieverTest.kt | 2 +- .../commons/service/OnlineCheckerTest.kt | 117 +++++++++++ 27 files changed, 366 insertions(+), 59 deletions(-) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedKeyPackageBundleStore.kt (90%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotMessageStore.kt (97%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMlsGroupStateStore.kt (95%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedPublishObligationStore.kt (97%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11}/Nip11CachedRetriever.kt (92%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11}/Nip11Retriever.kt (98%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11}/RetrieveResult.kt (97%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons}/service/OnlineCheck.kt (98%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotStoresTest.kt rename {amethyst/src/test/java/com/vitorpamplona/amethyst/model/nip11RelayInfo => commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11}/Nip11RetrieverTest.kt (97%) create mode 100644 commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/OnlineCheckerTest.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 8c98c1f1b4..956a3aba61 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -55,6 +55,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.event.EventFinderQueryStat import com.vitorpamplona.amethyst.commons.relayClient.speedLogger.RelaySpeedLogger import com.vitorpamplona.amethyst.commons.relayClient.user.UserFinderQueryState import com.vitorpamplona.amethyst.commons.relays.health.TorCircuitHealthTracker +import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.richtext.CachedAsciiDocToMarkdown import com.vitorpamplona.amethyst.commons.richtext.CachedRichTextParser import com.vitorpamplona.amethyst.commons.robohash.CachedRobohash @@ -75,7 +76,6 @@ import com.vitorpamplona.amethyst.commons.state.UiSettingsState import com.vitorpamplona.amethyst.commons.tor.TorSettings import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState -import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.model.nip60Cashu.CashuPreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder 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 2c347c81c7..c5559ecbe3 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 @@ -26,6 +26,10 @@ import com.vitorpamplona.amethyst.commons.connectedApps.nip46.InMemoryNip46Clien import com.vitorpamplona.amethyst.commons.connectedApps.nip46.Nip46ClientStore import com.vitorpamplona.amethyst.commons.connectedApps.signers.InMemoryNostrSignerPermissionStore import com.vitorpamplona.amethyst.commons.connectedApps.signers.NostrSignerPermissionStore +import com.vitorpamplona.amethyst.commons.marmot.EncryptedKeyPackageBundleStore +import com.vitorpamplona.amethyst.commons.marmot.EncryptedMarmotMessageStore +import com.vitorpamplona.amethyst.commons.marmot.EncryptedMlsGroupStateStore +import com.vitorpamplona.amethyst.commons.marmot.EncryptedPublishObligationStore import com.vitorpamplona.amethyst.commons.marmot.InMemoryMlsGroupStateStore import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.marmot.AndroidIngestDedupStore @@ -36,10 +40,6 @@ import com.vitorpamplona.amethyst.commons.relayauth.DataStoreRelayAuthPermission import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.AccountSettings -import com.vitorpamplona.amethyst.model.marmot.AndroidKeyPackageBundleStore -import com.vitorpamplona.amethyst.model.marmot.AndroidMarmotMessageStore -import com.vitorpamplona.amethyst.model.marmot.AndroidMlsGroupStateStore -import com.vitorpamplona.amethyst.model.marmot.AndroidPublishObligationStore import com.vitorpamplona.amethyst.service.location.LocationState import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey @@ -250,13 +250,13 @@ class AccountCacheState( val mlsStore = try { Log.d("AccountCacheState") { - "Initializing AndroidMlsGroupStateStore for ${signer.pubKey.take(8)}… at ${accountDir.absolutePath}" + "Initializing EncryptedMlsGroupStateStore for ${signer.pubKey.take(8)}… at ${accountDir.absolutePath}" } - AndroidMlsGroupStateStore(accountDir) + EncryptedMlsGroupStateStore(accountDir) } catch (e: Exception) { Log.e( "AccountCacheState", - "Failed to initialize AndroidMlsGroupStateStore, falling back to in-memory store (Marmot groups will NOT persist across restarts)", + "Failed to initialize EncryptedMlsGroupStateStore, falling back to in-memory store (Marmot groups will NOT persist across restarts)", e, ) InMemoryMlsGroupStateStore() @@ -267,11 +267,11 @@ class AccountCacheState( val marmotMessageStore = try { - AndroidMarmotMessageStore(accountDir) + EncryptedMarmotMessageStore(accountDir) } catch (e: Exception) { Log.e( "AccountCacheState", - "Failed to initialize AndroidMarmotMessageStore (Marmot messages will NOT persist across restarts)", + "Failed to initialize EncryptedMarmotMessageStore (Marmot messages will NOT persist across restarts)", e, ) null @@ -279,11 +279,11 @@ class AccountCacheState( val marmotKeyPackageStore = try { - AndroidKeyPackageBundleStore(accountDir) + EncryptedKeyPackageBundleStore(accountDir) } catch (e: Exception) { Log.e( "AccountCacheState", - "Failed to initialize AndroidKeyPackageBundleStore (Marmot KeyPackages will NOT persist across restarts)", + "Failed to initialize EncryptedKeyPackageBundleStore (Marmot KeyPackages will NOT persist across restarts)", e, ) null @@ -291,11 +291,11 @@ class AccountCacheState( val marmotPublishObligationStore = try { - AndroidPublishObligationStore(accountDir) + EncryptedPublishObligationStore(accountDir) } catch (e: Exception) { Log.e( "AccountCacheState", - "Failed to initialize AndroidPublishObligationStore " + + "Failed to initialize EncryptedPublishObligationStore " + "(a Marmot commit interrupted mid-publish will NOT be retried after a restart)", e, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt index 854e7147ea..0d8df07141 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt @@ -25,6 +25,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.State import androidx.compose.runtime.produceState import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation import com.vitorpamplona.quartz.utils.Log 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 a3229731b7..64c2e1ec1e 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 @@ -96,6 +96,7 @@ import com.vitorpamplona.amethyst.commons.resources.unauthorized_exception import com.vitorpamplona.amethyst.commons.resources.unauthorized_exception_description import com.vitorpamplona.amethyst.commons.resources.user_x_does_not_have_a_lightning_address_setup_to_receive_sats import com.vitorpamplona.amethyst.commons.resources.video_saved_to_the_gallery +import com.vitorpamplona.amethyst.commons.service.OnlineChecker import com.vitorpamplona.amethyst.commons.service.broadcast.BroadcastTracker import com.vitorpamplona.amethyst.commons.service.http.EmptyRoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.commons.service.http.IRoleBasedHttpClientBuilder @@ -116,7 +117,6 @@ import com.vitorpamplona.amethyst.model.LatestKeyPackageOwner import com.vitorpamplona.amethyst.model.UrlCachedPreviewer import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.service.ClinkDebitPayer -import com.vitorpamplona.amethyst.service.OnlineChecker import com.vitorpamplona.amethyst.service.V4VPaymentHandler import com.vitorpamplona.amethyst.service.ZapPaymentHandler import com.vitorpamplona.amethyst.service.cashu.melt.MeltProcessor diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt index 3ff4e70d03..bf3b19c433 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/LiveActivityChannelScreen.kt @@ -27,8 +27,8 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import com.vitorpamplona.amethyst.commons.model.cache.LocalCache +import com.vitorpamplona.amethyst.commons.service.OnlineChecker import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav -import com.vitorpamplona.amethyst.service.OnlineChecker import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold import com.vitorpamplona.amethyst.ui.note.LoadLiveActivityChannel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt index 3f1dd2d396..8b7e5cb5e5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/DiscoverLiveFeedFilter.kt @@ -32,8 +32,8 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.Aut import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavFilter import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsByOutboxTopNavFilter import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsByProxyTopNavFilter +import com.vitorpamplona.amethyst.commons.service.OnlineChecker import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.service.OnlineChecker import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt index b3fb2e01f5..66ebccef97 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt @@ -74,6 +74,7 @@ import com.vitorpamplona.amethyst.commons.resources.feed_is_empty import com.vitorpamplona.amethyst.commons.resources.home_tab_everything import com.vitorpamplona.amethyst.commons.resources.new_threads import com.vitorpamplona.amethyst.commons.resources.refresh +import com.vitorpamplona.amethyst.commons.service.OnlineChecker import com.vitorpamplona.amethyst.commons.ui.components.CrossfadeIfEnabled import com.vitorpamplona.amethyst.commons.ui.feeds.FeedError import com.vitorpamplona.amethyst.commons.ui.feeds.LoadingFeed @@ -94,7 +95,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size5dp import com.vitorpamplona.amethyst.commons.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.commons.ui.theme.TabRowHeight import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow -import com.vitorpamplona.amethyst.service.OnlineChecker import com.vitorpamplona.amethyst.service.location.LocationState import com.vitorpamplona.amethyst.ui.feeds.ChannelFeedContentState import com.vitorpamplona.amethyst.ui.feeds.ChannelFeedState diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt index 85f932fee3..69679d2ea5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/live/LiveStatusIndicator.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.amethyst.commons.model.Channel import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel import com.vitorpamplona.amethyst.commons.model.nip53LiveActivities.LiveActivitiesChannel -import com.vitorpamplona.amethyst.service.OnlineChecker +import com.vitorpamplona.amethyst.commons.service.OnlineChecker import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.utils.Log diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/dal/LiveStreamsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/dal/LiveStreamsFeedFilter.kt index 6c1bc81034..5fe9419106 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/dal/LiveStreamsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/livestreams/dal/LiveStreamsFeedFilter.kt @@ -32,8 +32,8 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.author.Aut import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.community.SingleCommunityTopNavFilter import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsByOutboxTopNavFilter import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsByProxyTopNavFilter +import com.vitorpamplona.amethyst.commons.service.OnlineChecker import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.service.OnlineChecker import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt index abe244fb9b..90ff2fca72 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt @@ -41,6 +41,7 @@ import androidx.compose.ui.platform.LocalClipboard import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.relays.ui.RelayCountResult import com.vitorpamplona.amethyst.commons.relays.ui.RelayDragState import com.vitorpamplona.amethyst.commons.relays.ui.RelayEventCountRow @@ -59,7 +60,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Height25Modifier import com.vitorpamplona.amethyst.commons.ui.theme.LargeRelayIconModifier import com.vitorpamplona.amethyst.commons.ui.theme.ReactionRowHeightChatMaxWidth import com.vitorpamplona.amethyst.commons.ui.theme.Size25dp -import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.model.nip11RelayInfo.loadRelayInfo import com.vitorpamplona.amethyst.ui.note.RenderRelayIcon import com.vitorpamplona.amethyst.ui.note.UserPicture diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt index d5f1e6e2af..a188c63141 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt @@ -23,11 +23,11 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.vitorpamplona.amethyst.commons.model.navigation.Route +import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.relays.ui.RelayCountResult import com.vitorpamplona.amethyst.commons.relays.ui.RelayDragState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings -import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @Composable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt index 3a503a1724..ca80618511 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt @@ -45,6 +45,7 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.add import com.vitorpamplona.amethyst.commons.resources.add_a_relay @@ -58,7 +59,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.PopupUpEffect import com.vitorpamplona.amethyst.commons.ui.theme.StdEndPadding import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText -import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.quartz.nip01Core.relay.client.stats.RelayStat diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt index 3b91761c41..ec43a64991 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt @@ -26,11 +26,11 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.HalfVertPadding -import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt index 834f109067..47d7aa6059 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt @@ -68,6 +68,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.cancel import com.vitorpamplona.amethyst.commons.resources.confirm @@ -96,7 +97,6 @@ import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.HorzHalfVertPadding import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn -import com.vitorpamplona.amethyst.model.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.ui.note.formatMediumDateTime import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/InMemoryMlsGroupStateStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/InMemoryMlsGroupStateStore.kt index a5edbd0bd2..39df421c8b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/InMemoryMlsGroupStateStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/InMemoryMlsGroupStateStore.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.utils.concurrent.ConcurrentMap /** * In-memory fallback implementation of [MlsGroupStateStore]. * - * Used only when [AndroidMlsGroupStateStore] cannot be initialized (e.g., when the + * Used only when [EncryptedMlsGroupStateStore] cannot be initialized (e.g., when the * Android KeyStore is unavailable). State is lost on app restart, but this lets * Marmot group operations at least work within a single session instead of failing * with "Marmot not initialized". diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedAppendLog.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedAppendLog.kt index b8ef668cb8..0f662c8e58 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedAppendLog.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedAppendLog.kt @@ -58,7 +58,7 @@ import java.io.RandomAccessFile * * **Not thread-safe.** Entries are cached in memory so an append never has to * read the log back, and that cache assumes one owner. Callers hold their own - * lock around every method (see `AndroidMarmotMessageStore`), and one instance + * lock around every method (see `EncryptedMarmotMessageStore`), and one instance * must own any given file. * * @param encrypt must produce a self-describing blob — it carries its own IV / diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedKeyPackageBundleStore.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedKeyPackageBundleStore.kt index 04c0db4493..4a67d695ec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidKeyPackageBundleStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedKeyPackageBundleStore.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.marmot +package com.vitorpamplona.amethyst.commons.marmot import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.marmot.mip00KeyPackages.KeyPackageBundleStore @@ -30,7 +30,7 @@ import kotlinx.coroutines.withContext import java.io.File /** - * Android implementation of [KeyPackageBundleStore] using file-based encrypted storage. + * File-backed [KeyPackageBundleStore], encrypted at rest. * * Storage layout: * ``` @@ -40,10 +40,10 @@ import java.io.File * The blob contains private key material — init keys, encryption keys, * signature keys — that the MLS engine needs to process Welcome events * received days or weeks after the corresponding KeyPackage was published. - * It is encrypted at rest with [SecretEncryption] (AES/GCM via Android - * KeyStore), the same primitive used by [AndroidMlsGroupStateStore]. + * It is encrypted at rest with [SecretEncryption] (AES-256-GCM, keyed by the platform's + * keystore), the same primitive used by [EncryptedMlsGroupStateStore]. */ -class AndroidKeyPackageBundleStore( +class EncryptedKeyPackageBundleStore( private val rootDir: File, private val encryption: SecretEncryption = SecretEncryption(), ) : KeyPackageBundleStore { @@ -51,7 +51,7 @@ class AndroidKeyPackageBundleStore( init { Log.d(TAG) { - "Initialized AndroidKeyPackageBundleStore: rootDir=${rootDir.absolutePath}" + "Initialized EncryptedKeyPackageBundleStore: rootDir=${rootDir.absolutePath}" } } @@ -121,6 +121,6 @@ class AndroidKeyPackageBundleStore( } companion object { - private const val TAG = "AndroidKeyPackageBundleStore" + private const val TAG = "EncryptedKeyPackageBundleStore" } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotMessageStore.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotMessageStore.kt index e6775aa56a..b1a5b8b7a8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMarmotMessageStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotMessageStore.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.marmot +package com.vitorpamplona.amethyst.commons.marmot import com.vitorpamplona.amethyst.commons.marmot.EncryptedAppendLog import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption @@ -32,9 +32,9 @@ import kotlinx.coroutines.withContext import java.io.File /** - * Android implementation of [MarmotMessageStore] using file-based encrypted storage. + * File-backed [MarmotMessageStore], encrypted at rest. * - * Stored alongside the [AndroidMlsGroupStateStore] data: + * Stored alongside the [EncryptedMlsGroupStateStore] data: * ``` * <rootDir>/mls_groups/<nostrGroupId>/messages — encrypted message log * ``` @@ -44,7 +44,7 @@ import java.io.File * small encrypted segment instead of rewriting the conversation, which is what * keeps the cost of a send flat as the history grows. */ -class AndroidMarmotMessageStore( +class EncryptedMarmotMessageStore( private val rootDir: File, private val encryption: SecretEncryption = SecretEncryption(), ) : MarmotMessageStore { @@ -52,7 +52,7 @@ class AndroidMarmotMessageStore( init { Log.d(TAG) { - "Initialized AndroidMarmotMessageStore: rootDir=${rootDir.absolutePath}" + "Initialized EncryptedMarmotMessageStore: rootDir=${rootDir.absolutePath}" } } @@ -353,7 +353,7 @@ class AndroidMarmotMessageStore( ) = log.rewrite(file, messages) companion object { - private const val TAG = "AndroidMarmotMessageStore" + private const val TAG = "EncryptedMarmotMessageStore" private val HEX_PATTERN = Regex("^[0-9a-fA-F]+$") } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMlsGroupStateStore.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMlsGroupStateStore.kt index 8d509ed7fc..8775e23087 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidMlsGroupStateStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMlsGroupStateStore.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.marmot +package com.vitorpamplona.amethyst.commons.marmot import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.marmot.mls.group.MlsGroupStateStore @@ -29,10 +29,10 @@ import java.io.File import java.io.FileOutputStream /** - * Android implementation of [MlsGroupStateStore] using file-based encrypted storage. + * File-backed [MlsGroupStateStore], encrypted at rest. * * All MLS group state (containing private keys and epoch secrets) is encrypted - * at rest using [SecretEncryption] (AES/GCM backed by Android KeyStore). + * at rest using [SecretEncryption] (AES-256-GCM, keyed by the platform's keystore). * * Storage layout: * ``` @@ -41,13 +41,13 @@ import java.io.FileOutputStream * <rootDir>/mls_groups/<nostrGroupId>/ratchet — encrypted OwnSenderRatchet * ``` */ -class AndroidMlsGroupStateStore( +class EncryptedMlsGroupStateStore( private val rootDir: File, private val encryption: SecretEncryption = SecretEncryption(), ) : MlsGroupStateStore { init { Log.d(TAG) { - "Initialized AndroidMlsGroupStateStore: rootDir=${rootDir.absolutePath}, " + + "Initialized EncryptedMlsGroupStateStore: rootDir=${rootDir.absolutePath}, " + "mls_groups exists=${File(rootDir, "mls_groups").exists()}" } } @@ -61,7 +61,7 @@ class AndroidMlsGroupStateStore( } companion object { - private const val TAG = "AndroidMlsGroupStateStore" + private const val TAG = "EncryptedMlsGroupStateStore" private val HEX_PATTERN = Regex("^[0-9a-fA-F]+$") } @@ -274,7 +274,7 @@ class AndroidMlsGroupStateStore( // Fallback: if rename fails (e.g., cross-filesystem), copy and delete tempFile.copyTo(target, overwrite = true) if (!tempFile.delete()) { - Log.w("AndroidMlsGroupStateStore") { "Failed to delete temp file after copy fallback: ${tempFile.absolutePath}" } + Log.w("EncryptedMlsGroupStateStore") { "Failed to delete temp file after copy fallback: ${tempFile.absolutePath}" } } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedPublishObligationStore.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedPublishObligationStore.kt index 64b561935e..054ec0d035 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/marmot/AndroidPublishObligationStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedPublishObligationStore.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.marmot +package com.vitorpamplona.amethyst.commons.marmot import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption import com.vitorpamplona.quartz.marmot.protocolCore.MarmotPublishObligationStore @@ -31,7 +31,7 @@ import kotlinx.coroutines.withContext import java.io.File /** - * Android implementation of [MarmotPublishObligationStore], encrypted at rest + * File-backed [MarmotPublishObligationStore], encrypted at rest * with [SecretEncryption] like the group-state and KeyPackage stores. * * ``` @@ -49,7 +49,7 @@ import java.io.File * concurrently and resolve out of order, so removing one record must not * rewrite another's. */ -class AndroidPublishObligationStore( +class EncryptedPublishObligationStore( private val rootDir: File, private val encryption: SecretEncryption = SecretEncryption(), ) : MarmotPublishObligationStore { @@ -184,6 +184,6 @@ class AndroidPublishObligationStore( } companion object { - private const val TAG = "AndroidPublishObligationStore" + private const val TAG = "EncryptedPublishObligationStore" } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11CachedRetriever.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11CachedRetriever.kt similarity index 92% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11CachedRetriever.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11CachedRetriever.kt index e97b3a6270..5e89abff2a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11CachedRetriever.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11CachedRetriever.kt @@ -18,9 +18,9 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip11RelayInfo +package com.vitorpamplona.amethyst.commons.relays.nip11 -import android.util.LruCache +import androidx.collection.LruCache import androidx.compose.runtime.Stable import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl @@ -33,7 +33,12 @@ class Nip11CachedRetriever( val okHttpClient: (NormalizedRelayUrl) -> OkHttpClient, ) { private val relayInformationEmptyCache = LruCache<NormalizedRelayUrl, Nip11RelayInformation>(1000) - private val relayInformationDocumentCache = LruCache<NormalizedRelayUrl, RetrieveResult?>(1000) + + // Value type is non-null: androidx.collection.LruCache bounds V to Any, and every put here + // stores a concrete RetrieveResult. The old android.util.LruCache was a Java platform type, so + // the nullable argument compiled but never meant anything — get() returns null on a miss either + // way, which is what the readers below already branch on. + private val relayInformationDocumentCache = LruCache<NormalizedRelayUrl, RetrieveResult>(1000) private val retriever = Nip11Retriever(okHttpClient) /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11Retriever.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11Retriever.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11Retriever.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11Retriever.kt index 10118b09ac..8380827a66 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11Retriever.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11Retriever.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip11RelayInfo +package com.vitorpamplona.amethyst.commons.relays.nip11 import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.toHttp diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RetrieveResult.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RetrieveResult.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RetrieveResult.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RetrieveResult.kt index 7f749ae12b..1fa3fde337 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RetrieveResult.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RetrieveResult.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip11RelayInfo +package com.vitorpamplona.amethyst.commons.relays.nip11 import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation import com.vitorpamplona.quartz.utils.TimeUtils diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/OnlineCheck.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/OnlineCheck.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/OnlineCheck.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/OnlineCheck.kt index 4f1aa7271b..834d011380 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/OnlineCheck.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/OnlineCheck.kt @@ -18,9 +18,9 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service +package com.vitorpamplona.amethyst.commons.service -import android.util.LruCache +import androidx.collection.LruCache import androidx.compose.runtime.Immutable import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.RandomInstance diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotStoresTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotStoresTest.kt new file mode 100644 index 0000000000..4c9c0a3719 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/EncryptedMarmotStoresTest.kt @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.marmot + +import com.vitorpamplona.amethyst.commons.model.preferences.SecretEncryption +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder +import java.io.File + +/** + * Round trips for the file-backed Marmot stores, which had no coverage while they sat in `amethyst/` + * behind an `Android` prefix they never earned. + * + * What matters here is that the bytes survive a restart: these hold MLS group state and the message + * log, so a store that writes but cannot read back loses a group's history and its ratchet — and MLS + * state that cannot be reloaded is not recoverable from the relays. + */ +class EncryptedMarmotStoresTest { + @get:Rule + val folder = TemporaryFolder() + + private var seq = 0 + + /** A fresh account directory plus its own key file, so tests cannot read each other's data. */ + private fun accountDir(): Pair<File, SecretEncryption> { + val n = seq++ + val dir = folder.newFolder("account_$n") + return dir to SecretEncryption(File(folder.root, "secret_$n.key")) + } + + // Group ids must be hex: both stores validate, which is what stops a crafted id escaping the + // account directory. Using a realistic 64-char id rather than a label keeps the tests honest. + private val groupId = "a".repeat(63) + "1" + private val otherGroupId = "b".repeat(63) + "2" + + @Test + fun groupStateSurvivesANewStoreOverTheSameDirectory() = + runTest { + val (dir, encryption) = accountDir() + val payload = byteArrayOf(1, 2, 3, 4, 5) + + EncryptedMlsGroupStateStore(dir, encryption).save(groupId, payload) + + val reopened = EncryptedMlsGroupStateStore(dir, encryption).load(groupId) + assertEquals("the same bytes come back", payload.toList(), reopened?.toList()) + } + + @Test + fun anUnknownGroupLoadsAsNull() = + runTest { + val (dir, encryption) = accountDir() + + assertNull(EncryptedMlsGroupStateStore(dir, encryption).load("c".repeat(63) + "3")) + } + + @Test + fun deletingAGroupRemovesItFromTheListing() = + runTest { + val (dir, encryption) = accountDir() + val store = EncryptedMlsGroupStateStore(dir, encryption) + store.save(groupId, byteArrayOf(9)) + store.save(otherGroupId, byteArrayOf(8)) + + store.delete(groupId) + + assertEquals("only the other group is left", listOf(otherGroupId), store.listGroups()) + assertNull("and its state is gone", store.load(groupId)) + } + + /** The sender ratchet is stored separately from the group blob; losing it breaks decryption. */ + @Test + fun theSenderRatchetRoundTripsIndependentlyOfTheGroupState() = + runTest { + val (dir, encryption) = accountDir() + val store = EncryptedMlsGroupStateStore(dir, encryption) + + store.save(groupId, byteArrayOf(1)) + store.saveSenderRatchet(groupId, byteArrayOf(7, 7, 7)) + + val reopened = EncryptedMlsGroupStateStore(dir, encryption) + assertEquals("ratchet preserved", listOf<Byte>(7, 7, 7), reopened.loadSenderRatchet(groupId)?.toList()) + assertEquals("and the group blob is untouched", listOf<Byte>(1), reopened.load(groupId)?.toList()) + } + + @Test + fun appendedMessagesComeBackInOrderAfterAReopen() = + runTest { + val (dir, encryption) = accountDir() + val store = EncryptedMarmotMessageStore(dir, encryption) + + store.appendMessage(groupId, """{"id":"one"}""") + store.appendMessage(groupId, """{"id":"two"}""") + + val reopened = EncryptedMarmotMessageStore(dir, encryption).loadMessages(groupId) + assertEquals("both, in append order", listOf("""{"id":"one"}""", """{"id":"two"}"""), reopened) + } + + @Test + fun aGroupWithNoMessagesLoadsEmptyRatherThanFailing() = + runTest { + val (dir, encryption) = accountDir() + + assertTrue(EncryptedMarmotMessageStore(dir, encryption).loadMessages("d".repeat(63) + "4").isEmpty()) + } + + @Test + fun deletingAGroupDropsItsMessageLog() = + runTest { + val (dir, encryption) = accountDir() + val store = EncryptedMarmotMessageStore(dir, encryption) + store.appendMessage(groupId, """{"id":"one"}""") + + store.delete(groupId) + + assertTrue(EncryptedMarmotMessageStore(dir, encryption).loadMessages(groupId).isEmpty()) + } + + /** The group snapshot is what a cold start restores from before replaying the log. */ + @Test + fun theGroupSnapshotRoundTrips() = + runTest { + val (dir, encryption) = accountDir() + val store = EncryptedMarmotMessageStore(dir, encryption) + + store.recordGroupSnapshot(groupId, """{"epoch":4}""") + + assertEquals("""{"epoch":4}""", EncryptedMarmotMessageStore(dir, encryption).loadGroupSnapshot(groupId)) + } + + /** Two accounts are two directories: one must never read the other's groups. */ + @Test + fun twoAccountDirectoriesDoNotSeeEachOther() = + runTest { + val (dirA, encA) = accountDir() + val (dirB, encB) = accountDir() + + EncryptedMlsGroupStateStore(dirA, encA).save(groupId, byteArrayOf(1)) + + assertNull("B cannot see A's group", EncryptedMlsGroupStateStore(dirB, encB).load(groupId)) + assertTrue("nor list it", EncryptedMlsGroupStateStore(dirB, encB).listGroups().isEmpty()) + } + + /** The hex check is a path-traversal guard: a crafted id must not be able to leave the account dir. */ + @Test + fun aNonHexGroupIdIsRejected() = + runTest { + val (dir, encryption) = accountDir() + val store = EncryptedMlsGroupStateStore(dir, encryption) + + listOf("../escape", "not hex", "abc/def", "").forEach { bad -> + val thrown = + try { + store.load(bad) + false + } catch (e: IllegalArgumentException) { + true + } + assertTrue("\"$bad\" must be rejected, not resolved to a path", thrown) + } + } +} diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11RetrieverTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11RetrieverTest.kt similarity index 97% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11RetrieverTest.kt rename to commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11RetrieverTest.kt index 07c46de62e..cb936017fe 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/Nip11RetrieverTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11RetrieverTest.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip11RelayInfo +package com.vitorpamplona.amethyst.commons.relays.nip11 import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.coroutines.runBlocking diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/OnlineCheckerTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/OnlineCheckerTest.kt new file mode 100644 index 0000000000..70ebf5bf93 --- /dev/null +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/OnlineCheckerTest.kt @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.service + +import com.vitorpamplona.quartz.utils.TimeUtils +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test + +/** + * [OnlineChecker]'s cache predicates — the part that decides, without touching the network, whether a + * media URL is known-good, known-bad, or unknown. + * + * These decide whether the UI shows a player or a "this is offline" placeholder, and a stale entry + * being trusted is the difference between a video that plays and one that never gets retried. Nothing + * here had coverage while the object sat in `amethyst/`. + * + * The suspend `isOnline` probe is deliberately not exercised: it needs a real OkHttp round trip and + * `commons` has no MockWebServer, so there is no honest way to drive it from here. + */ +class OnlineCheckerTest { + private val url = "https://example.com/video.mp4" + + @Before + fun clearSharedCache() { + // OnlineChecker is an object, so its LruCache outlives each test. + OnlineChecker.checkOnlineCache.evictAll() + } + + private fun seed( + online: Boolean, + ageSeconds: Long, + ) { + OnlineChecker.checkOnlineCache.put(url, OnlineCheckResult(TimeUtils.now() - ageSeconds, online)) + } + + @Test + fun anUnknownUrlIsNeitherOnlineNorKnownOffline() { + assertFalse("nothing cached, so not known online", OnlineChecker.isOnlineCached(url)) + assertFalse("and not known offline either", OnlineChecker.isCachedAndOffline(url)) + } + + @Test + fun aFreshOnlineEntryReadsOnline() { + seed(online = true, ageSeconds = 10) + + assertTrue(OnlineChecker.isOnlineCached(url)) + assertFalse("an online entry is not 'cached and offline'", OnlineChecker.isCachedAndOffline(url)) + } + + @Test + fun aFreshOfflineEntryReadsOffline() { + seed(online = false, ageSeconds = 10) + + assertTrue(OnlineChecker.isCachedAndOffline(url)) + assertFalse("and must not read as online", OnlineChecker.isOnlineCached(url)) + } + + /** + * The five-minute TTL in both directions. Trusting a stale *online* entry shows a player for + * something that has since gone; trusting a stale *offline* one never retries a URL that came back. + */ + @Test + fun anEntryOlderThanFiveMinutesIsTrustedForNothing() { + seed(online = true, ageSeconds = 301) + assertFalse("a stale online entry is no longer online", OnlineChecker.isOnlineCached(url)) + + seed(online = false, ageSeconds = 301) + assertFalse("and a stale offline entry no longer counts as known-offline", OnlineChecker.isCachedAndOffline(url)) + } + + @Test + fun anEntryJustInsideFiveMinutesIsStillTrusted() { + seed(online = true, ageSeconds = 290) + + assertTrue(OnlineChecker.isOnlineCached(url)) + } + + /** Retry is for failures only: dropping a good entry would refetch every URL that already worked. */ + @Test + fun resetIfOfflineToRetryDropsOnlyTheOfflineEntries() { + seed(online = false, ageSeconds = 10) + OnlineChecker.resetIfOfflineToRetry(url) + assertFalse("the offline entry is gone, so the next check refetches", OnlineChecker.isCachedAndOffline(url)) + + seed(online = true, ageSeconds = 10) + OnlineChecker.resetIfOfflineToRetry(url) + assertTrue("the online entry survived", OnlineChecker.isOnlineCached(url)) + } + + @Test + fun aBlankOrNullUrlIsNeverOnline() { + assertFalse(OnlineChecker.isOnlineCached(null)) + assertFalse(OnlineChecker.isOnlineCached(" ")) + assertFalse(OnlineChecker.isCachedAndOffline(null)) + assertFalse(OnlineChecker.isCachedAndOffline(" ")) + } +} From 5b103385bcaed7f2f6fca6592c98ed1ef70ae9b6 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Fri, 25 Sep 2026 21:54:20 +0000 Subject: [PATCH 40/57] refactor(commons): move PowJobStore, OkHttpWebSocket, TorRelayState and the NIP-29 predicates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four small, verified moves. Each was shared-layer code whose only tie to the app module was where the file happened to sit. - PowJobStore -> commons/service/pow. Its interface (PoWJobPersistence) and DTO (PersistedPoWJob) were already in commons; only the File-backed implementation was stranded. Zero android imports. PowJobRestorer stays: it takes an Account. - OkHttpWebSocket -> commons/service/http, beside the other OkHttp adapters. Zero android imports; quartz socket interfaces plus okhttp. Its close-handshake test travels with it. - TorRelayState -> commons/tor, beside the TorRelaySettings/TorType it reasons over. Only androidx.compose.runtime.Stable, which commons allows; jvmAndroid because of okhttp. AccountsTorStateConnector does NOT travel with it, contrary to the survey that proposed this batch — it imports Account and AccountCacheState. - The two pure NIP-29 predicates out of RelaySupportsNip -> commons/relays/nip11, next to the retriever moved in f5fc432e. looksLikeNonNip29Relay and the 2-arg isRelaySignedRelayGroup take a resolved Nip11RelayInformation and are therefore shareable; the three convenience forms that read Amethyst.instance.nip11Cache stay behind. Callers split by which overload they use. No new tests here: these are relocations of code whose behaviour is unchanged, and the one suite that existed (the websocket close handshake) moved with its class. The NIP-29 predicates are now reachable for testing from commons, which they were not before, but writing those tests is separable from the move. The same-package trap bit three more times and is worth naming, because grepping for imports cannot find it: a file in the moved class's own package has no import line to rewrite. It caught AccountsTorStateConnector and PowJobRestorer in main sources, PowAndUsageFileFormatTest in test sources — via PowJobsFile, a second public type declared inside PowJobStore.kt that a search for the class name does not match — and a [PowJobStore] KDoc link in PowMiningForegroundService. The check that actually works is to enumerate every top-level declaration in each moved file and grep for bare usages of all of them. Verified: :commons:jvmTest (2552, 0 failures), :amethyst:testPlayDebugUnitTest, :cli:compileKotlin, :commons:verifyKmpPurity, :commons:compileCommonMainKotlinMetadata, :amethyst:compilePlayDebugKotlin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../NotificationFeedFilterModeOverrideTest.kt | 2 +- .../ThreadDualAxisChartAssemblerTest.kt | 2 +- .../com/vitorpamplona/amethyst/AppModules.kt | 6 +- .../model/nip11RelayInfo/RelaySupportsNip.kt | 35 +---------- .../torState/AccountsTorStateConnector.kt | 1 + .../amethyst/service/pow/PowJobRestorer.kt | 1 + .../service/pow/PowMiningForegroundService.kt | 2 +- .../relayGroup/RelayGroupChannelListScreen.kt | 4 +- .../relayGroup/RelayGroupParentPicker.kt | 2 +- .../relayGroup/RelayGroupServerList.kt | 2 +- .../service/pow/PowAndUsageFileFormatTest.kt | 1 + .../commons/relays/nip11/RelaySupportsNip.kt | 61 +++++++++++++++++++ .../commons/service/http}/OkHttpWebSocket.kt | 2 +- .../commons}/service/pow/PowJobStore.kt | 4 +- .../amethyst/commons/tor}/TorRelayState.kt | 7 +-- .../OkHttpWebSocketCloseHandshakeTest.kt | 2 +- 16 files changed, 79 insertions(+), 55 deletions(-) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RelaySupportsNip.kt rename {amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/http}/OkHttpWebSocket.kt (99%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons}/service/pow/PowJobStore.kt (96%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState => commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/tor}/TorRelayState.kt (95%) rename {amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp => commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/http}/OkHttpWebSocketCloseHandshakeTest.kt (99%) diff --git a/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/NotificationFeedFilterModeOverrideTest.kt b/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/NotificationFeedFilterModeOverrideTest.kt index d51726d393..8c8bf58097 100644 --- a/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/NotificationFeedFilterModeOverrideTest.kt +++ b/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/NotificationFeedFilterModeOverrideTest.kt @@ -25,10 +25,10 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.commons.relayClient.assemblers.CashuMintDirectoryFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.nip47WalletConnect.NWCPaymentFilterAssembler +import com.vitorpamplona.amethyst.commons.service.http.OkHttpWebSocket import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.amethyst.service.location.LocationState -import com.vitorpamplona.amethyst.service.okhttp.OkHttpWebSocket import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.dal.NotificationFeedFilter import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.relay.client.NostrClient diff --git a/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/ThreadDualAxisChartAssemblerTest.kt b/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/ThreadDualAxisChartAssemblerTest.kt index 1a205eaf1b..06c0b9ba0c 100644 --- a/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/ThreadDualAxisChartAssemblerTest.kt +++ b/amethyst/src/androidTest/java/com/vitorpamplona/amethyst/ThreadDualAxisChartAssemblerTest.kt @@ -24,11 +24,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.relayClient.assemblers.CashuMintDirectoryFilterAssembler import com.vitorpamplona.amethyst.commons.relayClient.nip47WalletConnect.NWCPaymentFilterAssembler +import com.vitorpamplona.amethyst.commons.service.http.OkHttpWebSocket import com.vitorpamplona.amethyst.commons.viewmodels.thread.ThreadFeedFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.amethyst.service.location.LocationState -import com.vitorpamplona.amethyst.service.okhttp.OkHttpWebSocket import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.crypto.verify diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 956a3aba61..f0c1bffff2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -68,11 +68,14 @@ import com.vitorpamplona.amethyst.commons.service.http.DualHttpClientManager import com.vitorpamplona.amethyst.commons.service.http.DualHttpClientManagerForRelays import com.vitorpamplona.amethyst.commons.service.http.EncryptionKeyCache import com.vitorpamplona.amethyst.commons.service.http.LocalBlossomMediaCallFactory +import com.vitorpamplona.amethyst.commons.service.http.OkHttpWebSocket import com.vitorpamplona.amethyst.commons.service.http.OnionLocationCache import com.vitorpamplona.amethyst.commons.service.lnurl.OkHttpLnurlEndpointResolver import com.vitorpamplona.amethyst.commons.service.pow.PoWPolicy import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue +import com.vitorpamplona.amethyst.commons.service.pow.PowJobStore import com.vitorpamplona.amethyst.commons.state.UiSettingsState +import com.vitorpamplona.amethyst.commons.tor.TorRelayState import com.vitorpamplona.amethyst.commons.tor.TorSettings import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState @@ -80,7 +83,6 @@ import com.vitorpamplona.amethyst.model.nip60Cashu.CashuPreferences import com.vitorpamplona.amethyst.model.preferences.UiSharedPreferences import com.vitorpamplona.amethyst.model.privacyOptions.RoleBasedHttpClientBuilder import com.vitorpamplona.amethyst.model.torState.AccountsTorStateConnector -import com.vitorpamplona.amethyst.model.torState.TorRelayState import com.vitorpamplona.amethyst.napplet.DataStoreNappletPermissionStore import com.vitorpamplona.amethyst.service.calendar.CALENDAR_REMINDER_LOG_STORE import com.vitorpamplona.amethyst.service.calendar.CALENDAR_REMINDER_SETTINGS_STORE @@ -102,13 +104,11 @@ import com.vitorpamplona.amethyst.service.notifications.AlwaysOnNotificationServ import com.vitorpamplona.amethyst.service.notifications.NotificationDispatcher import com.vitorpamplona.amethyst.service.notifications.NwcPaymentNotificationWatcher import com.vitorpamplona.amethyst.service.notifications.PokeyReceiver -import com.vitorpamplona.amethyst.service.okhttp.OkHttpWebSocket import com.vitorpamplona.amethyst.service.playback.diskCache.VideoCache import com.vitorpamplona.amethyst.service.playback.diskCache.VideoCacheFactory import com.vitorpamplona.amethyst.service.playback.pip.BackgroundMedia import com.vitorpamplona.amethyst.service.playback.service.PlaybackServiceClient import com.vitorpamplona.amethyst.service.pow.PowJobRestorer -import com.vitorpamplona.amethyst.service.pow.PowJobStore import com.vitorpamplona.amethyst.service.pow.PowMiningForegroundService import com.vitorpamplona.amethyst.service.relayClient.CacheClientConnector import com.vitorpamplona.amethyst.service.relayClient.RelayProxyClientConnector diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt index 792daf74fd..12edff9e8b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt @@ -22,8 +22,8 @@ package com.vitorpamplona.amethyst.model.nip11RelayInfo import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel +import com.vitorpamplona.amethyst.commons.relays.nip11.isRelaySignedRelayGroup import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation /** * Whether [relay]'s cached NIP-11 document advertises support for [nip] (as a decimal string, e.g. @@ -43,38 +43,5 @@ fun relayAdvertisesNip( /** NIP-29 (relay-based groups): the relay must run it for its groups to be real. */ fun relayAdvertisesNip29(relay: NormalizedRelayUrl): Boolean = relayAdvertisesNip(relay, "29") -/** - * Whether [relayInfo] affirmatively signals that its relay does NOT run NIP-29 groups: the doc - * resolved with an explicit `supported_nips` list that lacks "29" and no `self` key (the field - * NIP-29 relays publish so clients can verify their relay-signed group metadata — see - * [isRelaySignedRelayGroup]). A doc with a null `supported_nips` proves nothing (still loading, - * or the fetch failed), so it never triggers the warning. - */ -fun looksLikeNonNip29Relay(relayInfo: Nip11RelayInformation): Boolean = relayInfo.supported_nips?.none { it == "29" } == true && relayInfo.self == null - -/** - * Whether [channel]'s relay-signed metadata is genuinely from its host relay, per NIP-29: - * "these are addressable events signed by the relay keypair directly … as stated by the NIP-11 - * `self` pubkey", and "relays shouldn't accept these events if they're signed by anyone else". - * - * So the authoritative check is `39000.author == relay.self`. When the relay publishes a `self` - * key we enforce that strictly — this rejects a stray user-published 39000 even on a real NIP-29 - * relay. When the relay does NOT advertise `self` at all (we can't verify cryptographically), we - * fall back to the weaker "advertises NIP-29" signal so a compliant relay that merely omits `self` - * still works. A relay with neither fails. Reads only the cached NIP-11 doc ([relayInfo]); callers - * driving a live surface should warm it first and re-evaluate as it resolves. - */ -fun isRelaySignedRelayGroup( - channel: RelayGroupChannel, - relayInfo: Nip11RelayInformation, -): Boolean { - val self = relayInfo.self - return if (self != null) { - channel.event?.pubKey == self - } else { - relayInfo.supported_nips?.any { it == "29" } == true - } -} - /** [isRelaySignedRelayGroup] reading the host relay's cached NIP-11 doc (for non-Compose callers). */ fun isRelaySignedRelayGroup(channel: RelayGroupChannel): Boolean = isRelaySignedRelayGroup(channel, Amethyst.instance.nip11Cache.getFromCache(channel.groupId.relayUrl)) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/AccountsTorStateConnector.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/AccountsTorStateConnector.kt index 8f6dc5c9c0..8476c746b8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/AccountsTorStateConnector.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/AccountsTorStateConnector.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.model.torState +import com.vitorpamplona.amethyst.commons.tor.TorRelayState import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.model.accountsCache.AccountCacheState import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt index e28ec90c8a..20dad23f49 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt @@ -24,6 +24,7 @@ import com.vitorpamplona.amethyst.commons.scheduledposts.ScheduledPost import com.vitorpamplona.amethyst.commons.scheduledposts.ScheduledPostStore import com.vitorpamplona.amethyst.commons.service.pow.PersistedPoWJob import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue +import com.vitorpamplona.amethyst.commons.service.pow.PowJobStore import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt index 08d040d01c..8c373cbdb6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt @@ -45,7 +45,7 @@ import kotlinx.coroutines.launch * * Uses the Android 14+ `shortService` type — no special permission, but a * hard ~3 minute budget. On `onTimeout` the service exits cleanly; every - * persistable job is already checkpointed by [PowJobStore], so anything still + * persistable job is already checkpointed by [com.vitorpamplona.amethyst.commons.service.pow.PowJobStore], so anything still * unmined resumes on the next app launch. Started on every enqueue (the app * is necessarily in the foreground then), stops itself when the queue drains. * diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt index 7ce0a5aed3..1dd12c3e92 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt @@ -74,6 +74,8 @@ import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.navigation.routeFor import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupDeletions +import com.vitorpamplona.amethyst.commons.relays.nip11.isRelaySignedRelayGroup +import com.vitorpamplona.amethyst.commons.relays.nip11.looksLikeNonNip29Relay import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.buzz_channel_create_title import com.vitorpamplona.amethyst.commons.resources.buzz_community_add_people @@ -103,8 +105,6 @@ import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.warningColor import com.vitorpamplona.amethyst.commons.util.sortedBySnapshot -import com.vitorpamplona.amethyst.model.nip11RelayInfo.isRelaySignedRelayGroup -import com.vitorpamplona.amethyst.model.nip11RelayInfo.looksLikeNonNip29Relay import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserName import com.vitorpamplona.amethyst.ui.navigation.bottombars.AppBottomBar import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt index 0fc9ff32be..03b1528cbe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt @@ -64,6 +64,7 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel +import com.vitorpamplona.amethyst.commons.relays.nip11.isRelaySignedRelayGroup import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.relay_group_member_count import com.vitorpamplona.amethyst.commons.resources.relay_group_parent_desc @@ -80,7 +81,6 @@ import com.vitorpamplona.amethyst.commons.ui.pluralStringRes import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.util.sortedBySnapshot -import com.vitorpamplona.amethyst.model.nip11RelayInfo.isRelaySignedRelayGroup import com.vitorpamplona.amethyst.model.nip11RelayInfo.loadRelayInfo import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.relayGroup.datasource.RelayGroupCardWarmupSubscription diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt index b471fe199c..391ee0fa22 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt @@ -37,6 +37,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols +import com.vitorpamplona.amethyst.commons.relays.nip11.looksLikeNonNip29Relay import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.relay_group_relay_not_nip29 import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings @@ -44,7 +45,6 @@ import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.LargeRelayIconModifier import com.vitorpamplona.amethyst.commons.ui.theme.warningColor import com.vitorpamplona.amethyst.model.nip11RelayInfo.loadRelayInfo -import com.vitorpamplona.amethyst.model.nip11RelayInfo.looksLikeNonNip29Relay import com.vitorpamplona.amethyst.ui.note.RenderRelayIcon import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt index dbea72be3d..942d6ae828 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt @@ -21,6 +21,7 @@ package com.vitorpamplona.amethyst.service.pow import com.vitorpamplona.amethyst.commons.service.pow.PersistedPoWJob +import com.vitorpamplona.amethyst.commons.service.pow.PowJobsFile import com.vitorpamplona.amethyst.service.resourceusage.ResourceUsageStore import kotlinx.serialization.json.Json import org.junit.Assert.assertEquals diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RelaySupportsNip.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RelaySupportsNip.kt new file mode 100644 index 0000000000..4f25aeb13c --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RelaySupportsNip.kt @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.relays.nip11 + +import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel +import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation + +/** + * Whether [relayInfo] affirmatively signals that its relay does NOT run NIP-29 groups: the doc + * resolved with an explicit `supported_nips` list that lacks "29" and no `self` key (the field + * NIP-29 relays publish so clients can verify their relay-signed group metadata — see + * [isRelaySignedRelayGroup]). A doc with a null `supported_nips` proves nothing (still loading, + * or the fetch failed), so it never triggers the warning. + * + * Takes the resolved document rather than a relay URL, which is what makes it shared: the cache + * lookup that produces one is the front end's business, the rule applied to it is not. The + * convenience forms that read Amethyst's in-memory cache stay in the app. + */ +fun looksLikeNonNip29Relay(relayInfo: Nip11RelayInformation): Boolean = relayInfo.supported_nips?.none { it == "29" } == true && relayInfo.self == null + +/** + * Whether [channel]'s relay-signed metadata is genuinely from its host relay, per NIP-29: + * "these are addressable events signed by the relay keypair directly … as stated by the NIP-11 + * `self` pubkey", and "relays shouldn't accept these events if they're signed by anyone else". + * + * So the authoritative check is `39000.author == relay.self`. When the relay publishes a `self` + * key we enforce that strictly — this rejects a stray user-published 39000 even on a real NIP-29 + * relay. When the relay does NOT advertise `self` at all (we can't verify cryptographically), we + * fall back to the weaker "advertises NIP-29" signal so a compliant relay that merely omits `self` + * still works. A relay with neither fails. Reads only the resolved doc ([relayInfo]); callers + * driving a live surface should warm it first and re-evaluate as it resolves. + */ +fun isRelaySignedRelayGroup( + channel: RelayGroupChannel, + relayInfo: Nip11RelayInformation, +): Boolean { + val self = relayInfo.self + return if (self != null) { + channel.event?.pubKey == self + } else { + relayInfo.supported_nips?.any { it == "29" } == true + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocket.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/http/OkHttpWebSocket.kt similarity index 99% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocket.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/http/OkHttpWebSocket.kt index e90277072f..60591cc64c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocket.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/http/OkHttpWebSocket.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.okhttp +package com.vitorpamplona.amethyst.commons.service.http import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.sockets.WebSocket diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PowJobStore.kt similarity index 96% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobStore.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PowJobStore.kt index 97e68b8b19..4a51a5d68f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PowJobStore.kt @@ -18,10 +18,8 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.pow +package com.vitorpamplona.amethyst.commons.service.pow -import com.vitorpamplona.amethyst.commons.service.pow.PersistedPoWJob -import com.vitorpamplona.amethyst.commons.service.pow.PoWJobPersistence import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/tor/TorRelayState.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/tor/TorRelayState.kt index 589fe2ebf7..0c00f35f06 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/tor/TorRelayState.kt @@ -18,15 +18,10 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.torState +package com.vitorpamplona.amethyst.commons.tor import androidx.compose.runtime.Stable import com.vitorpamplona.amethyst.commons.service.http.DualHttpClientManager -import com.vitorpamplona.amethyst.commons.tor.RelayClassification -import com.vitorpamplona.amethyst.commons.tor.TorRelayEvaluation -import com.vitorpamplona.amethyst.commons.tor.TorRelaySettings -import com.vitorpamplona.amethyst.commons.tor.TorSettingsFlow -import com.vitorpamplona.amethyst.commons.tor.TorType import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocketCloseHandshakeTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/http/OkHttpWebSocketCloseHandshakeTest.kt similarity index 99% rename from amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocketCloseHandshakeTest.kt rename to commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/http/OkHttpWebSocketCloseHandshakeTest.kt index 907a0b1ec4..424bba7093 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/OkHttpWebSocketCloseHandshakeTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/service/http/OkHttpWebSocketCloseHandshakeTest.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.service.okhttp +package com.vitorpamplona.amethyst.commons.service.http import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.sockets.WebSocketListener From e88bf34a7410f0bc8a42aa869e8b7406c6f8bd97 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Fri, 25 Sep 2026 21:56:17 +0000 Subject: [PATCH 41/57] ci: give Android Lint its own job instead of tuning memory a third time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test-and-build-android has now died with "the runner has received a shutdown signal" seven times in this workflow's history — SIGTERM, exit 143, the OOM killer taking the runner agent on a 16GB box. Twice on this PR alone: 2cd6569f at 35 minutes during compileFdroidDebugKotlin, f5fc432e at 29.5 minutes during testFdroidDebugUnitTest. Neither had a failing test; the job is simply killed, which is why the report steps come back "skipped" rather than red. Two attempts to fix this by changing numbers are already spent, and the existing comments in this file record both. Capping both daemons to 4g traded the runner OOM for an R8/lintAnalyze "java.lang.OutOfMemoryError: Java heap space" — those draw on the Gradle daemon's heap and 4g is not enough for them here. Dropping to --max-workers=3 survives a warm cache but still dies on a cold one, which is the case that matters: a PR touching quartz or commons invalidates the read-only cache the PR runs restore, so they rebuild from cold at 2-3x the main-branch time. Every commit on this PR touches commons. So this is the structural fix rather than a third number. lintAnalyze is the single heaviest step in that job — 13 of the 35 minutes on the 2cd6569f run — and it holds a large analysis graph while the Kotlin daemon, a forked test JVM and R8 are still resident. Moving the two lint tasks to their own runner removes that peak from the critical job instead of trying to squeeze everything under one ceiling, and the two now run concurrently rather than in series. The cost is real and worth stating: both jobs restore the same read-only Gradle cache and therefore repeat some module compilation. That trade is favourable because the duplicated work is parallel while the memory pressure was not. Nothing about the tasks themselves changes — same task names, same daemon caps, same --max-workers. The lint-report artifact upload moves to the new job. Not verified locally: lintPlayBenchmark is a 13-minute task on CI hardware and this container is the same shape as the runner that keeps dying, so running it here would prove nothing useful. What is checked is that the workflow still parses, that lint-android carries needs: lint like its sibling, and that the android job no longer references the lint tasks. CI is the test for this one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .github/workflows/build.yml | 80 ++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 72b2548016..32fad8469a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -335,6 +335,62 @@ jobs: name: Quartz iOS Test Reports path: quartz/build/reports + # Android Lint, split out of test-and-build-android. + # + # That job died with "the runner has received a shutdown signal" (SIGTERM, + # exit 143) seven times across this workflow's history — the OOM killer taking + # the runner agent on a 16GB box. Two attempts to fix it by tuning numbers + # have now been spent: capping both daemons to 4g traded the runner OOM for an + # R8/lintAnalyze "Java heap space", and --max-workers=3 survives a warm cache + # but still dies on a cold one. + # + # This is the structural fix rather than a third number. lintAnalyze is the + # single heaviest step in that job — measured at 13 of its 35 minutes on one + # cold run — and it holds a large analysis graph while the Kotlin daemon, a + # forked test JVM and R8 are all still resident. Giving the two lint tasks + # their own runner removes that peak from the critical job instead of trying + # to squeeze everything under one ceiling, and the two now run concurrently. + # + # The cost is honest: both jobs restore the same read-only Gradle cache and so + # repeat some module compilation. That buys back more than it spends here, + # because the duplicated work is parallel while the memory pressure was not. + lint-android: + needs: lint + runs-on: ubuntu-latest + timeout-minutes: 90 + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Set up JDK 21 + uses: actions/setup-java@v6.0.0 + with: + distribution: 'temurin' + java-version: 21 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 + with: + cache-read-only: ${{ github.ref != 'refs/heads/main' }} + + # Same daemon cap as the sibling job: lintAnalyze draws on the Gradle + # daemon's heap, which is why the earlier 4g experiment broke it. Only the + # Kotlin daemon is trimmed. + - name: Lint Android (gradle) + run: | + ./gradlew \ + -Dkotlin.daemon.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=1g" \ + --max-workers=3 \ + :amethyst:lintFdroidBenchmark \ + :amethyst:lintPlayBenchmark + + - name: Upload Android Lint Reports + uses: actions/upload-artifact@v7 + if: always() + with: + name: Android Lint Reports + path: amethyst/build/reports/lint-results-*.html + test-and-build-android: needs: lint runs-on: ubuntu-latest @@ -363,12 +419,15 @@ jobs: with: cache-read-only: ${{ github.ref != 'refs/heads/main' }} - # Lint + focused unit tests + benchmark assembly in one Gradle invocation. - # Previously: one invocation for lint, one for `test` (which compiled all - # six amethyst variants × all flavors), one for `assembleBenchmark` - # (re-walking the same task graph). Combining them keeps the daemon hot - # across phases and lets task-level dedup (e.g. compileKotlin) only - # happen once. + # Focused unit tests + benchmark assembly in one Gradle invocation. + # Previously: one invocation for `test` (which compiled all six amethyst + # variants × all flavors) and one for `assembleBenchmark` (re-walking the + # same task graph). Combining them keeps the daemon hot across phases and + # lets task-level dedup (e.g. compileKotlin) only happen once. + # + # Lint used to run here too and now has its own job (lint-android above) — + # see the note there for why. What remains is still the heaviest job in + # the workflow, so the memory notes below continue to apply. # # `-PdisableAbiSplits=true` produces a single non-split APK per # (flavor, buildType) instead of 5 (4 ABIs + universal). The CI only @@ -421,8 +480,6 @@ jobs: ./gradlew \ -Dkotlin.daemon.jvmargs="-Xmx4g -XX:MaxMetaspaceSize=1g" \ --max-workers=3 \ - :amethyst:lintFdroidBenchmark \ - :amethyst:lintPlayBenchmark \ :quartz:jvmTest \ :commons:jvmTest \ :commonsUI:jvmTest \ @@ -433,13 +490,6 @@ jobs: :amethyst:assembleBenchmark \ -PdisableAbiSplits=true - - name: Upload Android Lint Reports - uses: actions/upload-artifact@v7 - if: always() - with: - name: Android Lint Reports - path: amethyst/build/reports/lint-results-*.html - # Publishes the JUnit XML produced by the unit-test tasks above as inline # annotations plus a job summary. Replaces asadmansr/android-test-report-action, # which was abandoned (last release 2020) and rebuilt an EOL Ubuntu 18.04 + From 07436be50d26cb1109a8db4974ed02fda171f5f6 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Fri, 25 Sep 2026 22:19:51 +0000 Subject: [PATCH 42/57] refactor(commons): match the documented package conventions for the moved classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A review of where this session's moves landed, against commons/ARCHITECTURE.md — which I should have read before placing them, not after. Two of the ten placements broke conventions the doc states explicitly. relays/nip11 -> relays/nip11RelayInfo. The rule is "inside a layer, NIP-specific code goes in a nipNN<slug> subpackage whose name matches quartz exactly", with the worked trace quartz/nip57Zaps -> commons/model/nip57Zaps. Quartz's package is nip11RelayInfo, so nip11 broke the trace the convention exists to preserve. The point is that someone reading quartz/nip11RelayInfo can guess the commons package without searching. PowJobStore -> PoWJobStore (and PowJobsFile -> PoWJobsFile). Its five new siblings are PoWEstimator, PoWJobPersistence, PoWPolicy, PoWPublishQueue and PoWReplay. The name was fine in amethyst/service/pow; moving it next to those made it the odd one out. Same reasoning as the Encrypted* rename earlier: a name that was merely unremarkable in its old home can be wrong in the new one. Not changed, and the reasoning for each: - service/OnlineCheck.kt stays loose at the service root. Its callers are livestream and video URL checks and it also probes wss:// for LiveKit, so service/image is too narrow and service/connectivity is about device connectivity, not URL reachability. BundledUpdate.kt already sits at that root, and the doc says to resist a new package for a single file. This is the weakest of the ten placements and worth revisiting if a second URL-probing concern ever appears. - The amethyst-side Pow* classes (PowJobRestorer, PowMiningForegroundService, the PowOverrideButton/PowDifficultyTile UI) keep their spelling. That inconsistency predates this work and lives in a different module; renaming it is a separate change. - marmot, favorites, browser, tor, service/pow and service/http were already correct: each moved class landed in a package that existed and holds its siblings. marmot in particular is named in the doc as a self-contained feature package matching quartz. Verified: :commons:jvmTest, :amethyst:testPlayDebugUnitTest, :cli:compileKotlin, :commons:verifyKmpPurity, :commons:compileCommonMainKotlinMetadata, spotless. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../main/java/com/vitorpamplona/amethyst/AppModules.kt | 6 +++--- .../amethyst/model/nip11RelayInfo/LoadRelayInfo.kt | 2 +- .../amethyst/model/nip11RelayInfo/RelaySupportsNip.kt | 2 +- .../amethyst/service/pow/PowJobRestorer.kt | 6 +++--- .../amethyst/service/pow/PowMiningForegroundService.kt | 2 +- .../relayGroup/RelayGroupChannelListScreen.kt | 4 ++-- .../relayGroup/RelayGroupParentPicker.kt | 2 +- .../publicChannels/relayGroup/RelayGroupServerList.kt | 2 +- .../relays/common/BasicRelaySetupInfoClickableRow.kt | 2 +- .../relays/common/BasicRelaySetupInfoDialog.kt | 2 +- .../screen/loggedIn/relays/common/RelayUrlEditField.kt | 2 +- .../loggedIn/relays/common/ShowRelaySuggestionList.kt | 2 +- .../loggedIn/relays/vanish/RequestToVanishScreen.kt | 2 +- .../amethyst/service/pow/PowAndUsageFileFormatTest.kt | 8 ++++---- .../{nip11 => nip11RelayInfo}/RelaySupportsNip.kt | 2 +- .../{nip11 => nip11RelayInfo}/Nip11CachedRetriever.kt | 2 +- .../relays/{nip11 => nip11RelayInfo}/Nip11Retriever.kt | 2 +- .../relays/{nip11 => nip11RelayInfo}/RetrieveResult.kt | 2 +- .../service/pow/{PowJobStore.kt => PoWJobStore.kt} | 10 +++++----- .../{nip11 => nip11RelayInfo}/Nip11RetrieverTest.kt | 2 +- 20 files changed, 32 insertions(+), 32 deletions(-) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/{nip11 => nip11RelayInfo}/RelaySupportsNip.kt (98%) rename commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/{nip11 => nip11RelayInfo}/Nip11CachedRetriever.kt (99%) rename commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/{nip11 => nip11RelayInfo}/Nip11Retriever.kt (98%) rename commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/{nip11 => nip11RelayInfo}/RetrieveResult.kt (96%) rename commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/{PowJobStore.kt => PoWJobStore.kt} (96%) rename commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/{nip11 => nip11RelayInfo}/Nip11RetrieverTest.kt (97%) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index f0c1bffff2..3e0c5f6a6e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -55,7 +55,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.event.EventFinderQueryStat import com.vitorpamplona.amethyst.commons.relayClient.speedLogger.RelaySpeedLogger import com.vitorpamplona.amethyst.commons.relayClient.user.UserFinderQueryState import com.vitorpamplona.amethyst.commons.relays.health.TorCircuitHealthTracker -import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.richtext.CachedAsciiDocToMarkdown import com.vitorpamplona.amethyst.commons.richtext.CachedRichTextParser import com.vitorpamplona.amethyst.commons.robohash.CachedRobohash @@ -71,9 +71,9 @@ import com.vitorpamplona.amethyst.commons.service.http.LocalBlossomMediaCallFact import com.vitorpamplona.amethyst.commons.service.http.OkHttpWebSocket import com.vitorpamplona.amethyst.commons.service.http.OnionLocationCache import com.vitorpamplona.amethyst.commons.service.lnurl.OkHttpLnurlEndpointResolver +import com.vitorpamplona.amethyst.commons.service.pow.PoWJobStore import com.vitorpamplona.amethyst.commons.service.pow.PoWPolicy import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue -import com.vitorpamplona.amethyst.commons.service.pow.PowJobStore import com.vitorpamplona.amethyst.commons.state.UiSettingsState import com.vitorpamplona.amethyst.commons.tor.TorRelayState import com.vitorpamplona.amethyst.commons.tor.TorSettings @@ -983,7 +983,7 @@ class AppModules( // and every enqueue raises the shortService shield so backgrounding // doesn't freeze a miner. val powJobStore by lazy { - PowJobStore(File(appContext.filesDir, PowJobStore.FILE_NAME), applicationIOScope) + PoWJobStore(File(appContext.filesDir, PoWJobStore.FILE_NAME), applicationIOScope) } val powPublishQueue by lazy { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt index 0d8df07141..86a39afb05 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/LoadRelayInfo.kt @@ -25,7 +25,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.State import androidx.compose.runtime.produceState import com.vitorpamplona.amethyst.Amethyst -import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation import com.vitorpamplona.quartz.utils.Log diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt index 12edff9e8b..6cf7b588c7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip11RelayInfo/RelaySupportsNip.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.model.nip11RelayInfo import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel -import com.vitorpamplona.amethyst.commons.relays.nip11.isRelaySignedRelayGroup +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.isRelaySignedRelayGroup import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt index 20dad23f49..2dfdcfb482 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowJobRestorer.kt @@ -23,8 +23,8 @@ package com.vitorpamplona.amethyst.service.pow import com.vitorpamplona.amethyst.commons.scheduledposts.ScheduledPost import com.vitorpamplona.amethyst.commons.scheduledposts.ScheduledPostStore import com.vitorpamplona.amethyst.commons.service.pow.PersistedPoWJob +import com.vitorpamplona.amethyst.commons.service.pow.PoWJobStore import com.vitorpamplona.amethyst.commons.service.pow.PoWPublishQueue -import com.vitorpamplona.amethyst.commons.service.pow.PowJobStore import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl @@ -34,14 +34,14 @@ import com.vitorpamplona.quartz.utils.Log import java.util.UUID /** - * Re-enqueues the mining jobs checkpointed by [PowJobStore] when an account + * Re-enqueues the mining jobs checkpointed by [PoWJobStore] when an account * logs in, replacing the lost in-memory continuation with the headless replay * described by each record. Restore is idempotent: the queue dedupes by job * id, so a login flow that emits twice cannot double-mine. */ class PowJobRestorer( private val queue: PoWPublishQueue, - private val store: PowJobStore, + private val store: PoWJobStore, private val scheduledPostStore: ScheduledPostStore, ) { suspend fun restore(account: Account) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt index 8c373cbdb6..2686ae587d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/pow/PowMiningForegroundService.kt @@ -45,7 +45,7 @@ import kotlinx.coroutines.launch * * Uses the Android 14+ `shortService` type — no special permission, but a * hard ~3 minute budget. On `onTimeout` the service exits cleanly; every - * persistable job is already checkpointed by [com.vitorpamplona.amethyst.commons.service.pow.PowJobStore], so anything still + * persistable job is already checkpointed by [com.vitorpamplona.amethyst.commons.service.pow.PoWJobStore], so anything still * unmined resumes on the next app launch. Started on every enqueue (the app * is necessarily in the foreground then), stops itself when the queue drains. * diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt index 1dd12c3e92..c6e2de0394 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupChannelListScreen.kt @@ -74,8 +74,8 @@ import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.navigation.routeFor import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupDeletions -import com.vitorpamplona.amethyst.commons.relays.nip11.isRelaySignedRelayGroup -import com.vitorpamplona.amethyst.commons.relays.nip11.looksLikeNonNip29Relay +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.isRelaySignedRelayGroup +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.looksLikeNonNip29Relay import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.buzz_channel_create_title import com.vitorpamplona.amethyst.commons.resources.buzz_community_add_people diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt index 03b1528cbe..d0da74a4c0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt @@ -64,7 +64,7 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel -import com.vitorpamplona.amethyst.commons.relays.nip11.isRelaySignedRelayGroup +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.isRelaySignedRelayGroup import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.relay_group_member_count import com.vitorpamplona.amethyst.commons.resources.relay_group_parent_desc diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt index 391ee0fa22..8489a8e868 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupServerList.kt @@ -37,7 +37,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols -import com.vitorpamplona.amethyst.commons.relays.nip11.looksLikeNonNip29Relay +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.looksLikeNonNip29Relay import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.relay_group_relay_not_nip29 import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt index 90ff2fca72..a9f424323e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoClickableRow.kt @@ -41,7 +41,7 @@ import androidx.compose.ui.platform.LocalClipboard import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols -import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.relays.ui.RelayCountResult import com.vitorpamplona.amethyst.commons.relays.ui.RelayDragState import com.vitorpamplona.amethyst.commons.relays.ui.RelayEventCountRow diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt index a188c63141..85fe0a2ad8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoDialog.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.vitorpamplona.amethyst.commons.model.navigation.Route -import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.relays.ui.RelayCountResult import com.vitorpamplona.amethyst.commons.relays.ui.RelayDragState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt index ca80618511..c069ff51dd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/RelayUrlEditField.kt @@ -45,7 +45,7 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.Amethyst -import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.add import com.vitorpamplona.amethyst.commons.resources.add_a_relay diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt index ec43a64991..3c9c6771c1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/ShowRelaySuggestionList.kt @@ -26,7 +26,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt index 47d7aa6059..abbb321c4c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/vanish/RequestToVanishScreen.kt @@ -68,7 +68,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols -import com.vitorpamplona.amethyst.commons.relays.nip11.Nip11CachedRetriever +import com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo.Nip11CachedRetriever import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.cancel import com.vitorpamplona.amethyst.commons.resources.confirm diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt index 942d6ae828..91583920c1 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/pow/PowAndUsageFileFormatTest.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.amethyst.service.pow import com.vitorpamplona.amethyst.commons.service.pow.PersistedPoWJob -import com.vitorpamplona.amethyst.commons.service.pow.PowJobsFile +import com.vitorpamplona.amethyst.commons.service.pow.PoWJobsFile import com.vitorpamplona.amethyst.service.resourceusage.ResourceUsageStore import kotlinx.serialization.json.Json import org.junit.Assert.assertEquals @@ -44,7 +44,7 @@ class PowAndUsageFileFormatTest { } private val powSample = - PowJobsFile( + PoWJobsFile( version = 1, jobs = listOf( @@ -80,7 +80,7 @@ class PowAndUsageFileFormatTest { @Test fun powJobsFromTheJacksonBuildStillLoad() { - val loaded = json.decodeFromString<PowJobsFile>(POW_JACKSON_OUTPUT) + val loaded = json.decodeFromString<PoWJobsFile>(POW_JACKSON_OUTPUT) assertEquals(1, loaded.jobs.size) val job = loaded.jobs.first() @@ -114,7 +114,7 @@ class PowAndUsageFileFormatTest { assertEquals( "j1", json - .decodeFromString<PowJobsFile>(pow) + .decodeFromString<PoWJobsFile>(pow) .jobs .first() .id, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RelaySupportsNip.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/RelaySupportsNip.kt similarity index 98% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RelaySupportsNip.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/RelaySupportsNip.kt index 4f25aeb13c..d59f7bd6c1 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RelaySupportsNip.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/RelaySupportsNip.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.relays.nip11 +package com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11CachedRetriever.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11CachedRetriever.kt similarity index 99% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11CachedRetriever.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11CachedRetriever.kt index 5e89abff2a..b6fc1b1e38 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11CachedRetriever.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11CachedRetriever.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.relays.nip11 +package com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo import androidx.collection.LruCache import androidx.compose.runtime.Stable diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11Retriever.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11Retriever.kt similarity index 98% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11Retriever.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11Retriever.kt index 8380827a66..a8ca53429d 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11Retriever.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11Retriever.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.relays.nip11 +package com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.toHttp diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RetrieveResult.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/RetrieveResult.kt similarity index 96% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RetrieveResult.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/RetrieveResult.kt index 1fa3fde337..bb44f63cb7 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/RetrieveResult.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/RetrieveResult.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.relays.nip11 +package com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation import com.vitorpamplona.quartz.utils.TimeUtils diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PowJobStore.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWJobStore.kt similarity index 96% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PowJobStore.kt rename to commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWJobStore.kt index 4a51a5d68f..7ee8316c18 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PowJobStore.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWJobStore.kt @@ -39,7 +39,7 @@ import java.io.File * [save]/[remove] are the queue-facing fire-and-forget hooks; they serialize * onto a single-lane dispatcher so writes land in call order. */ -class PowJobStore( +class PoWJobStore( private val storageFile: File, scope: CoroutineScope, ) : PoWJobPersistence { @@ -109,7 +109,7 @@ class PowJobStore( jobs = try { if (storageFile.exists() && storageFile.length() > 0) { - json.decodeFromString<PowJobsFile>(storageFile.readText()).jobs.toMutableList() + json.decodeFromString<PoWJobsFile>(storageFile.readText()).jobs.toMutableList() } else { mutableListOf() } @@ -126,7 +126,7 @@ class PowJobStore( storageFile.parentFile?.mkdirs() val tmp = File(storageFile.parentFile, storageFile.name + ".tmp") try { - tmp.writeText(json.encodeToString(PowJobsFile(version = 1, jobs = jobs.toList()))) + tmp.writeText(json.encodeToString(PoWJobsFile(version = 1, jobs = jobs.toList()))) if (!tmp.renameTo(storageFile)) { if (!storageFile.delete() || !tmp.renameTo(storageFile)) { Log.e(TAG) { "Failed to rename $tmp to $storageFile" } @@ -144,7 +144,7 @@ class PowJobStore( } companion object { - private const val TAG = "PowJobStore" + private const val TAG = "PoWJobStore" const val FILE_NAME = "pending_pow_jobs.json" // a job this stale is a post the user has long forgotten; publishing @@ -154,7 +154,7 @@ class PowJobStore( } @Serializable -data class PowJobsFile( +data class PoWJobsFile( val version: Int = 1, val jobs: List<PersistedPoWJob> = emptyList(), ) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11RetrieverTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11RetrieverTest.kt similarity index 97% rename from commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11RetrieverTest.kt rename to commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11RetrieverTest.kt index cb936017fe..73a11a6335 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11/Nip11RetrieverTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relays/nip11RelayInfo/Nip11RetrieverTest.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.relays.nip11 +package com.vitorpamplona.amethyst.commons.relays.nip11RelayInfo import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.coroutines.runBlocking From 8346b43c06a45a6bdd8ac3efb02826cdc86fb0ad Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Fri, 25 Sep 2026 22:42:25 +0000 Subject: [PATCH 43/57] perf(commons): resolve the favicon directory once instead of per lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regression I introduced in 2cd6569f, found by a pre-merge review pass. The object this replaced cached its directory as a File in init(). Taking iconDir as a () -> Path is what freed the class from Context, but I then called it on every access, including from iconModelFor. On Android that lambda is `appContext.filesDir.toOkioPath() / DIR`, and Context.getFilesDir() is not a field read: it takes a lock and calls mkdir() to ensure the directory exists. iconModelFor is read from composition on the main thread — the bottom bar, the favorites grid, the omnibox suggestions and the napplet icon all call it, once per icon per recomposition. So the move quietly put a filesystem syscall, a lock and two allocations on every frame that draws a favicon. Resolved once in a lazy now, which is what the old code did and what the lambda was always meant to allow: the front end still owns the location, nothing resolves at construction, and the path is computed on first use rather than on every use. No test changes. aMissingIconDirectoryIsCreated already covers the case that matters for laziness — the directory does not exist when the registry is built, and is created when init() first touches it — and still passes. Verified: :commons:jvmTest, :commons:verifyKmpPurity, :commons:compileCommonMainKotlinMetadata, :amethyst:compilePlayDebugKotlin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../amethyst/commons/browser/BrowserIconRegistry.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt index f7f6c4bb69..bdd40d5199 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/browser/BrowserIconRegistry.kt @@ -54,6 +54,15 @@ class BrowserIconRegistry( private val iconDir: () -> Path, private val scope: CoroutineScope, ) { + // Resolved once, not per call. [iconDir] is a lambda so the front end owns the location and + // nothing resolves at construction; but on Android it is `appContext.filesDir`, and + // Context.getFilesDir() takes a lock and mkdir()s the directory every time it is asked. The + // object this replaced cached the File in init(), and iconModelFor is read from composition on + // the main thread by the bottom bar, the favorites grid, the omnibox suggestions and the + // napplet icon — so re-invoking the lambda there put a filesystem syscall on every frame that + // draws an icon. + private val dir: Path by lazy { iconDir() } + private val _keys = MutableStateFlow<Set<String>>(emptySet()) /** Sanitized host keys that currently have a stored icon. Observe to recompose when an icon arrives. */ @@ -73,7 +82,6 @@ class BrowserIconRegistry( started = true scope.launch { try { - val dir = iconDir() platformFileSystem.createDirectories(dir) val scanned = platformFileSystem @@ -103,7 +111,6 @@ class BrowserIconRegistry( // icon exists before the file backing it does. scope.launch { try { - val dir = iconDir() platformFileSystem.createDirectories(dir) platformFileSystem.write(dir / (key + PNG)) { write(bytes) } _keys.update { it + key } @@ -120,7 +127,7 @@ class BrowserIconRegistry( fun iconModelFor(host: String): String? { val key = sanitize(host) if (key !in _keys.value) return null - return "file://" + (iconDir() / (key + PNG)) + return "file://" + (dir / (key + PNG)) } companion object { From 1770ef27c5b5a959c9cba53415b7fbf5f407d2ed Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 15:52:53 +0000 Subject: [PATCH 44/57] fix(quartz): give each addressable tagging target its own d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EventTagging's deterministic `d` is `event-tag-<tagSlug>-<target8>-<asserter8>`, and for an addressable target `<target8>` was `address.pubKeyHex.take(8)` — the author segment of the coordinate, which repeats across everything that author writes. Two of the same author's addressable events, tagged with the same tag by the same asserter, therefore produced the same `d`. Kind 39999 is addressable, so those two assertions do not sit side by side: the later one silently replaces the earlier, and the first tagging disappears. `<target8>` is now the first 8 hex of sha256 over the whole coordinate, so all three segments discriminate. `ByEventId` is unchanged — an event id already covers the whole event, and hashing it would only cost a round of SHA-256 per assertion. The `d` stays deterministic, which is what lets a re-tag replace its own assertion rather than pile up a second one, and nothing parses the `d` back into a target: it is read only as an identity, and the target itself is in the `a`/`e` tag. Nothing published depends on the old format — `EventTagging` has no caller outside quartz's own tests yet. Regressions pinned in AuditRegressionTest, each failing first: two targets differing only by d-tag, only by kind, and only by author. The derivation is pinned against SHA-256 prefixes computed outside this codebase, so the tests cross-check it rather than restate it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../taggings/EventTagging.kt | 14 ++++- .../decentralizedLists/AuditRegressionTest.kt | 61 +++++++++++++++++++ .../TapestryExtensionsTest.kt | 4 +- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt index 1e157b23e6..782ad80571 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt @@ -32,22 +32,30 @@ import com.vitorpamplona.quartz.experimental.decentralizedLists.taggings.tags.Po import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.fastFirstNotNullOfOrNull +import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag import com.vitorpamplona.quartz.nip01Core.tags.events.ETag import com.vitorpamplona.quartz.utils.TimeUtils +import com.vitorpamplona.quartz.utils.sha256.sha256 /** What an event tagging is about: an addressable event (`a`) or a plain one (`e`). */ @Immutable sealed interface TaggingTarget { - /** The first 8 characters used in the assertion `d`. */ + /** + * The 8 hex characters that stand for this target in the assertion `d`. Two distinct targets + * must not produce the same one: kind 39999 is addressable, so taggings that share a `d` do + * not sit side by side — the later one replaces the earlier. + */ val prefix: String @Immutable data class ByAddress( val address: Address, ) : TaggingTarget { - // the author segment of the coordinate, not its kind - override val prefix get() = address.pubKeyHex.take(8) + // Hashed over the WHOLE coordinate, because no single segment identifies the target: the + // author repeats across everything they write, and the kind across everything of a type. + // A plain event can use its own id (below) since that already covers the whole event. + override val prefix get() = sha256(address.toValue().encodeToByteArray()).toHexKey().take(8) } @Immutable diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt index ab0579b6df..e1f2f2c56a 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt @@ -36,6 +36,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertIs +import kotlin.test.assertNotEquals /** Regressions found in the audit: each failed before its fix. */ class AuditRegressionTest { @@ -111,6 +112,66 @@ class AuditRegressionTest { assertFalse(name in node.linkedAddressIds()) } + // The `d` must separate two addressable targets. kind 39999 is addressable, so a colliding + // `d` means the second tagging silently replaces the first. + @Test + fun twoAddressableTargetsByTheSameAuthorGetDifferentDTags() { + val first = TaggingTarget.ByAddress(Address(39999, bob, "good-tag")) + val second = TaggingTarget.ByAddress(Address(39999, bob, "other-tag")) + + assertNotEquals( + EventTagging.dTag("awesome-tag", first, alice), + EventTagging.dTag("awesome-tag", second, alice), + ) + } + + // Same idea across the other two coordinate segments: only one of the three may differ. + @Test + fun addressableTargetsDifferingOnlyByKindGetDifferentDTags() { + assertNotEquals( + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, "tag")), alice), + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(30023, bob, "tag")), alice), + ) + } + + @Test + fun addressableTargetsDifferingOnlyByAuthorGetDifferentDTags() { + assertNotEquals( + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, "tag")), alice), + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, other, "tag")), alice), + ) + } + + // ...while the `d` stays deterministic, which is what lets a re-tag replace its own assertion + // instead of piling up a second one. Pinned against SHA-256 prefixes of the coordinates + // computed outside this codebase, so the test cross-checks the derivation rather than + // restating it: a change of hash input would silently orphan every assertion already signed. + @Test + fun theAddressablePrefixIsTheHashOfTheWholeCoordinate() { + assertEquals( + "event-tag-awesome-tag-6a5e1c40-aaaaaaaa", + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, "good-tag")), alice), + ) + assertEquals( + "event-tag-awesome-tag-e89b797c-aaaaaaaa", + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, "other-tag")), alice), + ) + assertEquals( + "event-tag-awesome-tag-96856fd8-aaaaaaaa", + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(30023, bob, "good-tag")), alice), + ) + } + + // A plain event is still named by its own id: it already covers the whole event, and hashing + // it would only cost a round of SHA-256 per assertion built. + @Test + fun plainEventTargetsStillUseTheirOwnId() { + assertEquals( + "event-tag-awesome-tag-11111111-aaaaaaaa", + EventTagging.dTag("awesome-tag", TaggingTarget.ByEventId("1".repeat(64)), alice), + ) + } + // Authored JSON: an explicit null in a list field must not make the whole section unreadable. @Test fun explicitNullListsInTheWordSectionAreTolerated() { diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt index 8e4b8a72a6..c212e8deb2 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt @@ -247,7 +247,9 @@ class TapestryExtensionsTest { assertEquals( listOf( - listOf("d", "event-tag-awesome-tag-cccccccc-aaaaaaaa"), + // 4d7a80b1 is sha256("39999:${"c".repeat(64)}:good-tag").take(8) — the whole + // coordinate, so two of the assistant's tags cannot share this `d`. + listOf("d", "event-tag-awesome-tag-4d7a80b1-aaaaaaaa"), listOf("z", "39998:$ta:nostr-event-tag"), listOf("z", "39999:$bob:tagging:awesome-tag-tagging"), listOf("a", "39999:$assistant:good-tag"), From 333d305c1ac5358a62805219e029f0202e05bb7f Mon Sep 17 00:00:00 2001 From: Vitor Pamplona <vitor@vitorpamplona.com> Date: Sat, 26 Sep 2026 15:47:25 -0400 Subject: [PATCH 45/57] fix(cordn): observe the two StateFlows these screens were reading flat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Android Lint's `StateFlowValueCalledInComposition` on both, and in both cases the value it could not see changing is one the screen exists to show. `CordnCreateGroupScreen` read `runtime.groups.all.value` to count the groups this coordinator already carries for the exposure card. That count is the number the card is *about* — how much one operator can correlate — and creating a group is exactly what moves it, so a frozen read is wrong on the screen where it matters most. `CordnInvitationsScreen` read `runtime.coordinators.value` to choose between "you have no coordinators" and "nobody has invited you". Adding a coordinator elsewhere has to change which of those two sentences is on screen; otherwise it keeps telling you to add one you already added. Both now collect with `collectAsStateWithLifecycle`, which the create screen was already doing one line above for `coordinators`. Found running the Android Lint job locally; it was the only thing failing it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --- .../chats/cordnGroup/CordnCreateGroupScreen.kt | 11 +++++++---- .../chats/cordnGroup/CordnInvitationsScreen.kt | 9 ++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt index 651859f69e..6deedde2d4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt @@ -147,6 +147,12 @@ fun CordnCreateGroupScreen( } val known by runtime.coordinators.collectAsStateWithLifecycle() + // Collected, not read as `.value` below: the exposure card counts the + // groups this coordinator already carries, and reading the flow inside + // composition would leave that count frozen at whatever it was when the + // screen opened — the one number on the card that can change while you + // are looking at it, since creating a group is what changes it. + val rooms by runtime.groups.all.collectAsStateWithLifecycle() val scope = rememberCoroutineScope() val me = accountViewModel.account.signer.pubKey @@ -491,10 +497,7 @@ fun CordnCreateGroupScreen( // serves for this account: the disclosure is about what // one coordinator can correlate, so a second group on // the same one widens it. - linkedGroupCount = - 1 + - runtime.groups.all.value - .count { room -> room.coordinatorPubKey == it.pubKey }, + linkedGroupCount = 1 + rooms.count { room -> room.coordinatorPubKey == it.pubKey }, joinedFromShareLink = false, publishedKeyPackage = false, encryptionPinned = true, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt index 147527e9ea..a1292ad0e6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt @@ -50,6 +50,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols @@ -155,6 +156,12 @@ fun CordnInvitationsScreen( return@Column } + // Collected rather than read as `.value` further down: the empty + // state says either "you have no coordinators" or "nobody has + // invited you", and adding a coordinator in another tab has to + // change which of those two this screen is showing. + val coordinators by runtime.coordinators.collectAsStateWithLifecycle() + Text( text = stringRes(R.string.cordn_invitations_explainer), style = MaterialTheme.typography.bodyMedium, @@ -227,7 +234,7 @@ fun CordnInvitationsScreen( if (loaded.isEmpty) { Text( text = - if (runtime.coordinators.value.isEmpty()) { + if (coordinators.isEmpty()) { stringRes(R.string.cordn_invitations_no_coordinators) } else { stringRes(R.string.cordn_invitations_none) From 69c2feab3ac35c0f2153e444c99136bb5e04324b Mon Sep 17 00:00:00 2001 From: Vitor Pamplona <vitor@vitorpamplona.com> Date: Sat, 26 Sep 2026 15:59:18 -0400 Subject: [PATCH 46/57] fix(quartz): drop the commas Kotlin/Native will not take in a test name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `:quartz:compileTestKotlinLinuxX64` and `compileTestKotlinIosSimulatorArm64` both fail with `Name contains illegal characters: ","`. A backtick-quoted identifier may hold a comma on the JVM and may not on Native, and these are `commonTest`, so they build for every target. Sixteen names across seven cordn/contextvm test files, all of which arrived with #4201 and none of which had ever been compiled for a native target. Reworded rather than stripped: "a failed negotiation, not a downgrade" becomes "rather than a downgrade" and the three "needs kind N, an e tag, and text" names become "with an e tag and text", so each still reads as the sentence it was. Hyphens and apostrophes are fine on Native and are left alone. Checked the whole of commonTest for the rest of the illegal set as well (. ; : [ ] / < > \) — the commas were all of it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --- .../quartz/contextvm/cep08Payments/PaymentTest.kt | 2 +- .../cep22OversizedTransfer/OversizedTransferTest.kt | 2 +- .../quartz/contextvm/core/CvmMessageEventTest.kt | 4 ++-- .../quartz/cordn/appEncryptedMedia/CordnBlobUploadTest.kt | 6 +++--- .../cordn/appEncryptedMedia/CordnMediaEncryptionTest.kt | 6 +++--- .../cordn/spec02Envelopes/CordnAnnotationIndexTest.kt | 4 ++-- .../quartz/cordn/spec02Envelopes/CordnMessageKindsTest.kt | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep08Payments/PaymentTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep08Payments/PaymentTest.kt index da76d4711c..2225f18361 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep08Payments/PaymentTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep08Payments/PaymentTest.kt @@ -184,7 +184,7 @@ class PaymentTest { } @Test - fun `CVM-8-22 a server that ignores the request is a failed negotiation, not a downgrade`() { + fun `CVM-8-22 a server that ignores the request is a failed negotiation rather than a downgrade`() { val session = PaymentSession(requested = PaymentInteraction.EXPLICIT_GATING) session.observeServerTags(emptyArray()) assertTrue(session.negotiationFailed, "silent fallback must be visible to the caller") diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep22OversizedTransfer/OversizedTransferTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep22OversizedTransfer/OversizedTransferTest.kt index eb1f15a2e2..dfb9dc02a2 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep22OversizedTransfer/OversizedTransferTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/cep22OversizedTransfer/OversizedTransferTest.kt @@ -76,7 +76,7 @@ class OversizedTransferTest { } @Test - fun `CVM-22-02 assembles out-of-order chunks by progress, not arrival order`() { + fun `CVM-22-02 assembles out-of-order chunks by progress rather than arrival order`() { // Relays may reorder. `progress` is the canonical assembly index. val frames = sender().frame(token, payload) val start = frames.first() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/core/CvmMessageEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/core/CvmMessageEventTest.kt index 61cbd5490e..3ce2747447 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/core/CvmMessageEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/contextvm/core/CvmMessageEventTest.kt @@ -43,7 +43,7 @@ class CvmMessageEventTest { private val ping = JsonRpcRequest(JsonRpcId.Num(1), "ping") @Test - fun `CVM-CORE-02 content is a stringified JSON-RPC message, not an embedded object`() { + fun `CVM-CORE-02 content is a stringified JSON-RPC message rather than an embedded object`() { val template = CvmMessageEvent.build(ping, serverPubKey) // The spec's examples print `content` unstringified for readability, @@ -91,7 +91,7 @@ class CvmMessageEventTest { } @Test - fun `CVM-CORE-06 kind 25910 is ephemeral, so delivery has no replay`() { + fun `CVM-CORE-06 kind 25910 is ephemeral so delivery has no replay`() { // Consequence, not decoration: relays do not retain this kind, so a // subscription must be live before the peer publishes. The transport's // request API is built around this and the property is worth pinning. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnBlobUploadTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnBlobUploadTest.kt index 2852d6c080..7d1be0ed02 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnBlobUploadTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnBlobUploadTest.kt @@ -44,7 +44,7 @@ class CordnBlobUploadTest { private val sealed = CordnMediaEncryption.encrypt(file, key, "image/jpeg", "holiday.jpg") @Test - fun `the host is given the ciphertext, and its hash names the blob`() { + fun `the host is given the ciphertext and its hash names the blob`() { val blob = CordnBlobUpload.of(sealed) // Blossom addresses a blob by the hash of what it stores. @@ -65,7 +65,7 @@ class CordnBlobUploadTest { } @Test - fun `the declared type is opaque, never the real one`() { + fun `the declared type is opaque rather than the real one`() { val blob = CordnBlobUpload.of(sealed) assertEquals("application/octet-stream", blob.contentType) @@ -93,7 +93,7 @@ class CordnBlobUploadTest { } @Test - fun `upload, never the media endpoint`() { + fun `upload rather than the media endpoint`() { // `/media` asks the server to re-encode. Re-encoding ciphertext // destroys it, so an account with "optimize uploads" on would break // every attachment and only the recipient would find out. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnMediaEncryptionTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnMediaEncryptionTest.kt index 817de45134..572c412b28 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnMediaEncryptionTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/appEncryptedMedia/CordnMediaEncryptionTest.kt @@ -69,7 +69,7 @@ class CordnMediaEncryptionTest { } @Test - fun `renaming a file breaks it, because the name is authenticated`() { + fun `renaming a file breaks it because the name is authenticated`() { val sealed = roundTrip(name = "photo.jpg") assertFailsWith<Exception> { @@ -180,7 +180,7 @@ class CordnMediaEncryptionTest { } @Test - fun `the display hints round-trip, including the waveform`() { + fun `the display hints round-trip including the waveform`() { // The recorder measures amplitudes and the composer preview already // draws them; without somewhere to put them they were dropped at upload // and the sender's own voice note came back bar-less. @@ -207,7 +207,7 @@ class CordnMediaEncryptionTest { } @Test - fun `a hint that is absent or malformed costs the hint, not the attachment`() { + fun `a hint that is absent or malformed costs the hint rather than the attachment`() { // Every one of these is optional, so a reader that cannot make sense of // one must still be able to fetch and open the file. val tag = CordnMediaTag.build(roundTrip(), url = "https://b.example.com/b") diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnAnnotationIndexTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnAnnotationIndexTest.kt index 24d5ce7ef4..6dc636a727 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnAnnotationIndexTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnAnnotationIndexTest.kt @@ -73,7 +73,7 @@ class CordnAnnotationIndexTest { } @Test - fun `only the author may edit, and the newest edit wins`() { + fun `only the author may edit and the newest edit wins`() { val note = message(alice, CordnMessageKinds.TEXT, "original", createdAt = 100) val tags = CordnMessageReferences.editTags(note.asTarget()) @@ -177,7 +177,7 @@ class CordnAnnotationIndexTest { } @Test - fun `any member may pin, and the last write wins`() { + fun `any member may pin and the last write wins`() { val note = message(alice, CordnMessageKinds.TEXT, "important", createdAt = 100) val t = note.asTarget() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnMessageKindsTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnMessageKindsTest.kt index 8cc2c492f0..3acef99dd3 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnMessageKindsTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/cordn/spec02Envelopes/CordnMessageKindsTest.kt @@ -64,7 +64,7 @@ class CordnMessageKindsTest { } @Test - fun `the numbers are cordn-web's, and differ from Marmot's on purpose`() { + fun `the numbers are cordn-web's and differ from Marmot's on purpose`() { // Pinned because they are the interop surface with the only other cordn // client, and because two of them disagree with Marmot (1009 edit, no // pin) by decision rather than accident. @@ -170,7 +170,7 @@ class CordnMessageKindsTest { // ---- inbound ------------------------------------------------------- @Test - fun `a reaction needs kind 7, e p k, and content`() { + fun `a reaction needs kind 7 with e p k and content`() { val good = CordnMessageReferences.reactionTags(target()) assertNotNull(CordnMessageReferences.reaction(7, "+", good)) @@ -210,7 +210,7 @@ class CordnMessageKindsTest { } @Test - fun `an edit needs kind 1010, an e tag, and text`() { + fun `an edit needs kind 1010 with an e tag and text`() { val tags = CordnMessageReferences.editTags(target()) assertEquals("1".repeat(64), assertNotNull(CordnMessageReferences.edit(1010, "new", tags)).targetId) @@ -230,7 +230,7 @@ class CordnMessageKindsTest { } @Test - fun `a pin needs kind 1011, an e tag, and a known op`() { + fun `a pin needs kind 1011 with an e tag and a known op`() { assertEquals( PinOp.ADD, assertNotNull(CordnMessageReferences.pin(1011, CordnMessageReferences.pinTags(target(), PinOp.ADD))).op, From 6d2c37c3460ab1b0339df6d7b759e06a8afa6365 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 20:19:55 +0000 Subject: [PATCH 47/57] refactor(quartz): rename event classes to match their NIP names Old class names drifted from the NIP wording (or described the wrong kind). Every old name stays available as a @Deprecated typealias with a ReplaceWith, so external Quartz users get an IDE quick-fix instead of a break. Wire format is unchanged: parsing goes by kind. Renames: - FollowListEvent (39089) -> StarterPackEvent - LnZapPaymentRequestEvent/ResponseEvent (NIP-47) -> NwcRequestEvent/NwcResponseEvent - VideoHorizontalEvent/VideoVerticalEvent -> AddressableNormalVideoEvent/AddressableShortVideoEvent - CalendarEvent (31924) -> CalendarCollectionEvent - HashtagListEvent -> InterestListEvent - ContactCardEvent (30382) -> UserAssertionEvent - LnZapEvent/LnZapRequestEvent/LnZapEventInterface -> ZapReceiptEvent/ZapRequestEvent/ZapReceiptEventInterface - PrivateDmEvent -> EncryptedDmEvent, DeletionEvent -> DeletionRequestEvent - LongTextNoteEvent -> LongFormContentEvent, WikiNoteEvent -> WikiArticleEvent - PeopleListEvent -> FollowSetEvent, LabeledBookmarkListEvent -> BookmarkSetEvent - RelayFeedsListEvent -> FavoriteRelayListEvent, EmojiPackSelectionEvent -> EmojiListEvent - ChannelListEvent -> PublicChatListEvent, ChatMessageRelayListEvent -> DmRelayListEvent - SealedRumorEvent -> SealEvent, FileHeaderEvent -> FileMetadataEvent - GoalEvent -> ZapGoalEvent, StatusEvent -> UserStatusEvent - NIP90*Event -> Dvm*Event (all NIP-90 events) - NIP-29 group events get the Group prefix to separate them from NIP-43: PutUser, RemoveUser, EditMetadata, DeleteEvent, CreateInvite, UpdatePinList, JoinRequest, LeaveRequest; SupportedRolesEvent -> GroupRolesEvent Merged duplicate classes for the same kind: - nip61 TokenEvent (7375) was unreachable in EventFactory; now an alias of CashuTokenEvent. - nip61 NutzapRedemptionEvent (7376) was unreachable; CashuSpendingHistoryEvent now carries its hint providers and redeemedNutzaps(), plus CashuSpendingHistoryEvent.buildNutzapRedemption. - NIP-82 SoftwareReleaseEvent (30063) was never built by EventFactory; ReleaseArtifactSetEvent now exposes appId/version/channel/assets/releaseNotes and buildSoftwareRelease, and the app no longer re-parses the event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015VvJ8XpeYqBe8bYT3bJ7UD --- .claude/skills/auth-signers/SKILL.md | 2 +- .../skills/nip85-trusted-assertions/SKILL.md | 12 +- .../references/event-hierarchy.md | 18 +- .../nostr-expert/references/nip-catalog.md | 12 +- .claude/skills/quartz-integration/SKILL.md | 22 +- .../references/searchable-kinds.md | 40 +-- .../amethyst/LocalPreferences.kt | 16 +- .../vitorpamplona/amethyst/model/Account.kt | 46 +-- .../model/AccountRelayGroupActions.kt | 32 +- .../amethyst/model/AccountSettings.kt | 36 +-- .../amethyst/model/AccountSyncedSettings.kt | 4 +- .../model/AccountSyncedSettingsInternal.kt | 4 +- .../amethyst/model/AccountZapActions.kt | 20 +- .../amethyst/model/EventBroadcaster.kt | 14 +- .../FavoriteAlgoFeedsOrchestrator.kt | 14 +- .../model/nip17Dms/DmRelayListState.kt | 16 +- .../nip30CustomEmojis/OwnedEmojiPacksState.kt | 8 +- .../nip47WalletConnect/NwcSignerState.kt | 18 +- .../hashtagLists/HashtagListState.kt | 26 +- .../interestSets/InterestSetsState.kt | 8 +- .../LabeledBookmarkListsState.kt | 42 +-- .../nip51Lists/peopleList/FollowListsState.kt | 26 +- .../nip51Lists/peopleList/PeopleListsState.kt | 42 +-- .../relayFeeds/RelayFeedListState.kt | 20 +- .../model/nip60Cashu/CashuWalletState.kt | 8 +- .../amethyst/napplet/NappletConsentSummary.kt | 4 +- .../napplet/gateways/AccountIdentityReader.kt | 4 +- .../amethyst/service/V4VPaymentHandler.kt | 6 +- .../amethyst/service/ZapPaymentHandler.kt | 22 +- .../service/lnurl/LightningAddressResolver.kt | 8 +- .../EventNotificationConsumer.kt | 26 +- .../notifications/NotificationContent.kt | 10 +- .../notifications/NotificationDispatcher.kt | 24 +- .../renderers/DirectMessageNotification.kt | 4 +- .../renderers/ZapNotification.kt | 8 +- .../FilterAccountInfoAndListsFromKey.kt | 16 +- .../NWCFinderFilterAssemblerSubscription.kt | 4 +- .../reqCommand/user/UserObservers.kt | 10 +- .../resourceusage/MeteringNostrSigner.kt | 4 +- .../uploads/hls/HlsVideoEventBuilder.kt | 14 +- .../markdown/RenderContentAsMarkdown.kt | 4 +- .../amethyst/ui/dal/FilterByListParams.kt | 4 +- .../amethyst/ui/feeds/PrefetchFeedMedia.kt | 4 +- .../ui/navigation/routes/RouteMaker.kt | 18 +- .../ui/note/NIP05VerificationDisplay.kt | 8 +- .../amethyst/ui/note/NoteCompose.kt | 64 ++-- .../amethyst/ui/note/NoteQuickActionMenu.kt | 8 +- .../ui/note/UpdateReactionTypeDialog.kt | 4 +- .../amethyst/ui/note/UpdateZapAmountDialog.kt | 10 +- .../ui/note/UpdateZapAmountViewModel.kt | 4 +- .../amethyst/ui/note/ZapCustomDialog.kt | 22 +- .../amethyst/ui/note/ZapPollNote.kt | 4 +- .../amethyst/ui/note/ZapPollNoteViewModel.kt | 12 +- .../WatchAndLoadMyEmojiList.kt | 6 +- .../note/elements/AddInboxRelayForDMCard.kt | 10 +- .../ui/note/elements/NoteActionSections.kt | 10 +- .../nip22Comments/CommentPostViewModel.kt | 10 +- .../amethyst/ui/note/share/SharedNoteCard.kt | 6 +- .../ui/note/types/CalendarCollectionRender.kt | 4 +- .../amethyst/ui/note/types/FileHeader.kt | 10 +- .../amethyst/ui/note/types/FollowList.kt | 6 +- .../amethyst/ui/note/types/Goal.kt | 6 +- .../amethyst/ui/note/types/LongForm.kt | 6 +- .../types/NIP90ContentDiscoveryResponse.kt | 4 +- .../amethyst/ui/note/types/NIP90Status.kt | 4 +- .../amethyst/ui/note/types/PeopleList.kt | 4 +- .../amethyst/ui/note/types/PrivateMessage.kt | 4 +- .../amethyst/ui/note/types/Publication.kt | 8 +- .../ui/note/types/PublicationSection.kt | 6 +- .../amethyst/ui/note/types/RelayList.kt | 4 +- .../amethyst/ui/note/types/SoftwareApp.kt | 48 ++- .../amethyst/ui/note/types/Text.kt | 4 +- .../amethyst/ui/note/types/Wiki.kt | 6 +- .../ui/note/types/WikiCollaboration.kt | 6 +- .../amethyst/ui/note/types/ZapEvent.kt | 4 +- .../ui/note/types/lists/BookmarkLists.kt | 4 +- .../amethyst/ui/note/types/lists/TagLists.kt | 6 +- .../amethyst/ui/screen/TopNavFilterState.kt | 8 +- .../ui/screen/loggedIn/AccountViewModel.kt | 68 ++-- .../loggedIn/DecryptAndIndexProcessor.kt | 34 +- .../loggedIn/articles/ArticlesFeedLoaded.kt | 4 +- .../loggedIn/articles/ArticlesTopBar.kt | 4 +- .../articles/dal/ArticlesFeedFilter.kt | 8 +- .../backups/BackupConflictListViews.kt | 16 +- .../display/BookmarkGroupItemOptions.kt | 4 +- .../calendars/CalendarCollectionsTopBar.kt | 4 +- .../calendars/CalendarCollectionsView.kt | 6 +- .../loggedIn/calendars/CalendarsViewModel.kt | 8 +- .../create/NewCalendarCollectionViewModel.kt | 12 +- .../dal/CalendarCollectionsFeedFilter.kt | 6 +- .../calendars/detail/AddToCalendarSheet.kt | 14 +- .../detail/CalendarEventDetailScreen.kt | 12 +- .../loggedIn/chats/feed/ChatMessageCompose.kt | 12 +- .../screen/loggedIn/chats/feed/ChatTimeAgo.kt | 6 +- .../chats/feed/layouts/ChatGroupPosition.kt | 4 +- .../chats/feed/types/RenderChatZap.kt | 4 +- .../chats/geohashChat/GeohashChatViewModel.kt | 4 +- .../loggedIn/chats/privateDM/ChatroomView.kt | 4 +- .../privateDM/datasource/FilterNip04DMs.kt | 6 +- .../privateDM/send/ChatNewMessageViewModel.kt | 10 +- .../header/LiveStreamGoalHeader.kt | 4 +- .../rooms/dal/ChatroomListKnownFeedFilter.kt | 6 +- .../rooms/dal/ChatroomListNewFeedFilter.kt | 6 +- .../rooms/datasource/FilterNip04DMsFromMe.kt | 4 +- .../rooms/datasource/FilterNip04DMsToMe.kt | 4 +- .../chats/rooms/feed/ChatroomListFeedView.kt | 6 +- .../loggedIn/discover/ChannelCardCompose.kt | 12 +- .../loggedIn/discover/DiscoverScreen.kt | 8 +- .../DiscoverLongFormFeedFilter.kt | 8 +- .../discover/nip23LongForm/LongFormCard.kt | 4 +- .../nip23LongForm/LongFormPostViewModel.kt | 10 +- .../DiscoverFollowSetsFeedFilter.kt | 8 +- .../discover/nip51FollowSets/FollowSetCard.kt | 6 +- .../dvms/DvmContentDiscoveryScreen.kt | 18 +- .../loggedIn/dvms/FavoriteAlgoFeedToggle.kt | 4 +- .../NIP90ContentDiscoveryResponseFilter.kt | 8 +- .../membershipManagement/MyEmojiListScreen.kt | 4 +- .../followPacks/feed/FollowPackFeedScreen.kt | 6 +- .../FollowPackFeedConversationsFeedFilter.kt | 4 +- .../dal/FollowPackFeedNewThreadFeedFilter.kt | 16 +- .../feed/dal/FollowPackMembersFeedFilter.kt | 6 +- .../FollowPackFeedFilterSubAssembler.kt | 4 +- .../followPacks/list/FollowPacksFeedLoaded.kt | 4 +- .../followPacks/list/FollowPacksTopBar.kt | 4 +- .../loggedIn/geohash/dal/GeoHashFeedFilter.kt | 12 +- .../loggedIn/hashtag/dal/HashtagFeedFilter.kt | 12 +- .../datasource/FilterPostsByHashtags.kt | 8 +- .../home/dal/HomeNewThreadFeedFilter.kt | 24 +- .../home/nip75Goals/NewGoalViewModel.kt | 4 +- .../display/lists/PeopleListViewModel.kt | 4 +- .../display/packs/FollowPackViewModel.kt | 4 +- .../ui/screen/loggedIn/longs/LongsTopBar.kt | 4 +- .../loggedIn/longs/dal/LongsFeedFilter.kt | 8 +- .../datasource/NestRoomFilterAssembler.kt | 4 +- .../room/lifecycle/NestRoomEventCollectors.kt | 8 +- .../notifications/CardFeedContentState.kt | 12 +- .../notifications/NotificationSummaryState.kt | 6 +- .../dal/NotificationFeedFilter.kt | 38 +-- .../loggedIn/podcasts/PodcastTopSupporters.kt | 4 +- .../dal/UserProfileGalleryFeedFilter.kt | 6 +- .../mutual/dal/UserProfileMutualFeedFilter.kt | 8 +- .../dal/UserProfileNewThreadFeedFilter.kt | 8 +- .../profile/payment/SendPaymentContent.kt | 30 +- .../profile/payment/SendPaymentScreen.kt | 14 +- .../profile/relays/RelayFeedViewModel.kt | 6 +- .../zaps/dal/UserProfileZapsViewModel.kt | 8 +- .../screen/loggedIn/relays/KindDisplayName.kt | 116 +++---- .../loggedIn/relays/RelayInformationScreen.kt | 4 +- .../relays/dm/DMRelayListViewModel.kt | 4 +- .../ui/screen/loggedIn/shorts/ShortsTopBar.kt | 4 +- .../loggedIn/shorts/dal/ShortsFeedFilter.kt | 8 +- .../loggedIn/threadview/ThreadFeedView.kt | 48 +-- .../loggedIn/video/FileHeaderCardCompose.kt | 8 +- .../ui/screen/loggedIn/video/StoriesTopBar.kt | 6 +- .../ui/screen/loggedIn/video/VideoScreen.kt | 4 +- .../loggedIn/video/dal/VideoFeedFilter.kt | 22 +- .../appfunctions/AmethystAppFunctions.kt | 18 +- .../calendar/CalendarsViewModelFlowTest.kt | 6 +- .../model/AddressedAuthorRoutingTest.kt | 4 +- .../model/BuzzWorkspaceChannelTest.kt | 4 +- .../amethyst/model/HomeFeedTypeTest.kt | 8 +- .../FavoriteAlgoFeedTopNavFilterTest.kt | 4 +- .../service/okhttp/DelayingTestSigner.kt | 4 +- .../FilterGroupNotificationsToPubkeyTest.kt | 2 +- .../resourceusage/ResourceUsageLedgerTest.kt | 4 +- .../uploads/hls/HlsVideoEventBuilderTest.kt | 8 +- .../amethyst/ui/RouteForPointerTest.kt | 12 +- .../amethyst/ui/note/share/QrPayloadTest.kt | 6 +- .../ui/note/share/SharedNoteCardTest.kt | 4 +- .../dal/NotificationTagsAnEventByUserTest.kt | 10 +- .../quartz/benchmark/GiftWrapBenchmark.kt | 6 +- .../benchmark/GiftWrapReceivingBenchmark.kt | 8 +- .../benchmark/GiftWrapSigningBenchmark.kt | 8 +- .../benchmark/LargeDBInsertBenchmark.kt | 4 +- cli/ROADMAP.md | 2 +- .../com/vitorpamplona/amethyst/cli/Context.kt | 8 +- .../amethyst/cli/commands/GiftCommands.kt | 8 +- .../amethyst/cli/commands/GrapeRankCommand.kt | 2 +- .../amethyst/cli/commands/RelayCommands.kt | 14 +- .../cli/commands/RelayGroupCommands.kt | 12 +- .../commands/RelayGroupModerationCommands.kt | 16 +- .../amethyst/cli/commands/StatusReport.kt | 8 +- .../amethyst/cli/commands/ZapCommand.kt | 18 +- .../commands/graperank/GrapeRankOperator.kt | 8 +- .../commands/graperank/GrapeRankPublish.kt | 10 +- .../cli/commands/graperank/GrapeRankScore.kt | 6 +- .../commons/account/AccountBootstrapEvents.kt | 18 +- .../amethyst/commons/actions/ZapActions.kt | 24 +- .../signers/NostrSignerPermissionLedger.kt | 28 +- .../commons/feeds/FeedContentState.kt | 4 +- .../amethyst/commons/marmot/MarmotManager.kt | 8 +- .../amethyst/commons/model/DvmHeartbeat.kt | 4 +- .../amethyst/commons/model/HomeFeedType.kt | 16 +- .../amethyst/commons/model/IAccount.kt | 12 +- .../amethyst/commons/model/Note.kt | 28 +- .../amethyst/commons/model/ThreadAssembler.kt | 4 +- .../amethyst/commons/model/User.kt | 6 +- .../backups/ReplaceableBackupConflict.kt | 16 +- .../commons/model/cache/CachePruner.kt | 22 +- .../commons/model/cache/EventCache.kt | 200 ++++++------ .../nip23LongContent/LongFormPublishAction.kt | 8 +- .../PublicChatListDecryptionCache.kt | 12 +- .../nip28PublicChats/PublicChatListState.kt | 30 +- .../nip29RelayGroups/RelayGroupChannel.kt | 4 +- .../model/nip30CustomEmojis/EmojiPackState.kt | 20 +- .../nip38UserStatuses/UserStatusAction.kt | 20 +- .../blockPeopleList/BlockPeopleListState.kt | 34 +- .../HashtagListDecryptionCache.kt | 8 +- .../peopleList/PeopleListDecryptionCache.kt | 28 +- .../RelayFeedsListDecryptionCache.kt | 4 +- .../ContactCardDecryptionCache.kt | 12 +- .../ContactCardsState.kt | 18 +- .../nip85TrustedAssertions/UserCardsCache.kt | 6 +- .../commons/model/privateChats/ChatPreview.kt | 14 +- .../commons/model/privateChats/Chatroom.kt | 6 +- .../model/topNavFeeds/UsingRelayUnwrapper.kt | 8 +- .../topNavFeeds/noteBased/NoteFeedFlow.kt | 38 +-- .../commons/moderation/HashtagSpamCheck.kt | 4 +- .../notifications/NotificationKinds.kt | 10 +- .../commons/napplet/NappletRelayCleartext.kt | 4 +- .../FilterBasicAccountInfoFromKeys.kt | 12 +- .../FilterBookmarksAndReportsFromKey.kt | 4 +- .../metadata/FilterFollowsAndMutesFromKey.kt | 16 +- .../FilterNotificationsToPubkey.kt | 10 +- .../assemblers/ContactCardFilters.kt | 4 +- .../relayClient/calendars/CalendarKinds.kt | 4 +- .../channel/FilterGoalForLiveActivity.kt | 8 +- .../channel/FilterMessagesToLiveStream.kt | 4 +- .../relayGroup/RelayGroupFilterBuilders.kt | 12 +- .../communities/FilterCommunityPosts.kt | 4 +- .../diagnostics/DmRelayDiagnosticsLogger.kt | 4 +- .../FilterLongFormByAllCommunities.kt | 6 +- .../nip23LongForm/FilterLongFormByAuthors.kt | 4 +- .../FilterLongFormByCommunity.kt | 6 +- .../nip23LongForm/FilterLongFormByGeohash.kt | 4 +- .../nip23LongForm/FilterLongFormByHashtag.kt | 4 +- .../nip23LongForm/FilterLongFormGlobal.kt | 4 +- .../FilterFollowSetsByAllCommunities.kt | 6 +- .../FilterFollowSetsByAuthors.kt | 4 +- .../FilterFollowSetsByCommunity.kt | 6 +- .../FilterFollowSetsByGeohash.kt | 4 +- .../FilterFollowSetsByHashtag.kt | 4 +- .../nip51FollowSets/FilterFollowSetsGlobal.kt | 4 +- .../FilterRepliesAndReactionsToAddresses.kt | 8 +- .../FilterRepliesAndReactionsToNotes.kt | 16 +- .../geohash/FilterPostsByGeohash.kt | 8 +- .../nip01Core/FilterHomePostsByGeohashes.kt | 16 +- .../nip01Core/FilterHomePostsByHashtags.kt | 16 +- .../nip65Follows/FilterHomePostsByAuthors.kt | 16 +- .../FilterHomePostsFromCommunities.kt | 16 +- .../FilterHomePostsByAlgoFeedIds.kt | 8 +- .../longs/FilterLongsByAllCommunities.kt | 6 +- .../relayClient/longs/FilterLongsByAuthors.kt | 4 +- .../longs/FilterLongsByGeohashes.kt | 4 +- .../relayClient/longs/FilterLongsByHashtag.kt | 4 +- .../relayClient/longs/FilterLongsGlobal.kt | 4 +- .../relayClient/nip17Dm/GiftWrapDecryptor.kt | 8 +- .../FilterNWCPaymentsFromRequests.kt | 4 +- .../profile/FilterUserProfileLists.kt | 12 +- .../profile/FilterUserProfileMedia.kt | 8 +- .../profile/FilterUserProfilePosts.kt | 8 +- .../profile/FilterUserProfileZapReceived.kt | 4 +- .../relayClient/relay/FilterPostsByRelay.kt | 8 +- .../shorts/FilterShortsByAllCommunities.kt | 6 +- .../shorts/FilterShortsByAuthors.kt | 4 +- .../shorts/FilterShortsByGeohashes.kt | 4 +- .../shorts/FilterShortsByHashtag.kt | 4 +- .../relayClient/shorts/FilterShortsGlobal.kt | 4 +- .../FilterSoftwareAppsByAuthors.kt | 4 +- .../FilterSoftwareAppsByHashtag.kt | 4 +- .../softwareapps/FilterSoftwareAppsGlobal.kt | 4 +- .../user/watchers/FilterUserMetadataForKey.kt | 8 +- .../commons/relayClient/video/FeedBasis.kt | 18 +- .../FilterPictureAndVideoByAllCommunities.kt | 4 +- .../amethyst/commons/search/KindRegistry.kt | 32 +- .../commons/search/RenderableKinds.kt | 44 +-- .../commons/search/SearchResultSorter.kt | 4 +- .../commons/service/nwc/NwcPaymentTracker.kt | 8 +- .../amethyst/commons/service/pow/PoWPolicy.kt | 8 +- .../LiveStreamTopZappersViewModel.kt | 12 +- .../commons/viewmodels/RoomZapsState.kt | 8 +- .../commons/actions/PrivateNoteFactoryTest.kt | 8 +- .../commons/actions/ZapActionsTest.kt | 8 +- .../commons/model/ThreadAssemblerTest.kt | 4 +- .../model/privateChats/ChatPreviewTest.kt | 4 +- .../notifications/NotificationKindsTest.kt | 16 +- .../commons/napplet/NappletBrokerTest.kt | 4 +- .../commons/onchain/OnchainZapSenderTest.kt | 4 +- .../channel/FilterRelayGroupStateTest.kt | 4 +- .../RelayGroupFilterBuildersTest.kt | 10 +- .../home/HomeMediaKindCoverageTest.kt | 8 +- .../FilterHomePostsByAlgoFeedIdsTest.kt | 6 +- .../commons/search/SearchResultSorterTest.kt | 6 +- .../amethyst/commons/search/SearchSeedTest.kt | 6 +- .../commons/viewmodels/RoomZapsStateTest.kt | 6 +- .../commons/cashu/ops/CashuWalletOps.kt | 34 +- .../commons/model/nip52Calendar/IcsExport.kt | 6 +- .../commons/model/nip57Zaps/ZapAction.kt | 12 +- .../service/lnurl/LightningAddressResolver.kt | 6 +- .../lnurl/OkHttpLnurlEndpointResolver.kt | 2 +- .../commons/viewmodels/NestViewModel.kt | 2 +- .../marmot/MarmotEditsAndSystemRowsTest.kt | 6 +- .../model/nip52Calendar/IcsExportTest.kt | 4 +- .../nip71Video/DivineVideoInteropTest.kt | 20 +- .../nip71Video/VideoTrackSelectionTest.kt | 4 +- .../nip17Dm/DmInboxRelayResolverOutboxTest.kt | 10 +- .../commons/viewmodels/NestViewModelTest.kt | 4 +- .../commons/nip17Dm/ui/IncognitoBadge.kt | 4 +- .../commons/ui/note/CalendarCollectionCard.kt | 4 +- .../vitorpamplona/amethyst/desktop/Main.kt | 10 +- .../desktop/cache/DesktopLocalCache.kt | 50 +-- .../desktop/feeds/DesktopFeedFilters.kt | 10 +- .../desktop/followpacks/BulkFollowAction.kt | 6 +- .../desktop/followpacks/FollowPackEditor.kt | 8 +- .../desktop/followpacks/FollowPacksState.kt | 18 +- .../desktop/followpacks/ui/DiscoverScreen.kt | 4 +- .../followpacks/ui/FollowAllConfirmDialog.kt | 4 +- .../ui/FollowPackBrowseAllScreen.kt | 6 +- .../followpacks/ui/FollowPackComponents.kt | 6 +- .../followpacks/ui/FollowPackDetailScreen.kt | 6 +- .../followpacks/ui/RenderFollowPackCard.kt | 4 +- .../desktop/model/DesktopAccountRelays.kt | 12 +- .../desktop/model/DesktopDmRelayState.kt | 2 +- .../desktop/model/DesktopHiddenUsersState.kt | 10 +- .../amethyst/desktop/model/DesktopIAccount.kt | 12 +- .../desktop/model/DesktopRelayListMutator.kt | 4 +- .../amethyst/desktop/nwc/NwcPaymentHandler.kt | 14 +- .../DesktopRelaySubscriptionsCoordinator.kt | 2 +- .../desktop/subscriptions/FilterBuilders.kt | 14 +- .../desktop/subscriptions/FilterDMs.kt | 10 +- .../desktop/ui/ArticleReaderScreen.kt | 10 +- .../amethyst/desktop/ui/NoteActions.kt | 8 +- .../desktop/ui/NotificationsScreen.kt | 10 +- .../amethyst/desktop/ui/ReadsScreen.kt | 16 +- .../amethyst/desktop/ui/UserProfileScreen.kt | 26 +- .../amethyst/desktop/ui/chats/ChatPane.kt | 10 +- .../desktop/ui/chats/ChatroomListState.kt | 4 +- .../desktop/ui/chats/composer/GifResult.kt | 6 +- .../desktop/ui/note/DesktopRichText.kt | 2 +- .../DesktopNotificationAutoDispatcher.kt | 12 +- .../desktop/ui/relay/DmRelayEditor.kt | 4 +- .../desktop/ui/search/SearchResultsList.kt | 6 +- .../cache/DesktopDmRelayListConsumeTest.kt | 4 +- .../desktop/nwc/NwcPaymentHandlerTest.kt | 6 +- .../desktop/nwc/NwcRpcIntegrationTest.kt | 18 +- .../geode/ConcordPlaneKeyDeletionTest.kt | 6 +- .../geode/DeletionSettleBenchmark.kt | 4 +- .../vitorpamplona/geode/DeletionSyncTest.kt | 18 +- .../geode/Nip01ComplianceTest.kt | 12 +- .../vitorpamplona/geode/Nip09DeletionTest.kt | 12 +- quartz/CLIENT.md | 4 +- .../quartz/nip01Core/EventSigCheck.kt | 4 +- .../LnZapPaymentRequestNip44EventTest.kt | 6 +- .../quartz/nip57Zaps/PrivateZapTests.kt | 8 +- .../nip59GiftWraps/GiftWrapEventTest.kt | 46 +-- .../intents/requests/DecryptZapRequest.kt | 4 +- .../client/NostrSignerExternal.kt | 4 +- .../handlers/BackgroundRequestHandler.kt | 4 +- .../handlers/ForegroundRequestHandler.kt | 4 +- .../com/vitorpamplona/quartz/buzz/README.md | 2 +- .../buzz/moderation/ModerationUnbanEvent.kt | 6 +- .../cord05Invites/ConcordDirectInvite.kt | 6 +- .../assistant/CurationCopy.kt | 4 +- .../graperank/GrapeRankCrawler.kt | 4 +- .../graperank/GrapeRankPublisher.kt | 26 +- .../release/Nip82ReleaseDetector.kt | 10 +- .../release/SoftwareReleaseEvent.kt | 94 +----- .../release/TagArrayBuilderExt.kt | 11 +- .../publications/PublicationSectionRef.kt | 8 +- .../vitorpamplona/quartz/kinds/KindNames.kt | 284 ++++++++--------- .../quartz/marmot/MarmotWelcomeSender.kt | 2 +- .../quartz/marmot/RecipientRelayFetcher.kt | 8 +- .../KeyPackageRelayListEvent.kt | 2 +- .../marmot/mip02Welcome/WelcomeGiftWrap.kt | 8 +- .../cache/projection/EventStoreProjection.kt | 6 +- .../NostrClientNegentropyDeletionSettleExt.kt | 4 +- .../quartz/nip01Core/signers/NostrSigner.kt | 4 +- .../nip01Core/signers/NostrSignerInternal.kt | 4 +- .../nip01Core/signers/NostrSignerSync.kt | 6 +- .../nip01Core/store/EventStoreDeletionsExt.kt | 8 +- .../store/sqlite/DeletionRequestModule.kt | 4 +- .../store/sqlite/SQLiteEventStore.kt | 4 +- .../quartz/nip04Dm/PrivateDMCache.kt | 14 +- ...{PrivateDmEvent.kt => EncryptedDmEvent.kt} | 14 +- .../nip04Dm/messages/TagArrayBuilderExt.kt | 4 +- .../quartz/nip09Deletions/DeletionIndex.kt | 8 +- ...letionEvent.kt => DeletionRequestEvent.kt} | 14 +- .../quartz/nip10Notes/BaseThreadedEvent.kt | 4 +- .../quartz/nip13Pow/signer/PoWNostrSigner.kt | 4 +- .../quartz/nip17Dm/NIP17Factory.kt | 10 +- ...eRelayListEvent.kt => DmRelayListEvent.kt} | 18 +- ...xtNoteEvent.kt => LongFormContentEvent.kt} | 10 +- .../nip23LongContent/TagArrayBuilderExt.kt | 8 +- ...nelListEvent.kt => PublicChatListEvent.kt} | 32 +- .../list/TagArrayBuilderExt.kt | 4 +- .../metadata/GroupPinnedEvent.kt | 2 +- ...portedRolesEvent.kt => GroupRolesEvent.kt} | 10 +- ...viteEvent.kt => GroupCreateInviteEvent.kt} | 10 +- ...EventEvent.kt => GroupDeleteEventEvent.kt} | 10 +- ...dataEvent.kt => GroupEditMetadataEvent.kt} | 10 +- .../{PutUserEvent.kt => GroupPutUserEvent.kt} | 10 +- ...veUserEvent.kt => GroupRemoveUserEvent.kt} | 10 +- ...istEvent.kt => GroupUpdatePinListEvent.kt} | 10 +- ...questEvent.kt => GroupJoinRequestEvent.kt} | 10 +- ...uestEvent.kt => GroupLeaveRequestEvent.kt} | 10 +- ...ackSelectionEvent.kt => EmojiListEvent.kt} | 18 +- .../selection/TagArrayBuilderExt.kt | 6 +- .../{StatusEvent.kt => UserStatusEvent.kt} | 18 +- .../signer/NostrSignerRemote.kt | 4 +- .../quartz/nip47WalletConnect/Nip47Client.kt | 40 +-- .../quartz/nip47WalletConnect/Nip47Server.kt | 54 ++-- .../quartz/nip47WalletConnect/README.md | 16 +- .../cache/NostrWalletConnectRequestCache.kt | 14 +- .../cache/NostrWalletConnectResponseCache.kt | 14 +- ...mentRequestEvent.kt => NwcRequestEvent.kt} | 12 +- ...ntResponseEvent.kt => NwcResponseEvent.kt} | 12 +- .../rpc/NwcTransactionMetadata.kt | 2 +- .../nip50Search/SearchFieldExtractor.kt | 40 +-- .../quartz/nip50Search/SearchableKinds.kt | 40 +-- ...FollowListEvent.kt => StarterPackEvent.kt} | 26 +- .../followList/TagArrayBuilderExt.kt | 16 +- ...shtagListEvent.kt => InterestListEvent.kt} | 32 +- .../hashtagList/TagArrayBuilderExt.kt | 4 +- ...okmarkListEvent.kt => BookmarkSetEvent.kt} | 36 ++- .../labeledBookmarkList/TagArrayBuilderExt.kt | 10 +- .../{PeopleListEvent.kt => FollowSetEvent.kt} | 56 ++-- .../peopleList/TagArrayBuilderExt.kt | 10 +- ...ListEvent.kt => FavoriteRelayListEvent.kt} | 22 +- .../relayLists/tags/TagArrayBuilderExt.kt | 4 +- .../ReleaseArtifactSetEvent.kt | 57 +++- ...darEvent.kt => CalendarCollectionEvent.kt} | 10 +- .../calendar/TagArrayBuilderExt.kt | 4 +- .../quartz/nip54Wiki/TagArrayBuilderExt.kt | 8 +- .../{WikiNoteEvent.kt => WikiArticleEvent.kt} | 12 +- .../nip57Zaps/IPrivateZapsDecryptionCache.kt | 4 +- .../quartz/nip57Zaps/PrivateZapCache.kt | 14 +- .../nip57Zaps/PrivateZapRequestBuilder.kt | 2 +- .../{LnZapEvent.kt => ZapReceiptEvent.kt} | 22 +- ...terface.kt => ZapReceiptEventInterface.kt} | 8 +- ...nZapRequestEvent.kt => ZapRequestEvent.kt} | 32 +- .../validate/LnZapReceiptValidator.kt | 10 +- .../quartz/nip59Giftwrap/HasInnerEvent.kt | 2 +- .../quartz/nip59Giftwrap/rumors/Rumor.kt | 4 +- .../{SealedRumorEvent.kt => SealEvent.kt} | 16 +- .../history/CashuSpendingHistoryEvent.kt | 26 +- .../redemption/NutzapRedemptionEvent.kt | 69 ++--- .../redemption/TagArrayBuilderExt.kt | 5 +- .../quartz/nip61Nutzaps/token/TokenEvent.kt | 38 +-- ...vent.kt => AddressableNormalVideoEvent.kt} | 14 +- ...Event.kt => AddressableShortVideoEvent.kt} | 12 +- .../nip75ZapGoals/TagArrayBuilderExt.kt | 14 +- .../{GoalEvent.kt => ZapGoalEvent.kt} | 10 +- .../users/TagArrayBuilderExt.kt | 40 +-- ...tactCardEvent.kt => UserAssertionEvent.kt} | 24 +- .../clientTag/NostrSignerWithClientTag.kt | 4 +- ....kt => DvmContentDiscoveryRequestEvent.kt} | 10 +- .../TagArrayBuilderExt.kt | 6 +- ...kt => DvmContentDiscoveryResponseEvent.kt} | 12 +- ...ent.kt => DvmContentSearchRequestEvent.kt} | 10 +- ...nt.kt => DvmContentSearchResponseEvent.kt} | 12 +- ...tEvent.kt => DvmEventCountRequestEvent.kt} | 10 +- ...Event.kt => DvmEventCountResponseEvent.kt} | 10 +- ...t => DvmEventPowDelegationRequestEvent.kt} | 10 +- ... => DvmEventPowDelegationResponseEvent.kt} | 10 +- ...=> DvmEventPublishScheduleRequestEvent.kt} | 10 +- ...> DvmEventPublishScheduleResponseEvent.kt} | 10 +- ...kt => DvmEventTimestampingRequestEvent.kt} | 10 +- ...t => DvmEventTimestampingResponseEvent.kt} | 10 +- ...t.kt => DvmImageGenerationRequestEvent.kt} | 10 +- ....kt => DvmImageGenerationResponseEvent.kt} | 10 +- ...vent.kt => DvmImageToVideoRequestEvent.kt} | 10 +- ...ent.kt => DvmImageToVideoResponseEvent.kt} | 10 +- ...Event.kt => DvmMalwareScanRequestEvent.kt} | 10 +- ...vent.kt => DvmMalwareScanResponseEvent.kt} | 10 +- ...estEvent.kt => DvmOpReturnRequestEvent.kt} | 10 +- ...seEvent.kt => DvmOpReturnResponseEvent.kt} | 10 +- ...vent.kt => DvmPeopleSearchRequestEvent.kt} | 10 +- ...ent.kt => DvmPeopleSearchResponseEvent.kt} | 12 +- ...{NIP90StatusEvent.kt => DvmStatusEvent.kt} | 10 +- .../nip90Dvms/status/TagArrayBuilderExt.kt | 6 +- ...ent.kt => DvmSummarizationRequestEvent.kt} | 10 +- ...nt.kt => DvmSummarizationResponseEvent.kt} | 10 +- ...nt.kt => DvmTextExtractionRequestEvent.kt} | 10 +- ...t.kt => DvmTextExtractionResponseEvent.kt} | 10 +- ...nt.kt => DvmTextGenerationRequestEvent.kt} | 10 +- ...t.kt => DvmTextGenerationResponseEvent.kt} | 10 +- ...vent.kt => DvmTextToSpeechRequestEvent.kt} | 10 +- ...ent.kt => DvmTextToSpeechResponseEvent.kt} | 10 +- ...Event.kt => DvmTranslationRequestEvent.kt} | 10 +- ...vent.kt => DvmTranslationResponseEvent.kt} | 10 +- ...ent.kt => DvmUserDiscoveryRequestEvent.kt} | 10 +- ...nt.kt => DvmUserDiscoveryResponseEvent.kt} | 12 +- ...t.kt => DvmVideoConversionRequestEvent.kt} | 10 +- ....kt => DvmVideoConversionResponseEvent.kt} | 10 +- ....kt => DvmVideoTranslationRequestEvent.kt} | 10 +- ...kt => DvmVideoTranslationResponseEvent.kt} | 10 +- ...ileHeaderEvent.kt => FileMetadataEvent.kt} | 12 +- .../nip94FileMetadata/TagArrayBuilderExt.kt | 30 +- .../quartz/utils/EventFactory.kt | 292 +++++++++--------- .../moderation/ModerationUnbanEventTest.kt | 6 +- .../graperank/GrapeRankPublisherTest.kt | 20 +- .../SoftwareApplicationEventTest.kt | 57 +++- .../AssertionEventTest.kt | 8 +- .../ContactCardPetNameTest.kt | 24 +- .../projection/EventStoreProjectionTest.kt | 24 +- .../nip01Core/store/sqlite/AddressableTest.kt | 22 +- .../store/sqlite/AuthorsMissingOutboxTest.kt | 4 +- .../nip01Core/store/sqlite/BasicTest.kt | 4 +- .../nip01Core/store/sqlite/DeletionTest.kt | 48 +-- .../sqlite/InsertOutcomeClassificationTest.kt | 6 +- .../store/sqlite/QueryAssemblerTest.kt | 4 +- .../nip01Core/store/sqlite/SearchTest.kt | 14 +- .../ChannelSettingsTagTest.kt | 14 +- .../Nip29ArmadaInteropTest.kt | 48 +-- .../quartz/nip29RelayGroups/PinEventsTest.kt | 12 +- .../quartz/nip29RelayGroups/SubgroupTest.kt | 10 +- .../BunkerRequestProcessorConcurrencyTest.kt | 4 +- .../server/BunkerRequestProcessorTest.kt | 6 +- .../server/NostrConnectSignerServiceTest.kt | 4 +- .../LnZapPaymentRequestNip44EventTest.kt | 6 +- .../NwcOutgoingMetadataTest.kt | 2 +- .../NwcRefusalRoundTripTest.kt | 12 +- ...estEventTest.kt => NwcRequestEventTest.kt} | 16 +- .../nip50Search/SearchFieldExtractorTest.kt | 16 +- ...tTest.kt => FavoriteRelayListEventTest.kt} | 34 +- .../relayLists/RelayListPublicEntriesTest.kt | 4 +- .../nip52Calendar/CalendarHintProviderTest.kt | 4 +- .../quartz/nip54Wiki/WikiCollaborationTest.kt | 10 +- .../nip57Zaps/LnZapRequestAnonTagTest.kt | 14 +- .../nip57Zaps/LnZapRequestGroupTagTest.kt | 4 +- .../nip57Zaps/LnZapRequestKindTagTest.kt | 12 +- .../validate/LnZapReceiptValidatorTest.kt | 6 +- .../nip61Nutzaps/NutzapInfoEventTest.kt | 4 +- .../nip61Nutzaps/NutzapRedemptionTest.kt | 61 ++++ .../AddressableVideoEventAddressTest.kt | 14 +- .../quartz/marmot/MarmotMipBehaviorTest.kt | 6 +- .../nip01Core/jackson/JacksonMapperTest.kt | 4 +- .../KotlinSerializationMapperTest.kt | 10 +- .../RelayGroupFilterServingRelayTest.kt | 10 +- .../quartz/nip01Core/store/fs/FsEventStore.kt | 8 +- .../buzz/interop/BuzzRelayLiveInteropTest.kt | 8 +- .../store/fs/FsAuthorsMissingOutboxTest.kt | 4 +- .../nip01Core/store/fs/FsDeletionTest.kt | 62 ++-- .../quartz/nip01Core/store/fs/FsParityTest.kt | 28 +- .../quartz/nip01Core/store/fs/FsSearchTest.kt | 4 +- .../quartz/nip01Core/store/fs/FsSlotsTest.kt | 22 +- 546 files changed, 3851 insertions(+), 3343 deletions(-) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/{PrivateDmEvent.kt => EncryptedDmEvent.kt} (92%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/{DeletionEvent.kt => DeletionRequestEvent.kt} (90%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/settings/{ChatMessageRelayListEvent.kt => DmRelayListEvent.kt} (86%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/{LongTextNoteEvent.kt => LongFormContentEvent.kt} (94%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/{ChannelListEvent.kt => PublicChatListEvent.kt} (89%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/{SupportedRolesEvent.kt => GroupRolesEvent.kt} (83%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/{CreateInviteEvent.kt => GroupCreateInviteEvent.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/{DeleteEventEvent.kt => GroupDeleteEventEvent.kt} (84%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/{EditMetadataEvent.kt => GroupEditMetadataEvent.kt} (92%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/{PutUserEvent.kt => GroupPutUserEvent.kt} (88%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/{RemoveUserEvent.kt => GroupRemoveUserEvent.kt} (84%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/{UpdatePinListEvent.kt => GroupUpdatePinListEvent.kt} (85%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/{JoinRequestEvent.kt => GroupJoinRequestEvent.kt} (84%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/{LeaveRequestEvent.kt => GroupLeaveRequestEvent.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/{EmojiPackSelectionEvent.kt => EmojiListEvent.kt} (85%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip38UserStatus/{StatusEvent.kt => UserStatusEvent.kt} (90%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/{LnZapPaymentRequestEvent.kt => NwcRequestEvent.kt} (91%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/{LnZapPaymentResponseEvent.kt => NwcResponseEvent.kt} (90%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/{FollowListEvent.kt => StarterPackEvent.kt} (90%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/{HashtagListEvent.kt => InterestListEvent.kt} (90%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/{LabeledBookmarkListEvent.kt => BookmarkSetEvent.kt} (94%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/{PeopleListEvent.kt => FollowSetEvent.kt} (93%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/{RelayFeedsListEvent.kt => FavoriteRelayListEvent.kt} (88%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/{CalendarEvent.kt => CalendarCollectionEvent.kt} (89%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/{WikiNoteEvent.kt => WikiArticleEvent.kt} (95%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/{LnZapEvent.kt => ZapReceiptEvent.kt} (87%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/{LnZapEventInterface.kt => ZapReceiptEventInterface.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/{LnZapRequestEvent.kt => ZapRequestEvent.kt} (91%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/{SealedRumorEvent.kt => SealEvent.kt} (93%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/{VideoHorizontalEvent.kt => AddressableNormalVideoEvent.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/{VideoVerticalEvent.kt => AddressableShortVideoEvent.kt} (83%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/{GoalEvent.kt => ZapGoalEvent.kt} (94%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/{ContactCardEvent.kt => UserAssertionEvent.kt} (89%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/{NIP90ContentDiscoveryRequestEvent.kt => DvmContentDiscoveryRequestEvent.kt} (85%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryResponse/{NIP90ContentDiscoveryResponseEvent.kt => DvmContentDiscoveryResponseEvent.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/{NIP90ContentSearchRequestEvent.kt => DvmContentSearchRequestEvent.kt} (89%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/{NIP90ContentSearchResponseEvent.kt => DvmContentSearchResponseEvent.kt} (83%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/{NIP90EventCountRequestEvent.kt => DvmEventCountRequestEvent.kt} (86%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/{NIP90EventCountResponseEvent.kt => DvmEventCountResponseEvent.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/{NIP90EventPowDelegationRequestEvent.kt => DvmEventPowDelegationRequestEvent.kt} (83%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/{NIP90EventPowDelegationResponseEvent.kt => DvmEventPowDelegationResponseEvent.kt} (79%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/{NIP90EventPublishScheduleRequestEvent.kt => DvmEventPublishScheduleRequestEvent.kt} (84%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/{NIP90EventPublishScheduleResponseEvent.kt => DvmEventPublishScheduleResponseEvent.kt} (79%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/{NIP90EventTimestampingRequestEvent.kt => DvmEventTimestampingRequestEvent.kt} (83%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/{NIP90EventTimestampingResponseEvent.kt => DvmEventTimestampingResponseEvent.kt} (80%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/{NIP90ImageGenerationRequestEvent.kt => DvmImageGenerationRequestEvent.kt} (89%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/{NIP90ImageGenerationResponseEvent.kt => DvmImageGenerationResponseEvent.kt} (80%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/{NIP90ImageToVideoRequestEvent.kt => DvmImageToVideoRequestEvent.kt} (84%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/{NIP90ImageToVideoResponseEvent.kt => DvmImageToVideoResponseEvent.kt} (81%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/{NIP90MalwareScanRequestEvent.kt => DvmMalwareScanRequestEvent.kt} (84%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/{NIP90MalwareScanResponseEvent.kt => DvmMalwareScanResponseEvent.kt} (81%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/{NIP90OpReturnRequestEvent.kt => DvmOpReturnRequestEvent.kt} (85%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/{NIP90OpReturnResponseEvent.kt => DvmOpReturnResponseEvent.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/{NIP90PeopleSearchRequestEvent.kt => DvmPeopleSearchRequestEvent.kt} (87%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/{NIP90PeopleSearchResponseEvent.kt => DvmPeopleSearchResponseEvent.kt} (83%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/{NIP90StatusEvent.kt => DvmStatusEvent.kt} (85%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/{NIP90SummarizationRequestEvent.kt => DvmSummarizationRequestEvent.kt} (85%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/{NIP90SummarizationResponseEvent.kt => DvmSummarizationResponseEvent.kt} (80%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/{NIP90TextExtractionRequestEvent.kt => DvmTextExtractionRequestEvent.kt} (87%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/{NIP90TextExtractionResponseEvent.kt => DvmTextExtractionResponseEvent.kt} (80%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/{NIP90TextGenerationRequestEvent.kt => DvmTextGenerationRequestEvent.kt} (90%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/{NIP90TextGenerationResponseEvent.kt => DvmTextGenerationResponseEvent.kt} (80%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/{NIP90TextToSpeechRequestEvent.kt => DvmTextToSpeechRequestEvent.kt} (87%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/{NIP90TextToSpeechResponseEvent.kt => DvmTextToSpeechResponseEvent.kt} (81%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/{NIP90TranslationRequestEvent.kt => DvmTranslationRequestEvent.kt} (85%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/{NIP90TranslationResponseEvent.kt => DvmTranslationResponseEvent.kt} (81%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryRequest/{NIP90UserDiscoveryRequestEvent.kt => DvmUserDiscoveryRequestEvent.kt} (83%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryResponse/{NIP90UserDiscoveryResponseEvent.kt => DvmUserDiscoveryResponseEvent.kt} (82%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/{NIP90VideoConversionRequestEvent.kt => DvmVideoConversionRequestEvent.kt} (86%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/{NIP90VideoConversionResponseEvent.kt => DvmVideoConversionResponseEvent.kt} (80%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/{NIP90VideoTranslationRequestEvent.kt => DvmVideoTranslationRequestEvent.kt} (87%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/{NIP90VideoTranslationResponseEvent.kt => DvmVideoTranslationResponseEvent.kt} (80%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/{FileHeaderEvent.kt => FileMetadataEvent.kt} (93%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/{LnZapPaymentRequestEventTest.kt => NwcRequestEventTest.kt} (93%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/{RelayFeedsListEventTest.kt => FavoriteRelayListEventTest.kt} (87%) create mode 100644 quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapRedemptionTest.kt diff --git a/.claude/skills/auth-signers/SKILL.md b/.claude/skills/auth-signers/SKILL.md index 8b11a52d1b..0d32eedf8c 100644 --- a/.claude/skills/auth-signers/SKILL.md +++ b/.claude/skills/auth-signers/SKILL.md @@ -29,7 +29,7 @@ abstract class NostrSigner(val pubKey: HexKey) { abstract fun nip04Decrypt(ciphertext: String, fromPubKey: HexKey, onReady: (String) -> Unit) abstract fun nip44Encrypt(...) abstract fun nip44Decrypt(...) - abstract fun decryptZapEvent(event: LnZapRequestEvent, onReady: (LnZapRequestEvent) -> Unit) + abstract fun decryptZapEvent(event: ZapRequestEvent, onReady: (ZapRequestEvent) -> Unit) } ``` diff --git a/.claude/skills/nip85-trusted-assertions/SKILL.md b/.claude/skills/nip85-trusted-assertions/SKILL.md index b0b17f22ea..d75415e4df 100644 --- a/.claude/skills/nip85-trusted-assertions/SKILL.md +++ b/.claude/skills/nip85-trusted-assertions/SKILL.md @@ -26,16 +26,16 @@ event signatures; the 10040→assertion link is **consumer-side convention** (se | Kind | Class | Kind class | d-tag = the subject | Content | |---|---|---|---|---| | 10040 | `list/TrustProviderListEvent` | replaceable | *(none — always `""`)* | NIP-44 private provider entries (optional) | -| 30382 | `users/ContactCardEvent` | addressable | **target user's pubkey** (hex) | NIP-44 private tags (petname/summary/emoji) | +| 30382 | `users/UserAssertionEvent` | addressable | **target user's pubkey** (hex) | NIP-44 private tags (petname/summary/emoji) | | 30383 | `events/EventAssertionEvent` | addressable | **target event id** (hex) | `""` | | 30384 | `addressables/AddressableAssertionEvent` | addressable | **target coordinate** `kind:pubkey:dtag` | `""` | | 30385 | `externalIds/ExternalIdAssertionEvent` | addressable | **external identifier** (e.g. `isbn:978-0-13-468599-1`) | `""` | -Addresses: `ContactCardEvent.createAddress(owner, target)` → `Address(30382, owner, target)` +Addresses: `UserAssertionEvent.createAddress(owner, target)` → `Address(30382, owner, target)` (owner = signer, target = subject). `TrustProviderListEvent.createAddress(pubKey)` uses `FIXED_D_TAG = ""`. `AssertionEventTest.eventKindsAreCorrect` pins all five numbers. -`ContactCardEvent` is also a `SearchableEvent` — it indexes only the **public** petname/summary +`UserAssertionEvent` is also a `SearchableEvent` — it indexes only the **public** petname/summary tags plus topics; the encrypted card content is intentionally never indexed. ## The 10040 provider entry (`ServiceProviderTag` / `ServiceType`) @@ -91,7 +91,7 @@ The same kind serves two roles, distinguished **by author**: `followers`, `hops`, …); this is what 10040 discovery points at. 2. **The account's own contact cards (nicknames, NIP-81-style)** — signed by the account, one per target user. The petname, summary, and their NIP-30 emoji mappings **always live in - the NIP-44 encrypted content, never in public tags** (`ContactCardEvent.build`/ + the NIP-44 encrypted content, never in public tags** (`UserAssertionEvent.build`/ `updatePetNameAndSummary` strip stray public copies; asserted by `ContactCardPetNameTest`). `commons/.../ContactCardsState.kt` keys everything on `author == account` and ignores provider cards. @@ -104,7 +104,7 @@ value — a bad tag is *dropped*, never an error) + `assemble(value)` → `[name validation (rank isn't clamped, hours aren't checked against 0–23, counts may be negative) — consumers must defend. -**On 30382** (`users/tags/`, accessors on `ContactCardEvent` and as `TagArray` extensions in +**On 30382** (`users/tags/`, accessors on `UserAssertionEvent` and as `TagArray` extensions in `users/TagArrayExt.kt` so they also work on decrypted private arrays): | Tag name | Accessor | Type | Semantics | @@ -138,7 +138,7 @@ val providers: List<ServiceProviderTag> = updated.serviceProviders() // val private = updated.privateTags(signer)?.serviceProviders() // private side // Provider-style contact card (public metrics) — the GrapeRankPublisher pattern: -val card = ContactCardEvent.create( +val card = UserAssertionEvent.create( targetUser = subjectPubkey, signer = providerSigner, publicInitializer = { diff --git a/.claude/skills/nostr-expert/references/event-hierarchy.md b/.claude/skills/nostr-expert/references/event-hierarchy.md index 1ca0c0fa1c..cf6f6dfd12 100644 --- a/.claude/skills/nostr-expert/references/event-hierarchy.md +++ b/.claude/skills/nostr-expert/references/event-hierarchy.md @@ -79,28 +79,28 @@ companion object { ### Zap Request/Receipt (kinds 9734, 9735) ```kotlin -class LnZapRequestEvent(...) : Event(...) +class ZapRequestEvent(...) : Event(...) // Created by client, sent to Lightning Address -class LnZapEvent(...) : Event(...) +class ZapReceiptEvent(...) : Event(...) // Receipt from LSP, contains bolt11 + embedded zap request - val zapRequest: LnZapRequestEvent? by lazy { containedPost() } + val zapRequest: ZapRequestEvent? by lazy { containedPost() } val amount: BigDecimal? by lazy { /* parse from bolt11 */ } ``` ### Long-Form Content (kind 30023) ```kotlin -class LongTextNoteEvent(...) : BaseAddressableEvent(...) +class LongFormContentEvent(...) : BaseAddressableEvent(...) // Blog posts, articles // Addressable via kind:pubkey:d-tag ``` ### Lists (kinds 10000-30004) ```kotlin -sealed class PeopleListEvent : BaseAddressableEvent { - object MuteList : PeopleListEvent(10000) - object PinList : PeopleListEvent(10001) - object BookmarkList : PeopleListEvent(10003) +sealed class FollowSetEvent : BaseAddressableEvent { + object MuteList : FollowSetEvent(10000) + object PinList : FollowSetEvent(10001) + object BookmarkList : FollowSetEvent(10003) // ... 18 list types total } ``` @@ -279,7 +279,7 @@ val metadata2 = MetadataEvent.createNew(name = "Alice Updated", picture = "url2" ### Event Deletion ```kotlin // Delete events -val deletion = DeletionEvent.create( +val deletion = DeletionRequestEvent.create( deleteEvents = listOf(eventId1, eventId2), reason = "Spam", signer = signer diff --git a/.claude/skills/nostr-expert/references/nip-catalog.md b/.claude/skills/nostr-expert/references/nip-catalog.md index 78ed47ee11..996addba10 100644 --- a/.claude/skills/nostr-expert/references/nip-catalog.md +++ b/.claude/skills/nostr-expert/references/nip-catalog.md @@ -15,7 +15,7 @@ under `experimental/`**. The categorized list below may lag behind — | 04 | `nip04Dm/` | EncryptedDmEvent.kt | Legacy encrypted DMs (deprecated for NIP-17) | | 05 | `nip05DnsIdentifiers/` | UserHexResolver.kt, Nip05Client.kt | Internet identifiers; `resolveUserHexOrNull` resolves hex/npub/nprofile/`name@domain` → pubkey (see references/nip05-identifiers.md) | | 06 | `nip06KeyDerivation/` | Mnemonic-related | BIP-39 key derivation | -| 09 | `nip09Deletions/` | DeletionEvent.kt | Event deletion requests (kind 5) | +| 09 | `nip09Deletions/` | DeletionRequestEvent.kt | Event deletion requests (kind 5) | | 11 | `nip11RelayInfo/` | RelayInformation.kt | Relay metadata | | 13 | `nip13Pow/` | ProofOfWork.kt | Proof of work | | 14 | `nip14Subject/` | Subject tags | Subject tags for text notes | @@ -33,7 +33,7 @@ ent for NIP-04) | | 10 | `nip10Notes/` | TextNoteEvent.kt | Text notes with threading (kind 1) | | 18 | `nip18Reposts/` | RepostEvent.kt, GenericRepostEvent.kt | Reposts (kind 6, 16) | | 22 | `nip22Comments/` | CommentEvent.kt | Comments (kind 1111) | -| 23 | `nip23LongContent/` | LongTextNoteEvent.kt | Long-form content (kind 30023) | +| 23 | `nip23LongContent/` | LongFormContentEvent.kt | Long-form content (kind 30023) | | 25 | `nip25Reactions/` | ReactionEvent.kt | Reactions (kind 7) | | 31 | `nip31Alts/` | Alt tags | Alt description tags | | 36 | `nip36SensitiveContent/` | Content warnings | Content warning tags | @@ -62,7 +62,7 @@ ent for NIP-04) | | 46 | `nip46RemoteSigner/` | NostrConnectEvent.kt | Remote signer protocol (bunker) | | 47 | `nip47WalletConnect/` | Nostr Wallet Connect | Wallet connection protocol | | 56 | `nip56Reports/` | ReportEvent.kt | Reports (kind 1984) | -| 57 | `nip57Zaps/` | LnZapEvent.kt, LnZapRequestEvent.kt | Lightning zaps (kinds 9734, 9735) | +| 57 | `nip57Zaps/` | ZapReceiptEvent.kt, ZapRequestEvent.kt | Lightning zaps (kinds 9734, 9735) | | 58 | `nip58Badges/` | Badge events | Badge definitions & awards (kinds 30009, 8) | | 59 | `nip59Giftwrap/` | GiftWrapEvent.kt | Gift-wrapped events for privacy | | 75 | `nip75ZapGoals/` | ZapGoalEvent.kt | Zap goals (kind 9041) | @@ -76,7 +76,7 @@ ent for NIP-04) | | 35 | `nip35Torrents/` | Torrent events | Torrent tracking | | 52 | `nip52Calendar/` | Calendar events | Calendar time-based/date-based (kinds 31922-31925) | | 53 | `nip53LiveActivities/` | LiveActivitiesEvent.kt | Live events/streaming (kind 30311) | -| 54 | `nip54Wiki/` | WikiNoteEvent.kt | Wiki pages (kind 30818) | +| 54 | `nip54Wiki/` | WikiArticleEvent.kt | Wiki pages (kind 30818) | | 68 | `nip68Picture/` | Picture metadata | Picture metadata | | 71 | `nip71Video/` | 7 video event types | Video events (kinds 34235, 35235, 1234, 1235) | | 72 | `nip72ModCommunities/` | Community events | Moderated communities (kinds 34550, 34551, 9041) | @@ -84,7 +84,7 @@ ent for NIP-04) | | 89 | `nip89AppHandlers/` | AppDefinitionEvent.kt | App recommendations (kinds 31990, 31989) | | 90 | `nip90Dvms/` | DVM job events | Data Vending Machines (DVMs) (kinds 5000-7000) | | 92 | `nip92IMeta/` | IMeta tags | Image metadata tags | -| 94 | `nip94FileMetadata/` | FileHeaderEvent.kt, FileStorageEvent.kt | File metadata (kind 1063) | +| 94 | `nip94FileMetadata/` | FileMetadataEvent.kt, FileStorageEvent.kt | File metadata (kind 1063) | | 96 | `nip96FileStorage/` | HTTP file storage | HTTP-based file storage | | 99 | `nip99Classifieds/` | ClassifiedsEvent.kt | Classifieds/marketplace (kind 30402) | | A0 | `nipA0VoiceMessages/` | Voice messages | Voice message events | @@ -93,7 +93,7 @@ ent for NIP-04) | ### Web/Storage/Other | NIP | Directory | Key Files | Description | |-----|-----------|-----------|-------------| -| 38 | `nip38UserStatus/` | StatusEvent.kt | User status (kind 30315) | +| 38 | `nip38UserStatus/` | UserStatusEvent.kt | User status (kind 30315) | | 60 | `nip60Payment/` | Wallet events | Wallet info (kind 13194) | | 61 | `nip61PaymentRequest/` | Nut zaps | Cashu payment requests | | 64 | `nip64Chess/` | Chess moves | Chess move events | diff --git a/.claude/skills/quartz-integration/SKILL.md b/.claude/skills/quartz-integration/SKILL.md index 55dc9ad12f..8bd65f92e1 100644 --- a/.claude/skills/quartz-integration/SKILL.md +++ b/.claude/skills/quartz-integration/SKILL.md @@ -650,15 +650,15 @@ val custom = ReactionEvent.build("🤙", targetEvent) ### NIP-57 — Zap request (kind 9734) ```kotlin -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent -val template = LnZapRequestEvent.build( +val template = ZapRequestEvent.build( message = "Great post!", relays = listOf("wss://relay.damus.io"), target = targetEvent, - zapType = LnZapRequestEvent.ZapType.PUBLIC + zapType = ZapRequestEvent.ZapType.PUBLIC ) -val zapRequest: LnZapRequestEvent = signer.sign(template) +val zapRequest: ZapRequestEvent = signer.sign(template) ``` ### NIP-59 — Gift wrap / sealed DM (kind 1059 + 14) @@ -678,9 +678,9 @@ val (dmEvent, giftWrap) = NIP17Factory.create( ### NIP-23 — Long-form article (kind 30023) ```kotlin -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent -val template = LongTextNoteEvent.build( +val template = LongFormContentEvent.build( body = markdownContent, title = "My Article", image = "https://example.com/cover.jpg", @@ -882,16 +882,16 @@ use `Nip11RelayInformation.fromJson(json)`. | 0 | User metadata | 01 | `MetadataEvent` | | 1 | Text note | 10 | `TextNoteEvent` | | 3 | Follow list | 02 | `ContactListEvent` | -| 4 | Legacy DM | 04 | `PrivateDmEvent` | -| 5 | Deletion | 09 | `DeletionEvent` | +| 4 | Legacy DM | 04 | `EncryptedDmEvent` | +| 5 | Deletion | 09 | `DeletionRequestEvent` | | 6 | Repost | 18 | `RepostEvent` | | 7 | Reaction | 25 | `ReactionEvent` | | 14 | Chat message (sealed) | 17 | `NIP17GroupMessage` | | 1059 | Gift wrap | 59 | `GiftWrapEvent` | -| 9734 | Zap request | 57 | `LnZapRequestEvent` | -| 9735 | Zap receipt | 57 | `LnZapEvent` | +| 9734 | Zap request | 57 | `ZapRequestEvent` | +| 9735 | Zap receipt | 57 | `ZapReceiptEvent` | | 10002 | Relay list | 65 | `AdvertisedRelayListEvent` | -| 30023 | Long-form content | 23 | `LongTextNoteEvent` | +| 30023 | Long-form content | 23 | `LongFormContentEvent` | ## Related Skills diff --git a/.claude/skills/searchable-events/references/searchable-kinds.md b/.claude/skills/searchable-events/references/searchable-kinds.md index b2e3348127..92688128ec 100644 --- a/.claude/skills/searchable-events/references/searchable-kinds.md +++ b/.claude/skills/searchable-events/references/searchable-kinds.md @@ -26,7 +26,7 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 42 | ChannelMessageEvent | nip28PublicChat/message | `content` | | 54 | PodcastEpisodeEvent | nipF4Podcasts/episode | `listOfNotNull(title(), description(), content)` NL | | 1010 | TextNoteModificationEvent | experimental/edits | `listOfNotNull(content, summary())` NL (content first) | -| 1063 | FileHeaderEvent | nip94FileMetadata | `listOfNotNull(summary(), content)` NL | +| 1063 | FileMetadataEvent | nip94FileMetadata | `listOfNotNull(summary(), content)` NL | | 1065 | FileStorageHeaderEvent | experimental/nip95/header | `listOfNotNull(summary())` NL | | 1068 | PollEvent | nip88Polls/poll | `buildString { append(content); options().forEach { append('\n').append(it.label) } }` | | 1111 | CommentEvent | nip22Comments | `(listOf(content) + tags.hashtags())` NL | @@ -48,20 +48,20 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 2004 | TorrentCommentEvent | nip35Torrents | `content` | | 2473 | BirdDetectionEvent | experimental/birdstar | `listOfNotNull(summary(), speciesName())` NL | | 3302 | ConcordChatEditEvent | concord/cord03Channels | `content` | -| 5050 | NIP90TextGenerationRequestEvent | nip90Dvms/textGeneration | `inputs().filter { it.type == "prompt" \|\| it.type == "text" }.joinToString(" ") { it.value }` (SP) | -| 5100 | NIP90ImageGenerationRequestEvent | nip90Dvms/imageGeneration | `listOfNotNull(prompt(), negativePrompt()).joinToString(" ")` (SP) | +| 5050 | DvmTextGenerationRequestEvent | nip90Dvms/textGeneration | `inputs().filter { it.type == "prompt" \|\| it.type == "text" }.joinToString(" ") { it.value }` (SP) | +| 5100 | DvmImageGenerationRequestEvent | nip90Dvms/imageGeneration | `listOfNotNull(prompt(), negativePrompt()).joinToString(" ")` (SP) | | 5129 | NappletSnapshotEvent | nip5dNapplets | `listOfNotNull(title(), description())` NL | -| 5250 | NIP90TextToSpeechRequestEvent | nip90Dvms/textToSpeech | `text() ?: ""` | -| 5302 | NIP90ContentSearchRequestEvent | nip90Dvms/contentSearch | `searchQuery() ?: ""` | -| 5303 | NIP90PeopleSearchRequestEvent | nip90Dvms/peopleSearch | `searchQuery() ?: ""` | +| 5250 | DvmTextToSpeechRequestEvent | nip90Dvms/textToSpeech | `text() ?: ""` | +| 5302 | DvmContentSearchRequestEvent | nip90Dvms/contentSearch | `searchQuery() ?: ""` | +| 5303 | DvmPeopleSearchRequestEvent | nip90Dvms/peopleSearch | `searchQuery() ?: ""` | | 6969 | ZapPollEvent | experimental/zapPolls | `buildString { append(content); pollOptionsArray().forEach { append('\n').append(it.descriptor) } }` | | 7516 | GeocacheFoundLogEvent | nipCCGeocaching/foundLog | `content` | | 8333 | OnchainZapEvent | nipBCOnchainZaps/zap | `content` | -| 9002 | EditMetadataEvent | nip29RelayGroups/moderation | `(listOfNotNull(name(), about()) + hashtags())` NL | -| 9041 | GoalEvent | nip75ZapGoals | `listOfNotNull(summary(), content)` NL | +| 9002 | GroupEditMetadataEvent | nip29RelayGroups/moderation | `(listOfNotNull(name(), about()) + hashtags())` NL | +| 9041 | ZapGoalEvent | nip75ZapGoals | `listOfNotNull(summary(), content)` NL | | 9321 | NutzapEvent | nip61Nutzaps/nutzap | `content` | -| 9734 | LnZapRequestEvent | nip57Zaps | `content` | -| 9735 | LnZapEvent | nip57Zaps | `zapRequest?.content.orEmpty()` — indexes the **embedded 9734's** content | +| 9734 | ZapRequestEvent | nip57Zaps | `content` | +| 9735 | ZapReceiptEvent | nip57Zaps | `zapRequest?.content.orEmpty()` — indexes the **embedded 9734's** content | | 9736 | Bolt12ZapEvent | nipB1Bolt12Zaps/zap | `content` | | 9737 | Bolt12ZapIntentEvent | nipB1Bolt12Zaps/intent | `content` | | 9802 | HighlightEvent | nip84Highlights | `listOfNotNull(comment(), context(), content)` NL | @@ -74,10 +74,10 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 12473 | BirdexEvent | experimental/birdstar | `(listOfNotNull(summary()) + speciesNames())` NL | | 15128 | RootSiteEvent | nip5aStaticWebsites | `listOfNotNull(title(), description())` NL | | 15129 | RootNappletEvent | nip5dNapplets | `listOfNotNull(title(), description())` NL | -| 30000 | PeopleListEvent | nip51Lists/peopleList | `listOfNotNull(titleOrName(), description())` NL | +| 30000 | FollowSetEvent | nip51Lists/peopleList | `listOfNotNull(titleOrName(), description())` NL | | 30001 | OldBookmarkListEvent | nip51Lists/bookmarkList | `listOfNotNull(title())` NL | | 30002 | RelaySetEvent | nip51Lists/relaySets | `listOfNotNull(title(), description())` NL | -| 30003 | LabeledBookmarkListEvent | nip51Lists/labeledBookmarkList | `listOfNotNull(titleOrName(), description())` NL | +| 30003 | BookmarkSetEvent | nip51Lists/labeledBookmarkList | `listOfNotNull(titleOrName(), description())` NL | | 30004 | ArticleCurationSetEvent | nip51Lists/articleCurationSet | `listOfNotNull(title(), description())` NL | | 30005 | VideoCurationSetEvent | nip51Lists/videoCurationSet | `listOfNotNull(title(), description())` NL | | 30006 | PictureCurationSetEvent | nip51Lists/pictureCurationSet | `listOfNotNull(title(), description())` NL | @@ -87,7 +87,7 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 30018 | ProductEvent | nip15Marketplace/product | `productData()?.let { (listOfNotNull(it.name, it.description) + categories()).joinToString("\n") } ?: ""` | | 30019 | MarketplaceEvent | nip15Marketplace/marketplace | `marketplaceData()?.let { listOfNotNull(it.name, it.about).joinToString("\n") } ?: ""` | | 30020 | AuctionEvent | nip15Marketplace/auction | `auctionData()?.let { (listOfNotNull(it.name, it.description) + tags.hashtags()).joinToString("\n") } ?: ""` | -| 30023 | LongTextNoteEvent | nip23LongContent | `listOfNotNull(title(), summary(), content)` NL | +| 30023 | LongFormContentEvent | nip23LongContent | `listOfNotNull(title(), summary(), content)` NL | | 30030 | EmojiPackEvent | nip30CustomEmoji/pack | `listOfNotNull(titleOrName(), description(), content)` NL | | 30054 | Podcasting20EpisodeEvent | nipXXPodcasting20/episode | `(listOfNotNull(title(), description(), content) + topics())` NL | | 30055 | Podcasting20TrailerEvent | nipXXPodcasting20/trailer | `listOfNotNull(title(), content)` NL | @@ -101,8 +101,8 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 30311 | LiveActivitiesEvent | nip53LiveActivities/streaming | `listOfNotNull(title(), summary(), content)` NL | | 30312 | MeetingSpaceEvent | nip53LiveActivities/meetingSpaces | `listOfNotNull(room(), summary(), content)` NL | | 30313 | MeetingRoomEvent | nip53LiveActivities/meetingSpaces | `listOfNotNull(title(), summary())` NL | -| 30315 | StatusEvent | nip38UserStatus | `content` | -| 30382 | ContactCardEvent | nip85TrustedAssertions/users | `(listOfNotNull(petName(), summary()) + topics())` NL — public tags only, never the NIP-44 content | +| 30315 | UserStatusEvent | nip38UserStatus | `content` | +| 30382 | UserAssertionEvent | nip85TrustedAssertions/users | `(listOfNotNull(petName(), summary()) + topics())` NL — public tags only, never the NIP-44 content | | 30392 | UserTrustedListEvent | experimental/trustedLists/users | inherited `TrustedListEvent`: `title() ?: ""` — the label only; `metric`/`d` are machine ids and `content` is a JSON echo of the membership | | 30393 | EventTrustedListEvent | experimental/trustedLists/events | inherited `TrustedListEvent`: `title() ?: ""` | | 30394 | AddressableTrustedListEvent | experimental/trustedLists/addressables | inherited `TrustedListEvent`: `title() ?: ""` | @@ -111,7 +111,7 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 30617 | GitRepositoryEvent | nip34Git/repository | `listOfNotNull(name(), description(), content)` NL | | 30620 | WorkflowDefEvent | buzz/workflow | `listOfNotNull(name(), content)` NL | | 30817 | NipTextEvent | experimental/nipsOnNostr | `listOfNotNull(title(), content)` NL | -| 30818 | WikiNoteEvent | nip54Wiki | `listOfNotNull(title(), summary(), content)` NL | +| 30818 | WikiArticleEvent | nip54Wiki | `listOfNotNull(title(), summary(), content)` NL | | 31337 | AudioTrackEvent | experimental/audio/track | `listOfNotNull(subject())` NL | | 31871 | AttestationEvent | experimental/attestations/attestation | `content` | | 31872 | AttestationRequestEvent | experimental/attestations/request | `content` | @@ -119,15 +119,15 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 31890 | FeedDefinitionEvent | feedDefinition | `title().orEmpty()` | | 31922 | CalendarDateSlotEvent | nip52Calendar/appt/day | `listOfNotNull(title(), summary(), content)` NL | | 31923 | CalendarTimeSlotEvent | nip52Calendar/appt/time | `listOfNotNull(title(), summary(), content)` NL | -| 31924 | CalendarEvent | nip52Calendar/calendar | `listOfNotNull(title(), content)` NL | +| 31924 | CalendarCollectionEvent | nip52Calendar/calendar | `listOfNotNull(title(), content)` NL | | 31925 | CalendarRSVPEvent | nip52Calendar/rsvp | `content` | | 31990 | AppDefinitionEvent | nip89AppHandlers/definition | `appMetaData()?.let { listOfNotNull(it.name, it.username, it.displayName, it.about, it.nip05, it.lud06, it.lud16, it.website, it.picture, it.banner, it.image).joinToString(" ") } ?: ""` (SP) | | 32267 | SoftwareApplicationEvent | experimental/nip82SoftwareApps/application | `listOfNotNull(name(), summary(), content)` NL | | 33401 | ExerciseTemplateEvent | experimental/fitness/workout | `listOfNotNull(title(), content)` NL | | 33863 | FundraiserEvent | experimental/agora | `listOfNotNull(title(), content)` NL | | 34139 | MusicPlaylistEvent | experimental/music/playlist | `listOfNotNull(title(), description(), content)` NL | -| 34235 | VideoHorizontalEvent | nip71Video | inherited `AddressableVideoEvent`: `listOfNotNull(title(), content)` NL | -| 34236 | VideoVerticalEvent | nip71Video | inherited `AddressableVideoEvent`: `listOfNotNull(title(), content)` NL | +| 34235 | AddressableNormalVideoEvent | nip71Video | inherited `AddressableVideoEvent`: `listOfNotNull(title(), content)` NL | +| 34236 | AddressableShortVideoEvent | nip71Video | inherited `AddressableVideoEvent`: `listOfNotNull(title(), content)` NL | | 34550 | CommunityDefinitionEvent | nip72ModCommunities/definition | `listOfNotNull(name(), description(), rules(), content)` NL | | 35128 | NamedSiteEvent | nip5aStaticWebsites | `listOfNotNull(title(), description())` NL | | 35129 | NamedNappletEvent | nip5dNapplets | `listOfNotNull(title(), description())` NL | @@ -138,7 +138,7 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 38192 | Ps1SaveEvent | experimental/ps1saves | `listOfNotNull(summary(), saveTitle(), region(), filename())` NL | | 38383 | P2POrderEvent | nip69P2pOrderEvents | `(listOfNotNull(makerName(), currency()) + paymentMethods().orEmpty()).joinToString(" ")` (SP) | | 39000 | GroupMetadataEvent | nip29RelayGroups/metadata | `listOfNotNull(name(), about())` NL | -| 39089 | FollowListEvent | nip51Lists/followList | `listOfNotNull(title(), description())` NL | +| 39089 | StarterPackEvent | nip51Lists/followList | `listOfNotNull(title(), description())` NL | | 39092 | MediaStarterPackEvent | nip51Lists/mediaStarterPack | `listOfNotNull(title(), description())` NL | | 39307 | TextTrackEvent | nip71Video/textTrack | `content` (the WebVTT cue text) | | 39701 | WebBookmarkEvent | nipB0WebBookmarks | `listOfNotNull(title(), description())` NL | diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index a0acb8bad9..7f1b0da472 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -54,19 +54,19 @@ import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip19Bech32.toNpub -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -887,19 +887,19 @@ object LocalPreferences { val pendingAttestations = async { parseOrNull<Map<HexKey, String>>(pendingAttestationsStr) ?: mapOf() } val latestUserMetadata = async { parseEventOrNull<MetadataEvent>(latestUserMetadataStr) } val latestContactList = async { parseEventOrNull<ContactListEvent>(latestContactListStr) } - val latestDmRelayList = async { parseEventOrNull<ChatMessageRelayListEvent>(latestDmRelayListStr) } + val latestDmRelayList = async { parseEventOrNull<DmRelayListEvent>(latestDmRelayListStr) } val latestNip65RelayList = async { parseEventOrNull<AdvertisedRelayListEvent>(latestNip65RelayListStr) } val latestSearchRelayList = async { parseEventOrNull<SearchRelayListEvent>(latestSearchRelayListStr) } val latestIndexRelayList = async { parseEventOrNull<IndexerRelayListEvent>(latestIndexRelayListStr) } - val latestRelayFeedsList = async { parseEventOrNull<RelayFeedsListEvent>(latestRelayFeedsListStr) } + val latestRelayFeedsList = async { parseEventOrNull<FavoriteRelayListEvent>(latestRelayFeedsListStr) } val latestBlockedRelayList = async { parseEventOrNull<BlockedRelayListEvent>(latestBlockedRelayListStr) } val latestTrustedRelayList = async { parseEventOrNull<TrustedRelayListEvent>(latestTrustedRelayListStr) } val latestMuteList = async { parseEventOrNull<MuteListEvent>(latestMuteListStr) } val latestPrivateHomeRelayList = async { parseEventOrNull<PrivateOutboxRelayListEvent>(latestPrivateHomeRelayListStr) } val latestAppSpecificData = async { parseEventOrNull<AppSpecificDataEvent>(latestAppSpecificDataStr) } - val latestChannelList = async { parseEventOrNull<ChannelListEvent>(latestChannelListStr) } + val latestChannelList = async { parseEventOrNull<PublicChatListEvent>(latestChannelListStr) } val latestCommunityList = async { parseEventOrNull<CommunityListEvent>(latestCommunityListStr) } - val latestHashtagList = async { parseEventOrNull<HashtagListEvent>(latestHashtagListStr) } + val latestHashtagList = async { parseEventOrNull<InterestListEvent>(latestHashtagListStr) } val latestGeohashList = async { parseEventOrNull<GeohashListEvent>(latestGeohashListStr) } val latestEphemeralList = async { parseEventOrNull<EphemeralChatListEvent>(latestEphemeralListStr) } val latestRelayGroupList = async { parseEventOrNull<SimpleGroupListEvent>(latestRelayGroupListStr) } 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 406c21e081..438be42d4f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -238,8 +238,8 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUserIds import com.vitorpamplona.quartz.nip01Core.tags.references.references import com.vitorpamplona.quartz.nip03Timestamp.OtsResolver import com.vitorpamplona.quartz.nip04Dm.PrivateDMCache -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip10Notes.content.findHashtags import com.vitorpamplona.quartz.nip10Notes.content.findNostrUris @@ -281,10 +281,10 @@ import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip56Reports.ReportType -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.PrivateZapCache +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup import com.vitorpamplona.quartz.nip57Zaps.splits.zapSplits import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiser @@ -320,10 +320,10 @@ import com.vitorpamplona.quartz.nip88Polls.poll.tags.PollType import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent import com.vitorpamplona.quartz.nip89AppHandlers.clientTag.NostrSignerWithClientTag import com.vitorpamplona.quartz.nip89AppHandlers.clientTag.withoutClientTag -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent import com.vitorpamplona.quartz.nip92IMeta.IMetaTag import com.vitorpamplona.quartz.nip92IMeta.imetas -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip94FileMetadata.blurhash import com.vitorpamplona.quartz.nip94FileMetadata.dimension import com.vitorpamplona.quartz.nip94FileMetadata.fileSize @@ -1283,7 +1283,7 @@ class Account( suspend fun updateZapAmounts( amountSet: List<Long>, - selectedZapType: LnZapEvent.ZapType, + selectedZapType: ZapReceiptEvent.ZapType, nip47Update: Nip47WalletConnect.Nip47URINorm?, ) { var changed = false @@ -1707,7 +1707,7 @@ class Account( if (myNotes.isNotEmpty()) { // chunks in 200 elements to avoid going over the 65KB limit for events. myNotes.chunked(200).forEach { chunkedList -> - val template = DeletionEvent.build(chunkedList.mapNotNull { it.event }) + val template = DeletionRequestEvent.build(chunkedList.mapNotNull { it.event }) val deletionEvent = signer.sign(template) val myRelayList = outboxRelays.flow.value.toMutableSet() chunkedList.forEach { @@ -1738,7 +1738,7 @@ class Account( val recipients = (targetEvent.taggedUserIds() + targetEvent.pubKey).distinct().minus(signer.pubKey) broadcastPrivately( - NIP17Factory().createDeletionNIP17(DeletionEvent.build(myRumors), recipients, signer), + NIP17Factory().createDeletionNIP17(DeletionRequestEvent.build(myRumors), recipients, signer), ) } @@ -1749,7 +1749,7 @@ class Account( if (!isWriteable()) return if (event.pubKey != signer.pubKey) return - val deletionEvent = signer.sign(DeletionEvent.build(listOf(event))) + val deletionEvent = signer.sign(DeletionRequestEvent.build(listOf(event))) client.publish(deletionEvent, outboxRelays.flow.value + additionalRelays) cache.justConsumeMyOwnEvent(deletionEvent) } @@ -2176,7 +2176,7 @@ class Account( suspend fun deleteWebBookmark(event: WebBookmarkEvent) { if (!isWriteable()) return - val template = DeletionEvent.build(listOf(event)) + val template = DeletionRequestEvent.build(listOf(event)) val signedEvent = signer.sign(template) cache.justConsumeMyOwnEvent(signedEvent) @@ -2212,7 +2212,7 @@ class Account( if (!isWriteable()) return if (event.pubKey != signer.pubKey) return - val template = DeletionEvent.build(listOf(event)) + val template = DeletionRequestEvent.build(listOf(event)) val signedEvent = signer.sign(template) cache.justConsumeMyOwnEvent(signedEvent) @@ -2597,7 +2597,7 @@ class Account( } } } else { - FileHeaderEvent.build(url, alt) { + FileMetadataEvent.build(url, alt) { hash(headerInfo.hash) fileSize(headerInfo.size) @@ -2711,7 +2711,7 @@ class Account( val extraRelays = draftNote.relays val deletedDraft = DraftWrapEvent.createDeletedEvent(draftTag, signer) - val deletionEvent = signer.sign(DeletionEvent.build(listOf(deletedDraft))) + val deletionEvent = signer.sign(DeletionRequestEvent.build(listOf(deletedDraft))) val relayList = (privateStorageRelayList.flow.value + localRelayList.flow.value + extraRelays).toSet() @@ -2937,7 +2937,7 @@ class Account( broadcast.forEach { client.publish(it, relayList) } } - override suspend fun sendNip04PrivateMessage(eventTemplate: EventTemplate<PrivateDmEvent>) { + override suspend fun sendNip04PrivateMessage(eventTemplate: EventTemplate<EncryptedDmEvent>) { if (!isWriteable()) return val newEvent = signer.sign(eventTemplate) @@ -3481,10 +3481,10 @@ class Account( suspend fun requestDVMContentDiscovery( dvmPublicKey: User, - onReady: (event: NIP90ContentDiscoveryRequestEvent, relays: Set<NormalizedRelayUrl>) -> Unit, + onReady: (event: DvmContentDiscoveryRequestEvent, relays: Set<NormalizedRelayUrl>) -> Unit, ) { val relays = nip65RelayList.inboxFlow.value.toSet() - val request = signer.sign<NIP90ContentDiscoveryRequestEvent>(NIP90ContentDiscoveryRequestEvent.build(dvmPublicKey.pubkeyHex, signer.pubKey, relays)) + val request = signer.sign<DvmContentDiscoveryRequestEvent>(DvmContentDiscoveryRequestEvent.build(dvmPublicKey.pubkeyHex, signer.pubKey, relays)) val relayList = dvmPublicKey.inboxRelays()?.toSet()?.ifEmpty { null } @@ -3503,8 +3503,8 @@ class Account( return if (isWriteable()) { when { - event is PrivateDmEvent -> privateDMDecryptionCache.cachedDM(event) - event is LnZapRequestEvent && event.isPrivateZap() -> privateZapsDecryptionCache.cachedPrivateZap(event)?.content + event is EncryptedDmEvent -> privateDMDecryptionCache.cachedDM(event) + event is ZapRequestEvent && event.isPrivateZap() -> privateZapsDecryptionCache.cachedPrivateZap(event)?.content event is DraftWrapEvent -> draftsDecryptionCache.preCachedDraft(event)?.content else -> event.content } @@ -3519,11 +3519,11 @@ class Account( suspend fun decryptContent(note: Note): String? { val event = note.event return when { - event is PrivateDmEvent && isWriteable() -> { + event is EncryptedDmEvent && isWriteable() -> { privateDMDecryptionCache.decryptDM(event) } - event is LnZapRequestEvent && isWriteable() -> { + event is ZapRequestEvent && isWriteable() -> { if (event.isPrivateZap()) { if (isWriteable()) { privateZapsDecryptionCache.decryptPrivateZap(event)?.content @@ -3550,7 +3550,7 @@ class Account( } } - suspend fun decryptZapOrNull(event: LnZapRequestEvent): LnZapPrivateEvent? = if (event.isPrivateZap() && isWriteable()) privateZapsDecryptionCache.decryptPrivateZap(event) else null + suspend fun decryptZapOrNull(event: ZapRequestEvent): LnZapPrivateEvent? = if (event.isPrivateZap() && isWriteable()) privateZapsDecryptionCache.decryptPrivateZap(event) else null fun isAllHidden(users: Set<HexKey>): Boolean = users.all { isHidden(it) } @@ -3602,7 +3602,7 @@ class Account( note.countReportAuthorsBy(followingKeySet()) < reportWarningThreshold } - fun isDecryptedContentHidden(noteEvent: PrivateDmEvent): Boolean = + fun isDecryptedContentHidden(noteEvent: EncryptedDmEvent): Boolean = if (hiddenUsers.flow.value.hiddenWordsCase .isNotEmpty() ) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountRelayGroupActions.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountRelayGroupActions.kt index 33612b11ef..884213d17f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountRelayGroupActions.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountRelayGroupActions.kt @@ -58,15 +58,15 @@ import com.vitorpamplona.quartz.nip29RelayGroups.GroupId import com.vitorpamplona.quartz.nip29RelayGroups.hTag import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateInviteEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.PutUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.RemoveUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.UpdatePinListEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupCreateInviteEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupPutUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupRemoveUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupUpdatePinListEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.previous -import com.vitorpamplona.quartz.nip29RelayGroups.request.JoinRequestEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.LeaveRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent import com.vitorpamplona.quartz.nip29RelayGroups.tags.GroupIdTag import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.utils.RandomInstance @@ -92,7 +92,7 @@ class AccountRelayGroupActions( channel: RelayGroupChannel, code: String? = null, ) { - val template = JoinRequestEvent.build(channel.groupId.id, inviteCode = code) + val template = GroupJoinRequestEvent.build(channel.groupId.id, inviteCode = code) account.broadcaster.signAndSendPrivatelyOrBroadcast(template) { channel.relays().toList() } account.follow(channel) } @@ -295,7 +295,7 @@ class AccountRelayGroupActions( /** Send a kind 9022 leave request to the host relay and drop it from our list. */ suspend fun leaveRelayGroup(channel: RelayGroupChannel) { - val template = LeaveRequestEvent.build(channel.groupId.id) + val template = GroupLeaveRequestEvent.build(channel.groupId.id) account.broadcaster.signAndSendPrivatelyOrBroadcast(template) { channel.relays().toList() } account.unfollow(channel) } @@ -351,7 +351,7 @@ class AccountRelayGroupActions( ) { listOf(relay) } val edit = - EditMetadataEvent.build( + GroupEditMetadataEvent.build( groupId, name = name, about = about, @@ -405,7 +405,7 @@ class AccountRelayGroupActions( channel: RelayGroupChannel, code: String, ) { - val template = CreateInviteEvent.build(channel.groupId.id, code) + val template = GroupCreateInviteEvent.build(channel.groupId.id, code) account.broadcaster.signAndSendPrivatelyOrBroadcast(template) { channel.relays().toList() } } @@ -418,7 +418,7 @@ class AccountRelayGroupActions( channel: RelayGroupChannel, pinnedEventIds: List<HexKey>, ) { - val template = UpdatePinListEvent.build(channel.groupId.id, pinnedEventIds) + val template = GroupUpdatePinListEvent.build(channel.groupId.id, pinnedEventIds) account.broadcaster.signAndSendPrivatelyOrBroadcast(template) { channel.relays().toList() } } @@ -445,7 +445,7 @@ class AccountRelayGroupActions( channel: RelayGroupChannel, pubkey: HexKey, ) { - val template = RemoveUserEvent.build(channel.groupId.id, listOf(pubkey)) + val template = GroupRemoveUserEvent.build(channel.groupId.id, listOf(pubkey)) account.broadcaster.signAndSendPrivatelyOrBroadcast(template) { channel.relays().toList() } } @@ -470,7 +470,7 @@ class AccountRelayGroupActions( } else { null } - val template = PutUserEvent.build(channel.groupId.id, listOf(pubkey to roles), buzzRole = buzzRole) + val template = GroupPutUserEvent.build(channel.groupId.id, listOf(pubkey to roles), buzzRole = buzzRole) account.broadcaster.signAndSendPrivatelyOrBroadcast(template) { channel.relays().toList() } } @@ -525,7 +525,7 @@ class AccountRelayGroupActions( // edit when we send that tag. A plain NIP-29 relay ignores it and honours the status flag. val isBuzz = BuzzRelayDialect.isBuzz(channel.groupId.relayUrl) val template = - EditMetadataEvent.build( + GroupEditMetadataEvent.build( channel.groupId.id, name = name, about = about, @@ -549,7 +549,7 @@ class AccountRelayGroupActions( channel: RelayGroupChannel, archived: Boolean, ) { - val template = EditMetadataEvent.build(channel.groupId.id, archived = archived) + val template = GroupEditMetadataEvent.build(channel.groupId.id, archived = archived) account.broadcaster.signAndSendPrivatelyOrBroadcast(template) { channel.relays().toList() } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt index e2613fbe36..b70197390c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt @@ -59,8 +59,8 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent import com.vitorpamplona.quartz.nip42RelayAuth.RelayAuthEvent @@ -68,16 +68,16 @@ import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip55AndroidSigner.api.CommandType import com.vitorpamplona.quartz.nip55AndroidSigner.api.permission.Permission -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.NutzapInfoEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -203,20 +203,20 @@ class AccountSettings( val showMessagesInNotifications: MutableStateFlow<Boolean> = MutableStateFlow(true), var backupUserMetadata: MetadataEvent? = null, var backupContactList: ContactListEvent? = null, - var backupDMRelayList: ChatMessageRelayListEvent? = null, + var backupDMRelayList: DmRelayListEvent? = null, var backupKeyPackageRelayList: KeyPackageRelayListEvent? = null, var backupNIP65RelayList: AdvertisedRelayListEvent? = null, var backupSearchRelayList: SearchRelayListEvent? = null, var backupIndexRelayList: IndexerRelayListEvent? = null, - var backupRelayFeedsList: RelayFeedsListEvent? = null, + var backupRelayFeedsList: FavoriteRelayListEvent? = null, var backupBlockedRelayList: BlockedRelayListEvent? = null, var backupTrustedRelayList: TrustedRelayListEvent? = null, var backupMuteList: MuteListEvent? = null, var backupPrivateHomeRelayList: PrivateOutboxRelayListEvent? = null, var backupAppSpecificData: AppSpecificDataEvent? = null, - var backupChannelList: ChannelListEvent? = null, + var backupChannelList: PublicChatListEvent? = null, var backupCommunityList: CommunityListEvent? = null, - var backupHashtagList: HashtagListEvent? = null, + var backupHashtagList: InterestListEvent? = null, var backupFavoriteAlgoFeedsList: FavoriteAlgoFeedsListEvent? = null, var backupGeohashList: GeohashListEvent? = null, var backupEphemeralChatList: EphemeralChatListEvent? = null, @@ -375,7 +375,7 @@ class AccountSettings( // Zaps and Reactions // --- - fun changeDefaultZapType(zapType: LnZapEvent.ZapType): Boolean { + fun changeDefaultZapType(zapType: ZapReceiptEvent.ZapType): Boolean { if (syncedSettings.zaps.defaultZapType.value != zapType) { syncedSettings.zaps.defaultZapType.tryEmit(zapType) saveAccountSettings() @@ -1075,7 +1075,7 @@ class AccountSettings( when (incoming) { is MetadataEvent -> updateUserMetadata(incoming) is ContactListEvent -> updateContactListTo(incoming) - is ChatMessageRelayListEvent -> updateDMRelayList(incoming) + is DmRelayListEvent -> updateDMRelayList(incoming) is KeyPackageRelayListEvent -> updateKeyPackageRelayList(incoming) is AdvertisedRelayListEvent -> updateNIP65RelayList(incoming) is CashuWalletEvent -> updateCashuWallet(incoming) @@ -1084,13 +1084,13 @@ class AccountSettings( is Bolt12OfferListEvent -> updateBolt12Offers(incoming) is SearchRelayListEvent -> updateSearchRelayList(incoming) is IndexerRelayListEvent -> updateIndexRelayList(incoming) - is RelayFeedsListEvent -> updateRelayFeedList(incoming) + is FavoriteRelayListEvent -> updateRelayFeedList(incoming) is BlockedRelayListEvent -> updateBlockedRelayList(incoming) is TrustedRelayListEvent -> updateTrustedRelayList(incoming) is PrivateOutboxRelayListEvent -> updatePrivateHomeRelayList(incoming) - is ChannelListEvent -> updateChannelListTo(incoming) + is PublicChatListEvent -> updateChannelListTo(incoming) is GeohashListEvent -> updateGeohashListTo(incoming) - is HashtagListEvent -> updateHashtagListTo(incoming) + is InterestListEvent -> updateHashtagListTo(incoming) is FavoriteAlgoFeedsListEvent -> updateFavoriteAlgoFeedsListTo(incoming) is CommunityListEvent -> updateCommunityListTo(incoming) is EphemeralChatListEvent -> updateEphemeralChatListTo(incoming) @@ -1140,7 +1140,7 @@ class AccountSettings( } } - fun updateDMRelayList(newDMRelayList: ChatMessageRelayListEvent?) { + fun updateDMRelayList(newDMRelayList: DmRelayListEvent?) { if (newDMRelayList == null) return if (backupGuard.accept(backupDMRelayList, newDMRelayList, isEmpty = newDMRelayList.tags.isEmpty()) { updateDMRelayList(newDMRelayList) }) { @@ -1284,7 +1284,7 @@ class AccountSettings( } } - fun updateRelayFeedList(newRelayFeedList: RelayFeedsListEvent?) { + fun updateRelayFeedList(newRelayFeedList: FavoriteRelayListEvent?) { if (newRelayFeedList == null) return if (backupGuard.accept(backupRelayFeedsList, newRelayFeedList, isEmpty = newRelayFeedList.tags.isEmpty()) { updateRelayFeedList(newRelayFeedList) }) { @@ -1322,7 +1322,7 @@ class AccountSettings( override fun channelList() = backupChannelList - override fun updateChannelListTo(newChannelList: ChannelListEvent?) { + override fun updateChannelListTo(newChannelList: PublicChatListEvent?) { if (newChannelList == null) return if (backupGuard.accept(backupChannelList, newChannelList, isEmpty = newChannelList.tags.isEmpty()) { updateChannelListTo(newChannelList) }) { @@ -1340,7 +1340,7 @@ class AccountSettings( } } - fun updateHashtagListTo(newHashtagList: HashtagListEvent?) { + fun updateHashtagListTo(newHashtagList: InterestListEvent?) { if (newHashtagList == null) return if (backupGuard.accept(backupHashtagList, newHashtagList, isEmpty = newHashtagList.tags.isEmpty()) { updateHashtagListTo(newHashtagList) }) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt index 3d1047d25a..3acb2ed75a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.amethyst.commons.service.pow.PoWCategory import com.vitorpamplona.amethyst.commons.service.pow.PoWPolicy import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.equalImmutableLists import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.MutableStateFlow @@ -265,7 +265,7 @@ class AccountVideoPlayerPreferences( @Stable class AccountZapPreferences( var zapAmountChoices: MutableStateFlow<ImmutableList<Long>>, - val defaultZapType: MutableStateFlow<LnZapEvent.ZapType>, + val defaultZapType: MutableStateFlow<ZapReceiptEvent.ZapType>, ) /** diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettingsInternal.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettingsInternal.kt index b167b7ba62..de721aefbe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettingsInternal.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettingsInternal.kt @@ -25,7 +25,7 @@ import androidx.core.os.ConfigurationCompat import com.vitorpamplona.amethyst.commons.model.navigation.BottomBarEntry import com.vitorpamplona.amethyst.commons.service.pow.PoWCategory import com.vitorpamplona.amethyst.ui.navigation.bottombars.DefaultBottomBarEntries -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.serialization.Serializable import java.util.Locale @@ -207,7 +207,7 @@ class AccountZapPreferencesInternal( // and so the on-chain-eligible subset round-trips back for them; on load it // is unioned into [zapAmountChoices]. See AccountSyncedSettings. var onchainZapAmountChoices: List<Long> = DefaultOnchainZapAmounts, - val defaultZapType: LnZapEvent.ZapType = LnZapEvent.ZapType.PUBLIC, + val defaultZapType: ZapReceiptEvent.ZapType = ZapReceiptEvent.ZapType.PUBLIC, ) @Serializable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountZapActions.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountZapActions.kt index 4bcfcaef46..cf994956f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountZapActions.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountZapActions.kt @@ -48,8 +48,8 @@ import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PaySuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Request import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.builder.Bolt12ZapBuilder import com.vitorpamplona.quartz.nipB1Bolt12Zaps.verify.Bolt12ZapValidation import com.vitorpamplona.quartz.utils.Log @@ -74,12 +74,12 @@ class AccountZapActions( event: Event, pollOption: Int?, message: String = "", - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, toUser: User?, additionalRelays: Set<NormalizedRelayUrl>? = null, amountMillisats: Long? = null, lnurl: String? = null, - ) = LnZapRequestEvent.create( + ) = ZapRequestEvent.create( zappedEvent = event, // Where the provider should publish the receipt. Zapping group content pins that to the room's // host relay: the receipt belongs where the message it pays for lives, so the room can show it @@ -205,7 +205,7 @@ class AccountZapActions( offer: String, amountMillisats: Long, message: String, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, // (messageResId, detail) — the caller localizes; detail carries a wallet error, if any. onError: (StringResource, String?) -> Unit, // (code, detail) — the wallet refused or failed the payment; no funds moved. @@ -215,7 +215,7 @@ class AccountZapActions( ) { // NONZAP means "pay, but publish no receipt" — settle the offer without binding // a zap intent or emitting a 9736, matching the privacy of a bolt11 NONZAP. - if (zapType == LnZapEvent.ZapType.NONZAP) { + if (zapType == ZapReceiptEvent.ZapType.NONZAP) { sendNwcRequest(PayMethod.create("bitcoin:?lno=$offer", amountMillisats), onTimeout) { response -> account.scope.launch { try { @@ -228,7 +228,7 @@ class AccountZapActions( return } - val anonymous = zapType == LnZapEvent.ZapType.ANONYMOUS + val anonymous = zapType == ZapReceiptEvent.ZapType.ANONYMOUS // The 9737 intent and the 9736 zap MUST be signed by the same key. An anonymous // zap uses a fresh ephemeral key so it carries no `P` tag and isn't traceable. val zapSigner = if (anonymous) NostrSignerInternal(KeyPair()) else account.signer @@ -284,12 +284,12 @@ class AccountZapActions( suspend fun createZapRequestFor( user: User, message: String = "", - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, amountMillisats: Long? = null, lnurl: String? = null, - ): LnZapRequestEvent { + ): ZapRequestEvent { val zapRequest = - LnZapRequestEvent.create( + ZapRequestEvent.create( userHex = user.pubkeyHex, relays = account.nip65RelayList.inboxFlow.value + (user.inboxRelays() ?: emptyList()), signer = account.signer, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt index 298fff1dff..9765753489 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt @@ -40,16 +40,16 @@ import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip17Dm.base.BaseDMGroupEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip29RelayGroups.isGroupScoped import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.NutzapInfoEvent @@ -121,7 +121,7 @@ class EventBroadcaster( event is AppSpecificDataEvent || event is BookmarkListEvent || event is OldBookmarkListEvent || - event is LabeledBookmarkListEvent + event is BookmarkSetEvent ) { return false } @@ -166,7 +166,7 @@ class EventBroadcaster( } // Seals, inner DM messages, and unsigned rumors never get broadcast // relays: they only travel inside gift wraps. - if (event is SealedRumorEvent || event is BaseDMGroupEvent || event.sig.isEmpty()) { + if (event is SealEvent || event is BaseDMGroupEvent || event.sig.isEmpty()) { return emptySet() } @@ -322,7 +322,7 @@ class EventBroadcaster( .toList() } val filter = - if (host.kind == SealedRumorEvent.KIND) { + if (host.kind == SealEvent.KIND) { Filter( kinds = listOf(host.kind), ids = listOf(host.id), @@ -383,7 +383,7 @@ class EventBroadcaster( fun sendRestoredVersion(event: Event) { when (event) { is AdvertisedRelayListEvent -> sendEverywhereAnd(event, event.relays().mapTo(mutableSetOf()) { it.relayUrl }) - is ChatMessageRelayListEvent -> sendEverywhereAnd(event, event.relays().toSet()) + is DmRelayListEvent -> sendEverywhereAnd(event, event.relays().toSet()) is KeyPackageRelayListEvent -> sendEverywhereAnd(event, event.relays().toSet()) is CashuWalletEvent -> sendLiterallyEverywhere(event) // Profiles and nutzap info are normally saved everywhere so others can find them; diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/algoFeeds/FavoriteAlgoFeedsOrchestrator.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/algoFeeds/FavoriteAlgoFeedsOrchestrator.kt index 0496ad62dd..e8aa1a078b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/algoFeeds/FavoriteAlgoFeedsOrchestrator.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/algoFeeds/FavoriteAlgoFeedsOrchestrator.kt @@ -25,8 +25,8 @@ import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope @@ -60,7 +60,7 @@ data class FavoriteAlgoFeedsSnapshot( val responseRelays: Set<NormalizedRelayUrl> = emptySet(), val ids: Set<HexKey> = emptySet(), val addresses: Set<String> = emptySet(), - val latestStatus: NIP90StatusEvent? = null, + val latestStatus: DvmStatusEvent? = null, val errorMessage: String? = null, ) @@ -139,9 +139,9 @@ class FavoriteAlgoFeedsOrchestrator( launch { account.cache - .observeLatestEvent<NIP90ContentDiscoveryResponseEvent>( + .observeLatestEvent<DvmContentDiscoveryResponseEvent>( Filter( - kinds = listOf(NIP90ContentDiscoveryResponseEvent.KIND), + kinds = listOf(DvmContentDiscoveryResponseEvent.KIND), tags = mapOf("e" to listOf(requestId)), limit = 1, ), @@ -159,9 +159,9 @@ class FavoriteAlgoFeedsOrchestrator( launch { account.cache - .observeLatestEvent<NIP90StatusEvent>( + .observeLatestEvent<DvmStatusEvent>( Filter( - kinds = listOf(NIP90StatusEvent.KIND), + kinds = listOf(DvmStatusEvent.KIND), tags = mapOf("e" to listOf(requestId)), limit = 1, ), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt index 360fd7309b..1f97c26b2f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip17Dms/DmRelayListState.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi @@ -48,14 +48,14 @@ class DmRelayListState( // Creates a long-term reference for this note so that the GC doesn't collect the note it self val dmListNote = cache.getOrCreateAddressableNote(getDMRelayListAddress()) - fun getDMRelayListAddress() = ChatMessageRelayListEvent.createAddress(signer.pubKey) + fun getDMRelayListAddress() = DmRelayListEvent.createAddress(signer.pubKey) fun getDMRelayListFlow(): StateFlow<NoteState> = dmListNote.flow().metadata.stateFlow - fun getDMRelayList(): ChatMessageRelayListEvent? = dmListNote.event as? ChatMessageRelayListEvent + fun getDMRelayList(): DmRelayListEvent? = dmListNote.event as? DmRelayListEvent fun normalizeDMRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> { - val event = note.event as? ChatMessageRelayListEvent ?: settings.backupDMRelayList + val event = note.event as? DmRelayListEvent ?: settings.backupDMRelayList return event?.relays()?.toSet() ?: emptySet() } @@ -70,16 +70,16 @@ class DmRelayListState( emptySet(), ) - suspend fun saveRelayList(dmRelays: List<NormalizedRelayUrl>): ChatMessageRelayListEvent { + suspend fun saveRelayList(dmRelays: List<NormalizedRelayUrl>): DmRelayListEvent { val relayListForDMs = getDMRelayList() return if (relayListForDMs != null && relayListForDMs.tags.isNotEmpty()) { - ChatMessageRelayListEvent.updateRelayList( + DmRelayListEvent.updateRelayList( earlierVersion = relayListForDMs, relays = dmRelays, signer = signer, ) } else { - ChatMessageRelayListEvent.create( + DmRelayListEvent.create( relays = dmRelays, signer = signer, ) @@ -99,7 +99,7 @@ class DmRelayListState( Log.d("AccountRegisterObservers", "NIP-17 Relay List Collector Start") getDMRelayListFlow().collect { Log.d("AccountRegisterObservers") { "Updating DM Relay List for ${signer.pubKey}" } - (it.note.event as? ChatMessageRelayListEvent)?.let { + (it.note.event as? DmRelayListEvent)?.let { settings.updateDMRelayList(it) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/OwnedEmojiPacksState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/OwnedEmojiPacksState.kt index 7021497479..b9af0de585 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/OwnedEmojiPacksState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip30CustomEmojis/OwnedEmojiPacksState.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.SignerExceptions import com.vitorpamplona.quartz.nip01Core.signers.update -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag import com.vitorpamplona.quartz.nip30CustomEmoji.emoji import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent @@ -129,12 +129,12 @@ class OwnedEmojiPacksState( .onStart { emit(listFeedFlow.value.getPack(dTag)) } .flowOn(Dispatchers.IO) - fun DeletionEvent.hasAnyDeletedOwnedEmojiPacks() = deleteAddressesWithKind(EmojiPackEvent.KIND) || deletesAnyEventIn(ownedEmojiPackEventIds.value) + fun DeletionRequestEvent.hasAnyDeletedOwnedEmojiPacks() = deleteAddressesWithKind(EmojiPackEvent.KIND) || deletesAnyEventIn(ownedEmojiPackEventIds.value) fun hasItemInNoteList(notes: Set<Note>): Boolean = notes.anyNotNullEvent { event -> if (event.pubKey == signer.pubKey) { - event is EmojiPackEvent || (event is DeletionEvent && event.hasAnyDeletedOwnedEmojiPacks()) + event is EmojiPackEvent || (event is DeletionRequestEvent && event.hasAnyDeletedOwnedEmojiPacks()) } else { false } @@ -269,7 +269,7 @@ class OwnedEmojiPacksState( account: Account, ) { val packEvent = getOwnedEmojiPackEvent(dTag) ?: return - val deletionEventTemplate = DeletionEvent.build(listOf(packEvent)) + val deletionEventTemplate = DeletionRequestEvent.build(listOf(packEvent)) val deletionEvent = signer.sign(deletionEventTemplate) account.sendMyPublicAndPrivateOutbox(deletionEvent) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt index 2252b83c4f..1c576e1a4f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip47WalletConnect/NwcSignerState.kt @@ -36,10 +36,10 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip47WalletConnect.cache.NostrWalletConnectRequestCache import com.vitorpamplona.quartz.nip47WalletConnect.cache.NostrWalletConnectResponseCache -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcInfoEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcNotificationEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.NwcTransaction import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayInvoiceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PaymentReceivedNotification @@ -199,12 +199,12 @@ class NwcSignerState( override fun isNIP47Author(pubKey: HexKey?): Boolean = nip47Signer.value.pubKey == pubKey - override suspend fun decryptRequest(event: LnZapPaymentRequestEvent): Request? { + override suspend fun decryptRequest(event: NwcRequestEvent): Request? { if (!hasWalletConnectSetup()) return null return zapPaymentRequestDecryptionCache.value.decryptRequest(event) } - override suspend fun decryptResponse(event: LnZapPaymentResponseEvent): Response? { + override suspend fun decryptResponse(event: NwcResponseEvent): Response? { if (!hasWalletConnectSetup()) return null return zapPaymentResponseDecryptionCache.value.decryptResponse(event) } @@ -252,7 +252,7 @@ class NwcSignerState( request: Request, onTimeout: () -> Unit = {}, onResponse: (Response?) -> Unit, - ): Pair<LnZapPaymentRequestEvent, NormalizedRelayUrl> = sendNwcRequestToWallet(defaultWalletUri.value, request, onTimeout, onResponse) + ): Pair<NwcRequestEvent, NormalizedRelayUrl> = sendNwcRequestToWallet(defaultWalletUri.value, request, onTimeout, onResponse) /** * Sends a generic NIP-47 request to a specific wallet. @@ -266,14 +266,14 @@ class NwcSignerState( request: Request, onTimeout: () -> Unit = {}, onResponse: (Response?) -> Unit, - ): Pair<LnZapPaymentRequestEvent, NormalizedRelayUrl> { + ): Pair<NwcRequestEvent, NormalizedRelayUrl> { val walletService = walletUri ?: throw IllegalArgumentException("No NIP47 setup") val walletSigner = buildSigner(walletService) ?: signer val info = walletInfo(walletService) request.dropMetadataIfUnsupported(info) - val event = LnZapPaymentRequestEvent.createRequest(request, walletService.pubKeyHex, walletSigner, useNip44 = prefersNip44(info)) + val event = NwcRequestEvent.createRequest(request, walletService.pubKeyHex, walletSigner, useNip44 = prefersNip44(info)) val filter = NWCPaymentQueryState( @@ -314,7 +314,7 @@ class NwcSignerState( onTimeout: () -> Unit = {}, metadata: Map<String, Any?>? = null, onResponse: (Response?) -> Unit, - ): Pair<LnZapPaymentRequestEvent, NormalizedRelayUrl> { + ): Pair<NwcRequestEvent, NormalizedRelayUrl> { val walletService = defaultWalletUri.value ?: throw IllegalArgumentException("No NIP47 setup") val info = walletInfo(walletService) @@ -322,7 +322,7 @@ class NwcSignerState( request.dropMetadataIfUnsupported(info) val event = - LnZapPaymentRequestEvent.createRequest( + NwcRequestEvent.createRequest( request, walletService.pubKeyHex, nip47Signer.value, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt index 92869bfbb5..8ef88a5e24 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.hashtagLists.HashtagListDecryptionCache import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi @@ -50,14 +50,14 @@ class HashtagListState( // Creates a long-term reference for this note so that the GC doesn't collect the note it self val hashtagListNote = cache.getOrCreateAddressableNote(getHashtagListAddress()) - fun getHashtagListAddress() = HashtagListEvent.createAddress(signer.pubKey) + fun getHashtagListAddress() = InterestListEvent.createAddress(signer.pubKey) fun getHashtagListFlow(): StateFlow<NoteState> = hashtagListNote.flow().metadata.stateFlow - fun getHashtagList(): HashtagListEvent? = hashtagListNote.event as? HashtagListEvent + fun getHashtagList(): InterestListEvent? = hashtagListNote.event as? InterestListEvent suspend fun hashtagListWithBackup(note: Note): Set<String> { - val event = note.event as? HashtagListEvent ?: settings.backupHashtagList + val event = note.event as? InterestListEvent ?: settings.backupHashtagList return event?.let { decryptionCache.hashtags(it).mapTo(mutableSetOf()) { it.lowercase() } } ?: emptySet() } @@ -75,31 +75,31 @@ class HashtagListState( emptySet(), ) - suspend fun follow(hashtags: List<String>): HashtagListEvent { + suspend fun follow(hashtags: List<String>): InterestListEvent { val hashtagList = getHashtagList() return if (hashtagList == null) { - HashtagListEvent.create(hashtags, true, signer) + InterestListEvent.create(hashtags, true, signer) } else { - HashtagListEvent.add(hashtagList, hashtags, true, signer) + InterestListEvent.add(hashtagList, hashtags, true, signer) } } - suspend fun follow(hashtag: String): HashtagListEvent { + suspend fun follow(hashtag: String): InterestListEvent { val hashtagList = getHashtagList() return if (hashtagList == null) { - HashtagListEvent.create(hashtag.lowercase(), true, signer) + InterestListEvent.create(hashtag.lowercase(), true, signer) } else { - HashtagListEvent.add(hashtagList, hashtag.lowercase(), true, signer) + InterestListEvent.add(hashtagList, hashtag.lowercase(), true, signer) } } - suspend fun unfollow(hashtag: String): HashtagListEvent? { + suspend fun unfollow(hashtag: String): InterestListEvent? { val hashtagList = getHashtagList() return if (hashtagList != null) { - HashtagListEvent.remove(hashtagList, hashtag, signer) + InterestListEvent.remove(hashtagList, hashtag, signer) } else { null } @@ -118,7 +118,7 @@ class HashtagListState( Log.d("AccountRegisterObservers", "Hashtag List Collector Start") getHashtagListFlow().collect { Log.d("AccountRegisterObservers") { "Hashtag List for ${signer.pubKey}" } - (it.note.event as? HashtagListEvent)?.let { + (it.note.event as? InterestListEvent)?.let { settings.updateHashtagListTo(it) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/interestSets/InterestSetsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/interestSets/InterestSetsState.kt index 487aa8748b..f70f9a13cb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/interestSets/InterestSetsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/interestSets/InterestSetsState.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.amethyst.commons.model.nip51Lists.interestSets.Interest import com.vitorpamplona.amethyst.commons.model.updateFlow import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.tags.TitleTag import kotlinx.coroutines.CoroutineScope @@ -106,12 +106,12 @@ class InterestSetsState( fun getInterestSet(dTag: String) = listFeedFlow.value.getSet(dTag) - fun DeletionEvent.hasAnyDeletedInterestSets() = deleteAddressesWithKind(InterestSetEvent.KIND) || deletesAnyEventIn(interestSetEventIds.value) + fun DeletionRequestEvent.hasAnyDeletedInterestSets() = deleteAddressesWithKind(InterestSetEvent.KIND) || deletesAnyEventIn(interestSetEventIds.value) fun hasItemInNoteList(notes: Set<Note>): Boolean = notes.anyNotNullEvent { event -> if (event.pubKey == signer.pubKey) { - event is InterestSetEvent || (event is DeletionEvent && event.hasAnyDeletedInterestSets()) + event is InterestSetEvent || (event is DeletionRequestEvent && event.hasAnyDeletedInterestSets()) } else { false } @@ -178,7 +178,7 @@ class InterestSetsState( account: Account, ) { val event = getInterestSetEvent(identifier) - val template = DeletionEvent.build(listOf(event)) + val template = DeletionRequestEvent.build(listOf(event)) val deletionEvent = account.signer.sign(template) account.sendMyPublicAndPrivateOutbox(deletionEvent) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkListsState.kt index 71626d7d4e..49a1c8b3d4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkListsState.kt @@ -33,11 +33,11 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.update -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.BookmarkIdTag import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.EventBookmark -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.description import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.image import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.title @@ -62,7 +62,7 @@ class LabeledBookmarkListsState( ) { val user = cache.getOrCreateUser(signer.pubKey) - fun existingLabeledBookmarkNotes() = cache.addressables.filter(LabeledBookmarkListEvent.KIND, user.pubkeyHex) + fun existingLabeledBookmarkNotes() = cache.addressables.filter(BookmarkSetEvent.KIND, user.pubkeyHex) val labeledBookmarkListVersions = MutableStateFlow(0) @@ -81,14 +81,14 @@ class LabeledBookmarkListsState( .stateIn(scope, SharingStarted.Eagerly, emptySet()) @OptIn(ExperimentalCoroutinesApi::class) - val latestBookmarkLists: StateFlow<List<LabeledBookmarkListEvent>> = + val latestBookmarkLists: StateFlow<List<BookmarkSetEvent>> = labeledBookmarkListNotes - .transformLatest { emitAll(it.updateFlow<LabeledBookmarkListEvent>()) } + .transformLatest { emitAll(it.updateFlow<BookmarkSetEvent>()) } .onStart { emit(labeledBookmarkListNotes.value.events()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) - suspend fun LabeledBookmarkListEvent.toLabeledBookmarkList() = + suspend fun BookmarkSetEvent.toLabeledBookmarkList() = LabeledBookmarkList( identifier = dTag(), title = titleOrName() ?: dTag(), @@ -98,7 +98,7 @@ class LabeledBookmarkListsState( publicBookmarks = publicBookmarks().toSet(), ) - suspend fun List<LabeledBookmarkListEvent>.toLabeledBookmarkListsFeed() = map { it.toLabeledBookmarkList() }.sortedBy { it.title } + suspend fun List<BookmarkSetEvent>.toLabeledBookmarkListsFeed() = map { it.toLabeledBookmarkList() }.sortedBy { it.title } val listFeedFlow = latestBookmarkLists @@ -114,12 +114,12 @@ class LabeledBookmarkListsState( fun getBookmarkList(dTag: String) = listFeedFlow.value.getList(bookmarkListId = dTag) - fun DeletionEvent.hasAnyDeletedBookmarkLists() = deleteAddressesWithKind(LabeledBookmarkListEvent.KIND) || deletesAnyEventIn(labeledBookmarkListEventIds.value) + fun DeletionRequestEvent.hasAnyDeletedBookmarkLists() = deleteAddressesWithKind(BookmarkSetEvent.KIND) || deletesAnyEventIn(labeledBookmarkListEventIds.value) fun hasItemInNoteList(notes: Set<Note>): Boolean = notes.anyNotNullEvent { event -> if (event.pubKey == signer.pubKey) { - event is LabeledBookmarkListEvent || (event is DeletionEvent && event.hasAnyDeletedBookmarkLists()) + event is BookmarkSetEvent || (event is DeletionRequestEvent && event.hasAnyDeletedBookmarkLists()) } else { false } @@ -143,7 +143,7 @@ class LabeledBookmarkListsState( fun getLabeledBookmarkListNote(bookmarkIdentifier: String): AddressableNote? = existingLabeledBookmarkNotes().find { it.dTag() == bookmarkIdentifier } - fun getLabeledBookmarkListEvent(bookmarkIdentifier: String): LabeledBookmarkListEvent = getLabeledBookmarkListNote(bookmarkIdentifier)?.event as LabeledBookmarkListEvent + fun getLabeledBookmarkListEvent(bookmarkIdentifier: String): BookmarkSetEvent = getLabeledBookmarkListNote(bookmarkIdentifier)?.event as BookmarkSetEvent fun getLabeledBookmarkListFlow(bookmarkIdentifier: String) = listFeedFlow @@ -163,7 +163,7 @@ class LabeledBookmarkListsState( account: Account, ) { val newList = - LabeledBookmarkListEvent.create( + BookmarkSetEvent.create( title = listName, description = listDescription, image = listImage, @@ -202,7 +202,7 @@ class LabeledBookmarkListsState( ) { val listEvent = getLabeledBookmarkListEvent(bookmarkList.identifier) val renamedList = - LabeledBookmarkListEvent.modifyName( + BookmarkSetEvent.modifyName( earlierVersion = listEvent, newTitle = newName, signer = account.signer, @@ -217,7 +217,7 @@ class LabeledBookmarkListsState( ) { val listEvent = getLabeledBookmarkListEvent(bookmarkList.identifier) val modifiedList = - LabeledBookmarkListEvent.modifyDescription( + BookmarkSetEvent.modifyDescription( earlierVersion = listEvent, newDescription = newDescription, signer = account.signer, @@ -232,7 +232,7 @@ class LabeledBookmarkListsState( account: Account, ) { val clonedList = - LabeledBookmarkListEvent.create( + BookmarkSetEvent.create( title = customCloneName ?: currentBookmarkList.title, description = customCloneDescription ?: currentBookmarkList.description, publicBookmarks = currentBookmarkList.publicBookmarks.toList(), @@ -247,7 +247,7 @@ class LabeledBookmarkListsState( account: Account, ) { val listEvent = getLabeledBookmarkListEvent(bookmarkListIdentifier) - val deletionEventTemplate = DeletionEvent.build(listOf(listEvent)) + val deletionEventTemplate = DeletionRequestEvent.build(listOf(listEvent)) val deletionEvent = account.signer.sign(deletionEventTemplate) account.sendMyPublicAndPrivateOutbox(deletionEvent) } @@ -260,7 +260,7 @@ class LabeledBookmarkListsState( ) { val currentBookmarkList = getLabeledBookmarkListEvent(bookmarkListIdentifier) val updatedList = - LabeledBookmarkListEvent.addBookmark( + BookmarkSetEvent.addBookmark( earlierVersion = currentBookmarkList, bookmarkIdTag = bookmark, isPrivate = isBookmarkPrivate, @@ -277,7 +277,7 @@ class LabeledBookmarkListsState( ) { val bookmarkList = getLabeledBookmarkListEvent(bookmarkListIdentifier) val updatedList = - LabeledBookmarkListEvent.moveBookmark( + BookmarkSetEvent.moveBookmark( earlierVersion = bookmarkList, bookmarkIdTag = bookmark, isCurrentlyPrivate = isBookmarkCurrentlyPrivate, @@ -294,7 +294,7 @@ class LabeledBookmarkListsState( ) { val currentBookmarkList = getLabeledBookmarkListEvent(bookmarkListIdentifier) val updatedList = - LabeledBookmarkListEvent.removeBookmark( + BookmarkSetEvent.removeBookmark( earlierVersion = currentBookmarkList, bookmarkIdTag = bookmark, isPrivate = isBookmarkPrivate, @@ -311,7 +311,7 @@ class LabeledBookmarkListsState( ) { if (deletedEventIds.isEmpty() && deletedAddresses.isEmpty()) return - val currentList = getLabeledBookmarkListNote(bookmarkListIdentifier)?.event as? LabeledBookmarkListEvent ?: return + val currentList = getLabeledBookmarkListNote(bookmarkListIdentifier)?.event as? BookmarkSetEvent ?: return val newPublicTags = currentList.tags @@ -328,7 +328,7 @@ class LabeledBookmarkListsState( val updatedList = if (oldPrivateTags == null) { if (newPublicTags.size == currentList.tags.size) return - LabeledBookmarkListEvent.resign( + BookmarkSetEvent.resign( content = currentList.content, tags = newPublicTags, signer = account.signer, @@ -344,7 +344,7 @@ class LabeledBookmarkListsState( } }.toTypedArray() if (newPublicTags.size == currentList.tags.size && newPrivateTags.size == oldPrivateTags.size) return - LabeledBookmarkListEvent.resign( + BookmarkSetEvent.resign( tags = newPublicTags, privateTags = newPrivateTags, signer = account.signer, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/FollowListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/FollowListsState.kt index 0c10d3d49b..fbcdfe4e46 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/FollowListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/FollowListsState.kt @@ -35,8 +35,8 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.update import com.vitorpamplona.quartz.nip01Core.tags.dTag.dTag -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.followList.description import com.vitorpamplona.quartz.nip51Lists.followList.image import com.vitorpamplona.quartz.nip51Lists.followList.person @@ -79,7 +79,7 @@ class FollowListsState( // them from relays. fun existingPeopleListNotes() = cache.addressables - .filter(FollowListEvent.KIND, user.pubkeyHex) + .filter(StarterPackEvent.KIND, user.pubkeyHex) .filter { it.event != null || !cache.hasBeenDeleted(it.address) } val followListVersions = MutableStateFlow(0) @@ -99,14 +99,14 @@ class FollowListsState( .stateIn(scope, SharingStarted.Eagerly, emptySet()) @OptIn(ExperimentalCoroutinesApi::class) - val latestLists: StateFlow<List<FollowListEvent>> = + val latestLists: StateFlow<List<StarterPackEvent>> = followListNotes - .transformLatest { emitAll(it.updateFlow<FollowListEvent>()) } + .transformLatest { emitAll(it.updateFlow<StarterPackEvent>()) } .onStart { emit(followListNotes.value.events()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) - fun List<FollowListEvent>.mapToUserIdSet() = this.map { it.followIdSet() }.flattenToSet() + fun List<StarterPackEvent>.mapToUserIdSet() = this.map { it.followIdSet() }.flattenToSet() val allPeopleListProfiles: StateFlow<Set<HexKey>> = latestLists @@ -115,7 +115,7 @@ class FollowListsState( .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptySet()) - fun FollowListEvent.toUI() = + fun StarterPackEvent.toUI() = PeopleList( identifierTag = this.dTag(), title = this.title() ?: this.dTag(), @@ -125,7 +125,7 @@ class FollowListsState( publicMembers = cache.load(this.followIdSet()), ) - fun List<FollowListEvent>.toUI() = this.map { it.toUI() } + fun List<StarterPackEvent>.toUI() = this.map { it.toUI() } val uiListFlow = latestLists @@ -148,12 +148,12 @@ class FollowListsState( fun isUserInFollowSets(user: User): Boolean = allPeopleListProfiles.value.contains(user.pubkeyHex) - fun DeletionEvent.hasDeletedAnyFollowList() = deleteAddressesWithKind(FollowListEvent.KIND) || deletesAnyEventIn(followListsEventIds.value) + fun DeletionRequestEvent.hasDeletedAnyFollowList() = deleteAddressesWithKind(StarterPackEvent.KIND) || deletesAnyEventIn(followListsEventIds.value) fun hasItemInNoteList(notes: Set<Note>): Boolean = notes.anyNotNullEvent { event -> if (event.pubKey == signer.pubKey) { - event is FollowListEvent || (event is DeletionEvent && event.hasDeletedAnyFollowList()) + event is StarterPackEvent || (event is DeletionRequestEvent && event.hasDeletedAnyFollowList()) } else { false } @@ -181,7 +181,7 @@ class FollowListsState( fun getPeopleListNote(noteIdentifier: String): AddressableNote? = existingPeopleListNotes().find { it.dTag() == noteIdentifier } - fun getPeopleList(noteIdentifier: String): FollowListEvent = getPeopleListNote(noteIdentifier)?.event as FollowListEvent + fun getPeopleList(noteIdentifier: String): StarterPackEvent = getPeopleListNote(noteIdentifier)?.event as StarterPackEvent fun User.toUserTag() = UserTag(this.pubkeyHex, this.bestRelayHint()) @@ -198,7 +198,7 @@ class FollowListsState( val dTag = UUID.randomUUID().toString() val newListTemplate = - FollowListEvent.build( + StarterPackEvent.build( name = name, people = if (!isPrivate && member != null) listOf(member.toUserTag()) else emptyList(), dTag = dTag, @@ -262,7 +262,7 @@ class FollowListsState( account: Account, ) { val followListEvent = getPeopleList(identifierTag) - val deletionEvent = account.signer.sign(DeletionEvent.build(listOf(followListEvent))) + val deletionEvent = account.signer.sign(DeletionRequestEvent.build(listOf(followListEvent))) account.sendMyPublicAndPrivateOutbox(deletionEvent) // Any screen whose persisted feed filter still points at this follow pack would // keep re-creating an empty shell for its address (and render the dTag/UUID in diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt index 013b2c0a07..bdd1731ab8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt @@ -35,9 +35,9 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.update -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.peopleList.description import com.vitorpamplona.quartz.nip51Lists.peopleList.image import com.vitorpamplona.quartz.nip51Lists.peopleList.title @@ -78,8 +78,8 @@ class PeopleListsState( // can subscribe and fetch them from relays. fun existingPeopleListNotes() = cache.addressables - .filter(PeopleListEvent.KIND, user.pubkeyHex) - .filter { it.dTag() != PeopleListEvent.BLOCK_LIST_D_TAG || it.event != null } + .filter(FollowSetEvent.KIND, user.pubkeyHex) + .filter { it.dTag() != FollowSetEvent.BLOCK_LIST_D_TAG || it.event != null } .filter { it.event != null || !cache.hasBeenDeleted(it.address) } val peopleListVersions = MutableStateFlow(0) @@ -99,21 +99,21 @@ class PeopleListsState( .stateIn(scope, SharingStarted.Eagerly, emptySet()) @OptIn(ExperimentalCoroutinesApi::class) - val latestLists: StateFlow<List<PeopleListEvent>> = + val latestLists: StateFlow<List<FollowSetEvent>> = peopleListNotes - .transformLatest { emitAll(it.updateFlow<PeopleListEvent>()) } + .transformLatest { emitAll(it.updateFlow<FollowSetEvent>()) } .onStart { emit(peopleListNotes.value.events()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) - suspend fun PeopleListEvent.userIdSet() = decryptionCache.userIdSet(this) + suspend fun FollowSetEvent.userIdSet() = decryptionCache.userIdSet(this) - suspend fun List<PeopleListEvent>.mapToUserIdSet() = this.map { it.userIdSet() }.flattenToSet() + suspend fun List<FollowSetEvent>.mapToUserIdSet() = this.map { it.userIdSet() }.flattenToSet() - suspend fun List<PeopleListEvent>.mapGoodUsersToIdSet() = + suspend fun List<FollowSetEvent>.mapGoodUsersToIdSet() = this .mapNotNull { - if (it.dTag() != PeopleListEvent.BLOCK_LIST_D_TAG) { + if (it.dTag() != FollowSetEvent.BLOCK_LIST_D_TAG) { it.userIdSet() } else { null @@ -127,7 +127,7 @@ class PeopleListsState( .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptySet()) - suspend fun PeopleListEvent.toUI() = + suspend fun FollowSetEvent.toUI() = PeopleList( identifierTag = this.dTag(), title = this.titleOrName() ?: this.dTag(), @@ -137,7 +137,7 @@ class PeopleListsState( publicMembers = cache.load(this.publicUsersIdSet()), ) - suspend fun List<PeopleListEvent>.toUI() = this.map { it.toUI() }.sortedBy { it.title } + suspend fun List<FollowSetEvent>.toUI() = this.map { it.toUI() }.sortedBy { it.title } val uiListFlow = latestLists @@ -158,12 +158,12 @@ class PeopleListsState( .map { it.select(dTag) } .onStart { emit(selectList(dTag)) } - fun DeletionEvent.hasDeletedAnyPeopleList() = deleteAddressesWithKind(PeopleListEvent.KIND) || deletesAnyEventIn(peopleListsEventIds.value) + fun DeletionRequestEvent.hasDeletedAnyPeopleList() = deleteAddressesWithKind(FollowSetEvent.KIND) || deletesAnyEventIn(peopleListsEventIds.value) fun hasItemInNoteList(notes: Set<Note>): Boolean = notes.anyNotNullEvent { event -> if (event.pubKey == signer.pubKey) { - event is PeopleListEvent || (event is DeletionEvent && event.hasDeletedAnyPeopleList()) + event is FollowSetEvent || (event is DeletionRequestEvent && event.hasDeletedAnyPeopleList()) } else { false } @@ -191,7 +191,7 @@ class PeopleListsState( fun getPeopleListNote(noteIdentifier: String): AddressableNote? = existingPeopleListNotes().find { it.dTag() == noteIdentifier } - fun getPeopleList(noteIdentifier: String): PeopleListEvent = getPeopleListNote(noteIdentifier)?.event as PeopleListEvent + fun getPeopleList(noteIdentifier: String): FollowSetEvent = getPeopleListNote(noteIdentifier)?.event as FollowSetEvent fun User.toUserTag() = UserTag(this.pubkeyHex, this.bestRelayHint()) @@ -207,7 +207,7 @@ class PeopleListsState( ): String { val dTag = UUID.randomUUID().toString() val newListTemplate = - PeopleListEvent.build( + FollowSetEvent.build( dTag = dTag, title = listName, publicMembers = if (!isPrivate && member != null) listOf(member.toUserTag()) else emptyList(), @@ -252,7 +252,7 @@ class PeopleListsState( account: Account, ) { val newList = - PeopleListEvent.createListWithDescription( + FollowSetEvent.createListWithDescription( dTag = UUID.randomUUID().toString(), title = customCloneName ?: currentPeopleList.title, description = customCloneDescription ?: currentPeopleList.description, @@ -268,7 +268,7 @@ class PeopleListsState( account: Account, ) { val followListEvent = getPeopleList(identifierTag) - val deletionEvent = account.signer.sign(DeletionEvent.build(listOf(followListEvent))) + val deletionEvent = account.signer.sign(DeletionRequestEvent.build(listOf(followListEvent))) account.sendMyPublicAndPrivateOutbox(deletionEvent) // Any screen whose persisted feed filter still points at this list would keep // re-creating an empty shell for its address (and render the dTag/UUID in the @@ -284,7 +284,7 @@ class PeopleListsState( ) { val followListEvent = getPeopleList(identifierTag) val newList = - PeopleListEvent.addUser( + FollowSetEvent.addUser( earlierVersion = followListEvent, pubKeyHex = user.pubkeyHex, relayHint = user.bestRelayHint(), @@ -302,7 +302,7 @@ class PeopleListsState( ) { val followListEvent = getPeopleList(identifierTag) val newList = - PeopleListEvent.addUserFirst( + FollowSetEvent.addUserFirst( earlierVersion = followListEvent, pubKeyHex = user.pubkeyHex, relayHint = user.bestRelayHint(), @@ -320,7 +320,7 @@ class PeopleListsState( ) { val followListEvent = getPeopleList(identifierTag) val newList = - PeopleListEvent.removeUser( + FollowSetEvent.removeUser( earlierVersion = followListEvent, pubKeyHex = user.pubkeyHex, isUserPrivate = isPrivate, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayFeeds/RelayFeedListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayFeeds/RelayFeedListState.kt index 7c803a398d..685e8411a9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayFeeds/RelayFeedListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayFeeds/RelayFeedListState.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.model.nip51Lists.relayFeeds.RelayFeeds import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi @@ -50,13 +50,13 @@ class RelayFeedListState( // Creates a long-term reference for this note so that the GC doesn't collect the note it self val relayFeedListNote = cache.getOrCreateAddressableNote(getRelayFeedsListAddress()) - fun getRelayFeedsListAddress() = RelayFeedsListEvent.createAddress(signer.pubKey) + fun getRelayFeedsListAddress() = FavoriteRelayListEvent.createAddress(signer.pubKey) fun getRelayFeedsListFlow(): StateFlow<NoteState> = relayFeedListNote.flow().metadata.stateFlow - fun getRelayFeedsList(): RelayFeedsListEvent? = relayFeedListNote.event as? RelayFeedsListEvent + fun getRelayFeedsList(): FavoriteRelayListEvent? = relayFeedListNote.event as? FavoriteRelayListEvent - fun relayFeedsListEvent(note: Note) = note.event as? RelayFeedsListEvent ?: settings.backupRelayFeedsList + fun relayFeedsListEvent(note: Note) = note.event as? FavoriteRelayListEvent ?: settings.backupRelayFeedsList suspend fun normalizeRelayFeedsListWithBackup(note: Note): Set<NormalizedRelayUrl> = relayFeedsListEvent(note)?.let { decryptionCache.relays(it) }?.ifEmpty { null } ?: emptySet() @@ -84,30 +84,30 @@ class RelayFeedListState( emptySet(), ) - suspend fun addRelay(relay: NormalizedRelayUrl): RelayFeedsListEvent { + suspend fun addRelay(relay: NormalizedRelayUrl): FavoriteRelayListEvent { val current = normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote).toMutableList() if (relay !in current) current.add(relay) return saveRelayList(current) } - suspend fun removeRelay(relay: NormalizedRelayUrl): RelayFeedsListEvent? { + suspend fun removeRelay(relay: NormalizedRelayUrl): FavoriteRelayListEvent? { val current = normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote).toMutableList() if (relay !in current) return null current.remove(relay) return saveRelayList(current) } - suspend fun saveRelayList(relayFeeds: List<NormalizedRelayUrl>): RelayFeedsListEvent { + suspend fun saveRelayList(relayFeeds: List<NormalizedRelayUrl>): FavoriteRelayListEvent { val relayFeedsList = getRelayFeedsList() return if (relayFeedsList != null && relayFeedsList.tags.isNotEmpty()) { - RelayFeedsListEvent.updateRelayList( + FavoriteRelayListEvent.updateRelayList( earlierVersion = relayFeedsList, relays = relayFeeds, signer = signer, ) } else { - RelayFeedsListEvent.create( + FavoriteRelayListEvent.create( relays = relayFeeds, signer = signer, ) @@ -125,7 +125,7 @@ class RelayFeedListState( Log.d("AccountRegisterObservers", "Relay feeds list Collector Start") getRelayFeedsListFlow().collect { Log.d("AccountRegisterObservers") { "Updating Relay feeds list for ${signer.pubKey}" } - (it.note.event as? RelayFeedsListEvent)?.let { + (it.note.event as? FavoriteRelayListEvent)?.let { settings.updateRelayFeedList(it) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuWalletState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuWalletState.kt index 98a005ebdc..1a97ee66c1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuWalletState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip60Cashu/CashuWalletState.kt @@ -41,7 +41,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.accessories.fetchAllPages import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent import com.vitorpamplona.quartz.nip60Cashu.mintApi.DeterministicSecretFactory import com.vitorpamplona.quartz.nip60Cashu.mintApi.MeltQuoteBolt11ResponseDto @@ -486,7 +486,7 @@ class CashuWalletState( // Process our own NIP-09 deletions inline rather than // relying on LocalCache's `deletedEventBundles`. That - // path only fires when `consume(DeletionEvent)` finds + // path only fires when `consume(DeletionRequestEvent)` finds // the target Note still resident in `notes` — a // LargeSoftCache backed by WeakReferences, which can // be cleared on any GC cycle. When the weak ref is @@ -503,7 +503,7 @@ class CashuWalletState( val ourDeleteIds = all .asSequence() - .filterIsInstance<DeletionEvent>() + .filterIsInstance<DeletionRequestEvent>() .filter { it.pubKey == pubKey } .flatMap { it.deleteEventIds().asSequence() } .toSet() @@ -1447,7 +1447,7 @@ class CashuWalletState( } val redundantIds = redundant.map { it.event.id }.toSet() runCatching { - val template = DeletionEvent.build(redundant.map { it.event }) + val template = DeletionRequestEvent.build(redundant.map { it.event }) val signed = signer.sign(template) publishEvent(signed) }.onFailure { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt index 500b133ef6..850374e92e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/NappletConsentSummary.kt @@ -67,7 +67,7 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.lightning.LnInvoiceUtil import com.vitorpamplona.quartz.nip01Core.core.fastForEach import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import org.jetbrains.compose.resources.PluralStringResource @@ -199,7 +199,7 @@ class NappletConsentSummary( oneRemoved = Res.string.napplet_consent_diff_unmute_one, ) // Deletions have no prior version to compare against — the tags are the whole request. - DeletionEvent.KIND -> + DeletionRequestEvent.KIND -> pluralFor(Res.plurals.napplet_consent_effect_deletes, countTag(tags, "e") + countTag(tags, "a")) ?.let { Consequence(it) } // Any other kind: at least tell the user tags exist and can be inspected, so an empty diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/gateways/AccountIdentityReader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/gateways/AccountIdentityReader.kt index 369a7b95c9..8bc8f18df3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/gateways/AccountIdentityReader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/napplet/gateways/AccountIdentityReader.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.napplet.gateways import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import kotlinx.serialization.json.add @@ -137,7 +137,7 @@ class AccountIdentityReader( val receipts = cache .filter(Filter(kinds = listOf(9735), tags = mapOf("p" to listOf(pubkey)))) - .mapNotNull { it.event as? LnZapEvent } + .mapNotNull { it.event as? ZapReceiptEvent } return buildJsonArray { receipts.forEach { zap -> addJsonObject { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/V4VPaymentHandler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/V4VPaymentHandler.kt index 0c07fa506f..cb7cc0ef22 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/V4VPaymentHandler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/V4VPaymentHandler.kt @@ -40,7 +40,7 @@ import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayKeysendMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response import com.vitorpamplona.quartz.nip47WalletConnect.rpc.TlvRecord -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlForm import com.vitorpamplona.quartz.podcasts.PodcastBoostagram import com.vitorpamplona.quartz.podcasts.PodcastValue @@ -91,7 +91,7 @@ class V4VPaymentHandler( onProgress: (percent: Float) -> Unit, onPayInvoicesViaIntent: (invoices: List<String>) -> Unit, asZap: Boolean = false, - zapType: LnZapEvent.ZapType = LnZapEvent.ZapType.PUBLIC, + zapType: ZapReceiptEvent.ZapType = ZapReceiptEvent.ZapType.PUBLIC, ) = withContext(Dispatchers.IO) { val shares = value.computeShares(totalMilliSats) if (shares.isEmpty()) { @@ -190,7 +190,7 @@ class V4VPaymentHandler( shares: List<PodcastValueShare>, message: String, asZap: Boolean, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, zappedNote: Note?, okHttpClient: (String) -> OkHttpClient, context: Context, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt index 86e3a61284..6c8a9e667c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt @@ -48,8 +48,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip47WalletConnect.rpc.NwcErrorCode import com.vitorpamplona.quartz.nip47WalletConnect.rpc.NwcTransactionMetadata import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetupLnAddress import com.vitorpamplona.quartz.nip57Zaps.splits.zapSplitSetup @@ -79,7 +79,7 @@ class ZapPaymentHandler( // The signed kind 9734 this invoice was fetched with, and the message on it. // Carried so the NWC payment can name the payee (NWC-06 `metadata`); null for // a NONZAP split, which has no zap request to send. - val zapRequest: LnZapRequestEvent? = null, + val zapRequest: ZapRequestEvent? = null, val message: String = "", ) @@ -122,7 +122,7 @@ class ZapPaymentHandler( onError: (String, String, User?) -> Unit, onProgress: (percent: Float) -> Unit, onPayViaIntent: (ImmutableList<Payable>) -> Unit, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, ) = withContext(Dispatchers.IO) { val noteEvent = note.event val zapSplitSetup = noteEvent?.zapSplitSetup() @@ -297,7 +297,7 @@ class ZapPaymentHandler( note: Note, pollOption: Int?, message: String, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, totalAmountMilliSats: Long, totalWeight: Double, okHttpClient: (String) -> OkHttpClient, @@ -360,14 +360,14 @@ class ZapPaymentHandler( class ZapRequestReady( val inputSetup: MyZapSplitSetup, - val zapRequest: LnZapRequestEvent?, + val zapRequest: ZapRequestEvent?, ) suspend fun signAllZapRequests( note: Note, pollOption: Int?, message: String, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, zapsToSend: List<MyZapSplitSetup>, totalAmountMilliSats: Long, // Shared across the lightning + BOLT12 lanes so a mixed split stays proportional. @@ -389,7 +389,7 @@ class ZapPaymentHandler( val splitLnurl = LnurlForm.toUrl(next.lnAddress)?.let(LnurlForm::urlToBech32) val zapRequest = - if (zapType != LnZapEvent.ZapType.NONZAP && noteEvent != null) { + if (zapType != ZapReceiptEvent.ZapType.NONZAP && noteEvent != null) { account.zaps.createZapRequestFor( event = noteEvent, pollOption = pollOption, @@ -535,7 +535,7 @@ class ZapPaymentHandler( totalAmountMilliSats: Long, totalWeight: Double, message: String, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, okHttpClient: (String) -> OkHttpClient, onError: (String, String, User?) -> Unit, onProgress: (percent: Float) -> Unit, @@ -672,7 +672,7 @@ class ZapPaymentHandler( private suspend fun assembleInvoice( lud16: String, splitSetup: MyZapSplitSetup, - nostrZapRequest: LnZapRequestEvent?, + nostrZapRequest: ZapRequestEvent?, zapValue: Long, message: String, okHttpClient: (String) -> OkHttpClient, @@ -683,7 +683,7 @@ class ZapPaymentHandler( // Only the request the provider actually accepted may be claimed as bound to // this invoice; see lnAddressInvoice's onZapRequestSent. - var sentZapRequest: LnZapRequestEvent? = null + var sentZapRequest: ZapRequestEvent? = null val invoice = LightningAddressResolver().lnAddressInvoice( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/lnurl/LightningAddressResolver.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/lnurl/LightningAddressResolver.kt index 83efb8028e..9056561530 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/lnurl/LightningAddressResolver.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/lnurl/LightningAddressResolver.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.amethyst.commons.ui.loadStringRes import com.vitorpamplona.amethyst.service.HttpStatusMessages import com.vitorpamplona.quartz.lightning.LnInvoiceUtil import com.vitorpamplona.quartz.lightning.Lud06 -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlEndpointCache import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlEndpointInfo import com.vitorpamplona.quartz.utils.Log @@ -128,7 +128,7 @@ class LightningAddressResolver { lnCallback: String, milliSats: Long, message: String, - nostrRequest: LnZapRequestEvent? = null, + nostrRequest: ZapRequestEvent? = null, okHttpClient: (String) -> OkHttpClient, context: Context, ): String { @@ -219,11 +219,11 @@ class LightningAddressResolver { lnAddress: String, milliSats: Long, message: String, - nostrRequest: LnZapRequestEvent? = null, + nostrRequest: ZapRequestEvent? = null, okHttpClient: (String) -> OkHttpClient, onProgress: (percent: Float) -> Unit, context: Context, - onZapRequestSent: (LnZapRequestEvent?) -> Unit = {}, + onZapRequestSent: (ZapRequestEvent?) -> Unit = {}, ): String { val mapper = ObjectMapper() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt index 30b71e240a..b596797b6a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/EventNotificationConsumer.kt @@ -64,7 +64,7 @@ import com.vitorpamplona.quartz.marmot.mip02Welcome.WelcomeEvent import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent @@ -72,7 +72,7 @@ import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip19Bech32.bech32.bechToBytes import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent @@ -84,17 +84,17 @@ import com.vitorpamplona.quartz.nip34Git.status.GitStatusAppliedEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusClosedEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusDraftEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusOpenEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.nip64Chess.challenge.accept.LiveChessGameAcceptEvent import com.vitorpamplona.quartz.nip64Chess.move.LiveChessMoveEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nipACWebRtcCalls.events.CallOfferEvent @@ -234,7 +234,7 @@ class EventNotificationConsumer( // public chat the user has silenced (matches the in-app feed, which mutes all four). // Without the second check, muting a channel still let a like on your own message // there notify you — the row's glyph promises silence, so it has to mean it. - if (event is ReactionEvent || event is LnZapEvent || event is RepostEvent || event is GenericRepostEvent) { + if (event is ReactionEvent || event is ZapReceiptEvent || event is RepostEvent || event is GenericRepostEvent) { val target = LocalCache.getNoteIfExists(event)?.replyTo?.lastOrNull() if (target != null && ( @@ -247,7 +247,7 @@ class EventNotificationConsumer( } when (event) { - is PrivateDmEvent -> DirectMessageNotification.notify(applicationContext, account, event) + is EncryptedDmEvent -> DirectMessageNotification.notify(applicationContext, account, event) is ChatMessageEvent -> DirectMessageNotification.notify(applicationContext, account, event) is ChatMessageEncryptedFileHeaderEvent -> DirectMessageNotification.notify(applicationContext, account, event) @@ -256,7 +256,7 @@ class EventNotificationConsumer( is StreamMessageV2Event -> BuzzDmNotification.notify(applicationContext, account, event) is ChatEvent -> BuzzDmNotification.notify(applicationContext, account, event) - is LnZapEvent -> ZapNotification.notify(applicationContext, account, event) + is ZapReceiptEvent -> ZapNotification.notify(applicationContext, account, event) is NutzapEvent -> ZapNotification.notify(applicationContext, account, event) is OnchainZapEvent -> ZapNotification.notify(applicationContext, account, event) @@ -274,15 +274,15 @@ class EventNotificationConsumer( is PictureEvent, is VideoNormalEvent, is VideoShortEvent, - is VideoHorizontalEvent, - is VideoVerticalEvent, + is AddressableNormalVideoEvent, + is AddressableShortVideoEvent, -> MediaNotification.notify(applicationContext, account, event) is PollEvent -> MentionNotification.notify(applicationContext, account, event, titleRes = Res.string.app_notification_poll_channel_message) is HighlightEvent, - is LongTextNoteEvent, - is WikiNoteEvent, + is LongFormContentEvent, + is WikiArticleEvent, -> ArticleNotification.notify(applicationContext, account, event) is GitIssueEvent -> CodeNotification.notify(applicationContext, account, event) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationContent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationContent.kt index 238b20c0bc..68077c7d66 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationContent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationContent.kt @@ -27,11 +27,11 @@ import com.vitorpamplona.amethyst.commons.model.nip71Video.selectVideoTrack import com.vitorpamplona.amethyst.commons.richtext.RichTextParser import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip19Bech32.Nip19Parser import com.vitorpamplona.quartz.nip19Bech32.entities.NProfile import com.vitorpamplona.quartz.nip19Bech32.entities.NPub -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip71Video.VideoEvent @@ -177,7 +177,7 @@ object NotificationContent { } suspend fun decryptZapContentAuthor( - event: LnZapRequestEvent, + event: ZapRequestEvent, signer: NostrSigner, ): Event? = if (event.isPrivateZap() && event.zappedAuthor().contains(event.pubKey)) { @@ -191,8 +191,8 @@ object NotificationContent { signer: NostrSigner, ): String? = when (val event = note.event) { - is PrivateDmEvent -> event.decryptContent(signer) - is LnZapRequestEvent -> decryptZapContentAuthor(event, signer)?.content + is EncryptedDmEvent -> event.decryptContent(signer) + is ZapRequestEvent -> decryptZapContentAuthor(event, signer)?.content else -> event?.content } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt index f75661b6f3..e9bca8f358 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.marmot.mip02Welcome.WelcomeEvent import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent @@ -40,7 +40,7 @@ import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip19Bech32.bech32.bechToBytes import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent @@ -52,17 +52,17 @@ import com.vitorpamplona.quartz.nip34Git.status.GitStatusAppliedEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusClosedEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusDraftEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusOpenEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.nip64Chess.challenge.accept.LiveChessGameAcceptEvent import com.vitorpamplona.quartz.nip64Chess.move.LiveChessMoveEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nipACWebRtcCalls.events.CallOfferEvent @@ -118,8 +118,8 @@ class NotificationDispatcher( internal val NOTIFICATION_KINDS: Set<Int> = setOf( // Direct-arrival - PrivateDmEvent.KIND, - LnZapEvent.KIND, + EncryptedDmEvent.KIND, + ZapReceiptEvent.KIND, NutzapEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND, @@ -133,8 +133,8 @@ class NotificationDispatcher( PictureEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, ChannelMessageEvent.KIND, PollEvent.KIND, GitPatchEvent.KIND, @@ -150,8 +150,8 @@ class NotificationDispatcher( GitStatusClosedEvent.KIND, GitStatusDraftEvent.KIND, HighlightEvent.KIND, - LongTextNoteEvent.KIND, - WikiNoteEvent.KIND, + LongFormContentEvent.KIND, + WikiArticleEvent.KIND, LiveChessGameAcceptEvent.KIND, LiveChessMoveEvent.KIND, WakeUpEvent.KIND, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/DirectMessageNotification.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/DirectMessageNotification.kt index 23a67fc369..6935da0691 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/DirectMessageNotification.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/DirectMessageNotification.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.Conver import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.ReplyAction import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.postConversation import com.vitorpamplona.amethyst.service.notifications.notificationManager -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent @@ -64,7 +64,7 @@ object DirectMessageNotification { suspend fun notify( context: Context, account: Account, - event: PrivateDmEvent, + event: EncryptedDmEvent, ) { if (account.signer.pubKey != event.verifiedRecipientPubKey()) return notifyRoom(context, account, event.id, event.createdAt, event.chatroomKey(account.signer.pubKey), decrypt = true) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/ZapNotification.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/ZapNotification.kt index f60e54aad7..6f13908502 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/ZapNotification.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/renderers/ZapNotification.kt @@ -39,8 +39,8 @@ import com.vitorpamplona.amethyst.service.notifications.NotificationRoutes import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.postStandard import com.vitorpamplona.amethyst.service.notifications.notificationManager import com.vitorpamplona.amethyst.ui.note.showAmount -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent import org.jetbrains.compose.resources.StringResource @@ -59,7 +59,7 @@ object ZapNotification { suspend fun notify( context: Context, account: Account, - event: LnZapEvent, + event: ZapReceiptEvent, ) { LocalCache.getNoteIfExists(event.id) ?: return val zapRequestNote = event.zapRequest?.id?.let { LocalCache.checkGetOrCreateNote(it) } ?: return @@ -67,7 +67,7 @@ object ZapNotification { if (!account.isAcceptable(zappedNote)) return if ((event.amount ?: BigDecimal.ZERO) < MIN_ZAP_AMOUNT) return - val zapRequestEvent = zapRequestNote.event as? LnZapRequestEvent ?: return + val zapRequestEvent = zapRequestNote.event as? ZapRequestEvent ?: return // Resolve the (possibly private) zapper once — never re-decrypt per tick. val decrypted = NotificationContent.decryptZapContentAuthor(zapRequestEvent, account.signer) ?: return val sender = LocalCache.getOrCreateUser(decrypted.pubKey) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt index 087e2cdeee..75a9090d82 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt @@ -32,18 +32,18 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip53LiveActivities.nestsServers.NestsServersEvent @@ -60,9 +60,9 @@ val AccountInfoAndListsFromKeyKinds = listOf( MetadataEvent.KIND, ContactListEvent.KIND, - StatusEvent.KIND, + UserStatusEvent.KIND, AdvertisedRelayListEvent.KIND, - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, KeyPackageRelayListEvent.KIND, SearchRelayListEvent.KIND, FileServersEvent.KIND, @@ -78,12 +78,12 @@ val AccountInfoAndListsFromKeyKinds2 = BroadcastRelayListEvent.KIND, IndexerRelayListEvent.KIND, ProxyRelayListEvent.KIND, - HashtagListEvent.KIND, + InterestListEvent.KIND, GeohashListEvent.KIND, TrustProviderListEvent.KIND, PaymentTargetsEvent.KIND, Bolt12OfferListEvent.KIND, - RelayFeedsListEvent.KIND, + FavoriteRelayListEvent.KIND, InterestSetEvent.KIND, // NIP-51 "simple groups" list (kind 10009): the user's joined NIP-29 groups + servers. // Loaded up-front so "My Groups" and group memberships resolve immediately at login, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/nwc/NWCFinderFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/nwc/NWCFinderFilterAssemblerSubscription.kt index 065304ec16..6f7d9e6064 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/nwc/NWCFinderFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/nwc/NWCFinderFilterAssemblerSubscription.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.nip47WalletConnect.NWCPaym import com.vitorpamplona.amethyst.commons.relayClient.nip47WalletConnect.NWCPaymentQueryState import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.KeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent @SuppressLint("StateFlowValueCalledInComposition") @Composable @@ -50,7 +50,7 @@ fun NWCFinderFilterAssemblerSubscription( val states = remember(note) { val zapPaymentRequestNote = note - (zapPaymentRequestNote.event as? LnZapPaymentRequestEvent)?.let { noteEvent -> + (zapPaymentRequestNote.event as? NwcRequestEvent)?.let { noteEvent -> noteEvent.walletServicePubKey()?.let { zapPaymentRequestNote.relays.map { NWCPaymentQueryState( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt index 691179b7e7..bd26b5ad5a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -132,9 +132,9 @@ fun observeUserTagFollowCount( .metadata.stateFlow .sample(1000) .mapLatest { noteState -> - (noteState.note.event as? HashtagListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.size ?: 0 + (noteState.note.event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.size ?: 0 }.onStart { - emit((accountViewModel.hashtagFollows(user).event as? HashtagListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.size ?: 0) + emit((accountViewModel.hashtagFollows(user).event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.size ?: 0) }.distinctUntilChanged() .flowOn(Dispatchers.IO) } @@ -160,9 +160,9 @@ fun observeUserTagFollows( .metadata.stateFlow .sample(200) .mapLatest { noteState -> - (noteState.note.event as? HashtagListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList() + (noteState.note.event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList() }.onStart { - emit((accountViewModel.hashtagFollows(user).event as? HashtagListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList()) + emit((accountViewModel.hashtagFollows(user).event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList()) }.distinctUntilChanged() .flowOn(Dispatchers.IO) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt index 93bb31f4a5..1b5355efef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip46RemoteSigner.signer.NostrSignerRemote import com.vitorpamplona.quartz.nip55AndroidSigner.client.NostrSignerExternal import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip89AppHandlers.clientTag.NostrSignerWithClientTag /** @@ -89,7 +89,7 @@ class MeteringNostrSigner( fromPublicKey: HexKey, ): String = metered(UsageKeys.DECRYPT_COUNT, UsageKeys.DECRYPT_US) { inner.nip44Decrypt(ciphertext, fromPublicKey) } - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = metered(UsageKeys.DECRYPT_COUNT, UsageKeys.DECRYPT_US) { inner.decryptZapEvent(event) } + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = metered(UsageKeys.DECRYPT_COUNT, UsageKeys.DECRYPT_US) { inner.decryptZapEvent(event) } override suspend fun deriveKey(nonce: HexKey): HexKey = inner.deriveKey(nonce) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilder.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilder.kt index 6a326f99c9..fe15bfee85 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilder.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilder.kt @@ -26,9 +26,9 @@ import com.davotoula.lightcompressor.hls.HlsUploaded import com.vitorpamplona.amethyst.service.uploads.MediaUploadResult import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoMeta -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip71Video.duration import com.vitorpamplona.quartz.nip71Video.title import com.vitorpamplona.quartz.nip71Video.videoIMetas @@ -61,11 +61,11 @@ data class HlsVideoPublishInput( sealed class HlsVideoEventTemplate { data class Horizontal( - val template: EventTemplate<VideoHorizontalEvent>, + val template: EventTemplate<AddressableNormalVideoEvent>, ) : HlsVideoEventTemplate() data class Vertical( - val template: EventTemplate<VideoVerticalEvent>, + val template: EventTemplate<AddressableShortVideoEvent>, ) : HlsVideoEventTemplate() } @@ -80,7 +80,7 @@ data class HlsBuiltTemplate( ) /** - * Assembles a NIP-71 VideoHorizontalEvent / VideoVerticalEvent template from an HLS upload + * Assembles a NIP-71 AddressableNormalVideoEvent / AddressableShortVideoEvent template from an HLS upload * result. Orientation is decided from the first rendition's width/height: portrait * (height > width) selects kind 34236, otherwise 34235. * @@ -142,7 +142,7 @@ object HlsVideoEventBuilder { val template = if (isVertical) { HlsVideoEventTemplate.Vertical( - VideoVerticalEvent.build(input.description, dTag, createdAt) { + AddressableShortVideoEvent.build(input.description, dTag, createdAt) { videoIMetas(videoMetas) title(input.title) input.durationSeconds?.let { duration(it) } @@ -151,7 +151,7 @@ object HlsVideoEventBuilder { ) } else { HlsVideoEventTemplate.Horizontal( - VideoHorizontalEvent.build(input.description, dTag, createdAt) { + AddressableNormalVideoEvent.build(input.description, dTag, createdAt) { videoIMetas(videoMetas) title(input.title) input.durationSeconds?.let { duration(it) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/markdown/RenderContentAsMarkdown.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/markdown/RenderContentAsMarkdown.kt index 650224ae95..2b0d73753f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/markdown/RenderContentAsMarkdown.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/markdown/RenderContentAsMarkdown.kt @@ -54,7 +54,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.amethyst.ui.uriToRoute import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip92IMeta.imetasByUrl import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking @@ -425,7 +425,7 @@ fun RenderContentAsMarkdownNotePreview() { runBlocking { withContext(Dispatchers.IO) { val blogPost = - LongTextNoteEvent( + LongFormContentEvent( id = "e69fa72a221d0b7362f8e63fd6ab84cc6b5e7b505fe49cefe6823a47a6a4b583", pubKey = "88cc134b1a65f54ef48acc1df3665063d3ea45f04eab8af4646e561c5ae99079", createdAt = 1718785725, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt index 9c36e806a9..79d22a9dbe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hasMoreHashtagsThan import com.vitorpamplona.quartz.nip10Notes.threadRootIdOrSelf import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.utils.TimeUtils class FilterByListParams( @@ -105,7 +105,7 @@ class FilterByListParams( fun showHiddenKey( selectedListName: String, userHex: String, - ) = selectedListName == PeopleListEvent.blockListFor(userHex) || selectedListName == MuteListEvent.blockListFor(userHex) + ) = selectedListName == FollowSetEvent.blockListFor(userHex) || selectedListName == MuteListEvent.blockListFor(userHex) fun create( followLists: IFeedTopNavFilter?, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt index 1fbdc53637..3d70cf26d2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt @@ -298,7 +298,7 @@ private class WarmTargets { /** * Adds NIP-94 file-header media: blobs declared as top-level `url` tags (not - * imeta), as used by FileHeaderEvent and the gallery/file kinds. Only image + * imeta), as used by FileMetadataEvent and the gallery/file kinds. Only image * files are prefetched — detected by the URL extension or the event's top-level * `m` mime type (a hashed URL may carry no extension). The decode listener * records their dims like any other image. @@ -333,7 +333,7 @@ private fun Note.collectWarmTargets(): WarmTargets? { } // NIP-94 file-header convention: the blob is a top-level `url` tag with sibling - // `m`/`dim`, not imeta (FileHeaderEvent and the gallery/file kinds). The generic + // `m`/`dim`, not imeta (FileMetadataEvent and the gallery/file kinds). The generic // imetas() above misses these entirely. targets.addFileHeaderMedia(ev) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt index 13f0e95cf2..3962bce3ac 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt @@ -44,7 +44,7 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.base.IsInPublicChatChannel import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent @@ -57,12 +57,12 @@ import com.vitorpamplona.quartz.nip34Git.pr.GitPullRequestEvent import com.vitorpamplona.quartz.nip34Git.pr.GitPullRequestUpdateEvent import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip59Giftwrap.HasInnerEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent @@ -247,7 +247,7 @@ fun routeForInner( } } - is FollowListEvent -> { + is StarterPackEvent -> { Route.FollowPack(noteEvent.address()) } @@ -294,7 +294,7 @@ fun routeForInner( Route.GeocacheHunt(noteEvent.kind, noteEvent.pubKey, noteEvent.dTag()) } - is GiftWrapEvent, is SealedRumorEvent -> { + is GiftWrapEvent, is SealEvent -> { val wrap = noteEvent as HasInnerEvent wrap.innerEventId?.let { routeFor(LocalCache.getOrCreateNote(it), loggedIn) @@ -456,7 +456,7 @@ fun routeReplyTo( } is ChatroomKeyable -> { - // Covers PrivateDmEvent (NIP-04) and BaseDMGroupEvent (NIP-17) — both + // Covers EncryptedDmEvent (NIP-04) and BaseDMGroupEvent (NIP-17) — both // implement ChatroomKeyable with identical routing semantics here. routeToMessage( room = noteEvent.chatroomKey(account.userProfile().pubkeyHex), @@ -477,7 +477,7 @@ fun routeReplyTo( } } - is LnZapEvent -> { + is ZapReceiptEvent -> { // A public reply can't tag a private zapper without exposing them. // When we hold the decrypted sender (we are the zap recipient), reply // in their DM room instead of the public comment composer. @@ -532,7 +532,7 @@ suspend fun routeEditDraftTo( Route.NewShortNote(draft = note.idHex) } - is LongTextNoteEvent -> { + is LongFormContentEvent -> { Route.NewLongFormPost(draft = note.idHex) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt index ee0acbe5e7..208b2c4ba1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NIP05VerificationDisplay.kt @@ -84,7 +84,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.events.ETag import com.vitorpamplona.quartz.nip01Core.tags.events.firstTaggedEvent import com.vitorpamplona.quartz.nip01Core.tags.people.firstTaggedUserId import com.vitorpamplona.quartz.nip30CustomEmoji.taggedEmojis -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableMap import kotlinx.collections.immutable.persistentMapOf @@ -219,14 +219,14 @@ fun DisplayStatus( nav: INav, ) { val noteState by observeNote(addressableNote, accountViewModel) - val noteEvent = noteState.note.event as? StatusEvent ?: return + val noteEvent = noteState.note.event as? UserStatusEvent ?: return DisplayStatus(noteEvent, accountViewModel, nav) } @Composable fun DisplayStatus( - event: StatusEvent, + event: UserStatusEvent, accountViewModel: AccountViewModel, nav: INav, ) { @@ -266,7 +266,7 @@ fun DisplayStatusInner( nav: INav, ) { when (type) { - StatusEvent.MUSIC -> { + UserStatusEvent.MUSIC -> { Icon( imageVector = CustomHashTagIcons.Tunestr, null, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index 08ae330cde..a05755b51f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -331,16 +331,16 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.tags.geohash.geoHashOrScope import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip13Pow.strongPoWOrNull import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ExternalReactionEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent @@ -368,26 +368,26 @@ import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSet import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent import com.vitorpamplona.quartz.nip51Lists.gitAuthorList.GitAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.gitRepositoryList.GitRepositoryListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiAuthorList.GoodWikiAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiRelayList.GoodWikiRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.kindMuteSet.KindMuteSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaFollowList.MediaFollowListEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent @@ -395,19 +395,19 @@ import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeAcceptanceEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeRequestEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.splits.hasZapSplitSetupBesidesAuthor import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent @@ -427,7 +427,7 @@ import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprov import com.vitorpamplona.quartz.nip72ModCommunities.communityAddress import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip72ModCommunities.isACommunityPost -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent @@ -437,9 +437,9 @@ import com.vitorpamplona.quartz.nip87Ecash.recommendation.MintRecommendationEven import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.BaseVoiceEvent import com.vitorpamplona.quartz.nipA4PublicMessages.PublicMessageEvent @@ -1145,7 +1145,7 @@ private fun RenderNoteRow( RenderReport(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) } - is LongTextNoteEvent -> { + is LongFormContentEvent -> { RenderLongFormContent(baseNote, accountViewModel, nav) } @@ -1171,7 +1171,7 @@ private fun RenderNoteRow( RenderCodeSnippetEvent(baseNote) } - is WikiNoteEvent -> { + is WikiArticleEvent -> { RenderWikiContent(baseNote, accountViewModel, nav) } @@ -1191,7 +1191,7 @@ private fun RenderNoteRow( BadgeDisplay(baseNote = baseNote, accountViewModel = accountViewModel, nav = nav) } - is LnZapEvent -> { + is ZapReceiptEvent -> { RenderLnZap(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) } @@ -1215,11 +1215,11 @@ private fun RenderNoteRow( RenderFhirResource(baseNote, accountViewModel, nav) } - is PeopleListEvent -> { + is FollowSetEvent -> { DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav) } - is FollowListEvent -> { + is StarterPackEvent -> { DisplayFollowList(baseNote, true, accountViewModel, nav) } @@ -1231,7 +1231,7 @@ private fun RenderNoteRow( DisplayRelaySet(baseNote, backgroundColor, accountViewModel, nav) } - is ChatMessageRelayListEvent -> { + is DmRelayListEvent -> { DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav) } @@ -1251,7 +1251,7 @@ private fun RenderNoteRow( DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav) } - is RelayFeedsListEvent -> { + is FavoriteRelayListEvent -> { DisplayRelayFeedsList(baseNote, backgroundColor, accountViewModel, nav) } @@ -1384,7 +1384,7 @@ private fun RenderNoteRow( ) } - is PrivateDmEvent -> { + is EncryptedDmEvent -> { RenderPrivateMessage( baseNote, makeItShort, @@ -1494,7 +1494,7 @@ private fun RenderNoteRow( RenderCalendarDateSlotEvent(baseNote, accountViewModel, nav) } - is CalendarEvent -> { + is CalendarCollectionEvent -> { RenderCalendarCollectionEvent(baseNote, accountViewModel, nav) } @@ -1502,7 +1502,7 @@ private fun RenderNoteRow( RenderCalendarRSVPEvent(baseNote, accountViewModel, nav) } - is GoalEvent -> { + is ZapGoalEvent -> { RenderGoal(baseNote, accountViewModel, nav) } @@ -1550,7 +1550,7 @@ private fun RenderNoteRow( ) } - is NIP90ContentDiscoveryResponseEvent -> { + is DvmContentDiscoveryResponseEvent -> { RenderNIP90ContentDiscoveryResponse( baseNote, makeItShort, @@ -1562,7 +1562,7 @@ private fun RenderNoteRow( ) } - is NIP90StatusEvent -> { + is DvmStatusEvent -> { RenderNIP90Status( baseNote, accountViewModel, @@ -1640,7 +1640,7 @@ private fun RenderNoteRow( ) } - is FileHeaderEvent -> { + is FileMetadataEvent -> { FileHeaderDisplay(baseNote, true, ContentScale.FillWidth, accountViewModel) } @@ -1879,7 +1879,7 @@ private fun RenderNoteRow( RenderOldBookmarkList(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) } - is LabeledBookmarkListEvent -> { + is BookmarkSetEvent -> { RenderLabeledBookmarkList(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) } @@ -1923,7 +1923,7 @@ private fun RenderNoteRow( RenderMediaStarterPack(baseNote, backgroundColor, accountViewModel, nav) } - is HashtagListEvent -> { + is InterestListEvent -> { RenderHashtagList(baseNote, backgroundColor, accountViewModel, nav) } @@ -2172,7 +2172,7 @@ fun FirstUserInfoRow( // Zap receipts are signed by the recipient's lightning provider; show the // sender from the embedded zap request instead of the service key. val zapSender = - if (baseNote.event is LnZapEvent) { + if (baseNote.event is ZapReceiptEvent) { observeZapSender(baseNote, accountViewModel).value } else { null @@ -2411,7 +2411,7 @@ fun RenderAuthorImages( } else { NoteAuthorPicture(baseNote, Size55dp, accountViewModel = accountViewModel, nav = nav) } - } else if (noteEvent is LnZapEvent) { + } else if (noteEvent is ZapReceiptEvent) { // Zap receipts are signed by the recipient's lightning provider; show the // sender from the embedded zap request instead of the service key, matching // how the thread's master note resolves the author. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt index 5cb7a5d1cd..a6999b790b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt @@ -116,8 +116,8 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.report.ReportNoteDialog import com.vitorpamplona.quartz.experimental.bounties.bountyBaseReward import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import kotlinx.coroutines.launch import org.jetbrains.compose.resources.StringResource @@ -149,8 +149,8 @@ val externalLinkForNote = { note: Note -> if (note is AddressableNote) { when { note.event?.bountyBaseReward() != null -> "https://nostrbounties.com/b/${note.toNAddr()}" - note.event is PeopleListEvent -> "https://listr.lol/a/${note.toNAddr()}" - note.event is FollowListEvent -> "https://following.space/d/${note.address.dTag}?p=${note.address.pubKeyHex}" + note.event is FollowSetEvent -> "https://listr.lol/a/${note.toNAddr()}" + note.event is StarterPackEvent -> "https://following.space/d/${note.address.dTag}?p=${note.address.pubKeyHex}" else -> njumpLink(note.toNAddr()) } } else { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt index 7fc4cc5be5..5faaa6a2e2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt @@ -95,7 +95,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -361,7 +361,7 @@ private fun EmojiSelector( accountViewModel.account.emoji.getEmojiPackSelectionAddress(), ) { emptyNote -> emptyNote?.let { usersEmojiList -> - val collections by observeNoteEventAndMapNotNull(usersEmojiList, accountViewModel) { event: EmojiPackSelectionEvent -> + val collections by observeNoteEventAndMapNotNull(usersEmojiList, accountViewModel) { event: EmojiListEvent -> event.emojiPacks().toImmutableList() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt index 51351dac5b..af65ce3dbb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt @@ -121,7 +121,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.keyBackup.getFragmentActivity import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.launch @@ -153,22 +153,22 @@ fun UpdateZapAmountContent( val zapTypes = listOf( Triple( - LnZapEvent.ZapType.PUBLIC, + ZapReceiptEvent.ZapType.PUBLIC, stringRes(id = Res.string.zap_type_public), stringRes(id = Res.string.zap_type_public_explainer), ), Triple( - LnZapEvent.ZapType.PRIVATE, + ZapReceiptEvent.ZapType.PRIVATE, stringRes(id = Res.string.zap_type_private), stringRes(id = Res.string.zap_type_private_explainer), ), Triple( - LnZapEvent.ZapType.ANONYMOUS, + ZapReceiptEvent.ZapType.ANONYMOUS, stringRes(id = Res.string.zap_type_anonymous), stringRes(id = Res.string.zap_type_anonymous_explainer), ), Triple( - LnZapEvent.ZapType.NONZAP, + ZapReceiptEvent.ZapType.NONZAP, stringRes(id = Res.string.zap_type_nonzap), stringRes(id = Res.string.zap_type_nonzap_explainer), ), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt index b1b44291e6..168e937299 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountViewModel.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip19Bech32.decodePrivateKeyAsHexOrNull import com.vitorpamplona.quartz.nip19Bech32.decodePublicKey import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.coroutines.CancellationException @Stable @@ -44,7 +44,7 @@ class UpdateZapAmountViewModel : ViewModel() { var walletConnectRelay by mutableStateOf(TextFieldValue("")) var walletConnectPubkey by mutableStateOf(TextFieldValue("")) var walletConnectSecret by mutableStateOf(TextFieldValue("")) - var selectedZapType by mutableStateOf(LnZapEvent.ZapType.PRIVATE) + var selectedZapType by mutableStateOf(ZapReceiptEvent.ZapType.PRIVATE) // A local UI preference rather than synced account state, but it is edited on // this screen, so it follows this screen's Save/Cancel contract instead of diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt index 75a78c8df2..ac414ad2b2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapCustomDialog.kt @@ -117,7 +117,7 @@ import com.vitorpamplona.amethyst.service.ZapPaymentHandler import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.wallet.OnchainZapSendDialog import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.coroutines.CancellationException @@ -163,35 +163,35 @@ fun ZapCustomDialog( val zapTypes = listOf( Triple( - LnZapEvent.ZapType.PUBLIC, + ZapReceiptEvent.ZapType.PUBLIC, stringRes(id = Res.string.zap_type_public), stringRes(id = Res.string.zap_type_public_explainer), ), Triple( - LnZapEvent.ZapType.PRIVATE, + ZapReceiptEvent.ZapType.PRIVATE, stringRes(id = Res.string.zap_type_private), stringRes(id = Res.string.zap_type_private_explainer), ), Triple( - LnZapEvent.ZapType.ANONYMOUS, + ZapReceiptEvent.ZapType.ANONYMOUS, stringRes(id = Res.string.zap_type_anonymous), stringRes(id = Res.string.zap_type_anonymous_explainer), ), Triple( - LnZapEvent.ZapType.NONZAP, + ZapReceiptEvent.ZapType.NONZAP, stringRes(id = Res.string.zap_type_nonzap), stringRes(id = Res.string.zap_type_nonzap_explainer), ), ).filter { - !isPrivateTarget || it.first == LnZapEvent.ZapType.PRIVATE || it.first == LnZapEvent.ZapType.NONZAP + !isPrivateTarget || it.first == ZapReceiptEvent.ZapType.PRIVATE || it.first == ZapReceiptEvent.ZapType.NONZAP } var selectedZapType by remember(accountViewModel, baseNote) { val default = accountViewModel.defaultZapType() mutableStateOf( - if (isPrivateTarget && default != LnZapEvent.ZapType.NONZAP) { - LnZapEvent.ZapType.PRIVATE + if (isPrivateTarget && default != ZapReceiptEvent.ZapType.NONZAP) { + ZapReceiptEvent.ZapType.PRIVATE } else { default }, @@ -327,15 +327,15 @@ fun ZapCustomDialog( OutlinedTextField( label = { when (selectedZapType) { - LnZapEvent.ZapType.PUBLIC, LnZapEvent.ZapType.ANONYMOUS -> { + ZapReceiptEvent.ZapType.PUBLIC, ZapReceiptEvent.ZapType.ANONYMOUS -> { Text(text = stringRes(id = Res.string.custom_zaps_add_a_message)) } - LnZapEvent.ZapType.PRIVATE -> { + ZapReceiptEvent.ZapType.PRIVATE -> { Text(text = stringRes(id = Res.string.custom_zaps_add_a_message_private)) } - LnZapEvent.ZapType.NONZAP -> { + ZapReceiptEvent.ZapType.NONZAP -> { Text(text = stringRes(id = Res.string.custom_zaps_add_a_message_nonzap)) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNote.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNote.kt index 445efa5a78..60899cf0e4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNote.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNote.kt @@ -113,7 +113,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockVitorAccountViewModel import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -145,7 +145,7 @@ fun ZapZapPollNotePreview() { ) val zapVote = - LnZapEvent( + ZapReceiptEvent( id = "2a17fdcd0e387d1623c7313d7aa2848e18dde8a942cfe8a2d6b686ea5f68f01a", pubKey = "79f00d3f5a19ec806189fcab03c1be4ff81d18ee4f653c88fac41fe03570f432", createdAt = 1729186293, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNoteViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNoteViewModel.kt index 1a331eb8ac..d8970b6b23 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNoteViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/ZapPollNoteViewModel.kt @@ -30,8 +30,8 @@ import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -233,9 +233,9 @@ class PollNoteViewModel : ViewModel() { user: User, ): Boolean = pollNote!!.zaps.any { - val zapEvent = it.value?.event as? LnZapEvent + val zapEvent = it.value?.event as? ZapReceiptEvent val privateZapAuthor = - (it.key.event as? LnZapRequestEvent)?.let { + (it.key.event as? ZapRequestEvent)?.let { account.privateZapsDecryptionCache.cachedPrivateZap(it) } zapEvent?.zappedPollOption() == option && @@ -244,7 +244,7 @@ class PollNoteViewModel : ViewModel() { private fun zappedPollOptionAmount(option: Int): BigDecimal = pollNote?.zaps?.values?.sumOf { - val event = it?.event as? LnZapEvent + val event = it?.event as? ZapReceiptEvent val zapAmount = event?.amount ?: BigDecimal.ZERO val isValidAmount = isValidInputVoteAmount(event?.amount) @@ -258,7 +258,7 @@ class PollNoteViewModel : ViewModel() { private fun totalZapped(): BigDecimal = pollNote?.zaps?.values?.sumOf { - val zapEvent = (it?.event as? LnZapEvent) + val zapEvent = (it?.event as? ZapReceiptEvent) val zapAmount = zapEvent?.amount ?: BigDecimal.ZERO val isValidAmount = isValidInputVoteAmount(zapEvent?.amount) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/WatchAndLoadMyEmojiList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/WatchAndLoadMyEmojiList.kt index 1687f0a6ea..cabe2aafbe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/WatchAndLoadMyEmojiList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/emojiSuggestions/WatchAndLoadMyEmojiList.kt @@ -27,16 +27,16 @@ import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNo import com.vitorpamplona.amethyst.ui.note.LoadAddressableNote import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.tags.aTag.taggedAddresses -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import kotlinx.collections.immutable.toImmutableList @Composable fun WatchAndLoadMyEmojiList(accountViewModel: AccountViewModel) { LoadAddressableNote( - EmojiPackSelectionEvent.createAddress(accountViewModel.userProfile().pubkeyHex), + EmojiListEvent.createAddress(accountViewModel.userProfile().pubkeyHex), ) { emptyNote -> emptyNote?.let { usersEmojiList -> - val collections by observeNoteEventAndMapNotNull(usersEmojiList, accountViewModel) { event: EmojiPackSelectionEvent -> + val collections by observeNoteEventAndMapNotNull(usersEmojiList, accountViewModel) { event: EmojiListEvent -> event.taggedAddresses().toImmutableList() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/AddInboxRelayForDMCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/AddInboxRelayForDMCard.kt index 15205698c9..856bddd12c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/AddInboxRelayForDMCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/AddInboxRelayForDMCard.kt @@ -55,7 +55,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.dm.AddDMRelayListDialog import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent @Preview @Composable @@ -88,7 +88,7 @@ fun ObserveRelayListForDMsAndDisplayIfNotFound( @Composable fun ObserveRelayListForDMs( accountViewModel: AccountViewModel, - inner: @Composable (relayListEvent: ChatMessageRelayListEvent?) -> Unit, + inner: @Composable (relayListEvent: DmRelayListEvent?) -> Unit, ) { ObserveRelayListForDMs( pubkey = accountViewModel.account.userProfile().pubkeyHex, @@ -102,13 +102,13 @@ fun ObserveRelayListForDMs( fun ObserveRelayListForDMs( pubkey: HexKey, accountViewModel: AccountViewModel, - inner: @Composable (relayListEvent: ChatMessageRelayListEvent?) -> Unit, + inner: @Composable (relayListEvent: DmRelayListEvent?) -> Unit, ) { LoadAddressableNote( - ChatMessageRelayListEvent.createAddress(pubkey), + DmRelayListEvent.createAddress(pubkey), ) { relayList -> if (relayList != null) { - val relayListEvent by observeNoteEvent<ChatMessageRelayListEvent>(relayList, accountViewModel) + val relayListEvent by observeNoteEvent<DmRelayListEvent>(relayList, accountViewModel) inner(relayListEvent) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteActionSections.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteActionSections.kt index cbb23ef5a4..958acad531 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteActionSections.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/NoteActionSections.kt @@ -80,7 +80,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.experimental.music.track.MusicTrackEvent import com.vitorpamplona.quartz.nip01Core.jackson.JacksonMapper import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent import kotlinx.coroutines.Dispatchers @@ -222,7 +222,7 @@ fun noteActionSections( // nostr source pre-tagged (`a` for an addressable article, else `e`) plus the author, // and the passage left for the user to type or paste. Prose kinds only, and never a // private rumor (a public highlight would e-tag the unsigned rumor onto relays). - if (!isPrivateRumor && (note.event is TextNoteEvent || note.event is LongTextNoteEvent)) { + if (!isPrivateRumor && (note.event is TextNoteEvent || note.event is LongFormContentEvent)) { add( NoteAction(MaterialSymbols.FormatQuote, stringRes(Res.string.highlight_action)) { val author = note.author?.pubkeyHex @@ -256,7 +256,7 @@ fun noteActionSections( onClick = handlers.onEditPost, ), ) - } else if (note.event is LongTextNoteEvent && state.isLoggedUser) { + } else if (note.event is LongFormContentEvent && state.isLoggedUser) { add( NoteAction(MaterialSymbols.Edit, stringRes(Res.string.edit_article)) { nav.nav { Route.NewLongFormPost(version = note.idHex) } @@ -343,10 +343,10 @@ fun noteActionSections( } else -> { - val noteBookmarkType = if (note.event is LongTextNoteEvent) stringRes(Res.string.article) else stringRes(Res.string.post) + val noteBookmarkType = if (note.event is LongFormContentEvent) stringRes(Res.string.article) else stringRes(Res.string.post) add( NoteAction(MaterialSymbols.BookmarkAdd, stringRes(Res.string.manage_bookmark_label, noteBookmarkType)) { - if (note.event is LongTextNoteEvent) { + if (note.event is LongFormContentEvent) { nav.nav(Route.ArticleBookmarkManagement((note as AddressableNote).address)) } else { nav.nav(Route.PostBookmarkManagement(note.idHex)) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt index 8afb6da337..f6550f6e3a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt @@ -109,7 +109,7 @@ import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarningReason import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitive import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip40Expiration.expiration -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.splits.zapSplits import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiser import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiserAmount @@ -352,7 +352,7 @@ open class CommentPostViewModel : this.externalIdentity = (post.event as? CommentEvent)?.scope() mutedNotifies = emptySet() notifyProvenance = emptyMap() - (post.event as? LnZapEvent)?.let { zap -> + (post.event as? ZapReceiptEvent)?.let { zap -> notifying = listOfNotNull(zapSenderToNotify(zap)) } observeCommunityRules(post) @@ -366,7 +366,7 @@ open class CommentPostViewModel : * by an ephemeral key: skip those — tagging the throwaway key is useless, and * tagging the decrypted sender would publicly expose a private zapper. */ - private fun zapSenderToNotify(zapEvent: LnZapEvent): User? { + private fun zapSenderToNotify(zapEvent: ZapReceiptEvent): User? { val request = zapEvent.zapRequest ?: return null if (request.hasAnonTag()) return null if (request.pubKey == account.signer.pubKey) return null @@ -554,7 +554,7 @@ open class CommentPostViewModel : // Replies to zaps notify the zap sender through a plain p tag (the receipt's // author keys above are the lightning provider). The sender chip always comes // back; a missing p tag in the draft means the user muted their bell. - (replyingTo?.event as? LnZapEvent)?.let { zap -> + (replyingTo?.event as? ZapReceiptEvent)?.let { zap -> zapSenderToNotify(zap)?.let { sender -> notifying = ((notifying ?: emptyList()) + sender).distinct() if (!draftEvent.tags.mapNotNull(PTag::parseKey).contains(sender.pubkeyHex)) { @@ -726,7 +726,7 @@ open class CommentPostViewModel : null } } - } else if (replyingToEvent is LnZapEvent) { + } else if (replyingToEvent is ZapReceiptEvent) { val sender = zapSenderToNotify(replyingToEvent) // The sender's chip stays in the list; a muted bell means // the user doesn't want to ping them, so don't tag them. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCard.kt index 0a54abc2f0..f0d9265a41 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCard.kt @@ -63,7 +63,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.gallery.GalleryThum import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.gallery.UrlImageView import com.vitorpamplona.quartz.experimental.profileGallery.ProfileGalleryEntryEvent import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip36SensitiveContent.ContentWarningTag import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitiveOrNSFW import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent @@ -278,7 +278,7 @@ private fun secondaryLineFor( return when { event is PictureEvent -> stringRes(Res.string.share_as_qr_kind_picture) event is VideoEvent -> stringRes(Res.string.kind_video) - event is LongTextNoteEvent -> stringRes(Res.string.article) + event is LongFormContentEvent -> stringRes(Res.string.article) hasContentImage -> stringRes(Res.string.share_as_qr_kind_picture) else -> "" } @@ -293,7 +293,7 @@ internal fun secondaryBodyTextFor( // Gated: never surface the note's own title, content or alt text, only the kind label above. if (isGated) return null - if (event is LongTextNoteEvent) { + if (event is LongFormContentEvent) { val title = event.title() if (!title.isNullOrBlank()) return title } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CalendarCollectionRender.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CalendarCollectionRender.kt index e28e4021e7..22b1fa72c6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CalendarCollectionRender.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CalendarCollectionRender.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.note.CalendarCollectionCard import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent /** * Entry for a NIP-52 calendar collection: decodes the [Note] and renders the shared commons @@ -38,7 +38,7 @@ fun RenderCalendarCollectionEvent( accountViewModel: AccountViewModel, nav: INav, ) { - val event = note.event as? CalendarEvent ?: return + val event = note.event as? CalendarCollectionEvent ?: return CalendarCollectionCard(event) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt index 81a4a54709..bda74a2880 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.amethyst.ui.components.SensitivityWarning import com.vitorpamplona.amethyst.ui.components.ZoomableContentView import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip31Alts.alt -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent @Composable fun FileHeaderDisplay( @@ -44,7 +44,7 @@ fun FileHeaderDisplay( contentScale: ContentScale, accountViewModel: AccountViewModel, ) { - val event = (note.event as? FileHeaderEvent) ?: return + val event = (note.event as? FileMetadataEvent) ?: return val fullUrl = event.url() ?: return val mimeType = remember(note) { event.mimeType() } val content = remember(note) { event.toMediaContent(note, fullUrl, mimeType) } @@ -72,7 +72,7 @@ fun FileHeaderDisplay( * video event the kind itself asserts nothing about how to render the payload. A null here means * the file belongs in [FileHeaderAttachmentCard] rather than being pushed into the video player. */ -internal fun FileHeaderEvent.toMediaContent( +internal fun FileMetadataEvent.toMediaContent( note: Note, url: String, mimeType: String?, @@ -129,7 +129,7 @@ internal fun FileHeaderEvent.toMediaContent( /** The link card a kind-1063 header falls back to when [toMediaContent] returns null. */ @Composable internal fun FileHeaderAttachmentCard( - event: FileHeaderEvent, + event: FileMetadataEvent, url: String, mimeType: String?, ) { @@ -145,4 +145,4 @@ internal fun FileHeaderAttachmentCard( } /** The human-facing name of the file: NIP-94 `content` when present, else the `alt` tag. */ -private fun FileHeaderEvent.fileDescription(): String? = content.ifEmpty { null } ?: alt() +private fun FileMetadataEvent.fileDescription(): String? = content.ifEmpty { null } ?: alt() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FollowList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FollowList.kt index 2f394b2fe8..ac06818f09 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FollowList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FollowList.kt @@ -66,7 +66,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeaderBackground import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.FollowSetCard import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -79,7 +79,7 @@ fun DisplayFollowList( nav: INav, ) { val card = - observeNoteEventAndMap(baseNote, accountViewModel) { event: FollowListEvent? -> + observeNoteEventAndMap(baseNote, accountViewModel) { event: StarterPackEvent? -> if (event == null) { FollowSetCard( name = "", @@ -190,7 +190,7 @@ fun RenderFollowSetThumbPreview() { val accountViewModel = mockAccountViewModel() val followCard = - FollowListEvent( + StarterPackEvent( id = "eca31634fce7c9068b56fa8db9f387da70bdcceb3986a77ca1a9844f3128eb5f", pubKey = "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da", createdAt = 1761736286, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Goal.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Goal.kt index a272a55618..0c314f5017 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Goal.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Goal.kt @@ -60,7 +60,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeader import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeaderBackground import com.vitorpamplona.amethyst.ui.note.showAmount import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.utils.TimeUtils import java.math.BigDecimal import kotlin.math.roundToInt @@ -71,14 +71,14 @@ fun RenderGoal( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = note.event as? GoalEvent ?: return + val noteEvent = note.event as? ZapGoalEvent ?: return GoalHeader(noteEvent, note, accountViewModel, nav) } @Composable fun GoalHeader( - noteEvent: GoalEvent, + noteEvent: ZapGoalEvent, note: Note, accountViewModel: AccountViewModel, nav: INav, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LongForm.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LongForm.kt index 7e87980caa..c316416092 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LongForm.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/LongForm.kt @@ -65,7 +65,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeader import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeaderBackground import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.collections.immutable.toImmutableList private const val WORDS_PER_MINUTE = 225 @@ -77,7 +77,7 @@ fun RenderLongFormContent( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = note.event as? LongTextNoteEvent ?: return + val noteEvent = note.event as? LongFormContentEvent ?: return LongFormHeader(noteEvent, note, accountViewModel) } @@ -85,7 +85,7 @@ fun RenderLongFormContent( @OptIn(ExperimentalLayoutApi::class) @Composable fun LongFormHeader( - noteEvent: LongTextNoteEvent, + noteEvent: LongFormContentEvent, note: Note, accountViewModel: AccountViewModel, ) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt index d5c9a604ab..2bee2e52d0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer import com.vitorpamplona.amethyst.ui.note.elements.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hasHashtags -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent @Composable fun RenderNIP90ContentDiscoveryResponse( @@ -47,7 +47,7 @@ fun RenderNIP90ContentDiscoveryResponse( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = note.event as? NIP90ContentDiscoveryResponseEvent ?: return + val noteEvent = note.event as? DvmContentDiscoveryResponseEvent ?: return val callbackUri = remember(note) { note.toNostrUri() } SensitivityWarning( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt index a2afc2ebec..6b6bfb0303 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt @@ -25,7 +25,7 @@ import androidx.compose.runtime.Composable import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent @Composable fun RenderNIP90Status( @@ -33,7 +33,7 @@ fun RenderNIP90Status( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = note.event as? NIP90StatusEvent ?: return + val noteEvent = note.event as? DvmStatusEvent ?: return Text(text = noteEvent.content) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt index effd49f5e1..64b4fa7b39 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt @@ -56,7 +56,7 @@ import com.vitorpamplona.amethyst.ui.note.UserCompose import com.vitorpamplona.amethyst.ui.note.getGradient import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUserIds -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf @@ -68,7 +68,7 @@ fun DisplayPeopleList( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = baseNote.event as? PeopleListEvent ?: return + val noteEvent = baseNote.event as? FollowSetEvent ?: return var members by remember { mutableStateOf<ImmutableList<User>>(persistentListOf()) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt index 1a2310f3fc..743ada7075 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PrivateMessage.kt @@ -53,7 +53,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.header.ChatroomHeader import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hasHashtags -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip19Bech32.toNpub @@ -67,7 +67,7 @@ fun RenderPrivateMessage( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = note.event as? PrivateDmEvent ?: return + val noteEvent = note.event as? EncryptedDmEvent ?: return val userRoom by remember(note) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Publication.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Publication.kt index ae654a1f05..fdccdb6b39 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Publication.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Publication.kt @@ -80,8 +80,8 @@ import com.vitorpamplona.quartz.experimental.publications.PublicationContentEven import com.vitorpamplona.quartz.experimental.publications.PublicationIndexEvent import com.vitorpamplona.quartz.experimental.publications.PublicationSectionRef import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import kotlinx.collections.immutable.toImmutableList // A 2:3 portrait cover — a book jacket, which is what NKBIP-01's default `book` type is. The @@ -355,8 +355,8 @@ private fun ObservedSectionRow( // list long-form, wiki and spec events as sections too. is PublicationIndexEvent -> event.titleOrIdentifier() is PublicationContentEvent -> event.titleOrIdentifier() - is LongTextNoteEvent -> event.title() - is WikiNoteEvent -> event.title() + is LongFormContentEvent -> event.title() + is WikiArticleEvent -> event.title() // A bookshelf directory lists whatever it likes, including another directory, so the // row has to name the library kinds too -- otherwise a nested entry falls through to // the section placeholder and reads "Untitled section", which it is not. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PublicationSection.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PublicationSection.kt index 73fea0a6e4..8eeaeba528 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PublicationSection.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PublicationSection.kt @@ -67,7 +67,7 @@ import com.vitorpamplona.quartz.experimental.publications.PublicationIndexEvent import com.vitorpamplona.quartz.experimental.publications.PublicationSectionRef import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent /** * Renders a kind-30041 NKBIP-01 publication section — a chapter, zettel or episode. @@ -331,12 +331,12 @@ private fun wikilinkResolver(event: PublicationContentEvent): (String) -> String link == null -> null link.eventId != null -> - "nostr:" + NEvent.create(link.eventId!!, link.pubKey, WikiNoteEvent.KIND, link.relay) + "nostr:" + NEvent.create(link.eventId!!, link.pubKey, WikiArticleEvent.KIND, link.relay) link.pubKey != null -> "nostr:" + NAddress.create( - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, link.pubKey!!, PublicationContentEvent.normalizeWikilink(link.target), link.relay, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt index e90e933cbb..ec1f485c88 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt @@ -70,7 +70,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.firstTagValueFor import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import kotlinx.collections.immutable.toImmutableList @@ -158,7 +158,7 @@ fun DisplayDMRelayList( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = baseNote.event as? ChatMessageRelayListEvent ?: return + val noteEvent = baseNote.event as? DmRelayListEvent ?: return val relays = remember(noteEvent) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt index 2bb1f341e6..8067e9db46 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt @@ -96,12 +96,11 @@ import com.vitorpamplona.amethyst.ui.note.elements.MoreOptionsButton import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.application.SoftwareApplicationEvent import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.SoftwareAssetEvent -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.SoftwareReleaseEvent -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.asSoftwareRelease import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.isNip82SoftwareRelease import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.tags.AppIdTag import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.tags.dTag.dTag +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.distinctUntilChanged @@ -209,7 +208,7 @@ fun RenderSoftwareApplication( } /** - * Latest NIP-82 [SoftwareReleaseEvent] version for [app], kept live. + * Latest NIP-82 [ReleaseArtifactSetEvent] version for [app], kept live. * * Releases (kind 30063) are separate events that point back to the app via an * `i` tag rather than an `a` tag, so they are never indexed as replies to the @@ -230,7 +229,7 @@ fun produceLatestReleaseVersion(app: SoftwareApplicationEvent): State<String?> { remember(app.pubKey, app.id) { val filter = Filter( - kinds = listOf(SoftwareReleaseEvent.KIND), + kinds = listOf(ReleaseArtifactSetEvent.KIND), authors = listOf(app.pubKey), tags = mapOf(AppIdTag.TAG_NAME to listOf(app.appId())), ) @@ -243,13 +242,13 @@ fun produceLatestReleaseVersion(app: SoftwareApplicationEvent): State<String?> { return flow.collectAsStateWithLifecycle(initialValue = null) } -fun findLatestNip82Release(app: SoftwareApplicationEvent): SoftwareReleaseEvent? = latestNip82Release(nip82ReleaseNotesFor(app), app) +fun findLatestNip82Release(app: SoftwareApplicationEvent): ReleaseArtifactSetEvent? = latestNip82Release(nip82ReleaseNotesFor(app), app) /** Picks the newest NIP-82 release for [app] out of an already-narrowed [notes] collection. */ private fun latestNip82Release( notes: Collection<Note>, app: SoftwareApplicationEvent, -): SoftwareReleaseEvent? { +): ReleaseArtifactSetEvent? { val prefix = "${app.dTag()}@" return notes .mapNotNull { it.asNip82ReleaseFor(prefix) } @@ -259,25 +258,22 @@ private fun latestNip82Release( /** kind-30063 addressables authored by [app] whose `d` tag is `<app-id>@<version>`. */ private fun nip82ReleaseNotesFor(app: SoftwareApplicationEvent): Set<Note> { val prefix = "${app.dTag()}@" - return LocalCache.addressables.filterIntoSet(SoftwareReleaseEvent.KIND, app.pubKey) { _, addr -> + return LocalCache.addressables.filterIntoSet(ReleaseArtifactSetEvent.KIND, app.pubKey) { _, addr -> val ev = addr.event ?: return@filterIntoSet false ev.isNip82SoftwareRelease() && ev.dTag().startsWith(prefix) } } /** - * Re-reads this note as the NIP-82 release for [prefix] (`<app-id>@`). kind 30063 - * collides with NIP-51 `ReleaseArtifactSetEvent`, which is what `EventFactory` - * builds, so we re-parse matching tag arrays as the NIP-82 form. + * This note as the NIP-82 release for [prefix] (`<app-id>@`). kind 30063 is shared + * with NIP-51 release artifact sets, so only events carrying the NIP-82 tags qualify. */ -private fun Note.asNip82ReleaseFor(prefix: String): SoftwareReleaseEvent? = - when (val ev = event) { - null -> null - is SoftwareReleaseEvent -> ev.takeIf { it.dTag().startsWith(prefix) } - else -> if (ev.isNip82SoftwareRelease() && ev.dTag().startsWith(prefix)) ev.asSoftwareRelease() else null - } +private fun Note.asNip82ReleaseFor(prefix: String): ReleaseArtifactSetEvent? { + val ev = event as? ReleaseArtifactSetEvent ?: return null + return ev.takeIf { it.isNip82SoftwareRelease() && it.dTag().startsWith(prefix) } +} -fun findAllNip82Releases(app: SoftwareApplicationEvent): List<SoftwareReleaseEvent> { +fun findAllNip82Releases(app: SoftwareApplicationEvent): List<ReleaseArtifactSetEvent> { val prefix = "${app.dTag()}@" return nip82ReleaseNotesFor(app) .mapNotNull { it.asNip82ReleaseFor(prefix) } @@ -486,25 +482,17 @@ fun RenderSoftwareRelease( accountViewModel: AccountViewModel, nav: INav, ) { - // kind 30063 is shared between NIP-51 ReleaseArtifactSetEvent and NIP-82 SoftwareReleaseEvent; - // EventFactory always returns the NIP-51 class, so we re-parse the same tag array as the - // NIP-82 form when the tag signature matches. - val rawEvent = note.event ?: return - val event: SoftwareReleaseEvent = - if (rawEvent is SoftwareReleaseEvent) { - rawEvent - } else if (rawEvent.isNip82SoftwareRelease()) { - rawEvent.asSoftwareRelease() - } else { - return - } + // kind 30063 is shared between NIP-51 release artifact sets and NIP-82 software + // releases; only render the NIP-82 form here. + val event = note.event as? ReleaseArtifactSetEvent ?: return + if (!event.isNip82SoftwareRelease()) return RenderSoftwareReleaseBody(event = event, accountViewModel = accountViewModel, nav = nav) } @Composable fun RenderSoftwareReleaseBody( - event: SoftwareReleaseEvent, + event: ReleaseArtifactSetEvent, accountViewModel: AccountViewModel, nav: INav, showAppId: Boolean = true, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt index b9bdd996a6..908ff3f919 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Text.kt @@ -60,7 +60,7 @@ import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip14Subject.subject import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent enum class ReplyRenderType { FULL, @@ -129,7 +129,7 @@ fun RenderTextEvent( // Zap receipts are signed by the recipient's lightning provider; // label the reply with the zap sender instead of the service key. val zapSender = - if (parentNote.event is LnZapEvent) { + if (parentNote.event is ZapReceiptEvent) { observeZapSender(parentNote, accountViewModel).value } else { null diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt index 22d717f56d..be61fdda0a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt @@ -50,7 +50,7 @@ import com.vitorpamplona.amethyst.ui.components.MyAsyncImage import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeader import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeaderBackground import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent @Composable fun RenderWikiContent( @@ -58,14 +58,14 @@ fun RenderWikiContent( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = note.event as? WikiNoteEvent ?: return + val noteEvent = note.event as? WikiArticleEvent ?: return WikiNoteHeader(noteEvent, note, accountViewModel, nav) } @Composable private fun WikiNoteHeader( - noteEvent: WikiNoteEvent, + noteEvent: WikiArticleEvent, note: Note, accountViewModel: AccountViewModel, nav: INav, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/WikiCollaboration.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/WikiCollaboration.kt index 4338782fd5..521e0e02db 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/WikiCollaboration.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/WikiCollaboration.kt @@ -55,9 +55,9 @@ import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer import com.vitorpamplona.amethyst.ui.note.LoadAddressableNote import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Address +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeAcceptanceEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeRequestEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent /** @@ -215,7 +215,7 @@ private fun WikiArticleRow( ) { LoadAddressableNote(address) { articleNote -> if (articleNote != null) { - val article by observeNoteEvent<WikiNoteEvent>(articleNote, accountViewModel) + val article by observeNoteEvent<WikiArticleEvent>(articleNote, accountViewModel) WikiRow( // The coordinate's own identifier is a readable slug, so it stands in until the @@ -240,7 +240,7 @@ private fun WikiVersionRow( ) { LoadNote(eventId) { versionNote -> if (versionNote != null) { - val article by observeNoteEvent<WikiNoteEvent>(versionNote, accountViewModel) + val article by observeNoteEvent<WikiArticleEvent>(versionNote, accountViewModel) WikiRow( title = article?.title() ?: eventId.take(8), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt index 94c76b141e..bc6d1bb5f8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt @@ -64,7 +64,7 @@ import com.vitorpamplona.amethyst.ui.note.UserPicture import com.vitorpamplona.amethyst.ui.note.ZapAmountCommentNotification import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext @@ -104,7 +104,7 @@ fun RenderLnZap( accountViewModel: AccountViewModel, nav: INav, ) { - val zapEvent = note.event as? LnZapEvent ?: return + val zapEvent = note.event as? ZapReceiptEvent ?: return val card by parseAuthorCommentAndAmount(note, accountViewModel) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt index 157bf7f0de..2a8a1ce57b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSet import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.BookmarkIdTag -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent /** NIP-51 kind 10003: the user's bookmarks — notes, articles, hashtags and links. */ @@ -108,7 +108,7 @@ fun RenderLabeledBookmarkList( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = baseNote.event as? LabeledBookmarkListEvent ?: return + val noteEvent = baseNote.event as? BookmarkSetEvent ?: return val public = remember(noteEvent) { noteEvent.publicBookmarks() } val private by loadPrivateItems(noteEvent, accountViewModel) { noteEvent.privateBookmarks(it) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt index 4294e5386d..b2186cbd21 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.tags.hashtags.HashtagTag import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent /** NIP-51 kind 10015: the hashtags this user follows. */ @@ -47,10 +47,10 @@ fun RenderHashtagList( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent = baseNote.event as? HashtagListEvent ?: return + val noteEvent = baseNote.event as? InterestListEvent ?: return val public = remember(noteEvent) { noteEvent.publicHashtags() } - // HashtagListEvent exposes no private accessor of its own, but it is a PrivateTagArrayEvent + // InterestListEvent exposes no private accessor of its own, but it is a PrivateTagArrayEvent // like the rest, so its private half is read the same way InterestSetEvent reads its own. val private by loadPrivateItems(noteEvent, accountViewModel) { signer -> noteEvent.privateTags(signer)?.mapNotNull(HashtagTag::parse) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt index 5a3eaf6059..8d0618d42d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt @@ -43,9 +43,9 @@ import com.vitorpamplona.amethyst.service.checkNotInMainThread import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.utils.Log @@ -594,9 +594,9 @@ class PeopleListName( NoteBackedName { override fun name(): String { val noteEvent = note.event - return if (noteEvent is PeopleListEvent) { + return if (noteEvent is FollowSetEvent) { noteEvent.titleOrName() ?: note.dTag() - } else if (noteEvent is FollowListEvent) { + } else if (noteEvent is StarterPackEvent) { noteEvent.title() ?: note.dTag() } else { note.dTag() 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 04244170d0..6cd968367e 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 @@ -172,7 +172,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.PubKeyReferenceTag import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip03Timestamp.EmptyOtsResolverBuilder -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip05DnsIdentifiers.EmptyNip05Client import com.vitorpamplona.quartz.nip05DnsIdentifiers.INip05Client import com.vitorpamplona.quartz.nip05DnsIdentifiers.Nip05Client @@ -202,16 +202,16 @@ import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip56Reports.ReportType -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlForm import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiserAmount -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip60Cashu.token.CashuToken -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent import com.vitorpamplona.quartz.nip92IMeta.imeta import com.vitorpamplona.quartz.nip94FileMetadata.tags.DimensionTag import com.vitorpamplona.quartz.podcasts.PodcastBoostagram @@ -725,7 +725,7 @@ class AccountViewModel( val isHiddenAuthor = note.author?.let { account.isHidden(it) } == true val noteEvent = note.event - val isDecryptedPostHidden = if (noteEvent is PrivateDmEvent) account.isDecryptedContentHidden(noteEvent) else false + val isDecryptedPostHidden = if (noteEvent is EncryptedDmEvent) account.isDecryptedContentHidden(noteEvent) else false return if (isPostHidden || isDecryptedPostHidden) { // Spam + Blocked Users + Hidden Words + Sensitive Content @@ -924,14 +924,14 @@ class AccountViewModel( it.request.event ?.content ?.ifBlank { null }, - showAmountInteger((it.response.event as? LnZapEvent)?.amount), + showAmountInteger((it.response.event as? ZapReceiptEvent)?.amount), it.response, ) }.toMutableMap() val results = mapNotNullAsync( - zaps.filter { (it.request.event as? LnZapRequestEvent)?.isPrivateZap() == true }, + zaps.filter { (it.request.event as? ZapRequestEvent)?.isPrivateZap() == true }, ) { next -> val info = innerDecryptAmountMessage(next.request, next.response) if (info != null) { @@ -950,14 +950,14 @@ class AccountViewModel( fun cachedDecryptAmountMessageInGroup(zapNotes: List<CombinedZap>): ImmutableList<ZapAmountCommentNotification> = zapNotes .map { - val request = it.request.event as? LnZapRequestEvent + val request = it.request.event as? ZapRequestEvent if (request?.isPrivateZap() == true) { val cachedPrivateRequest = account.privateZapsDecryptionCache.cachedPrivateZap(request) if (cachedPrivateRequest != null) { ZapAmountCommentNotification( LocalCache.getUserIfExists(cachedPrivateRequest.pubKey) ?: it.request.author, cachedPrivateRequest.content.ifBlank { null }, - showAmountInteger((it.response.event as? LnZapEvent)?.amount), + showAmountInteger((it.response.event as? ZapReceiptEvent)?.amount), it.response, ) } else { @@ -966,7 +966,7 @@ class AccountViewModel( it.request.event ?.content ?.ifBlank { null }, - showAmountInteger((it.response.event as? LnZapEvent)?.amount), + showAmountInteger((it.response.event as? ZapReceiptEvent)?.amount), it.response, ) } @@ -976,7 +976,7 @@ class AccountViewModel( it.request.event ?.content ?.ifBlank { null }, - showAmountInteger((it.response.event as? LnZapEvent)?.amount), + showAmountInteger((it.response.event as? ZapReceiptEvent)?.amount), it.response, ) } @@ -987,14 +987,14 @@ class AccountViewModel( return myList .map { - val request = it.first.event as? LnZapRequestEvent + val request = it.first.event as? ZapRequestEvent if (request?.isPrivateZap() == true) { val cachedPrivateRequest = account.privateZapsDecryptionCache.cachedPrivateZap(request) if (cachedPrivateRequest != null) { ZapAmountCommentNotification( LocalCache.getUserIfExists(cachedPrivateRequest.pubKey) ?: it.first.author, cachedPrivateRequest.content.ifBlank { null }, - showAmountInteger((it.second?.event as? LnZapEvent)?.amount), + showAmountInteger((it.second?.event as? ZapReceiptEvent)?.amount), it.second, ) } else { @@ -1003,7 +1003,7 @@ class AccountViewModel( it.first.event ?.content ?.ifBlank { null }, - showAmountInteger((it.second?.event as? LnZapEvent)?.amount), + showAmountInteger((it.second?.event as? ZapReceiptEvent)?.amount), it.second, ) } @@ -1013,7 +1013,7 @@ class AccountViewModel( it.first.event ?.content ?.ifBlank { null }, - showAmountInteger((it.second?.event as? LnZapEvent)?.amount), + showAmountInteger((it.second?.event as? ZapReceiptEvent)?.amount), it.second, ) } @@ -1036,7 +1036,7 @@ class AccountViewModel( it.first.event ?.content ?.ifBlank { null }, - showAmountInteger((it.second?.event as? LnZapEvent)?.amount), + showAmountInteger((it.second?.event as? ZapReceiptEvent)?.amount), it.second, ) }.toMutableMap() @@ -1073,7 +1073,7 @@ class AccountViewModel( } suspend fun innerDecryptAmountMessage(zapNote: Note): ZapAmountCommentNotification? { - val zapEvent = zapNote.event as? LnZapEvent ?: return null + val zapEvent = zapNote.event as? ZapReceiptEvent ?: return null val zapRequest = zapEvent.zapRequest ?: return null return innerDecryptAmountMessage(zapRequest, zapEvent)?.copy(zapNote = zapNote) @@ -1083,14 +1083,14 @@ class AccountViewModel( zapRequest: Note, zapEvent: Note, ): ZapAmountCommentNotification? { - val zapEvent = zapEvent.event as? LnZapEvent ?: return null - val zapRequest = zapRequest.event as? LnZapRequestEvent ?: return null + val zapEvent = zapEvent.event as? ZapReceiptEvent ?: return null + val zapRequest = zapRequest.event as? ZapRequestEvent ?: return null return innerDecryptAmountMessage(zapRequest, zapEvent) } suspend fun innerDecryptAmountMessage( - zapRequestEvent: LnZapRequestEvent, - zapEvent: LnZapEvent, + zapRequestEvent: ZapRequestEvent, + zapEvent: ZapReceiptEvent, ): ZapAmountCommentNotification? { val amount = showAmountInteger(zapEvent.amount) return if (zapRequestEvent.isPrivateZap()) { @@ -1148,7 +1148,7 @@ class AccountViewModel( onError: (String, String, User?) -> Unit, onProgress: (percent: Float) -> Unit, onPayViaIntent: (ImmutableList<ZapPaymentHandler.Payable>) -> Unit, - zapType: LnZapEvent.ZapType? = null, + zapType: ZapReceiptEvent.ZapType? = null, ) = launchSigner { // A podcast note (episode or show) can carry a Podcasting-2.0 value-for-value block. When it // does, "zapping" it means paying that split — lnaddress recipients go out as real zaps (with @@ -1177,8 +1177,8 @@ class AccountViewModel( // comment stay encrypted. NONZAP is kept: paying without a zap // request produces no receipt at all, which is even more private. val effectiveType = - if (note.isPrivateRumor() && requestedType != LnZapEvent.ZapType.NONZAP) { - LnZapEvent.ZapType.PRIVATE + if (note.isPrivateRumor() && requestedType != ZapReceiptEvent.ZapType.NONZAP) { + ZapReceiptEvent.ZapType.PRIVATE } else { requestedType } @@ -1299,7 +1299,7 @@ class AccountViewModel( zappedNote = zappedNote, context = context, asZap = !streaming, - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, okHttpClient = httpClientBuilder::okHttpClientForMoney, onError = { title, message -> if (!streaming) toastManager.toast(title, message) @@ -1463,7 +1463,7 @@ class AccountViewModel( fun follows(user: User): Note = LocalCache.getOrCreateAddressableNote(ContactListEvent.createAddress(user.pubkeyHex)) - fun hashtagFollows(user: User): Note = LocalCache.getOrCreateAddressableNote(HashtagListEvent.createAddress(user.pubkeyHex)) + fun hashtagFollows(user: User): Note = LocalCache.getOrCreateAddressableNote(InterestListEvent.createAddress(user.pubkeyHex)) fun bookmarks(user: User): Note = LocalCache.getOrCreateAddressableNote(BookmarkListEvent.createBookmarkAddress(user.pubkeyHex)) @@ -2122,7 +2122,7 @@ class AccountViewModel( fun updateZapAmounts( amountSet: List<Long>, - selectedZapType: LnZapEvent.ZapType, + selectedZapType: ZapReceiptEvent.ZapType, nip47Update: Nip47WalletConnect.Nip47URINorm?, ) = launchSigner { account.updateZapAmounts(amountSet, selectedZapType, nip47Update) } @@ -2848,7 +2848,7 @@ class AccountViewModel( } } - private suspend fun unwrapSeal(event: SealedRumorEvent): Note? { + private suspend fun unwrapSeal(event: SealEvent): Note? { val cacheInnerEventId = event.innerEventId return if (cacheInnerEventId != null) { val existingNoteEvent = LocalCache.getNoteIfExists(cacheInnerEventId)?.event @@ -2882,7 +2882,7 @@ class AccountViewModel( private suspend fun unwrapIfNeeded(event: Event): Note? = when (event) { is GiftWrapEvent -> unwrapGiftWrap(event) - is SealedRumorEvent -> unwrapSeal(event) + is SealEvent -> unwrapSeal(event) else -> LocalCache.getNoteIfExists(event.id) } @@ -2936,7 +2936,7 @@ class AccountViewModel( LocalCache.notes.maxOrNullOf( filter = { _, note -> val noteEvent = note.event - noteEvent is NIP90ContentDiscoveryResponseEvent && + noteEvent is DvmContentDiscoveryResponseEvent && noteEvent.pubKey == pubkeyHex && noteEvent.isTaggedUser(account.signer.pubKey) && noteEvent.createdAt > fifteenMinsAgo @@ -3005,13 +3005,13 @@ class AccountViewModel( onError: (String, String) -> Unit, onProgress: (percent: Float) -> Unit, context: Context, - zapType: LnZapEvent.ZapType? = null, + zapType: ZapReceiptEvent.ZapType? = null, ) { viewModelScope.launch(Dispatchers.IO) { try { val effectiveZapType = zapType ?: defaultZapType() val zapRequest = - if (effectiveZapType != LnZapEvent.ZapType.NONZAP) { + if (effectiveZapType != ZapReceiptEvent.ZapType.NONZAP) { // NIP-57 Appendix F: include amount + lnurl so the receipt can be validated. val splitLnurl = LnurlForm.toUrl(lnAddress)?.let(LnurlForm::urlToBech32) account.zaps.createZapRequestFor( 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 ab256b5804..794e1b3027 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 @@ -42,10 +42,10 @@ import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.PrivateZapCache -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.EphemeralGiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nipACWebRtcCalls.events.CallAnswerEvent @@ -112,9 +112,9 @@ class EventProcessor( is GiftWrapEvent -> giftWrapHandler.add(event, eventNote, publicNote) - is SealedRumorEvent -> sealHandler.add(event, eventNote, publicNote) + is SealEvent -> sealHandler.add(event, eventNote, publicNote) - is LnZapRequestEvent -> zapRequest.add(event, eventNote, publicNote) + is ZapRequestEvent -> zapRequest.add(event, eventNote, publicNote) } } @@ -153,9 +153,9 @@ class EventProcessor( is ChatroomKeyable -> chatHandler.delete(event, note) is DraftWrapEvent -> draftHandler.delete(event, note) is GiftWrapEvent -> giftWrapHandler.delete(event, note) - is SealedRumorEvent -> sealHandler.delete(event, note) - is LnZapRequestEvent -> zapRequest.delete(event, note) - is LnZapEvent -> zapEvent.delete(event, note) + is SealEvent -> sealHandler.delete(event, note) + is ZapRequestEvent -> zapRequest.delete(event, note) + is ZapReceiptEvent -> zapEvent.delete(event, note) } } @@ -457,9 +457,9 @@ class SealedRumorEventHandler( private val account: Account, private val cache: LocalCache, private val eventProcessor: EventProcessor, -) : EventHandler<SealedRumorEvent> { +) : EventHandler<SealEvent> { override suspend fun add( - event: SealedRumorEvent, + event: SealEvent, eventNote: Note, publicNote: Note, ) { @@ -477,7 +477,7 @@ class SealedRumorEventHandler( } override suspend fun delete( - event: SealedRumorEvent, + event: SealEvent, eventNote: Note, ) { event.innerEventId?.let { rumorId -> @@ -489,7 +489,7 @@ class SealedRumorEventHandler( } private suspend fun processNewSealedRumor( - event: SealedRumorEvent, + event: SealEvent, eventNote: Note, publicNote: Note, ) { @@ -538,9 +538,9 @@ class SealedRumorEventHandler( class LnZapRequestEventHandler( val decryptionCache: PrivateZapCache, -) : EventHandler<LnZapRequestEvent> { +) : EventHandler<ZapRequestEvent> { override suspend fun add( - event: LnZapRequestEvent, + event: ZapRequestEvent, eventNote: Note, publicNote: Note, ) { @@ -550,7 +550,7 @@ class LnZapRequestEventHandler( } override suspend fun delete( - event: LnZapRequestEvent, + event: ZapRequestEvent, eventNote: Note, ) { if (event.isPrivateZap()) { @@ -561,9 +561,9 @@ class LnZapRequestEventHandler( class LnZapEventHandler( val decryptionCache: PrivateZapCache, -) : EventHandler<LnZapEvent> { +) : EventHandler<ZapReceiptEvent> { override suspend fun delete( - event: LnZapEvent, + event: ZapReceiptEvent, eventNote: Note, ) { event.zapRequest?.let { req -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesFeedLoaded.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesFeedLoaded.kt index d2a3d6e0d5..13ab488bfd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesFeedLoaded.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesFeedLoaded.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.ChannelCardCompose -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent @Composable fun ArticlesFeedLoaded( @@ -61,7 +61,7 @@ fun ArticlesFeedLoaded( ChannelCardCompose( baseNote = item, modifier = Modifier.fillMaxWidth(), - forceEventKind = LongTextNoteEvent.KIND, + forceEventKind = LongFormContentEvent.KIND, accountViewModel = accountViewModel, nav = nav, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesTopBar.kt index 4163e6e015..922e4f8445 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/ArticlesTopBar.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.ui.navigation.topbars.UserDrawerSearchTopBar import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent @Composable fun ArticlesTopBar( @@ -49,7 +49,7 @@ fun ArticlesTopBar( // The feed's own kind window, plus whatever the list spinner narrowed it to — a hashtag or a // geohash says itself as a token; a follow set does not, and seeds nothing (see asSearchQuery). val me = accountViewModel.userProfile().pubkeyHex - val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(LongTextNoteEvent.KIND), list.asSearchQuery(me)) } + val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(LongFormContentEvent.KIND), list.asSearchQuery(me)) } UserDrawerSearchTopBar(accountViewModel, nav, seed) { ArticlesTopNavFilterBar( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/dal/ArticlesFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/dal/ArticlesFeedFilter.kt index 5ec4bd4976..7bea4bb080 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/dal/ArticlesFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/articles/dal/ArticlesFeedFilter.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent class ArticlesFeedFilter( val account: Account, @@ -50,9 +50,9 @@ class ArticlesFeedFilter( override fun feed(): List<Note> { val params = buildFilterParams(account) val notes = - LocalCache.addressables.filterIntoSet(LongTextNoteEvent.KIND) { _, it -> + LocalCache.addressables.filterIntoSet(LongFormContentEvent.KIND) { _, it -> val noteEvent = it.event - noteEvent is LongTextNoteEvent && params.match(noteEvent, it.relays) + noteEvent is LongFormContentEvent && params.match(noteEvent, it.relays) } return sort(notes) } @@ -70,7 +70,7 @@ class ArticlesFeedFilter( return collection.filterTo(HashSet()) { val noteEvent = it.event - noteEvent is LongTextNoteEvent && params.match(noteEvent, it.relays) + noteEvent is LongFormContentEvent && params.match(noteEvent, it.relays) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt index 55473cce27..6587568294 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt @@ -92,9 +92,9 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.diff.ContentChange import com.vitorpamplona.quartz.nip01Core.diff.ListDiff import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListDiff -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.list.channels import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent @@ -103,10 +103,10 @@ import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFee import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListDiff import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListDiff -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayListDiff import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletDiff @@ -137,7 +137,7 @@ internal fun LazyListScope.listDiffItems( is CommunityListDiff -> communityItems(diff, conflict, accountViewModel, nav) is EphemeralChatListDiff -> ephemeralRoomItems(diff, conflict, nav) is FavoriteAlgoFeedsListDiff -> favoriteFeedItems(diff, conflict, accountViewModel, nav) - is HashtagListDiff -> topicItems(diff.hashtags, (conflict.saved as? HashtagListEvent)?.publicHashtags().orEmpty(), diff.privateItems, isPlace = false, nav) + is HashtagListDiff -> topicItems(diff.hashtags, (conflict.saved as? InterestListEvent)?.publicHashtags().orEmpty(), diff.privateItems, isPlace = false, nav) is GeohashListDiff -> topicItems(diff.geohashes, (conflict.saved as? GeohashListEvent)?.publicGeohashes().orEmpty(), diff.privateItems, isPlace = true, nav) is TrustProviderListDiff -> trustProviderItems(diff, conflict, accountViewModel, nav) is PaymentTargetsDiff -> paymentTargetItems(diff, conflict) @@ -236,11 +236,11 @@ private fun framingOf(type: BackupEventType): RelayFraming = private fun savedRelaysOf(event: Event): List<NormalizedRelayUrl> = when (event) { - is ChatMessageRelayListEvent -> event.relays() + is DmRelayListEvent -> event.relays() is KeyPackageRelayListEvent -> event.relays() is SearchRelayListEvent -> event.publicRelays() is IndexerRelayListEvent -> event.publicRelays() - is RelayFeedsListEvent -> event.publicRelays() + is FavoriteRelayListEvent -> event.publicRelays() is BlockedRelayListEvent -> event.publicRelays() is TrustedRelayListEvent -> event.publicRelays() is PrivateOutboxRelayListEvent -> event.publicRelays() @@ -451,7 +451,7 @@ private fun LazyListScope.publicChatItems( accountViewModel: AccountViewModel, nav: INav, ) { - val saved = (conflict.saved as? ChannelListEvent)?.tags?.channels().orEmpty() + val saved = (conflict.saved as? PublicChatListEvent)?.tags?.channels().orEmpty() spaceGrid("chat-", fates(saved, diff.channels) { it.eventId }, { it.eventId }) { tag, fate, modifier -> LoadPublicChatChannel(tag.eventId) { channel -> // Subscribes to the channel's metadata on relays and recomposes when it arrives. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupItemOptions.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupItemOptions.kt index b2a31af51a..4c31575212 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupItemOptions.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupItemOptions.kt @@ -75,7 +75,7 @@ import com.vitorpamplona.amethyst.ui.note.types.EditState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.report.ReportNoteDialog import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -281,7 +281,7 @@ fun BookmarkGroupItemOptionsMenu( wantsToEditPost.value = true } } - } else if (note.event is LongTextNoteEvent && state.isLoggedUser) { + } else if (note.event is LongFormContentEvent && state.isLoggedUser) { M3ActionRow(icon = MaterialSymbols.Edit, text = stringRes(Res.string.edit_article)) { nav.nav { Route.NewLongFormPost(version = note.idHex) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsTopBar.kt index 996453f5e7..c5c54cff10 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsTopBar.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.ui.navigation.topbars.UserDrawerSearchTopBar import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent @Composable fun CalendarCollectionsTopBar( @@ -49,7 +49,7 @@ fun CalendarCollectionsTopBar( // The feed's own kind window, plus whatever the list spinner narrowed it to — a hashtag // or a geohash says itself as a token; a follow set does not, and seeds nothing. val me = accountViewModel.userProfile().pubkeyHex - val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(CalendarEvent.KIND), list.asSearchQuery(me)) } + val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(CalendarCollectionEvent.KIND), list.asSearchQuery(me)) } UserDrawerSearchTopBar(accountViewModel, nav, seed) { CalendarCollectionsTopNavFilterBar( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt index 644d10c45e..ea7cc7c295 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt @@ -76,7 +76,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.UserCardHeader import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.utils.TimeUtils @Composable @@ -153,7 +153,7 @@ fun CalendarCollectionCard( accountViewModel: AccountViewModel, nav: INav, ) { - val event = note.event as? CalendarEvent ?: return + val event = note.event as? CalendarCollectionEvent ?: return val title = remember(note.idHex) { event.title() } val description = remember(note.idHex) { event.content.take(180) } val count = remember(note.idHex) { event.calendarEventAddresses().size } @@ -241,7 +241,7 @@ fun CalendarCollectionCard( * arrived from relays yet or aren't appointments. Returns a list compatible with * [IcsExport.calendarToIcs]. */ -private fun collectMembers(calendar: CalendarEvent): List<Pair<Address, Any>> = +private fun collectMembers(calendar: CalendarCollectionEvent): List<Pair<Address, Any>> = calendar .calendarEventAddresses() .mapNotNull { addr -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarsViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarsViewModel.kt index dc74d818fa..5b41ea50f8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarsViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarsViewModel.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.amethyst.commons.model.nip52Calendar.groupByDayKeyExpan import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow @@ -162,13 +162,13 @@ class CalendarsViewModel : ViewModel() { * changes about once a week. */ @OptIn(ExperimentalCoroutinesApi::class) - val ownCalendars: StateFlow<List<CalendarEvent>> = + val ownCalendars: StateFlow<List<CalendarCollectionEvent>> = inputs .filterNotNull() .flatMapLatest { (myPubKey, _) -> LocalCache - .observeEvents<CalendarEvent>( - Filter(kinds = listOf(CalendarEvent.KIND), authors = listOf(myPubKey)), + .observeEvents<CalendarCollectionEvent>( + Filter(kinds = listOf(CalendarCollectionEvent.KIND), authors = listOf(myPubKey)), ).map { calendars -> calendars.sortedBy { it.title()?.lowercase() ?: "" } } } // The seed scan inside observeEvents walks the whole notes cache (LocalCache.filter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt index 62fc41a72a..f389c7a9c1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag import com.vitorpamplona.quartz.nip01Core.tags.aTag.aTags import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -62,7 +62,7 @@ class NewCalendarCollectionViewModel : ViewModel() { private var dTag: String? = null /** The full original event in edit mode; needed to publish a NIP-09 deletion. */ - private var loadedEvent: com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent? = null + private var loadedEvent: com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent? = null val selectedAddresses = mutableStateListOf<Address>() val availableAppointments = mutableStateOf<List<OwnedAppointmentSummary>>(emptyList()) @@ -81,9 +81,9 @@ class NewCalendarCollectionViewModel : ViewModel() { dTag = editDTag editDTag?.let { existingDTag -> - val existingAddress = Address(CalendarEvent.KIND, account.userProfile().pubkeyHex, existingDTag) + val existingAddress = Address(CalendarCollectionEvent.KIND, account.userProfile().pubkeyHex, existingDTag) val existingNote = LocalCache.addressables.get(existingAddress) - (existingNote?.event as? CalendarEvent)?.let { existing -> + (existingNote?.event as? CalendarCollectionEvent)?.let { existing -> loadedEvent = existing title.value = existing.title().orEmpty() description.value = existing.content @@ -140,7 +140,7 @@ class NewCalendarCollectionViewModel : ViewModel() { account.signAndComputeBroadcast( if (effectiveDTag != null) { - CalendarEvent.build( + CalendarCollectionEvent.build( title = parsedTitle, content = parsedDescription, dTag = effectiveDTag, @@ -148,7 +148,7 @@ class NewCalendarCollectionViewModel : ViewModel() { if (selected.isNotEmpty()) aTags(selected.map { ATag(it) }) } } else { - CalendarEvent.build( + CalendarCollectionEvent.build( title = parsedTitle, content = parsedDescription, ) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/dal/CalendarCollectionsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/dal/CalendarCollectionsFeedFilter.kt index c26935be56..7396b10d5a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/dal/CalendarCollectionsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/dal/CalendarCollectionsFeedFilter.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent class CalendarCollectionsFeedFilter( val account: Account, @@ -49,7 +49,7 @@ class CalendarCollectionsFeedFilter( val notes = LocalCache.addressables.filterIntoSet { _, it -> val e = it.event - e is CalendarEvent && params.match(e, it.relays) + e is CalendarCollectionEvent && params.match(e, it.relays) } return sort(notes) } @@ -66,7 +66,7 @@ class CalendarCollectionsFeedFilter( val params = buildFilterParams(account) return collection.filterTo(HashSet()) { val e = it.event - e is CalendarEvent && params.match(e, it.relays) + e is CalendarCollectionEvent && params.match(e, it.relays) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/AddToCalendarSheet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/AddToCalendarSheet.kt index 8f9deda35d..6d878afb92 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/AddToCalendarSheet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/AddToCalendarSheet.kt @@ -53,7 +53,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.tags.aTag.ATag import com.vitorpamplona.quartz.nip01Core.tags.aTag.aTags -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent /** * Bottom sheet that lists the current user's own kind-31924 calendars with a checkbox per @@ -74,7 +74,7 @@ fun AddToCalendarSheet( val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) val myPubKey = accountViewModel.userProfile().pubkeyHex - val ownCalendars by produceState<List<CalendarEvent>>(initialValue = ownCalendars(myPubKey), myPubKey) { + val ownCalendars by produceState<List<CalendarCollectionEvent>>(initialValue = ownCalendars(myPubKey), myPubKey) { LocalCache.live.newEventBundles.collect { value = ownCalendars(myPubKey) } @@ -152,17 +152,17 @@ private fun CalendarPickerRow( } } -private fun ownCalendars(myPubKey: String): List<CalendarEvent> = +private fun ownCalendars(myPubKey: String): List<CalendarCollectionEvent> = LocalCache.addressables .filterIntoSet { _, note -> val e = note.event - e is CalendarEvent && e.pubKey == myPubKey - }.mapNotNull { it.event as? CalendarEvent } + e is CalendarCollectionEvent && e.pubKey == myPubKey + }.mapNotNull { it.event as? CalendarCollectionEvent } .sortedBy { it.title()?.lowercase() ?: "" } private fun toggleMembership( accountViewModel: AccountViewModel, - calendar: CalendarEvent, + calendar: CalendarCollectionEvent, targetAddress: Address, isCurrentlyMember: Boolean, ) { @@ -177,7 +177,7 @@ private fun toggleMembership( } accountViewModel.launchSigner { accountViewModel.account.signAndComputeBroadcast( - CalendarEvent.build( + CalendarCollectionEvent.build( title = calendar.title().orEmpty(), content = calendar.content, dTag = calendar.dTag(), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/CalendarEventDetailScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/CalendarEventDetailScreen.kt index beece330fa..3072750bd7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/CalendarEventDetailScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/detail/CalendarEventDetailScreen.kt @@ -116,7 +116,7 @@ import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.tags.RSVPStatusTag import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.Dispatchers @@ -287,7 +287,7 @@ fun CalendarEventDetailScreen( targetAddress = targetAddress, ) - is CalendarEvent -> + is CalendarCollectionEvent -> CollectionBody( note = targetNote, accountViewModel = accountViewModel, @@ -432,7 +432,7 @@ private fun CollectionBody( nav: INav, targetAddress: Address, ) { - val event = note.event as? CalendarEvent ?: return + val event = note.event as? CalendarCollectionEvent ?: return val title = remember(note.idHex) { event.title() } val memberAddresses = remember(note.idHex) { event.calendarEventAddresses() } @@ -736,7 +736,7 @@ private fun InCalendarsSection( .clickable { nav.nav( Route.CalendarEventDetail( - kind = CalendarEvent.KIND, + kind = CalendarCollectionEvent.KIND, pubKeyHex = calendar.pubKey, dTag = calendar.dTag(), ), @@ -889,11 +889,11 @@ private fun rememberRsvpsFor(targetAddress: Address): State<List<CalendarRSVPEve } @Composable -private fun rememberCalendarsContaining(targetAddress: Address): State<List<CalendarEvent>> { +private fun rememberCalendarsContaining(targetAddress: Address): State<List<CalendarCollectionEvent>> { val calendars = remember(targetAddress) { LocalCache - .observeEvents<CalendarEvent>(Filter(kinds = listOf(CalendarEvent.KIND))) + .observeEvents<CalendarCollectionEvent>(Filter(kinds = listOf(CalendarCollectionEvent.KIND))) .map { all -> all .filter { it.calendarEventAddresses().contains(targetAddress) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatMessageCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatMessageCompose.kt index ccb19c4c2d..9ecb9c8776 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatMessageCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatMessageCompose.kt @@ -87,7 +87,7 @@ import com.vitorpamplona.quartz.buzz.stream.SystemMessageEvent import com.vitorpamplona.quartz.concord.cord03Channels.ConcordChatEditEvent import com.vitorpamplona.quartz.marmot.foundation.appEvents.MarmotAppEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.BaseNoteEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent @@ -97,7 +97,7 @@ import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip53LiveActivities.raid.LiveActivitiesRaidEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.splits.hasZapSplitSetup import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiserAmount @@ -156,7 +156,7 @@ fun ChatroomMessageCompose( } val event = baseNote.event - if (event is LnZapEvent) { + if (event is ZapReceiptEvent) { RenderChatZap(baseNote, accountViewModel, nav) } else if (event is LiveActivitiesRaidEvent) { RenderChatRaid(baseNote, accountViewModel, nav) @@ -248,10 +248,10 @@ fun NormalChatNote( when { // Own messages: normally no name; in a multi-identity chat, show it (unless a DM, // which never draws the user's own author info). - isLoggedInUser -> showSelfAuthorName && noteEvent !is PrivateDmEvent + isLoggedInUser -> showSelfAuthorName && noteEvent !is EncryptedDmEvent // never shows the user's pictures - noteEvent is PrivateDmEvent -> false + noteEvent is EncryptedDmEvent -> false // one-on-one, never shows it. // only shows in a group chat. @@ -588,7 +588,7 @@ private fun RenderReply( is ChatMessageEvent, is ChatMessageEncryptedFileHeaderEvent -> { { LoadingReplyNote(DmReplyProtocol.NIP17, accountViewModel) } } - is PrivateDmEvent -> { + is EncryptedDmEvent -> { { LoadingReplyNote(DmReplyProtocol.NIP04, accountViewModel) } } else -> null diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatTimeAgo.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatTimeAgo.kt index 7f0627d365..3f0c1a3f0d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatTimeAgo.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/ChatTimeAgo.kt @@ -51,7 +51,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.ToggleableTimeAgoText import com.vitorpamplona.amethyst.ui.note.timeAheadNoDot import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.tags.geohash.geoHashOrScope -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip13Pow.strongPoWOrNull import com.vitorpamplona.quartz.nip40Expiration.expiration @@ -84,7 +84,7 @@ fun chatFooterHasMeta( ): Boolean { val event = note.event ?: return false val geo = event.geoHashOrScope() - return event is PrivateDmEvent || + return event is EncryptedDmEvent || event.expiration() != null || (geo != null && geo != suppressGeohash) || event.strongPoWOrNull() != null || @@ -132,7 +132,7 @@ fun ChatMessageFooter( } if (showTime) { - val hasGlyph = note.isPinnedInRelayGroup() || event is PrivateDmEvent || event?.expiration() != null || geo != null || pow != null + val hasGlyph = note.isPinnedInRelayGroup() || event is EncryptedDmEvent || event?.expiration() != null || geo != null || pow != null if (hasGlyph) Spacer(StdHorzSpacer) // Drafts aren't published, so no relay/delivery detail; everything else gets diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/layouts/ChatGroupPosition.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/layouts/ChatGroupPosition.kt index d942a54dd9..fbbf82afd3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/layouts/ChatGroupPosition.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/layouts/ChatGroupPosition.kt @@ -41,7 +41,7 @@ import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip53LiveActivities.raid.LiveActivitiesRaidEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlin.math.abs /** @@ -96,7 +96,7 @@ internal const val CHAT_GROUP_WINDOW_SECONDS = 10 * 60L */ private fun isGroupableEvent(event: Event?): Boolean = event != null && - event !is LnZapEvent && + event !is ZapReceiptEvent && event !is LiveActivitiesRaidEvent && event !is LiveActivitiesClipEvent && event !is ChannelCreateEvent && diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderChatZap.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderChatZap.kt index ee5645fa71..c52b22a690 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderChatZap.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderChatZap.kt @@ -55,7 +55,7 @@ import com.vitorpamplona.amethyst.ui.note.UsernameDisplay import com.vitorpamplona.amethyst.ui.note.ZapAmountCommentNotification import com.vitorpamplona.amethyst.ui.note.showAmountInteger import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent private const val BIG_ZAP_THRESHOLD_SATS = 50_000L @@ -65,7 +65,7 @@ fun RenderChatZap( accountViewModel: AccountViewModel, nav: INav, ) { - val zapEvent = baseNote.event as? LnZapEvent ?: return + val zapEvent = baseNote.event as? ZapReceiptEvent ?: return val card by produceState( ZapAmountCommentNotification(user = null, comment = null, amount = null), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/geohashChat/GeohashChatViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/geohashChat/GeohashChatViewModel.kt index e653bad481..7a40654504 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/geohashChat/GeohashChatViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/geohashChat/GeohashChatViewModel.kt @@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow @@ -122,7 +122,7 @@ class GeohashChatViewModel : ViewModel() { val signer = NostrSignerInternal(keyPair) val template = if (mine.isNotEmpty()) { - DeletionEvent.build(mine) + DeletionRequestEvent.build(mine) } else { val hint = note.toEventHint<Event>() ?: return@launch ReactionEvent.build(reaction, hint) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt index 4a9c15f240..14f7c0528b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/ChatroomView.kt @@ -71,7 +71,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.paging.RelayPagingProgress import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.delay @@ -130,7 +130,7 @@ fun ChatroomView( // Reactively check if recipients have DM relays for NIP-17 delivery for (userHex in room.users) { LoadAddressableNote( - ChatMessageRelayListEvent.createAddress(userHex), + DmRelayListEvent.createAddress(userHex), ) { note -> if (note != null) { EventFinderFilterAssemblerSubscription(note, accountViewModel) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt index c203189fd2..2254624aee 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/datasource/FilterNip04DMs.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent /** @@ -114,7 +114,7 @@ private fun toMeFilter( filter = ExplainedFilter( purpose = SubPurpose.DIRECT_MESSAGES, - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), authors = authors.toList(), tags = mapOf("p" to listOf(account.userProfile().pubkeyHex)), since = since, @@ -135,7 +135,7 @@ private fun fromMeFilter( filter = ExplainedFilter( purpose = SubPurpose.DIRECT_MESSAGES, - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), authors = listOf(account.userProfile().pubkeyHex), tags = mapOf("p" to pTags.toList()), since = since, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt index 3bb0e5dce0..ca797a2b12 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt @@ -68,7 +68,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.geohash.geohash import com.vitorpamplona.quartz.nip01Core.tags.geohash.getGeoHash import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtags import com.vitorpamplona.quartz.nip01Core.tags.references.references -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.content.findHashtags import com.vitorpamplona.quartz.nip10Notes.content.findNostrEventUris import com.vitorpamplona.quartz.nip10Notes.content.findURLs @@ -78,7 +78,7 @@ import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey import com.vitorpamplona.quartz.nip17Dm.base.NIP17Group import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.quotes.quotes import com.vitorpamplona.quartz.nip19Bech32.toNpub import com.vitorpamplona.quartz.nip30CustomEmoji.emojis @@ -184,7 +184,7 @@ class ChatNewMessageViewModel : combine(dmRelayListNoteFlows) { dmRelayListNotes -> dmRelayListNotes .mapNotNull { noteState -> - val noteEvent = noteState.note.event as? ChatMessageRelayListEvent + val noteEvent = noteState.note.event as? DmRelayListEvent if (noteEvent == null || noteEvent.relays().isEmpty()) { noteState.note.author } else { @@ -409,7 +409,7 @@ class ChatNewMessageViewModel : if (replyId != null) { replyTo.value = LocalCache.checkGetOrCreateNote(replyId) } - } else if (draftEvent is PrivateDmEvent) { + } else if (draftEvent is EncryptedDmEvent) { val recipientNPub = draftEvent.verifiedRecipientPubKey()?.let { Hex.decode(it).toNpub() } toUsers.setTextAndPlaceCursorAtEnd("@$recipientNPub") @@ -420,7 +420,7 @@ class ChatNewMessageViewModel : } val draftText = - if (draftEvent is PrivateDmEvent) { + if (draftEvent is EncryptedDmEvent) { accountViewModel.account.privateDMDecryptionCache.cachedDM(draftEvent) ?: "" } else { draftEvent.content diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/header/LiveStreamGoalHeader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/header/LiveStreamGoalHeader.kt index 8ff9d9a3fd..c8f2739522 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/header/LiveStreamGoalHeader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/nip53LiveActivities/header/LiveStreamGoalHeader.kt @@ -48,7 +48,7 @@ import com.vitorpamplona.amethyst.ui.components.LoadNote import com.vitorpamplona.amethyst.ui.note.ZapReaction import com.vitorpamplona.amethyst.ui.note.types.GoalProgressBar import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent /** * Compact header rendered above the live-activity chat feed when the stream @@ -76,7 +76,7 @@ private fun GoalHeaderContent( accountViewModel: AccountViewModel, nav: INav, ) { - val goal = goalNote.event as? GoalEvent ?: return + val goal = goalNote.event as? ZapGoalEvent ?: return val title = remember(goal) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListKnownFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListKnownFeedFilter.kt index ad3d06dcbd..1ba516916f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListKnownFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListKnownFeedFilter.kt @@ -43,7 +43,7 @@ import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent @@ -59,8 +59,8 @@ class ChatroomListKnownFeedFilter( private fun isEnabled(type: ChatFeedType): Boolean = type in account.settings.enabledChatFeeds.value - /** A room note is NIP-04 when its event is a [PrivateDmEvent], otherwise it is a NIP-17 message. */ - private fun isDmEnabled(note: Note): Boolean = isEnabled(if (note.event is PrivateDmEvent) ChatFeedType.NIP04 else ChatFeedType.NIP17) + /** A room note is NIP-04 when its event is a [EncryptedDmEvent], otherwise it is a NIP-17 message. */ + private fun isDmEnabled(note: Note): Boolean = isEnabled(if (note.event is EncryptedDmEvent) ChatFeedType.NIP04 else ChatFeedType.NIP17) // returns the last Note of each user. override fun feed(): List<Note> { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListNewFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListNewFeedFilter.kt index 86acd5c0cf..14ef60fd83 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListNewFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/dal/ChatroomListNewFeedFilter.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.model.chats.ChatFeedType import com.vitorpamplona.amethyst.commons.util.replace import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable @@ -38,8 +38,8 @@ class ChatroomListNewFeedFilter( private fun isEnabled(type: ChatFeedType): Boolean = type in account.settings.enabledChatFeeds.value - /** A room note is NIP-04 when its event is a [PrivateDmEvent], otherwise it is a NIP-17 message. */ - private fun isDmEnabled(note: Note): Boolean = isEnabled(if (note.event is PrivateDmEvent) ChatFeedType.NIP04 else ChatFeedType.NIP17) + /** A room note is NIP-04 when its event is a [EncryptedDmEvent], otherwise it is a NIP-17 message. */ + private fun isDmEnabled(note: Note): Boolean = isEnabled(if (note.event is EncryptedDmEvent) ChatFeedType.NIP04 else ChatFeedType.NIP17) // returns the last Note of each user. override fun feed(): List<Note> { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt index 534ddcbb6e..516c98b011 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent fun filterNip04DMsFromMe( user: User, @@ -39,7 +39,7 @@ fun filterNip04DMsFromMe( filter = ExplainedFilter( purpose = SubPurpose.DIRECT_MESSAGES, - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), authors = listOf(user.pubkeyHex), since = since, until = until, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt index 4ebe2b0077..d7b68ba331 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent fun filterNip04DMsToMe( user: User, @@ -39,7 +39,7 @@ fun filterNip04DMsToMe( filter = ExplainedFilter( purpose = SubPurpose.DIRECT_MESSAGES, - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), tags = mapOf("p" to listOf(user.pubkeyHex)), since = since, until = until, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt index eefcbb1888..502d424d8c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/feed/ChatroomListFeedView.kt @@ -70,7 +70,7 @@ import com.vitorpamplona.quartz.experimental.ephemChat.chat.EphemeralChatEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.paging.RelayPagingProgress import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent @@ -180,8 +180,8 @@ private fun FeedLoaded( val user = accountViewModel.userProfile() val nip17Name = stringRes(Res.string.chats_history_proto_nip17) val nip04Name = stringRes(Res.string.chats_history_proto_nip04) - val oldestNip17Index = items.list.indexOfLast { it.event is ChatroomKeyable && it.event !is PrivateDmEvent } - val oldestNip04Index = items.list.indexOfLast { it.event is PrivateDmEvent } + val oldestNip17Index = items.list.indexOfLast { it.event is ChatroomKeyable && it.event !is EncryptedDmEvent } + val oldestNip04Index = items.list.indexOfLast { it.event is EncryptedDmEvent } // Each relay's window limit, carrying the advance() that pulls its OWN next page. Placed in the list // at its reached depth as a sentinel (see RelayReachMarkers): a relay pages only while its diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt index dc20c61fcd..b6eb04d860 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt @@ -43,9 +43,9 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip53LiveActivitie import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip72Communities.RenderCommunitiesThumb import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.RenderContentDVMThumb import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.RenderClassifiedsThumb -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent @@ -157,8 +157,8 @@ fun InnerChannelCardWithReactions( is ChannelCreateEvent -> InnerCardRow(baseNote, accountViewModel, nav) is ClassifiedsEvent -> InnerCardBox(baseNote, accountViewModel, nav) is AppDefinitionEvent -> InnerCardRow(baseNote, accountViewModel, nav) - is FollowListEvent -> InnerCardRow(baseNote, accountViewModel, nav) - is LongTextNoteEvent -> InnerCardRow(baseNote, accountViewModel, nav) + is StarterPackEvent -> InnerCardRow(baseNote, accountViewModel, nav) + is LongFormContentEvent -> InnerCardRow(baseNote, accountViewModel, nav) } } @@ -211,7 +211,7 @@ private fun RenderNoteRow( is CommunityDefinitionEvent -> RenderCommunitiesThumb(baseNote, accountViewModel, nav) is ChannelCreateEvent -> RenderPublicChatChannelThumb(baseNote, accountViewModel, nav) is AppDefinitionEvent -> RenderContentDVMThumb(baseNote, accountViewModel, nav) - is FollowListEvent -> RenderFollowSetThumb(baseNote, accountViewModel, nav) - is LongTextNoteEvent -> RenderLongFormThumb(baseNote, accountViewModel, nav) + is StarterPackEvent -> RenderFollowSetThumb(baseNote, accountViewModel, nav) + is LongFormContentEvent -> RenderLongFormThumb(baseNote, accountViewModel, nav) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt index bb061315f3..5d28a436a8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt @@ -86,9 +86,9 @@ import com.vitorpamplona.amethyst.ui.navigation.bottombars.AppBottomBar import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource.DiscoveryFilterAssemblerSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.TabItem -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent @@ -140,14 +140,14 @@ fun DiscoverScreen( discoveryFollowSetsFeedContentState, "DiscoverFollowSets", ScrollStateKeys.DISCOVER_FOLLOWS, - FollowListEvent.KIND, + StarterPackEvent.KIND, ), TabItem( Res.string.discover_reads, discoveryReadsFeedContentState, "DiscoverReads", ScrollStateKeys.DISCOVER_READS, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, ), TabItem( Res.string.discover_content_v2, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/DiscoverLongFormFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/DiscoverLongFormFeedFilter.kt index 4ac6cca8ed..33fdf104ce 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/DiscoverLongFormFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/DiscoverLongFormFeedFilter.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent open class DiscoverLongFormFeedFilter( val account: Account, @@ -50,9 +50,9 @@ open class DiscoverLongFormFeedFilter( override fun feed(): List<Note> { val params = buildFilterParams(account) val notes = - LocalCache.addressables.filterIntoSet(LongTextNoteEvent.KIND) { _, it -> + LocalCache.addressables.filterIntoSet(LongFormContentEvent.KIND) { _, it -> val noteEvent = it.event - noteEvent is LongTextNoteEvent && params.match(noteEvent, it.relays) + noteEvent is LongFormContentEvent && params.match(noteEvent, it.relays) } return sort(notes) } @@ -70,7 +70,7 @@ open class DiscoverLongFormFeedFilter( return collection.filterTo(HashSet()) { val noteEvent = it.event - noteEvent is LongTextNoteEvent && params.match(noteEvent, it.relays) + noteEvent is LongFormContentEvent && params.match(noteEvent, it.relays) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormCard.kt index 226c1c0675..e780927f4a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormCard.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteEvent import com.vitorpamplona.amethyst.ui.note.types.LongFormHeader import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent @Composable fun RenderLongFormThumb( @@ -35,7 +35,7 @@ fun RenderLongFormThumb( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent by observeNoteEvent<LongTextNoteEvent>(baseNote, accountViewModel) + val noteEvent by observeNoteEvent<LongFormContentEvent>(baseNote, accountViewModel) noteEvent?.let { LongFormHeader( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormPostViewModel.kt index d03ab0074b..e076080373 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/LongFormPostViewModel.kt @@ -91,7 +91,7 @@ import com.vitorpamplona.quartz.nip10Notes.content.findNostrUris import com.vitorpamplona.quartz.nip10Notes.content.findURLs import com.vitorpamplona.quartz.nip18Reposts.quotes.quotes import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip30CustomEmoji.emojis import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarningReason @@ -266,7 +266,7 @@ class LongFormPostViewModel : } else { val noteEvent = version?.event - if (noteEvent is LongTextNoteEvent) { + if (noteEvent is LongFormContentEvent) { title = TextFieldValue(noteEvent.title() ?: "") summary = TextFieldValue(noteEvent.summary() ?: "") publishedAt = noteEvent.publishedAt() ?: noteEvent.createdAt @@ -300,12 +300,12 @@ class LongFormPostViewModel : private fun loadFromDraft(draft: Note) { val draftEvent = draft.event ?: return - if (draftEvent is LongTextNoteEvent) { + if (draftEvent is LongFormContentEvent) { loadFromDraft(draftEvent) } } - private fun loadFromDraft(draftEvent: LongTextNoteEvent) { + private fun loadFromDraft(draftEvent: LongFormContentEvent) { title = TextFieldValue(draftEvent.title() ?: "") summary = TextFieldValue(draftEvent.summary() ?: "") publishedAt = draftEvent.publishedAt() ?: draftEvent.createdAt @@ -441,7 +441,7 @@ class LongFormPostViewModel : val contentWarningReason = if (wantsToMarkAsSensitive) contentWarningDescription else null val localExpirationDate = if (wantsExpirationDate) expirationDate else null - return LongTextNoteEvent.build( + return LongFormContentEvent.build( description = tagger.message, title = title.text.trim(), summary = summary.text.trim().ifBlank { null }, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt index 13de523110..2e09975f62 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent open class DiscoverFollowSetsFeedFilter( val account: Account, @@ -49,9 +49,9 @@ open class DiscoverFollowSetsFeedFilter( val params = buildFilterParams(account) val notes = - LocalCache.addressables.filterIntoSet(FollowListEvent.KIND) { _, it -> + LocalCache.addressables.filterIntoSet(StarterPackEvent.KIND) { _, it -> val noteEvent = it.event - noteEvent is FollowListEvent && params.match(noteEvent, it.relays) + noteEvent is StarterPackEvent && params.match(noteEvent, it.relays) } return sort(notes) @@ -70,7 +70,7 @@ open class DiscoverFollowSetsFeedFilter( return collection.filterTo(HashSet()) { val noteEvent = it.event - noteEvent is FollowListEvent && params.match(noteEvent, it.relays) + noteEvent is StarterPackEvent && params.match(noteEvent, it.relays) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt index 282e4abe69..d7399581f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt @@ -63,7 +63,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageBannerBackground import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList @@ -82,7 +82,7 @@ fun RenderFollowSetThumb( nav: INav, ) { val card by observeNoteAndMap(baseNote, accountViewModel) { - val noteEvent = it.event as? FollowListEvent + val noteEvent = it.event as? StarterPackEvent FollowSetCard( name = noteEvent?.title()?.ifBlank { null } ?: noteEvent?.dTag() ?: "", @@ -111,7 +111,7 @@ fun RenderFollowSetThumbPreview() { val nav = EmptyNav() val followCard = - FollowListEvent( + StarterPackEvent( id = "eca31634fce7c9068b56fa8db9f387da70bdcceb3986a77ca1a9844f3128eb5f", pubKey = "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da", createdAt = 1761736286, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt index 5bcbfa664a..ef283a4950 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt @@ -92,8 +92,8 @@ import com.vitorpamplona.quartz.lightning.LnInvoiceUtil import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppMetadata -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent import kotlinx.coroutines.launch @Composable @@ -190,9 +190,9 @@ fun ObserverContentDiscoveryResponse( val resultFlow = remember(dvmRequestId) { accountViewModel.account.cache - .observeLatestEvent<NIP90ContentDiscoveryResponseEvent>( + .observeLatestEvent<DvmContentDiscoveryResponseEvent>( Filter( - kinds = listOf(NIP90ContentDiscoveryResponseEvent.KIND), + kinds = listOf(DvmContentDiscoveryResponseEvent.KIND), tags = mapOf("e" to listOf(dvmRequestId.idHex)), limit = 1, ), @@ -231,9 +231,9 @@ fun ObserverDvmStatusResponse( val statusFlow = remember(dvmRequestId) { accountViewModel.account.cache - .observeLatestEvent<NIP90StatusEvent>( + .observeLatestEvent<DvmStatusEvent>( Filter( - kinds = listOf(NIP90StatusEvent.KIND), + kinds = listOf(DvmStatusEvent.KIND), tags = mapOf("e" to listOf(dvmRequestId)), limit = 1, ), @@ -258,7 +258,7 @@ fun ObserverDvmStatusResponse( fun PrepareViewContentDiscoveryModels( dvm: User, dvmRequestId: String, - latestResponse: NIP90ContentDiscoveryResponseEvent, + latestResponse: DvmContentDiscoveryResponseEvent, onRefresh: () -> Unit, accountViewModel: AccountViewModel, nav: INav, @@ -303,7 +303,7 @@ fun RenderNostrNIP90ContentDiscoveryScreen( @Composable fun FeedDVM( appDefinitionNote: Note, - latestStatus: NIP90StatusEvent, + latestStatus: DvmStatusEvent, accountViewModel: AccountViewModel, nav: INav, ) { @@ -374,7 +374,7 @@ fun FeedDVM( @Composable fun DvmPaymentActions( - latestStatus: NIP90StatusEvent, + latestStatus: DvmStatusEvent, accountViewModel: AccountViewModel, nav: INav, onStatusUpdate: (String) -> Unit, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteAlgoFeedToggle.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteAlgoFeedToggle.kt index 1f0670563d..2eb0e01e0b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteAlgoFeedToggle.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/FavoriteAlgoFeedToggle.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNo import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent /** * Inline star toggle that follows / unfollows a NIP-90 content-discovery DVM. @@ -60,7 +60,7 @@ fun FavoriteAlgoFeedToggle( ) { val supportsContentDiscovery by observeNoteAndMap(appDefinitionNote, accountViewModel) { note -> - (note.event as? AppDefinitionEvent)?.includeKind(NIP90ContentDiscoveryRequestEvent.KIND) == true + (note.event as? AppDefinitionEvent)?.includeKind(DvmContentDiscoveryRequestEvent.KIND) == true } if (!supportsContentDiscovery) return diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryResponseFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryResponseFilter.kt index 286a7e321a..acb70c2ab0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryResponseFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryResponseFilter.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.model.observables.CreatedAtComparator import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.quartz.nip01Core.tags.events.isTaggedEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent open class NIP90ContentDiscoveryResponseFilter( val account: Account, @@ -40,7 +40,7 @@ open class NIP90ContentDiscoveryResponseFilter( fun acceptableEvent(note: Note): Boolean { val noteEvent = note.event - return noteEvent is NIP90ContentDiscoveryResponseEvent && noteEvent.isTaggedEvent(request) + return noteEvent is DvmContentDiscoveryResponseEvent && noteEvent.isTaggedEvent(request) } override fun feed(): List<Note> { @@ -54,7 +54,7 @@ open class NIP90ContentDiscoveryResponseFilter( comparator = CreatedAtComparator, ) - val noteEvent = latestNote?.event as? NIP90ContentDiscoveryResponseEvent ?: return listOf() + val noteEvent = latestNote?.event as? DvmContentDiscoveryResponseEvent ?: return listOf() return noteEvent.innerTags().mapNotNull { LocalCache.checkGetOrCreateNote(it) @@ -78,7 +78,7 @@ open class NIP90ContentDiscoveryResponseFilter( latestNote = maxNote } - val noteEvent = latestNote?.event as? NIP90ContentDiscoveryResponseEvent ?: return setOf() + val noteEvent = latestNote?.event as? DvmContentDiscoveryResponseEvent ?: return setOf() return noteEvent .innerTags() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt index 6f5feccd25..6226d1a680 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt @@ -66,7 +66,7 @@ import com.vitorpamplona.amethyst.ui.note.LoadAddressableNote import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import com.vitorpamplona.quartz.nip30CustomEmoji.taggedEmojis // Screen that lets the logged-in user inspect the contents of their kind 10030 selection @@ -102,7 +102,7 @@ private fun MyEmojiListView( TopBarWithBackButton(caption = stringRes(Res.string.my_emoji_list_title), nav) }, ) { contentPadding -> - val packAddresses by observeNoteEventAndMap<EmojiPackSelectionEvent, List<Address>>( + val packAddresses by observeNoteEventAndMap<EmojiListEvent, List<Address>>( selectionNote, accountViewModel, ) { event -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt index 5d9412c8fb..e72a91d271 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt @@ -85,7 +85,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.dal.Follow import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.dal.FollowPackMembersUserFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.datasource.FollowPackFeedFilterAssemblerSubscription import com.vitorpamplona.quartz.nip01Core.core.Address -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) @@ -309,7 +309,7 @@ private fun DisplayBanner( modifier: Modifier = Modifier, accountViewModel: AccountViewModel, ) { - val noteEvent by observeNoteEvent<FollowListEvent>(baseNote, accountViewModel) + val noteEvent by observeNoteEvent<StarterPackEvent>(baseNote, accountViewModel) noteEvent?.image()?.let { AsyncImage( @@ -327,7 +327,7 @@ fun FollowPackHeader( accountViewModel: AccountViewModel, nav: INav, ) { - val noteEvent by observeNoteEvent<FollowListEvent>(baseNote, accountViewModel) + val noteEvent by observeNoteEvent<StarterPackEvent>(baseNote, accountViewModel) Text( text = noteEvent?.title() ?: baseNote.dTag(), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt index 352fc2da65..663afb6994 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceReplyEvent import com.vitorpamplona.quartz.nipA4PublicMessages.PublicMessageEvent @@ -62,7 +62,7 @@ class FollowPackFeedConversationsFeedFilter( ) } - val followPackEvent = followPackNote.event as? FollowListEvent + val followPackEvent = followPackNote.event as? StarterPackEvent val follows = followPackEvent?.followIdSet() ?: emptySet() override fun applyFilter(newItems: Set<Note>): Set<Note> = innerApplyFilter(newItems) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt index e721fbdb88..c89f21f3d7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt @@ -45,9 +45,9 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceEvent @@ -66,16 +66,16 @@ class FollowPackFeedNewThreadFeedFilter( MusicPlaylistEvent.KIND, PodcastMetadataEvent.KIND, InteractiveStoryPrologueEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, NipTextEvent.KIND, ClassifiedsEvent.KIND, FundraiserEvent.KIND, BirdexEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, ) } - val followPackEvent = followPackNote.event as? FollowListEvent + val followPackEvent = followPackNote.event as? StarterPackEvent val follows = followPackEvent?.followIdSet() ?: emptySet() override fun feedKey(): String = account.userProfile().pubkeyHex + "-" + followPackNote.idHex @@ -143,8 +143,8 @@ class FollowPackFeedNewThreadFeedFilter( noteEvent is BirdexEvent || noteEvent is BirdDetectionEvent || noteEvent.isRenderableRepost() || - (noteEvent is LongTextNoteEvent && noteEvent.content.isNotEmpty()) || - (noteEvent is WikiNoteEvent && noteEvent.content.isNotEmpty()) || + (noteEvent is LongFormContentEvent && noteEvent.content.isNotEmpty()) || + (noteEvent is WikiArticleEvent && noteEvent.content.isNotEmpty()) || noteEvent is ZapPollEvent || noteEvent is HighlightEvent || noteEvent is InteractiveStoryPrologueEvent || diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt index 033edb6744..a081c0031b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.LocalCache.checkGetOrCreateUser import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent class FollowPackMembersFeedFilter( val followPackNote: AddressableNote, @@ -33,10 +33,10 @@ class FollowPackMembersFeedFilter( ) : FeedFilter<User>() { override fun feedKey(): String = account.userProfile().pubkeyHex + "-" + followPackNote.idHex - val cache: MutableMap<FollowListEvent, List<User>> = mutableMapOf() + val cache: MutableMap<StarterPackEvent, List<User>> = mutableMapOf() override fun feed(): List<User> { - val followPackEvent = followPackNote.event as? FollowListEvent ?: return emptyList() + val followPackEvent = followPackNote.event as? StarterPackEvent ?: return emptyList() val previousList = cache[followPackEvent] if (previousList != null) return previousList diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt index d392e9ceb3..7c7b968467 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.home.nip65Follows.filterHo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent class FollowPackFeedFilterSubAssembler( client: INostrClient, @@ -40,7 +40,7 @@ class FollowPackFeedFilterSubAssembler( if (keys.isEmpty()) return emptyList() return keys.flatMap { val followPack = it.followPack.event - if (followPack is FollowListEvent) { + if (followPack is StarterPackEvent) { val filter = if (it.account.proxyRelayList.flow.value .isEmpty() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt index 9b77a2d811..4ff1d00053 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.ChannelCardCompose -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent @OptIn(ExperimentalFoundationApi::class) @Composable @@ -64,7 +64,7 @@ fun FollowPacksFeedLoaded( baseNote = item, routeForLastRead = "FollowPacksFeed", modifier = Modifier.fillMaxWidth(), - forceEventKind = FollowListEvent.KIND, + forceEventKind = StarterPackEvent.KIND, accountViewModel = accountViewModel, nav = nav, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt index 4775dd8a8c..1c67d0241b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.ui.navigation.topbars.UserDrawerSearchTopBar import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent @Composable fun FollowPacksTopBar( @@ -49,7 +49,7 @@ fun FollowPacksTopBar( // The feed's own kind window, plus whatever the list spinner narrowed it to — a hashtag // or a geohash says itself as a token; a follow set does not, and seeds nothing. val me = accountViewModel.userProfile().pubkeyHex - val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(FollowListEvent.KIND), list.asSearchQuery(me)) } + val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(StarterPackEvent.KIND), list.asSearchQuery(me)) } UserDrawerSearchTopBar(accountViewModel, nav, seed) { FollowPacksTopNavFilterBar( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt index 5e3caa267d..3322db8e7d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt @@ -34,12 +34,12 @@ import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.geohash.isTaggedGeoHash -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip73ExternalIds.location.GeohashId import com.vitorpamplona.quartz.nipF4Podcasts.episode.PodcastEpisodeEvent import com.vitorpamplona.quartz.nipF4Podcasts.metadata.PodcastMetadataEvent @@ -79,10 +79,10 @@ class GeoHashFeedFilter( ): Boolean = ( event is TextNoteEvent || - event is LongTextNoteEvent || - event is WikiNoteEvent || + event is LongFormContentEvent || + event is WikiArticleEvent || event is ChannelMessageEvent || - event is PrivateDmEvent || + event is EncryptedDmEvent || event is ZapPollEvent || event is AudioHeaderEvent || event is MusicTrackEvent || diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/dal/HashtagFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/dal/HashtagFeedFilter.kt index 99c78942fd..0c7d4f80cc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/dal/HashtagFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/dal/HashtagFeedFilter.kt @@ -34,12 +34,12 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.isTaggedHash -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip73ExternalIds.topics.HashtagId import com.vitorpamplona.quartz.nipF4Podcasts.episode.PodcastEpisodeEvent import com.vitorpamplona.quartz.nipF4Podcasts.metadata.PodcastMetadataEvent @@ -104,10 +104,10 @@ class HashtagFeedFilter( ( event is TextNoteEvent || event.isRenderableRepost() || - event is LongTextNoteEvent || - event is WikiNoteEvent || + event is LongFormContentEvent || + event is WikiArticleEvent || event is ChannelMessageEvent || - event is PrivateDmEvent || + event is EncryptedDmEvent || event is ZapPollEvent || event is AudioHeaderEvent || event is MusicTrackEvent || diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt index bfd839f1fa..2586985599 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/hashtag/datasource/FilterPostsByHashtags.kt @@ -36,10 +36,10 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtagAlts import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip73ExternalIds.topics.HashtagId import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent @@ -51,12 +51,12 @@ val PostsByHashtagsKinds = listOf( TextNoteEvent.KIND, ChannelMessageEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, PollEvent.KIND, LiveActivitiesChatMessageEvent.KIND, ClassifiedsEvent.KIND, HighlightEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, CommentEvent.KIND, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeNewThreadFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeNewThreadFeedFilter.kt index 3297759834..1cf99188dd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeNewThreadFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeNewThreadFeedFilter.kt @@ -49,16 +49,16 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip64Chess.end.LiveChessGameEndEvent import com.vitorpamplona.quartz.nip64Chess.game.ChessGameEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent @@ -77,15 +77,15 @@ class HomeNewThreadFeedFilter( MusicPlaylistEvent.KIND, PodcastMetadataEvent.KIND, InteractiveStoryPrologueEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, ClassifiedsEvent.KIND, FundraiserEvent.KIND, BirdexEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, LiveChessGameEndEvent.KIND, AttestationEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, EntityRatingEvent.KIND, ) } @@ -147,8 +147,8 @@ class HomeNewThreadFeedFilter( noteEvent is BirdexEvent || noteEvent is BirdDetectionEvent || noteEvent.isRenderableRepost() || - (noteEvent is LongTextNoteEvent && noteEvent.content.isNotEmpty()) || - (noteEvent is WikiNoteEvent && noteEvent.content.isNotEmpty()) || + (noteEvent is LongFormContentEvent && noteEvent.content.isNotEmpty()) || + (noteEvent is WikiArticleEvent && noteEvent.content.isNotEmpty()) || noteEvent is ZapPollEvent || noteEvent is PollEvent || noteEvent is HighlightEvent || @@ -166,8 +166,8 @@ class HomeNewThreadFeedFilter( noteEvent is PictureEvent || noteEvent is VideoNormalEvent || noteEvent is VideoShortEvent || - noteEvent is VideoHorizontalEvent || - noteEvent is VideoVerticalEvent || + noteEvent is AddressableNormalVideoEvent || + noteEvent is AddressableShortVideoEvent || noteEvent is TorrentEvent || noteEvent is AttestationEvent || noteEvent is AttestationRequestEvent || diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/nip75Goals/NewGoalViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/nip75Goals/NewGoalViewModel.kt index 22aac53186..1696cdae66 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/nip75Goals/NewGoalViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/nip75Goals/NewGoalViewModel.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.utils.TimeUtils @Stable @@ -89,7 +89,7 @@ class NewGoalViewModel : ViewModel() { val sum = summary.text.ifBlank { null } val web = websiteUrl.text.ifBlank { null } - return GoalEvent.build( + return ZapGoalEvent.build( description = description.text, amount = amountMillisats, relays = relays, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt index dc141e4b72..8733e7a42f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.note.creators.userSuggestions.UserSuggestionState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow @@ -62,7 +62,7 @@ class PeopleListViewModel : ViewModel() { }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null) - fun selectedAddress() = PeopleListEvent.createAddress(account.userProfile().pubkeyHex, selectedDTag.value) + fun selectedAddress() = FollowSetEvent.createAddress(account.userProfile().pubkeyHex, selectedDTag.value) fun selectedNote() = account.cache.getOrCreateAddressableNote(selectedAddress()) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt index 62948d2075..f54fa456ca 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.note.creators.userSuggestions.UserSuggestionState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow @@ -62,7 +62,7 @@ class FollowPackViewModel : ViewModel() { }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null) - fun selectedAddress() = FollowListEvent.createAddress(account.userProfile().pubkeyHex, selectedDTag.value) + fun selectedAddress() = StarterPackEvent.createAddress(account.userProfile().pubkeyHex, selectedDTag.value) fun selectedNote() = account.cache.getOrCreateAddressableNote(selectedAddress()) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/LongsTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/LongsTopBar.kt index 9e87884561..898057185a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/LongsTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/LongsTopBar.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.ui.navigation.topbars.UserDrawerSearchTopBar import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent @Composable fun LongsTopBar( @@ -49,7 +49,7 @@ fun LongsTopBar( // The feed's own kind window, plus whatever the list spinner narrowed it to — a hashtag // or a geohash says itself as a token; a follow set does not, and seeds nothing. val me = accountViewModel.userProfile().pubkeyHex - val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(VideoHorizontalEvent.KIND), list.asSearchQuery(me)) } + val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(AddressableNormalVideoEvent.KIND), list.asSearchQuery(me)) } UserDrawerSearchTopBar(accountViewModel, nav, seed) { LongsTopNavFilterBar( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt index cfe0cbc3b5..138d6b8e34 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/longs/dal/LongsFeedFilter.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.dal.SupportedContent import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoMeta import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent @@ -60,7 +60,7 @@ class LongsFeedFilter( LocalCache.notes.filterIntoSet { _, it -> acceptableEvent(it, params) } + - LocalCache.addressables.filterIntoSet(VideoHorizontalEvent.KIND) { _, it -> + LocalCache.addressables.filterIntoSet(AddressableNormalVideoEvent.KIND) { _, it -> acceptableEvent(it, params) } return sort(notes) @@ -91,7 +91,7 @@ class LongsFeedFilter( fun acceptableVideoiMetas(iMetas: List<VideoMeta>): Boolean = iMetas.any { videoFeedSupport.acceptableUrl(it.url, it.mimeType) } - fun acceptanceEvent(noteEvent: VideoHorizontalEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) + fun acceptanceEvent(noteEvent: AddressableNormalVideoEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) fun acceptanceEvent(noteEvent: VideoNormalEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) @@ -106,7 +106,7 @@ class LongsFeedFilter( } return ( - (noteEvent is VideoHorizontalEvent && acceptanceEvent(noteEvent)) || + (noteEvent is AddressableNormalVideoEvent && acceptanceEvent(noteEvent)) || (noteEvent is VideoNormalEvent && acceptanceEvent(noteEvent)) ) && params.match(noteEvent, note.relays) && diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestRoomFilterAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestRoomFilterAssembler.kt index 3923973d8f..ca4c53d621 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestRoomFilterAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/datasource/NestRoomFilterAssembler.kt @@ -41,7 +41,7 @@ import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.presence.MeetingRoomPresenceEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent /** @@ -100,7 +100,7 @@ class NestRoomFilterSubAssembler( LiveActivitiesChatMessageEvent.KIND, MeetingRoomPresenceEvent.KIND, ReactionEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, Bolt12ZapEvent.KIND, ), tags = mapOf("a" to listOf(key.note.idHex)), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lifecycle/NestRoomEventCollectors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lifecycle/NestRoomEventCollectors.kt index 6e3fb4d01b..a18200cfdd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lifecycle/NestRoomEventCollectors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/nests/room/lifecycle/NestRoomEventCollectors.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.presence.MeetingRoomPresenceEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.delay @@ -153,7 +153,7 @@ private fun ReactionsCollector( * floating zap-overlay aggregator. The same note flows two places: * * 1. [NestViewModel.onChatEvent] — `ChatroomMessageCompose` routes - * `LnZapEvent` notes through `RenderChatZap`, which is the same + * `ZapReceiptEvent` notes through `RenderChatZap`, which is the same * card live streams use. Sharing the chat ledger keeps zap * cards interleaved with kind-1311 chat messages in time order. * @@ -169,14 +169,14 @@ private fun ZapsCollector( LaunchedEffect(viewModel, roomATag) { val filter = Filter( - kinds = listOf(LnZapEvent.KIND, Bolt12ZapEvent.KIND), + kinds = listOf(ZapReceiptEvent.KIND, Bolt12ZapEvent.KIND), tags = mapOf("a" to listOf(roomATag)), ) LocalCache.observeNotes(filter).collect { notes -> val nowSec = System.currentTimeMillis() / 1000 notes.forEach { note -> viewModel.onChatEvent(note) - (note.event as? LnZapEvent)?.let { viewModel.onZapEvent(it, nowSec) } + (note.event as? ZapReceiptEvent)?.let { viewModel.onZapEvent(it, nowSec) } (note.event as? Bolt12ZapEvent)?.let { viewModel.onZapEvent(it, nowSec) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt index 25f3230185..a219448a67 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt @@ -45,14 +45,14 @@ import com.vitorpamplona.amethyst.ui.dal.NotificationFeedOrderCard import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.dal.NotificationFeedFilter import com.vitorpamplona.quartz.buzz.notifications.MemberAddedNotificationEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.NIP17Group import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.utils.Log @@ -183,7 +183,7 @@ class CardFeedContentState( val zapsPerUser = mutableMapOf<User, MutableList<CombinedZap>>() val zapsPerEvent = mutableMapOf<Note, MutableList<CombinedZap>>() notes - .filter { it.event is LnZapEvent } + .filter { it.event is ZapReceiptEvent } .forEach { zapEvent -> val zappedPost = zapEvent.replyTo?.lastOrNull() if (zappedPost != null) { @@ -200,7 +200,7 @@ class CardFeedContentState( .add(CombinedZap(zapRequest, zapEvent)) } } else { - val event = (zapEvent.event as LnZapEvent) + val event = (zapEvent.event as ZapReceiptEvent) val author = event.zappedAuthor().firstNotNullOfOrNull { LocalCache.getUserIfExists(it) // don't create user if it doesn't exist @@ -361,7 +361,7 @@ class CardFeedContentState( it.event !is ReactionEvent && it.event !is RepostEvent && it.event !is GenericRepostEvent && - it.event !is LnZapEvent && + it.event !is ZapReceiptEvent && // Nutzaps are already grouped into nutzapsPerEvent (MultiSetCard) // or nutzapsPerUser (NutzapUserSetCard) above, exactly like lightning // zaps. Without this exclusion a nutzap would ALSO fall through to a @@ -372,7 +372,7 @@ class CardFeedContentState( val pendingInvite = if (it.event is MemberAddedNotificationEvent) pendingInvites[it.idHex] else null if (pendingInvite != null) { ChannelInviteCard(it, pendingInvite) - } else if (it.event is PrivateDmEvent || it.event is NIP17Group || it.isInMarmotGroup()) { + } else if (it.event is EncryptedDmEvent || it.event is NIP17Group || it.isInMarmotGroup()) { MessageSetCard(it) } else if (it.event is BadgeAwardEvent) { BadgeCard(it) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationSummaryState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationSummaryState.kt index 8b86a5c5da..e1cc54cc4a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationSummaryState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationSummaryState.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip10Notes.BaseThreadedEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent import com.vitorpamplona.quartz.utils.Log @@ -117,7 +117,7 @@ class NotificationSummaryState( } } - noteEvent is LnZapEvent -> { + noteEvent is ZapReceiptEvent -> { // the user might be sending his own receipts noteEvent.pubKey != currentUser if (noteEvent.isTaggedUser(currentUser)) { val netDate = formatDate(noteEvent.createdAt) @@ -212,7 +212,7 @@ class NotificationSummaryState( } } - noteEvent is LnZapEvent -> { + noteEvent is ZapReceiptEvent -> { if (noteEvent.isTaggedUser(currentUser)) { // && noteEvent.pubKey != currentUser User might be sending his own receipts val netDate = formatDate(noteEvent.createdAt) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt index c9735bb746..433d8d8183 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationFeedFilter.kt @@ -52,7 +52,7 @@ import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.BaseNoteEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent @@ -60,7 +60,7 @@ import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent @@ -78,17 +78,17 @@ import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.nip64Chess.challenge.accept.LiveChessGameAcceptEvent import com.vitorpamplona.quartz.nip64Chess.move.LiveChessMoveEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip72ModCommunities.communityAddress import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent @@ -131,11 +131,11 @@ class NotificationFeedFilter( LiveActivitiesEvent.KIND, LiveChessGameAcceptEvent.KIND, LiveChessMoveEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, NipTextEvent.KIND, - VideoVerticalEvent.KIND, - VideoHorizontalEvent.KIND, - WikiNoteEvent.KIND, + AddressableShortVideoEvent.KIND, + AddressableNormalVideoEvent.KIND, + WikiArticleEvent.KIND, AttestationRequestEvent.KIND, ) @@ -198,7 +198,7 @@ class NotificationFeedFilter( TextNoteEvent.KIND, ReactionEvent.KIND, RepostEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, NutzapEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND, @@ -206,7 +206,7 @@ class NotificationFeedFilter( PictureEvent.KIND, PollEvent.KIND, ZapPollEvent.KIND, - PrivateDmEvent.KIND, + EncryptedDmEvent.KIND, PublicMessageEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, @@ -322,9 +322,9 @@ class NotificationFeedFilter( // proves the comment targets a zap; the reply's explicit p tag // on the user marks it as theirs. val targetsZapReceipt = - event.hasScopeKind(LnZapEvent.KIND.toString()) || + event.hasScopeKind(ZapReceiptEvent.KIND.toString()) || event.hasScopeKind(Bolt12ZapEvent.KIND.toString()) || - note.replyTo?.any { it.event is LnZapEvent || it.event is Bolt12ZapEvent } == true + note.replyTo?.any { it.event is ZapReceiptEvent || it.event is Bolt12ZapEvent } == true if (targetsZapReceipt && event.isTaggedUser(authorHex)) { return true @@ -578,13 +578,13 @@ class NotificationFeedFilter( ( noteEvent is ChatMessageEvent || noteEvent is ChatMessageEncryptedFileHeaderEvent || - noteEvent is PrivateDmEvent + noteEvent is EncryptedDmEvent ) ) { return false } val notifAuthor = - if (noteEvent is LnZapEvent) { + if (noteEvent is ZapReceiptEvent) { val zapRequest = noteEvent.zapRequest if (zapRequest != null) { if (noteEvent.zapRequest?.isPrivateZap() == true) { @@ -608,7 +608,7 @@ class NotificationFeedFilter( // Reactions/zaps/reposts target a note via `replyTo`, not via thread-root tags, // so isNotInMutedThread on the wrapper event misses them. - if (noteEvent is ReactionEvent || noteEvent is LnZapEvent || noteEvent is Bolt12ZapEvent || + if (noteEvent is ReactionEvent || noteEvent is ZapReceiptEvent || noteEvent is Bolt12ZapEvent || noteEvent is RepostEvent || noteEvent is GenericRepostEvent ) { val target = it.replyTo?.lastOrNull() @@ -679,11 +679,11 @@ class NotificationFeedFilter( // relevance check (tagsAnEventByUser is skipped below); it still scopes // to genuine replies, so unrelated channel chatter never leaks through. return noteEvent?.kind in NOTIFICATION_KINDS && - (noteEvent is LnZapEvent || noteEvent is Bolt12ZapEvent || notifAuthor != loggedInUserHex) && + (noteEvent is ZapReceiptEvent || noteEvent is Bolt12ZapEvent || notifAuthor != loggedInUserHex) && (isChessEvent || isConcord || isReactionToMe || isThreadReplyToMe || filterParams.isGlobal() || notifAuthor == null || filterParams.isAuthorInFollows(notifAuthor)) && (noteEvent?.isTaggedUser(loggedInUserHex) == true || isNotifiablePublicChatReply(it, loggedInUserHex) || isReactionToMe || isThreadReplyToMe) && (filterParams.isHiddenList || notifAuthor == null || !account.isHidden(notifAuthor)) && - (noteEvent !is PrivateDmEvent || !account.isDecryptedContentHidden(noteEvent)) && + (noteEvent !is EncryptedDmEvent || !account.isDecryptedContentHidden(noteEvent)) && // For a Concord note the explicit p-tag above IS the relevance signal (the reply/reaction/ // mention targets me directly), so skip the per-kind heuristic — which for a reaction would // otherwise need my target message already loaded to resolve replyTo. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/PodcastTopSupporters.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/PodcastTopSupporters.kt index 9ce804d10e..5b8fdcda06 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/PodcastTopSupporters.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/podcasts/PodcastTopSupporters.kt @@ -61,7 +61,7 @@ import com.vitorpamplona.amethyst.ui.note.UsernameDisplay import com.vitorpamplona.amethyst.ui.note.showAmountInteger import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.LoadUser -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import java.math.BigDecimal private val Gold = Color(0xFFFFC300) @@ -86,7 +86,7 @@ fun PodcastTopSupporters( remember(zapState) { val contributions = note.zaps.mapNotNull { (_, receiptNote) -> - val receipt = receiptNote?.event as? LnZapEvent ?: return@mapNotNull null + val receipt = receiptNote?.event as? ZapReceiptEvent ?: return@mapNotNull null val request = receipt.zapRequest ?: return@mapNotNull null val sats = receipt.amount()?.toLong() ?: return@mapNotNull null // Anon/private zaps carry an `anon` tag; collapse them into the shared bucket. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt index b6742d40aa..aef3178ea3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/dal/UserProfileGalleryFeedFilter.kt @@ -32,10 +32,10 @@ import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder import com.vitorpamplona.quartz.experimental.profileGallery.ProfileGalleryEntryEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.AddressableVideoEvent import com.vitorpamplona.quartz.nip71Video.RegularVideoEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent class UserProfileGalleryFeedFilter( val user: User, @@ -57,7 +57,7 @@ class UserProfileGalleryFeedFilter( // Both NIP-71 addressable kinds: acceptableEvent() takes any // AddressableVideoEvent, so listing 34236 twice silently kept every // 34235 (horizontal) video out of the gallery. - listOf(VideoVerticalEvent.KIND, VideoHorizontalEvent.KIND), + listOf(AddressableShortVideoEvent.KIND, AddressableNormalVideoEvent.KIND), user.pubkeyHex, ) { _, it -> acceptableEvent(it, params, user) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/mutual/dal/UserProfileMutualFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/mutual/dal/UserProfileMutualFeedFilter.kt index 4a1654ac55..1af33308ff 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/mutual/dal/UserProfileMutualFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/mutual/dal/UserProfileMutualFeedFilter.kt @@ -41,9 +41,9 @@ import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA4PublicMessages.PublicMessageEvent @@ -83,8 +83,8 @@ class UserProfileMutualFeedFilter( it.event is BirdexEvent || it.event is BirdDetectionEvent || it.event.isRenderableRepost() || - it.event is LongTextNoteEvent || - it.event is WikiNoteEvent || + it.event is LongFormContentEvent || + it.event is WikiArticleEvent || it.event is NipTextEvent || it.event is ZapPollEvent || it.event is HighlightEvent || diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/dal/UserProfileNewThreadFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/dal/UserProfileNewThreadFeedFilter.kt index f649abb356..561bc45837 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/dal/UserProfileNewThreadFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/dal/UserProfileNewThreadFeedFilter.kt @@ -47,9 +47,9 @@ import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent @@ -91,8 +91,8 @@ class UserProfileNewThreadFeedFilter( it.event is BirdexEvent || it.event is BirdDetectionEvent || it.event.isRenderableRepost() || - it.event is LongTextNoteEvent || - it.event is WikiNoteEvent || + it.event is LongFormContentEvent || + it.event is WikiArticleEvent || it.event is NipTextEvent || it.event is ZapPollEvent || it.event is PollEvent || diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentContent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentContent.kt index c437afb68d..1bd3ac0ebb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentContent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentContent.kt @@ -99,7 +99,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.ButtonBorder import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.note.showAmount -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -139,7 +139,7 @@ data class PaymentMethodUi( /** One entry of the zap-type selector (Public / Private / Anonymous / Non-Zap). */ @Immutable data class ZapTypeOption( - val type: LnZapEvent.ZapType, + val type: ZapReceiptEvent.ZapType, val label: String, val explainer: String, ) @@ -270,8 +270,8 @@ fun SendPaymentContent( showMessageField: Boolean, messageLabel: String, zapTypes: ImmutableList<ZapTypeOption>?, - selectedZapType: LnZapEvent.ZapType, - onZapTypeChange: (LnZapEvent.ZapType) -> Unit, + selectedZapType: ZapReceiptEvent.ZapType, + onZapTypeChange: (ZapReceiptEvent.ZapType) -> Unit, receiptNote: String?, stage: PaymentFlowStage, canSend: Boolean, @@ -630,8 +630,8 @@ private fun AmountSection( @Composable private fun ReceiptSection( zapTypes: ImmutableList<ZapTypeOption>?, - selectedZapType: LnZapEvent.ZapType, - onZapTypeChange: (LnZapEvent.ZapType) -> Unit, + selectedZapType: ZapReceiptEvent.ZapType, + onZapTypeChange: (ZapReceiptEvent.ZapType) -> Unit, receiptNote: String?, enabled: Boolean, ) { @@ -771,10 +771,10 @@ private val previewFromSources = private val previewZapTypes = listOf( - ZapTypeOption(LnZapEvent.ZapType.PUBLIC, "Public", "Everybody can see the transaction and message"), - ZapTypeOption(LnZapEvent.ZapType.PRIVATE, "Private", "Sender and receiver can see each other and read the message"), - ZapTypeOption(LnZapEvent.ZapType.ANONYMOUS, "Anonymous", "Receiver does not know who sent the payment"), - ZapTypeOption(LnZapEvent.ZapType.NONZAP, "Non-Zap", "No trace on Nostr, only in Lightning"), + ZapTypeOption(ZapReceiptEvent.ZapType.PUBLIC, "Public", "Everybody can see the transaction and message"), + ZapTypeOption(ZapReceiptEvent.ZapType.PRIVATE, "Private", "Sender and receiver can see each other and read the message"), + ZapTypeOption(ZapReceiptEvent.ZapType.ANONYMOUS, "Anonymous", "Receiver does not know who sent the payment"), + ZapTypeOption(ZapReceiptEvent.ZapType.NONZAP, "Non-Zap", "No trace on Nostr, only in Lightning"), ).toImmutableList() @Composable @@ -822,7 +822,7 @@ private fun SendPaymentLightningPreview() { showMessageField = true, messageLabel = PREVIEW_MESSAGE_LABEL, zapTypes = previewZapTypes, - selectedZapType = LnZapEvent.ZapType.PUBLIC, + selectedZapType = ZapReceiptEvent.ZapType.PUBLIC, onZapTypeChange = {}, receiptNote = null, stage = PaymentFlowStage.Editing, @@ -858,7 +858,7 @@ private fun SendPaymentClinkFixedPreview() { showMessageField = false, messageLabel = "", zapTypes = null, - selectedZapType = LnZapEvent.ZapType.PUBLIC, + selectedZapType = ZapReceiptEvent.ZapType.PUBLIC, onZapTypeChange = {}, receiptNote = "Direct Lightning payment — no zap receipt is published on Nostr.", stage = PaymentFlowStage.Editing, @@ -894,7 +894,7 @@ private fun SendPaymentInProgressPreview() { showMessageField = true, messageLabel = PREVIEW_MESSAGE_LABEL, zapTypes = null, - selectedZapType = LnZapEvent.ZapType.PUBLIC, + selectedZapType = ZapReceiptEvent.ZapType.PUBLIC, onZapTypeChange = {}, receiptNote = "The nutzap event delivers the ecash itself, so it is always published.", stage = PaymentFlowStage.InProgress("Locking and sending ecash…", progress = 0.55f), @@ -930,7 +930,7 @@ private fun SendPaymentSuccessPreview() { showMessageField = true, messageLabel = PREVIEW_MESSAGE_LABEL, zapTypes = previewZapTypes, - selectedZapType = LnZapEvent.ZapType.PUBLIC, + selectedZapType = ZapReceiptEvent.ZapType.PUBLIC, onZapTypeChange = {}, receiptNote = null, stage = PaymentFlowStage.Success("Payment sent!", "1,000 sats to Alice"), @@ -966,7 +966,7 @@ private fun SendPaymentFailurePreview() { showMessageField = true, messageLabel = "Comment", zapTypes = null, - selectedZapType = LnZapEvent.ZapType.PUBLIC, + selectedZapType = ZapReceiptEvent.ZapType.PUBLIC, onZapTypeChange = {}, receiptNote = "An on-chain zap receipt is published on Nostr so the recipient can find the payment.", stage = PaymentFlowStage.Failure("Insufficient funds to cover the amount plus the network fee."), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentScreen.kt index adaec88edf..32bfc5a77a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/payment/SendPaymentScreen.kt @@ -117,7 +117,7 @@ import com.vitorpamplona.quartz.experimental.clink.offers.OfferErrorCode import com.vitorpamplona.quartz.experimental.clink.pointers.ClinkPointerParser import com.vitorpamplona.quartz.experimental.clink.pointers.NOffer import com.vitorpamplona.quartz.experimental.clink.pointers.OfferPriceType -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.chain.FeeEstimates import com.vitorpamplona.quartz.nipBCOnchainZaps.taproot.SegwitAddress import com.vitorpamplona.quartz.nipBCOnchainZaps.taproot.TaprootAddress @@ -621,9 +621,9 @@ private fun SendPaymentLoaded( val messageLabel = when { selectedMethod == ProfilePaymentMethod.ONCHAIN -> stringRes(Res.string.note_to_receiver) - selectedMethod == ProfilePaymentMethod.LIGHTNING && zapType == LnZapEvent.ZapType.PRIVATE -> + selectedMethod == ProfilePaymentMethod.LIGHTNING && zapType == ZapReceiptEvent.ZapType.PRIVATE -> stringRes(Res.string.custom_zaps_add_a_message_private) - selectedMethod == ProfilePaymentMethod.LIGHTNING && zapType == LnZapEvent.ZapType.NONZAP -> + selectedMethod == ProfilePaymentMethod.LIGHTNING && zapType == ZapReceiptEvent.ZapType.NONZAP -> stringRes(Res.string.custom_zaps_add_a_message_nonzap) else -> stringRes(Res.string.custom_zaps_add_a_message) } @@ -738,10 +738,10 @@ private fun rememberLightningZapTypeOptions(): ImmutableList<ZapTypeOption> { return remember { persistentListOf( - ZapTypeOption(LnZapEvent.ZapType.PUBLIC, publicLabel, publicExplainer), - ZapTypeOption(LnZapEvent.ZapType.PRIVATE, privateLabel, privateExplainer), - ZapTypeOption(LnZapEvent.ZapType.ANONYMOUS, anonymousLabel, anonymousExplainer), - ZapTypeOption(LnZapEvent.ZapType.NONZAP, nonzapLabel, nonzapExplainer), + ZapTypeOption(ZapReceiptEvent.ZapType.PUBLIC, publicLabel, publicExplainer), + ZapTypeOption(ZapReceiptEvent.ZapType.PRIVATE, privateLabel, privateExplainer), + ZapTypeOption(ZapReceiptEvent.ZapType.ANONYMOUS, anonymousLabel, anonymousExplainer), + ZapTypeOption(ZapReceiptEvent.ZapType.NONZAP, nonzapLabel, nonzapExplainer), ) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt index cb0e4df73a..3c10216804 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/relays/RelayFeedViewModel.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.nip01Core.RelayInfo import com.vitorpamplona.amethyst.commons.model.nip01Core.Wrapper import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.Dispatchers @@ -144,7 +144,7 @@ class RelayFeedViewModel : .flow() .metadata.stateFlow .map { dmNote -> - (dmNote.note.event as? ChatMessageRelayListEvent)?.relays()?.toSet() ?: emptySet() + (dmNote.note.event as? DmRelayListEvent)?.relays()?.toSet() ?: emptySet() }, flow2 = user.relayState().flow(), transform = ::convert, @@ -154,7 +154,7 @@ class RelayFeedViewModel : emit(emptyList()) } }.onStart { - emit(convert((currentUser.value?.nip65RelayListNote?.event as? ChatMessageRelayListEvent)?.relays()?.toSet(), currentUser.value?.relayState()?.data)) + emit(convert((currentUser.value?.nip65RelayListNote?.event as? DmRelayListEvent)?.relays()?.toSet(), currentUser.value?.relayState()?.data)) }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList()) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/dal/UserProfileZapsViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/dal/UserProfileZapsViewModel.kt index 4e718ef67e..db71a85712 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/dal/UserProfileZapsViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/dal/UserProfileZapsViewModel.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent import com.vitorpamplona.quartz.utils.BigDecimal @@ -55,14 +55,14 @@ class UserProfileZapsViewModel( ) : ViewModel() { val zapsToUser = Filter( - kinds = listOf(LnZapEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND), + kinds = listOf(ZapReceiptEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND), tags = mapOf("p" to listOf(user.pubkeyHex)), ) val sortingModel: Comparator<ZapAmount> = compareByDescending<ZapAmount> { it.amount }.thenBy { it.user.pubkeyHex } - suspend fun mapRequest(zapEvent: LnZapEvent): ZapAmount? { + suspend fun mapRequest(zapEvent: ZapReceiptEvent): ZapAmount? { val zapRequest = zapEvent.zapRequest ?: return ZapAmount( LocalCache.getOrCreateUser(zapEvent.pubKey), @@ -122,7 +122,7 @@ class UserProfileZapsViewModel( this.forEach { zapEvent -> val zapAmount = when (zapEvent) { - is LnZapEvent -> mapRequest(zapEvent) + is ZapReceiptEvent -> mapRequest(zapEvent) is OnchainZapEvent -> mapOnchainZap(zapEvent) is Bolt12ZapEvent -> mapBolt12Zap(zapEvent) else -> null diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt index 2ea4d40bac..0684f76185 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt @@ -206,25 +206,25 @@ import com.vitorpamplona.quartz.kinds.KindNames import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip03Timestamp.OtsEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelHideMessageEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMuteUserEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent import com.vitorpamplona.quartz.nip34Git.patch.GitPatchEvent import com.vitorpamplona.quartz.nip34Git.pr.GitPullRequestEvent @@ -239,32 +239,32 @@ import com.vitorpamplona.quartz.nip35Torrents.TorrentCommentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip42RelayAuth.RelayAuthEvent import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent @@ -272,16 +272,16 @@ import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEv import com.vitorpamplona.quartz.nip53LiveActivities.nestsServers.NestsServersEvent import com.vitorpamplona.quartz.nip53LiveActivities.presence.MeetingRoomPresenceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip58Badges.profile.ProfileBadgesEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.EphemeralGiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent @@ -296,29 +296,29 @@ import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip66RelayMonitor.discovery.RelayDiscoveryEvent import com.vitorpamplona.quartz.nip66RelayMonitor.monitor.RelayMonitorEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip71Video.textTrack.TextTrackEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.NIP90UserDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.NIP90UserDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.DvmUserDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.DvmUserDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip96FileStorage.config.FileServersEvent import com.vitorpamplona.quartz.nip98HttpAuth.HTTPAuthorizationEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent @@ -366,12 +366,12 @@ fun kindDisplayName(kind: Int): StringResource? = BookmarkListEvent.KIND -> Res.string.kind_bookmark_list OldBookmarkListEvent.KIND -> Res.string.kind_old_bookmark_list CalendarDateSlotEvent.KIND -> Res.string.kind_day_appointment - CalendarEvent.KIND -> Res.string.kind_calendar + CalendarCollectionEvent.KIND -> Res.string.kind_calendar CalendarTimeSlotEvent.KIND -> Res.string.kind_appointment CalendarRSVPEvent.KIND -> Res.string.kind_appt_rsvp ChessGameEvent.KIND -> Res.string.kind_chess_games JesterEvent.KIND -> Res.string.kind_chess_auth - RelayFeedsListEvent.KIND -> Res.string.kind_favorite_relays + FavoriteRelayListEvent.KIND -> Res.string.kind_favorite_relays LiveChessGameChallengeEvent.KIND -> Res.string.kind_chess_challenges LiveChessGameAcceptEvent.KIND -> Res.string.kind_chess_game_accept LiveChessMoveEvent.KIND -> Res.string.kind_chess_move @@ -379,32 +379,32 @@ fun kindDisplayName(kind: Int): StringResource? = LiveChessDrawOfferEvent.KIND -> Res.string.kind_chess_draw_offer ChannelCreateEvent.KIND -> Res.string.kind_channel_definition ChannelHideMessageEvent.KIND -> Res.string.kind_channel_hide_msg - ChannelListEvent.KIND -> Res.string.kind_channel_list + PublicChatListEvent.KIND -> Res.string.kind_channel_list ChannelMessageEvent.KIND -> Res.string.kind_channel_message ChannelMetadataEvent.KIND -> Res.string.kind_channel_metadata ChannelMuteUserEvent.KIND -> Res.string.kind_channel_mute_user ChatMessageEncryptedFileHeaderEvent.KIND -> Res.string.kind_dm_file ChatMessageEvent.KIND -> Res.string.kind_dm_message - ChatMessageRelayListEvent.KIND -> Res.string.kind_dm_relays + DmRelayListEvent.KIND -> Res.string.kind_dm_relays ClassifiedsEvent.KIND -> Res.string.kind_classifieds CommentEvent.KIND -> Res.string.kind_comments CommunityDefinitionEvent.KIND -> Res.string.kind_community_def CommunityListEvent.KIND -> Res.string.kind_community_list CommunityPostApprovalEvent.KIND -> Res.string.kind_community_post ContactListEvent.KIND -> Res.string.kind_follow_list - DeletionEvent.KIND -> Res.string.kind_deletions + DeletionRequestEvent.KIND -> Res.string.kind_deletions DraftWrapEvent.KIND -> Res.string.kind_drafts EmojiPackEvent.KIND -> Res.string.kind_emoji_packs - EmojiPackSelectionEvent.KIND -> Res.string.kind_emoji_pack_list + EmojiListEvent.KIND -> Res.string.kind_emoji_pack_list EphemeralChatEvent.KIND -> Res.string.kind_ephemeral_chat EphemeralChatListEvent.KIND -> Res.string.kind_ephemeral_chatrooms - FileHeaderEvent.KIND -> Res.string.kind_file_headers + FileMetadataEvent.KIND -> Res.string.kind_file_headers ProfileGalleryEntryEvent.KIND -> Res.string.kind_profile_gallery FileServersEvent.KIND -> Res.string.kind_file_servers FileStorageEvent.KIND -> Res.string.kind_blob_data FileStorageHeaderEvent.KIND -> Res.string.kind_blob_headers FhirResourceEvent.KIND -> Res.string.kind_medical_data - FollowListEvent.KIND -> Res.string.kind_follow_packs + StarterPackEvent.KIND -> Res.string.kind_follow_packs GenericRepostEvent.KIND -> Res.string.kind_reposts_16 GeohashListEvent.KIND -> Res.string.kind_geohash_follows GiftWrapEvent.KIND -> Res.string.kind_gift_wraps @@ -419,24 +419,24 @@ fun kindDisplayName(kind: Int): StringResource? = GitStatusAppliedEvent.KIND -> Res.string.kind_git_status_applied GitStatusClosedEvent.KIND -> Res.string.kind_git_status_closed GitStatusDraftEvent.KIND -> Res.string.kind_git_status_draft - GoalEvent.KIND -> Res.string.kind_zap_goals - HashtagListEvent.KIND -> Res.string.kind_hashtag_follows + ZapGoalEvent.KIND -> Res.string.kind_zap_goals + InterestListEvent.KIND -> Res.string.kind_hashtag_follows HighlightEvent.KIND -> Res.string.kind_highlights HTTPAuthorizationEvent.KIND -> Res.string.kind_http_auth IndexerRelayListEvent.KIND -> Res.string.kind_index_relay_list InteractiveStoryPrologueEvent.KIND -> Res.string.kind_adventure_prologue InteractiveStorySceneEvent.KIND -> Res.string.kind_adventure_scene InteractiveStoryReadingStateEvent.KIND -> Res.string.kind_adventure_reading - LabeledBookmarkListEvent.KIND -> Res.string.kind_named_bookmarks + BookmarkSetEvent.KIND -> Res.string.kind_named_bookmarks LiveActivitiesChatMessageEvent.KIND -> Res.string.kind_live_chats LiveActivitiesEvent.KIND -> Res.string.kind_live_streams - LnZapEvent.KIND -> Res.string.kind_zaps + ZapReceiptEvent.KIND -> Res.string.kind_zaps Bolt12ZapEvent.KIND -> Res.string.kind_zaps - LnZapPaymentRequestEvent.KIND -> Res.string.kind_nwc_request - LnZapPaymentResponseEvent.KIND -> Res.string.kind_nwc_response + NwcRequestEvent.KIND -> Res.string.kind_nwc_request + NwcResponseEvent.KIND -> Res.string.kind_nwc_response LnZapPrivateEvent.KIND -> Res.string.kind_private_zaps - LnZapRequestEvent.KIND -> Res.string.kind_zap_req - LongTextNoteEvent.KIND -> Res.string.kind_blogs + ZapRequestEvent.KIND -> Res.string.kind_zap_req + LongFormContentEvent.KIND -> Res.string.kind_blogs MeetingRoomEvent.KIND -> Res.string.kind_meeting_room MeetingRoomPresenceEvent.KIND -> Res.string.kind_room_presence MeetingSpaceEvent.KIND -> Res.string.kind_meeting_space @@ -445,14 +445,14 @@ fun kindDisplayName(kind: Int): StringResource? = NNSEvent.KIND -> Res.string.kind_nns NipTextEvent.KIND -> Res.string.kind_nip NostrConnectEvent.KIND -> Res.string.kind_nostr_connect - NIP90StatusEvent.KIND -> Res.string.kind_dvm_status - NIP90ContentDiscoveryRequestEvent.KIND -> Res.string.kind_dvm_content_req - NIP90ContentDiscoveryResponseEvent.KIND -> Res.string.kind_dvm_content_resp - NIP90UserDiscoveryRequestEvent.KIND -> Res.string.kind_dvm_user_req - NIP90UserDiscoveryResponseEvent.KIND -> Res.string.kind_dvm_user_resp + DvmStatusEvent.KIND -> Res.string.kind_dvm_status + DvmContentDiscoveryRequestEvent.KIND -> Res.string.kind_dvm_content_req + DvmContentDiscoveryResponseEvent.KIND -> Res.string.kind_dvm_content_resp + DvmUserDiscoveryRequestEvent.KIND -> Res.string.kind_dvm_user_req + DvmUserDiscoveryResponseEvent.KIND -> Res.string.kind_dvm_user_resp OtsEvent.KIND -> Res.string.kind_ots PaymentTargetsEvent.KIND -> Res.string.kind_pay_to - PeopleListEvent.KIND -> Res.string.kind_people_lists + FollowSetEvent.KIND -> Res.string.kind_people_lists ProfileBadgesEvent.KIND -> Res.string.kind_profile_badges PictureEvent.KIND -> Res.string.kind_pictures WorkoutRecordEvent.KIND -> Res.string.kind_workouts @@ -460,12 +460,12 @@ fun kindDisplayName(kind: Int): StringResource? = ZapPollEvent.KIND -> Res.string.kind_zap_poll PollEvent.KIND -> Res.string.kind_poll PollResponseEvent.KIND -> Res.string.kind_poll_response - PrivateDmEvent.KIND -> Res.string.kind_nip04_dms + EncryptedDmEvent.KIND -> Res.string.kind_nip04_dms PrivateOutboxRelayListEvent.KIND -> Res.string.kind_private_relays ProxyRelayListEvent.KIND -> Res.string.kind_proxy_relays PublicMessageEvent.KIND -> Res.string.kind_public_message ReactionEvent.KIND -> Res.string.kind_reactions - ContactCardEvent.KIND -> Res.string.kind_contact_card + UserAssertionEvent.KIND -> Res.string.kind_contact_card RelayAuthEvent.KIND -> Res.string.kind_relay_auth RelayDiscoveryEvent.KIND -> Res.string.kind_relay_discovery RelayMonitorEvent.KIND -> Res.string.kind_relay_monitor @@ -473,9 +473,9 @@ fun kindDisplayName(kind: Int): StringResource? = ReportEvent.KIND -> Res.string.kind_reports RepostEvent.KIND -> Res.string.kind_reposts RequestToVanishEvent.KIND -> Res.string.kind_user_delete - SealedRumorEvent.KIND -> Res.string.kind_seals + SealEvent.KIND -> Res.string.kind_seals SearchRelayListEvent.KIND -> Res.string.kind_search_relays - StatusEvent.KIND -> Res.string.kind_user_status + UserStatusEvent.KIND -> Res.string.kind_user_status TextNoteEvent.KIND -> Res.string.kind_notes TextNoteModificationEvent.KIND -> Res.string.kind_edits TorrentEvent.KIND -> Res.string.kind_torrents @@ -485,15 +485,15 @@ fun kindDisplayName(kind: Int): StringResource? = VideoCurationSetEvent.KIND -> Res.string.kind_video_list VideoCollaborationEvent.KIND -> Res.string.kind_video_collaboration TextTrackEvent.KIND -> Res.string.kind_video_subtitles - VideoHorizontalEvent.KIND -> Res.string.kind_video_repl - VideoVerticalEvent.KIND -> Res.string.kind_shorts_repl + AddressableNormalVideoEvent.KIND -> Res.string.kind_video_repl + AddressableShortVideoEvent.KIND -> Res.string.kind_shorts_repl VideoNormalEvent.KIND -> Res.string.kind_video VideoShortEvent.KIND -> Res.string.kind_shorts VoiceEvent.KIND -> Res.string.kind_voice_msg VoiceReplyEvent.KIND -> Res.string.kind_voice_reply WakeUpEvent.KIND -> Res.string.kind_wake WebBookmarkEvent.KIND -> Res.string.kind_web_bookmark - WikiNoteEvent.KIND -> Res.string.kind_wiki + WikiArticleEvent.KIND -> Res.string.kind_wiki else -> null } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt index a49752d925..4cfcdbed55 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/RelayInformationScreen.kt @@ -198,7 +198,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent @@ -478,7 +478,7 @@ val posts = setOf(0, 1, 6, 7, 16, 30023) val settings = setOf(3, 10002, 10000, 10001, 10003, 10004, 30000) val dms = setOf(4, GiftWrapEvent.KIND, EphemeralGiftWrapEvent.KIND, 10050) val zaps = setOf(9734, 9735, 9041, 17375, 23194, 23195) -val reports = setOf(ReportEvent.KIND, MuteListEvent.KIND, DeletionEvent.KIND, RequestToVanishEvent.KIND) +val reports = setOf(ReportEvent.KIND, MuteListEvent.KIND, DeletionRequestEvent.KIND, RequestToVanishEvent.KIND) @Composable fun KindChip(kind: Int) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/DMRelayListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/DMRelayListViewModel.kt index 0d2c1399bf..d0f5ac593c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/DMRelayListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/dm/DMRelayListViewModel.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.resources.dms import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySetupInfoModel import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.EphemeralGiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent @@ -45,7 +45,7 @@ class DMRelayListViewModel : BasicRelaySetupInfoModel() { label = Res.string.dms, filter = Filter( - kinds = listOf(GiftWrapEvent.KIND, EphemeralGiftWrapEvent.KIND, PrivateDmEvent.KIND), + kinds = listOf(GiftWrapEvent.KIND, EphemeralGiftWrapEvent.KIND, EncryptedDmEvent.KIND), tags = mapOf("p" to listOf(account.pubKey)), ), ), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/ShortsTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/ShortsTopBar.kt index 86cb3bf712..0d129f2eec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/ShortsTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/ShortsTopBar.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.ui.navigation.topbars.UserDrawerSearchTopBar import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent @Composable fun ShortsTopBar( @@ -49,7 +49,7 @@ fun ShortsTopBar( // The feed's own kind window, plus whatever the list spinner narrowed it to — a hashtag // or a geohash says itself as a token; a follow set does not, and seeds nothing. val me = accountViewModel.userProfile().pubkeyHex - val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(VideoVerticalEvent.KIND), list.asSearchQuery(me)) } + val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(AddressableShortVideoEvent.KIND), list.asSearchQuery(me)) } UserDrawerSearchTopBar(accountViewModel, nav, seed) { ShortsTopNavFilterBar( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt index 4e5390209a..dfbaf15534 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/shorts/dal/ShortsFeedFilter.kt @@ -33,9 +33,9 @@ import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.dal.SupportedContent import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoMeta import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent class ShortsFeedFilter( val account: Account, @@ -60,7 +60,7 @@ class ShortsFeedFilter( LocalCache.notes.filterIntoSet { _, it -> acceptableEvent(it, params) } + - LocalCache.addressables.filterIntoSet(VideoVerticalEvent.KIND) { _, it -> + LocalCache.addressables.filterIntoSet(AddressableShortVideoEvent.KIND) { _, it -> acceptableEvent(it, params) } return sort(notes) @@ -91,7 +91,7 @@ class ShortsFeedFilter( fun acceptableVideoiMetas(iMetas: List<VideoMeta>): Boolean = iMetas.any { videoFeedSupport.acceptableUrl(it.url, it.mimeType) } - fun acceptanceEvent(noteEvent: VideoVerticalEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) + fun acceptanceEvent(noteEvent: AddressableShortVideoEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) fun acceptanceEvent(noteEvent: VideoShortEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) @@ -106,7 +106,7 @@ class ShortsFeedFilter( } return ( - (noteEvent is VideoVerticalEvent && acceptanceEvent(noteEvent)) || + (noteEvent is AddressableShortVideoEvent && acceptanceEvent(noteEvent)) || (noteEvent is VideoShortEvent && acceptanceEvent(noteEvent)) ) && params.match(noteEvent, note.relays) && diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index fbd05a0120..74d6155773 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -315,14 +315,14 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.tags.geohash.geoHashOrScope import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip13Pow.strongPoWOrNull import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent @@ -343,13 +343,13 @@ import com.vitorpamplona.quartz.nip43RelayMembers.list.RelayMembershipListEvent import com.vitorpamplona.quartz.nip43RelayMembers.removeMember.RelayRemoveMemberEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent @@ -358,8 +358,8 @@ import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.splits.hasZapSplitSetup import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent @@ -372,7 +372,7 @@ import com.vitorpamplona.quartz.nip71Video.VideoEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.communityAddress import com.vitorpamplona.quartz.nip72ModCommunities.isACommunityPost -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent @@ -382,7 +382,7 @@ import com.vitorpamplona.quartz.nip87Ecash.recommendation.MintRecommendationEven import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.BaseVoiceEvent import com.vitorpamplona.quartz.nipA4PublicMessages.PublicMessageEvent @@ -737,7 +737,7 @@ private fun FullBleedNoteCompose( // Zap receipts are signed by the recipient's lightning provider; show the // sender from the embedded zap request instead of the service key. val zapSender = - if (noteEvent is LnZapEvent) { + if (noteEvent is ZapReceiptEvent) { observeZapSender(baseNote, accountViewModel).value } else { null @@ -859,9 +859,9 @@ private fun FullBleedNoteCompose( when (noteEvent) { is BadgeDefinitionEvent -> BadgeDisplay(baseNote = baseNote, accountViewModel) - is LongTextNoteEvent -> RenderLongFormHeaderForThread(noteEvent, baseNote, accountViewModel) + is LongFormContentEvent -> RenderLongFormHeaderForThread(noteEvent, baseNote, accountViewModel) is ThreadEvent -> RenderThreadHeaderForThread(noteEvent) - is WikiNoteEvent -> RenderWikiHeaderForThread(noteEvent, accountViewModel, nav) + is WikiArticleEvent -> RenderWikiHeaderForThread(noteEvent, accountViewModel, nav) is ClassifiedsEvent -> RenderClassifiedsReaderForThread(noteEvent, baseNote, accountViewModel, nav) is CodeSnippetEvent -> RenderCodeSnippetHeaderForThread(noteEvent) } @@ -896,13 +896,13 @@ private fun FullBleedNoteCompose( WorkoutDisplay(baseNote, backgroundColor, canPreview = true, quotesLeft = 3, accountViewModel = accountViewModel, nav = nav) } else if (noteEvent is BaseVoiceEvent) { VoiceHeader(noteEvent, baseNote, accountViewModel, nav) - } else if (noteEvent is FileHeaderEvent) { + } else if (noteEvent is FileMetadataEvent) { FileHeaderDisplay(baseNote, roundedCorner = true, ContentScale.FillWidth, accountViewModel = accountViewModel) } else if (noteEvent is FileStorageHeaderEvent) { FileStorageHeaderDisplay(baseNote, roundedCorner = true, ContentScale.FillWidth, accountViewModel = accountViewModel) - } else if (noteEvent is PeopleListEvent) { + } else if (noteEvent is FollowSetEvent) { DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav) - } else if (noteEvent is FollowListEvent) { + } else if (noteEvent is StarterPackEvent) { DisplayFollowList(baseNote, false, accountViewModel, nav) } else if (noteEvent is ContactListEvent) { DisplayContactList(baseNote, accountViewModel, nav) @@ -954,7 +954,7 @@ private fun FullBleedNoteCompose( accountViewModel, nav, ) - } else if (noteEvent is ChatMessageRelayListEvent) { + } else if (noteEvent is DmRelayListEvent) { DisplayDMRelayList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is ChatMessageEncryptedFileHeaderEvent) { RenderChatMessageEncryptedFile( @@ -977,7 +977,7 @@ private fun FullBleedNoteCompose( RenderAttestorProficiency(baseNote, 3, backgroundColor, accountViewModel, nav) } else if (noteEvent is AdvertisedRelayListEvent) { DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav) - } else if (noteEvent is LnZapEvent) { + } else if (noteEvent is ZapReceiptEvent) { RenderLnZap(baseNote, quotesLeft = 3, backgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav) } else if (noteEvent is NutzapEvent) { RenderNutzap(baseNote, quotesLeft = 3, backgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav) @@ -995,7 +995,7 @@ private fun FullBleedNoteCompose( DisplayProxyRelayList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is TrustedRelayListEvent) { DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav) - } else if (noteEvent is RelayFeedsListEvent) { + } else if (noteEvent is FavoriteRelayListEvent) { DisplayRelayFeedsList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is IndexerRelayListEvent) { DisplayIndexerRelayList(baseNote, backgroundColor, accountViewModel, nav) @@ -1070,7 +1070,7 @@ private fun FullBleedNoteCompose( RenderCalendarTimeSlotEvent(baseNote, accountViewModel, nav) } else if (noteEvent is CalendarDateSlotEvent) { RenderCalendarDateSlotEvent(baseNote, accountViewModel, nav) - } else if (noteEvent is GoalEvent) { + } else if (noteEvent is ZapGoalEvent) { RenderGoal(baseNote, accountViewModel, nav) } else if (noteEvent is FundraiserEvent) { RenderFundraiser(baseNote, makeItShort = false, accountViewModel, nav) @@ -1158,7 +1158,7 @@ private fun FullBleedNoteCompose( accountViewModel = accountViewModel, nav = nav, ) - } else if (noteEvent is PrivateDmEvent) { + } else if (noteEvent is EncryptedDmEvent) { RenderPrivateMessage( baseNote, false, @@ -1492,7 +1492,7 @@ private fun RenderClassifiedsReaderForThread( @Composable private fun RenderLongFormHeaderForThread( - noteEvent: LongTextNoteEvent, + noteEvent: LongFormContentEvent, note: Note, accountViewModel: AccountViewModel, ) { @@ -1558,7 +1558,7 @@ private fun RenderThreadHeaderForThread(noteEvent: ThreadEvent) { @Preview @Composable private fun RenderWikiHeaderForThreadPreview() { - val event = Event.fromJson("{\"id\":\"277f982a4cd3f67cc47ad9282176acabee1713848f547d6021e0c155572078e1\",\"pubkey\":\"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c\",\"created_at\":1708695717,\"kind\":30818,\"tags\":[[\"d\",\"amethyst\"],[\"a\",\"30818:f03e7c5262648e0b7823dfb49f8f17309cfec9cb14711413dcabdf3d7fc6369a:amethyst\",\"wss://relay.nostr.band\",\"fork\"],[\"e\",\"ceabc60c8022c472c727aa25ae7691885964366386ce265c47e5a78be6cb00be\",\"wss://relay.nostr.band\",\"fork\"],[\"title\",\"Amethyst\"],[\"published_at\",\"1708707133\"]],\"content\":\"An Android-only app written in Kotlin with support for over 90 event kinds. \\n\\n![](https://play-lh.googleusercontent.com/lvZlAm9dBrpHeOo7sIPKCsiKOLYLhR2b0FiOT4tyiwWO2dvsR2gDS0xk9tOOr9U-6uM=w240-h480-rw)\\n\",\"sig\":\"6748126a909a20dbdb67947a09d64e41d7140a79335a4ad675c6173d7dd5dbcab9c360dec617bd67bbbc20dfad416b15056eda2e20716cd6c425a84301a125a0\"}") as WikiNoteEvent + val event = Event.fromJson("{\"id\":\"277f982a4cd3f67cc47ad9282176acabee1713848f547d6021e0c155572078e1\",\"pubkey\":\"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c\",\"created_at\":1708695717,\"kind\":30818,\"tags\":[[\"d\",\"amethyst\"],[\"a\",\"30818:f03e7c5262648e0b7823dfb49f8f17309cfec9cb14711413dcabdf3d7fc6369a:amethyst\",\"wss://relay.nostr.band\",\"fork\"],[\"e\",\"ceabc60c8022c472c727aa25ae7691885964366386ce265c47e5a78be6cb00be\",\"wss://relay.nostr.band\",\"fork\"],[\"title\",\"Amethyst\"],[\"published_at\",\"1708707133\"]],\"content\":\"An Android-only app written in Kotlin with support for over 90 event kinds. \\n\\n![](https://play-lh.googleusercontent.com/lvZlAm9dBrpHeOo7sIPKCsiKOLYLhR2b0FiOT4tyiwWO2dvsR2gDS0xk9tOOr9U-6uM=w240-h480-rw)\\n\",\"sig\":\"6748126a909a20dbdb67947a09d64e41d7140a79335a4ad675c6173d7dd5dbcab9c360dec617bd67bbbc20dfad416b15056eda2e20716cd6c425a84301a125a0\"}") as WikiArticleEvent val accountViewModel = mockAccountViewModel() val editState = @@ -1602,7 +1602,7 @@ private fun RenderWikiHeaderForThreadPreview() { @Composable private fun RenderWikiHeaderForThread( - noteEvent: WikiNoteEvent, + noteEvent: WikiArticleEvent, accountViewModel: AccountViewModel, nav: INav, ) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileHeaderCardCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileHeaderCardCompose.kt index 45f3eae01e..523cb12efd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileHeaderCardCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileHeaderCardCompose.kt @@ -52,7 +52,7 @@ import com.vitorpamplona.amethyst.ui.note.types.toMediaContent import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitiveOrNSFW -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent @Composable fun FileHeaderCardCompose( @@ -60,7 +60,7 @@ fun FileHeaderCardCompose( accountViewModel: AccountViewModel, nav: INav, ) { - val event = (baseNote.event as? FileHeaderEvent) ?: return + val event = (baseNote.event as? FileMetadataEvent) ?: return val backgroundColor = remember { mutableStateOf(Color.Transparent) } Column( @@ -90,7 +90,7 @@ fun FileHeaderCardCompose( @Composable private fun FileHeaderCardImage( note: Note, - event: FileHeaderEvent, + event: FileMetadataEvent, backgroundColor: MutableState<Color>, accountViewModel: AccountViewModel, ) { @@ -145,7 +145,7 @@ private fun FileHeaderCardImage( } @Composable -internal fun FileHeaderCardCaption(videoEvent: FileHeaderEvent) { +internal fun FileHeaderCardCaption(videoEvent: FileMetadataEvent) { val event = (videoEvent as? Event) ?: return val title = videoEvent.summary() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/StoriesTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/StoriesTopBar.kt index 74e418893f..831ee5d806 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/StoriesTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/StoriesTopBar.kt @@ -36,8 +36,8 @@ import com.vitorpamplona.amethyst.ui.navigation.topbars.UserDrawerSearchTopBar import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent @Composable fun StoriesTopBar( @@ -50,7 +50,7 @@ fun StoriesTopBar( // The feed's own kind window, plus whatever the list spinner narrowed it to — a hashtag // or a geohash says itself as a token; a follow set does not, and seeds nothing. val me = accountViewModel.userProfile().pubkeyHex - val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(VideoHorizontalEvent.KIND, VideoVerticalEvent.KIND), list.asSearchQuery(me)) } + val seed = remember(list, me) { SearchSeed.merge(SearchSeed.ofKinds(AddressableNormalVideoEvent.KIND, AddressableShortVideoEvent.KIND), list.asSearchQuery(me)) } UserDrawerSearchTopBar(accountViewModel, nav, seed) { TopNavFilterBar( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt index a4f8fccfcd..d9b3fe531b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt @@ -53,7 +53,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.shorts.VideoCardCompose import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.VideoFilterAssemblerSubscription import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip71Video.VideoEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent @Composable fun VideoScreen( @@ -199,7 +199,7 @@ fun VideoFeedLoaded( Spacer(modifier = Modifier.height(8.dp)) } - item.event is FileHeaderEvent -> { + item.event is FileMetadataEvent -> { FileHeaderCardCompose(item, accountViewModel, nav) HorizontalDivider( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt index b9b67e2ffc..7fad0d489e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/dal/VideoFeedFilter.kt @@ -34,12 +34,12 @@ import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip68Picture.PictureMeta -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoMeta import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent class VideoFeedFilter( val account: Account, @@ -72,10 +72,10 @@ class VideoFeedFilter( LocalCache.notes.filterIntoSet { _, it -> acceptableEvent(it, params) } + - LocalCache.addressables.filterIntoSet(VideoHorizontalEvent.KIND) { _, it -> + LocalCache.addressables.filterIntoSet(AddressableNormalVideoEvent.KIND) { _, it -> acceptableEvent(it, params) } + - LocalCache.addressables.filterIntoSet(VideoVerticalEvent.KIND) { _, it -> + LocalCache.addressables.filterIntoSet(AddressableShortVideoEvent.KIND) { _, it -> acceptableEvent(it, params) } @@ -101,11 +101,11 @@ class VideoFeedFilter( fun acceptanceEvent(noteEvent: PictureEvent) = acceptablePictureiMetas(noteEvent.imetaTags()) - fun acceptanceEvent(noteEvent: FileHeaderEvent) = acceptableUrls(noteEvent.urls(), noteEvent.mimeType()) + fun acceptanceEvent(noteEvent: FileMetadataEvent) = acceptableUrls(noteEvent.urls(), noteEvent.mimeType()) - fun acceptanceEvent(noteEvent: VideoVerticalEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) + fun acceptanceEvent(noteEvent: AddressableShortVideoEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) - fun acceptanceEvent(noteEvent: VideoHorizontalEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) + fun acceptanceEvent(noteEvent: AddressableNormalVideoEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) fun acceptanceEvent(noteEvent: VideoNormalEvent) = acceptableVideoiMetas(noteEvent.imetaTags()) @@ -122,9 +122,9 @@ class VideoFeedFilter( } return ( - (noteEvent is FileHeaderEvent && acceptanceEvent(noteEvent)) || - (noteEvent is VideoVerticalEvent && acceptanceEvent(noteEvent)) || - (noteEvent is VideoHorizontalEvent && acceptanceEvent(noteEvent)) || + (noteEvent is FileMetadataEvent && acceptanceEvent(noteEvent)) || + (noteEvent is AddressableShortVideoEvent && acceptanceEvent(noteEvent)) || + (noteEvent is AddressableNormalVideoEvent && acceptanceEvent(noteEvent)) || (noteEvent is VideoNormalEvent && acceptanceEvent(noteEvent)) || (noteEvent is VideoShortEvent && acceptanceEvent(noteEvent)) || (noteEvent is PictureEvent && acceptanceEvent(noteEvent)) diff --git a/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt b/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt index a0dd8d1bf9..f14ec732b7 100644 --- a/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt +++ b/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt @@ -54,14 +54,14 @@ import com.vitorpamplona.quartz.nip17Dm.base.BaseDMGroupEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent import com.vitorpamplona.quartz.nip19Bech32.decodePublicKey import com.vitorpamplona.quartz.nip19Bech32.entities.NPub -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.NwcErrorResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayInvoiceErrorResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayInvoiceSuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip55AndroidSigner.client.NostrSignerExternal -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.utils.TimeUtils @@ -778,7 +778,7 @@ class AmethystAppFunctions { val filter = Filter( - kinds = listOf(LnZapEvent.KIND, Bolt12ZapEvent.KIND), + kinds = listOf(ZapReceiptEvent.KIND, Bolt12ZapEvent.KIND), tags = mapOf("p" to listOf(myPub)), since = sinceSecs, limit = 500, @@ -789,7 +789,7 @@ class AmethystAppFunctions { idleTimeoutMs = GEMINI_FETCH_TIMEOUT_MS, ) - val receipts = events.mapNotNull { it as? LnZapEvent } + val receipts = events.mapNotNull { it as? ZapReceiptEvent } val zapperIds = mutableSetOf<HexKey>() var totalSats = 0L var unparseable = 0 @@ -936,7 +936,7 @@ class AmethystAppFunctions { val filter = SearchActions.searchNotesFilter( query = query, - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), limit = cappedLimit, ) ?: return SearchNotesResult.empty() @@ -953,7 +953,7 @@ class AmethystAppFunctions { val hits = events - .mapNotNull { it as? LongTextNoteEvent } + .mapNotNull { it as? LongFormContentEvent } .take(cappedLimit) .map { (it as com.vitorpamplona.quartz.nip01Core.core.Event).toFeedNoteHit() } @@ -1403,7 +1403,7 @@ class AmethystAppFunctions { amountMillisats = ZapActions.satsToMillisats(sats), inboxRelays = account.nip65RelayList.inboxFlow.value, comment = comment, - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, ) val invoice = fetchInvoiceOrThrow(lnAddress, sats, comment, zapRequest) @@ -1614,7 +1614,7 @@ class AmethystAppFunctions { lookupLnAddress = lookupLnAddress, lookupInboxRelays = lookupInboxRelays, comment = trimmedComment, - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, ) if (requests.isEmpty()) { throw AppFunctionInvalidArgumentException( @@ -1787,7 +1787,7 @@ class AmethystAppFunctions { lnAddress: String, sats: Long, comment: String, - zapRequest: com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent, + zapRequest: com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent, ): String { // Compute the LNURL-pay endpoint so we can ask the privacy-aware // HttpClient builder for the right OkHttpClient for that host. diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt index e504817753..aaf1c26d9b 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/calendar/CalendarsViewModelFlowTest.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.CalendarsViewMode import com.vitorpamplona.amethyst.ui.screen.loggedIn.calendars.dal.CalendarAppointmentsFeedFilter import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -90,7 +90,7 @@ class CalendarsViewModelFlowTest { dTag: String?, title: String, members: List<Address> = emptyList(), - ) = CalendarEvent( + ) = CalendarCollectionEvent( id = id, pubKey = pubKey, createdAt = 1_700_000_000L, @@ -121,7 +121,7 @@ class CalendarsViewModelFlowTest { * for the length of the test: `LocalCache.addressables` is a weak cache, and with nothing * holding a reference a calendar can be collected out from under the assertions. */ - private fun consume(vararg calendars: CalendarEvent): List<AddressableNote?> { + private fun consume(vararg calendars: CalendarCollectionEvent): List<AddressableNote?> { calendars.forEach { LocalCache.justConsumeMyOwnEvent(it) } return calendars.map { LocalCache.getAddressableNoteIfExists(it.address()) } } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/AddressedAuthorRoutingTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/AddressedAuthorRoutingTest.kt index 815b6e933b..3033cec228 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/AddressedAuthorRoutingTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/AddressedAuthorRoutingTest.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.amethyst.model -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue @@ -49,7 +49,7 @@ class AddressedAuthorRoutingTest { ) private fun calendar(vararg tags: Array<String>) = - CalendarEvent( + CalendarCollectionEvent( id = "22".repeat(32), pubKey = host, createdAt = 1700000000, diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/BuzzWorkspaceChannelTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/BuzzWorkspaceChannelTest.kt index 30766d0f2c..97512fd09b 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/BuzzWorkspaceChannelTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/BuzzWorkspaceChannelTest.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.buzz.stream.StreamMessageV2Event import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip29RelayGroups.GroupId import io.mockk.every import io.mockk.mockk @@ -225,7 +225,7 @@ class BuzzWorkspaceChannelTest { // The author deletes their own edit (NIP-09). It must stop overlaying the message and // be unlinked from Note.edits, not linger as a stale overlay. - val deletion = signer.sign(DeletionEvent.build(listOf(edit))) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(edit))) LocalCache.checkDeletionAndConsume(deletion, buzzRelay, false) assertNull("a deleted edit must no longer overlay its message", target.latestBuzzEdit()) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/HomeFeedTypeTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/HomeFeedTypeTest.kt index e9580d0ac5..7b96f5a90d 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/HomeFeedTypeTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/HomeFeedTypeTest.kt @@ -24,10 +24,10 @@ import com.vitorpamplona.amethyst.commons.model.HomeFeedType import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNull @@ -76,8 +76,8 @@ class HomeFeedTypeTest { fun picturesVideosShortsAndTorrentsOwnTheirKinds() { assertEquals(listOf(PictureEvent.KIND), HomeFeedType.PICTURES.kinds) // Long-form videos are the horizontal/normal kinds; vertical/short kinds belong to Shorts. - assertEquals(listOf(VideoNormalEvent.KIND, VideoHorizontalEvent.KIND), HomeFeedType.VIDEOS.kinds) - assertEquals(listOf(VideoShortEvent.KIND, VideoVerticalEvent.KIND), HomeFeedType.SHORTS.kinds) + assertEquals(listOf(VideoNormalEvent.KIND, AddressableNormalVideoEvent.KIND), HomeFeedType.VIDEOS.kinds) + assertEquals(listOf(VideoShortEvent.KIND, AddressableShortVideoEvent.KIND), HomeFeedType.SHORTS.kinds) assertEquals(listOf(TorrentEvent.KIND), HomeFeedType.TORRENTS.kinds) } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilterTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilterTest.kt index a8872f4ad3..3d06dfb3d5 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilterTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/model/topNavFeeds/favoriteAlgoFeeds/FavoriteAlgoFeedTopNavFilterTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.model.topNavFeeds.favoriteAlgoFeeds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavFilter import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -34,7 +34,7 @@ class FavoriteAlgoFeedTopNavFilterTest { private fun longFormNote( pubkey: String, dTag: String, - ) = LongTextNoteEvent( + ) = LongFormContentEvent( id = "0".repeat(64), pubKey = pubkey, createdAt = 1, diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/DelayingTestSigner.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/DelayingTestSigner.kt index ff18cabafc..9cb566f031 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/DelayingTestSigner.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/DelayingTestSigner.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.delay /** @@ -74,7 +74,7 @@ class DelayingTestSigner( fromPublicKey: HexKey, ) = unsupported() - override suspend fun decryptZapEvent(event: LnZapRequestEvent) = unsupported() + override suspend fun decryptZapEvent(event: ZapRequestEvent) = unsupported() override suspend fun deriveKey(nonce: HexKey) = unsupported() diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/FilterGroupNotificationsToPubkeyTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/FilterGroupNotificationsToPubkeyTest.kt index 475a99e29b..d87a15fded 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/FilterGroupNotificationsToPubkeyTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip01Notifications/FilterGroupNotificationsToPubkeyTest.kt @@ -58,7 +58,7 @@ class FilterGroupNotificationsToPubkeyTest { assertTrue(GroupNotificationKinds.contains(9)) // ChatEvent assertTrue(GroupNotificationKinds.contains(1111)) // CommentEvent assertTrue(GroupNotificationKinds.contains(7)) // ReactionEvent - assertTrue(GroupNotificationKinds.contains(9735)) // LnZapEvent + assertTrue(GroupNotificationKinds.contains(9735)) // ZapReceiptEvent } @Test diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt index 9eca6b4480..63bbe4a78b 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt @@ -44,7 +44,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import io.mockk.every import io.mockk.mockk import kotlinx.coroutines.CoroutineScope @@ -650,7 +650,7 @@ class MeteringNostrSignerTest { fromPublicKey: HexKey, ) = "dec44" - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = throw UnsupportedOperationException("fake") + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw UnsupportedOperationException("fake") override suspend fun deriveKey(nonce: HexKey): HexKey = "bb".repeat(32) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilderTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilderTest.kt index 1d7223b49c..114660dbb0 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilderTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/uploads/hls/HlsVideoEventBuilderTest.kt @@ -25,8 +25,8 @@ import com.davotoula.lightcompressor.hls.HlsRenditionSummary import com.davotoula.lightcompressor.hls.HlsUploaded import com.davotoula.lightcompressor.hls.Rendition import com.vitorpamplona.amethyst.service.uploads.MediaUploadResult -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Assert.assertNull @@ -122,7 +122,7 @@ class HlsVideoEventBuilderTest { assertTrue("expected Horizontal template", result.template is HlsVideoEventTemplate.Horizontal) val template = (result.template as HlsVideoEventTemplate.Horizontal).template - assertEquals(VideoHorizontalEvent.KIND, template.kind) + assertEquals(AddressableNormalVideoEvent.KIND, template.kind) assertEquals("A cool video", template.content) } @@ -132,7 +132,7 @@ class HlsVideoEventBuilderTest { assertTrue("expected Vertical template", result.template is HlsVideoEventTemplate.Vertical) val template = (result.template as HlsVideoEventTemplate.Vertical).template - assertEquals(VideoVerticalEvent.KIND, template.kind) + assertEquals(AddressableShortVideoEvent.KIND, template.kind) } @Test diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/RouteForPointerTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/RouteForPointerTest.kt index 92337c0f2e..19964c6862 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/RouteForPointerTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/RouteForPointerTest.kt @@ -31,12 +31,12 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.utils.EventFactory import io.mockk.mockk import org.junit.Assert.assertEquals @@ -73,7 +73,7 @@ class RouteForPointerTest { // the wrap has to be opened before it can say anything assertNull(routeForPointer(GiftWrapEvent.KIND, id)) // addressables are cited by `a` tag, not by id - assertNull(routeForPointer(LongTextNoteEvent.KIND, id)) + assertNull(routeForPointer(LongFormContentEvent.KIND, id)) // a kind:0 IS the person — Route.Profile, not a note assertNull(routeForPointer(MetadataEvent.KIND, id)) } @@ -111,7 +111,7 @@ class RouteForPointerTest { */ @Test fun addressableVideoKindsDoNotTakeTheShortcut() { - assertNull(routeForPointer(VideoHorizontalEvent.KIND, id)) - assertNull(routeForPointer(VideoVerticalEvent.KIND, id)) + assertNull(routeForPointer(AddressableNormalVideoEvent.KIND, id)) + assertNull(routeForPointer(AddressableShortVideoEvent.KIND, id)) } } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/QrPayloadTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/QrPayloadTest.kt index 72a8c43723..e00804aded 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/QrPayloadTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/QrPayloadTest.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue @@ -79,9 +79,9 @@ class QrPayloadTest { runTest { // build(description, title, summary, image, publishedAt, dTag, createdAt, init) // — `title` is a required positional; `dTag` must be named. - // LongTextNoteEvent.kt:148-157. + // LongFormContentEvent.kt:148-157. val event = - LongTextNoteEvent + LongFormContentEvent .build("body", "My Article", dTag = "my-article") {} .let { aliceSigner.sign(it) } val note = AddressableNote(event.address()) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCardTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCardTest.kt index 0e70df1ace..7d76a5852f 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCardTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/note/share/SharedNoteCardTest.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip92IMeta.IMetaTagBuilder import com.vitorpamplona.quartz.nip92IMeta.imetas import kotlinx.coroutines.test.runTest @@ -129,7 +129,7 @@ class SharedNoteCardTest { fun article_prefersItsTitle() = runTest { val note = - LongTextNoteEvent + LongFormContentEvent .build("the body", "My Article", dTag = "a1") {} .let { aliceSigner.sign(it) } diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationTagsAnEventByUserTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationTagsAnEventByUserTest.kt index 786c4eda28..f57bf851e3 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationTagsAnEventByUserTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/dal/NotificationTagsAnEventByUserTest.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.dal import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -81,10 +81,10 @@ class NotificationTagsAnEventByUserTest { 1000, arrayOf( arrayOf("E", zapId, "", wallet), - arrayOf("K", LnZapEvent.KIND.toString()), + arrayOf("K", ZapReceiptEvent.KIND.toString()), arrayOf("P", wallet), arrayOf("e", zapId, "", wallet), - arrayOf("k", LnZapEvent.KIND.toString()), + arrayOf("k", ZapReceiptEvent.KIND.toString()), arrayOf("p", wallet), arrayOf("p", me), ), @@ -109,10 +109,10 @@ class NotificationTagsAnEventByUserTest { 1000, arrayOf( arrayOf("E", zapId, "", wallet), - arrayOf("K", LnZapEvent.KIND.toString()), + arrayOf("K", ZapReceiptEvent.KIND.toString()), arrayOf("P", wallet), arrayOf("e", zapId, "", wallet), - arrayOf("k", LnZapEvent.KIND.toString()), + arrayOf("k", ZapReceiptEvent.KIND.toString()), arrayOf("p", wallet), ), "nice zap", diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapBenchmark.kt index 34431d9e3c..60e6b13cd7 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapBenchmark.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip01Core.tags.people.PTag import com.vitorpamplona.quartz.nip17Dm.NIP17Factory import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import kotlinx.coroutines.runBlocking import org.junit.Assert @@ -78,7 +78,7 @@ class GiftWrapBenchmark { val event = it.unwrapThrowing(keyToUse) event.checkSignature() - if (event is SealedRumorEvent) { + if (event is SealEvent) { val innerData = event.unsealThrowing(keyToUse) Assert.assertEquals(message, innerData.content) } else { @@ -116,7 +116,7 @@ class GiftWrapBenchmark { val seal = wrap.unwrapThrowing(keyToUse) seal.checkSignature() - if (seal is SealedRumorEvent) { + if (seal is SealEvent) { val innerData = seal.unsealThrowing(keyToUse) Assert.assertEquals(message, innerData.content) } else { diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapReceivingBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapReceivingBenchmark.kt index 62c3e676af..2501bb7845 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapReceivingBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapReceivingBenchmark.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning import com.vitorpamplona.quartz.nip44Encryption.Nip44 import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiser import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import junit.framework.TestCase.assertNotNull import kotlinx.coroutines.runBlocking @@ -62,7 +62,7 @@ class GiftWrapReceivingBenchmark { runBlocking { GiftWrapEvent.create( event = - SealedRumorEvent.create( + SealEvent.create( event = sender.sign( ChatMessageEvent.build( @@ -84,7 +84,7 @@ class GiftWrapReceivingBenchmark { fun createSeal( sender: NostrSigner, receiver: NostrSigner, - ): SealedRumorEvent = + ): SealEvent = runBlocking { val msg = sender.sign( @@ -101,7 +101,7 @@ class GiftWrapReceivingBenchmark { }, ) - SealedRumorEvent.create( + SealEvent.create( event = msg, encryptTo = receiver.pubKey, signer = sender, diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapSigningBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapSigningBenchmark.kt index 1395ab7202..796f2c309e 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapSigningBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/GiftWrapSigningBenchmark.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent import com.vitorpamplona.quartz.nip17Dm.messages.changeSubject import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiser -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import kotlinx.coroutines.runBlocking import org.junit.Rule @@ -95,7 +95,7 @@ class GiftWrapSigningBenchmark { benchmarkRule.measureRepeated { runBlocking { - SealedRumorEvent.create( + SealEvent.create( event = msg, encryptTo = receiver.pubKey, signer = sender, @@ -128,7 +128,7 @@ class GiftWrapSigningBenchmark { val seal = runBlocking { - SealedRumorEvent.create( + SealEvent.create( event = msg, encryptTo = receiver.pubKey, signer = sender, @@ -169,7 +169,7 @@ class GiftWrapSigningBenchmark { val seal = runBlocking { - SealedRumorEvent.create( + SealEvent.create( event = msg, encryptTo = receiver.pubKey, signer = sender, diff --git a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/LargeDBInsertBenchmark.kt b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/LargeDBInsertBenchmark.kt index 228f247b89..5882a26a03 100644 --- a/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/LargeDBInsertBenchmark.kt +++ b/benchmark/src/androidTest/java/com/vitorpamplona/quartz/benchmark/LargeDBInsertBenchmark.kt @@ -28,7 +28,7 @@ import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.vitorpamplona.quartz.nip01Core.core.AddressableEvent import com.vitorpamplona.quartz.nip01Core.store.sqlite.EventStore -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip40Expiration.isExpired import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.flattenToSet @@ -72,7 +72,7 @@ class LargeDBInsertBenchmark : BaseLargeCacheBenchmark() { @Test fun bench40DeletionRequestsEvents() { val context = ApplicationProvider.getApplicationContext<Context>() - val deletions = allEvents.filterIsInstance<DeletionEvent>() + val deletions = allEvents.filterIsInstance<DeletionRequestEvent>() val deletionIds = deletions.map { it.deleteEventIds() }.flattenToSet() val deletionAddresses = deletions.map { it.deleteAddressIds() }.flattenToSet() diff --git a/cli/ROADMAP.md b/cli/ROADMAP.md index 09b80c2072..41f46bbc9c 100644 --- a/cli/ROADMAP.md +++ b/cli/ROADMAP.md @@ -71,7 +71,7 @@ Status legend: ✅ shipped · 📦 logic lives in `commons/`, needs a command · | NIP-5A nsites + NIP-5D napplets | ✅ | `NsiteCommands` + `NappletCommands` — fetch/publish/serve/list with sha256 + aggregate-hash verification and `requires` capability reporting. | | Podcasting 2.0 / podstr (`amy podcast20`) | ✅ | `Podcast20Commands` — kind:30078 metadata, 30054 episodes, 30055 trailers, list. | | Follows-of-follows (`amy fof get/list/sync`) | ✅ | `FofCommand` — single-hop social proof from the local store (`wot` kept as deprecation alias). | -| NIP-85 GrapeRank web-of-trust (`amy graperank`) | ✅ | `GrapeRankCommand` — outbox-model crawl + scoring engine in `commons/wot/` (`GrapeRank`, `TrustGraph`, `TrustGraphBuilder`); every score run persists kind:30382 `ContactCardEvent` cards to the local store (diffed against prior ranks, kind:5 retractions), `publish` mirrors that set to the operator relays via NIP-77 up-sync, `rank` reads cards back, plus `register` / `unregister` / `providers` for the kind:10040 `TrustProviderListEvent` discovery layer. | +| NIP-85 GrapeRank web-of-trust (`amy graperank`) | ✅ | `GrapeRankCommand` — outbox-model crawl + scoring engine in `commons/wot/` (`GrapeRank`, `TrustGraph`, `TrustGraphBuilder`); every score run persists kind:30382 `UserAssertionEvent` cards to the local store (diffed against prior ranks, kind:5 retractions), `publish` mirrors that set to the operator relays via NIP-77 up-sync, `rank` reads cards back, plus `register` / `unregister` / `providers` for the kind:10040 `TrustProviderListEvent` discovery layer. | | NIP-72 communities | 🆕 | | | NIP-78 app-specific data (settings sync) | 🆕 | | | Long-form (NIP-23) publish / read | 🆕 | | diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Context.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Context.kt index af23b2f575..1db3013b82 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Context.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Context.kt @@ -66,7 +66,7 @@ import com.vitorpamplona.quartz.nip01Core.store.verifyAndInsert import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip05DnsIdentifiers.resolveUserHexOrNull import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip46RemoteSigner.signer.NostrSignerRemote import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip66RelayMonitor.reachability.RelayObserver @@ -760,11 +760,11 @@ class Context( * for [pubKey], or `null` if Amy has never observed one. Used by * `dm send` to resolve where to deliver a wrap. */ - suspend fun dmInboxOf(pubKey: HexKey): ChatMessageRelayListEvent? = + suspend fun dmInboxOf(pubKey: HexKey): DmRelayListEvent? = store .query<Event>( - Filter(authors = listOf(pubKey), kinds = listOf(ChatMessageRelayListEvent.KIND), limit = 1), - ).firstOrNull() as? ChatMessageRelayListEvent + Filter(authors = listOf(pubKey), kinds = listOf(DmRelayListEvent.KIND), limit = 1), + ).firstOrNull() as? DmRelayListEvent /** * Latest known kind:10051 KeyPackage relay list (MIP-00) for diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GiftCommands.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GiftCommands.kt index 4df0d26172..73db57cb9d 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GiftCommands.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GiftCommands.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.cli.Context import com.vitorpamplona.amethyst.cli.DataDir import com.vitorpamplona.amethyst.cli.Output import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent /** @@ -41,7 +41,7 @@ import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent * Inner/wrap JSON comes from the positional argument or stdin (`-`). * * Thin assembly only: seal/wrap/unwrap all live in quartz - * (`SealedRumorEvent`, `GiftWrapEvent`). + * (`SealEvent`, `GiftWrapEvent`). */ object GiftCommands { val USAGE: String = @@ -87,7 +87,7 @@ object GiftCommands { Context.open(dataDir).use { ctx -> ctx.prepare() val peer = ctx.requireUserHex(to) - val seal = SealedRumorEvent.create(event = inner, encryptTo = peer, signer = ctx.signer) + val seal = SealEvent.create(event = inner, encryptTo = peer, signer = ctx.signer) val giftWrap = GiftWrapEvent.create(event = seal, recipientPubKey = peer) val wrapNode = Output.mapper.readTree(giftWrap.toJson()) @@ -134,7 +134,7 @@ object GiftCommands { return Output.error("decrypt_failed", "could not unwrap (is this gift addressed to the active account?): ${e.message}") } // The wrap holds a seal (kind:13); unseal it to recover the rumor. - val inner = if (unwrapped is SealedRumorEvent) unwrapped.unsealThrowing(ctx.signer) else unwrapped + val inner = if (unwrapped is SealEvent) unwrapped.unsealThrowing(ctx.signer) else unwrapped Output.emit(mapOf("event" to Output.mapper.readTree(inner.toJson()))) return 0 } diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GrapeRankCommand.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GrapeRankCommand.kt index 0d4ae9c3b8..3beb8aacc0 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GrapeRankCommand.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/GrapeRankCommand.kt @@ -51,7 +51,7 @@ import com.vitorpamplona.amethyst.cli.commands.graperank.GrapeRankScore * Answers "do I need to crawl again?" with no network and no signing. * - `amy graperank score [OBSERVER]` — local only: build the graph from the store, * score (same as bare `--offline`), and ALWAYS reconcile the result into the - * store as kind:30382 ContactCardEvent cards signed by the observer's + * store as kind:30382 UserAssertionEvent cards signed by the observer's * per-observer service key (`rank = round(score*100)`, cutoff `--min-rank`): * changed ranks are re-signed, unchanged ones skipped, dropped targets * retracted with a kind:5. That persisted card set is what `publish` and diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayCommands.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayCommands.kt index 09f31e2e29..3d5a3746ec 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayCommands.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayCommands.kt @@ -32,14 +32,14 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.relay.normalizer.normalizeRelayUrlOrNull import com.vitorpamplona.quartz.nip01Core.relay.normalizer.toHttp import com.vitorpamplona.quartz.nip11RelayInfo.Nip11RelayInformation -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayFacet import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -144,14 +144,14 @@ object RelayCommands { Flat( "dm", "dm", - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, setOf("chat", "inbox-dm"), // allRelays(), not relays(): every Flat here is read for SELF, // and the filtered accessor drops local entries meant for // attacker-supplied lists — making a deliberately configured // local relay report as no configuration at all. read = { c, pk -> c.dmInboxOf(pk)?.allRelays().orEmpty() }, - build = { c, r -> ChatMessageRelayListEvent.create(r, c.signer) }, + build = { c, r -> DmRelayListEvent.create(r, c.signer) }, ), Flat( "key-package", @@ -220,10 +220,10 @@ object RelayCommands { Flat( "feeds", "feeds", - RelayFeedsListEvent.KIND, + FavoriteRelayListEvent.KIND, setOf("favorites", "relay_feeds"), - read = { c, pk -> (c.latestReplaceable(pk, RelayFeedsListEvent.KIND) as? RelayFeedsListEvent)?.decryptRelays(c.signer).orEmpty() }, - build = { c, r -> RelayFeedsListEvent.create(r, c.signer) }, + read = { c, pk -> (c.latestReplaceable(pk, FavoriteRelayListEvent.KIND) as? FavoriteRelayListEvent)?.decryptRelays(c.signer).orEmpty() }, + build = { c, r -> FavoriteRelayListEvent.create(r, c.signer) }, ), ) diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupCommands.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupCommands.kt index 2f7e08bfdf..0bf79a57d1 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupCommands.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupCommands.kt @@ -33,9 +33,9 @@ import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip29RelayGroups.hTag import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.JoinRequestEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.LeaveRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.GroupTag import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nipC7Chats.ChatEvent @@ -116,7 +116,7 @@ object RelayGroupCommands { val createAck = ctx.publish(ctx.signer.sign(CreateGroupEvent.build(groupId)), target) val status = groupStatus(isPrivate, isClosed) - val edit = EditMetadataEvent.build(groupId, name = name, about = about, status = status) + val edit = GroupEditMetadataEvent.build(groupId, name = name, about = about, status = status) val editAck = ctx.publish(ctx.signer.sign(edit), target) // Track it in our own kind:10009 so `relaygroup list` shows it, matching // the Android create flow (Account.createRelayGroup → follow). @@ -154,7 +154,7 @@ object RelayGroupCommands { Context.open(dataDir).use { ctx -> ctx.prepare() - val join = JoinRequestEvent.build(groupId, reason = args.flag("reason") ?: "", inviteCode = args.flag("code")) + val join = GroupJoinRequestEvent.build(groupId, reason = args.flag("reason") ?: "", inviteCode = args.flag("code")) args.rejectUnknown() val signed = ctx.signer.sign(join) val ack = ctx.publish(signed, setOf(relay)) @@ -184,7 +184,7 @@ object RelayGroupCommands { Context.open(dataDir).use { ctx -> ctx.prepare() - val signed = ctx.signer.sign(LeaveRequestEvent.build(groupId)) + val signed = ctx.signer.sign(GroupLeaveRequestEvent.build(groupId)) val ack = ctx.publish(signed, setOf(relay)) RawEventSupport.publishGuard(ack, signed.id)?.let { return it } val listed = updateGroupList(ctx, relay, groupId, add = false) diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupModerationCommands.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupModerationCommands.kt index 12bde96071..937b14ed19 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupModerationCommands.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/RelayGroupModerationCommands.kt @@ -26,10 +26,10 @@ import com.vitorpamplona.amethyst.cli.DataDir import com.vitorpamplona.amethyst.cli.Output import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateInviteEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.PutUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.RemoveUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupCreateInviteEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupPutUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupRemoveUserEvent /** * Moderator/admin write verbs for a relay group (the relay is the final authority @@ -94,7 +94,7 @@ object RelayGroupModerationCommands { // A kind-9002 re-asserts the whole metadata, so omitted fields must be carried over // from the current 39000 — otherwise editing only a flag would wipe name/about/tags. val template = - EditMetadataEvent.build( + GroupEditMetadataEvent.build( groupId, name = args.flag("name") ?: meta?.name(), about = args.flag("about") ?: meta?.about(), @@ -127,7 +127,7 @@ object RelayGroupModerationCommands { ): Int { val code = Args(rest).flag("code") ?: return Output.error("bad_args", "relaygroup invite RELAY GROUP_ID --code CODE") return publishScoped(dataDir, rest, "relaygroup invite RELAY GROUP_ID --code CODE", allowedFlags = arrayOf("code")) { _, groupId, _ -> - CreateInviteEvent.build(groupId, code) + GroupCreateInviteEvent.build(groupId, code) } } @@ -153,7 +153,7 @@ object RelayGroupModerationCommands { Context.open(dataDir).use { ctx -> ctx.prepare() val pubkey = ctx.requireUserHex(user) - val signed = ctx.signer.sign(PutUserEvent.build(groupId, listOf(pubkey to roles))) + val signed = ctx.signer.sign(GroupPutUserEvent.build(groupId, listOf(pubkey to roles))) val ack = ctx.publish(signed, setOf(relay)) RawEventSupport.publishGuard(ack, signed.id)?.let { return it } Output.emit( @@ -186,7 +186,7 @@ object RelayGroupModerationCommands { Context.open(dataDir).use { ctx -> ctx.prepare() val pubkey = ctx.requireUserHex(user) - val signed = ctx.signer.sign(RemoveUserEvent.build(groupId, listOf(pubkey))) + val signed = ctx.signer.sign(GroupRemoveUserEvent.build(groupId, listOf(pubkey))) val ack = ctx.publish(signed, setOf(relay)) RawEventSupport.publishGuard(ack, signed.id)?.let { return it } Output.emit( diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/StatusReport.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/StatusReport.kt index 5109d78728..91e692140d 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/StatusReport.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/StatusReport.kt @@ -34,7 +34,7 @@ import com.vitorpamplona.quartz.nip01Core.metadata.UserMetadata import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.store.IEventStore import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip19Bech32.entities.NPub import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -317,7 +317,7 @@ internal object StatusReport { var profile: MetadataEvent? = null var contacts: ContactListEvent? = null var relayList: AdvertisedRelayListEvent? = null - var dmInbox: ChatMessageRelayListEvent? = null + var dmInbox: DmRelayListEvent? = null var wallet = false // Newest-first with limit 1 gives the last-activity stamp. @@ -330,7 +330,7 @@ internal object StatusReport { MetadataEvent.KIND, ContactListEvent.KIND, AdvertisedRelayListEvent.KIND, - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, CashuWalletEvent.KIND, ) store.query<Event>(Filter(authors = authors, kinds = describes)) { event -> @@ -340,7 +340,7 @@ internal object StatusReport { is MetadataEvent -> if (isNewer(event, profile)) profile = event is ContactListEvent -> if (isNewer(event, contacts)) contacts = event is AdvertisedRelayListEvent -> if (isNewer(event, relayList)) relayList = event - is ChatMessageRelayListEvent -> if (isNewer(event, dmInbox)) dmInbox = event + is DmRelayListEvent -> if (isNewer(event, dmInbox)) dmInbox = event is CashuWalletEvent -> wallet = true else -> Unit } diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/ZapCommand.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/ZapCommand.kt index 7f0300c989..df39413b02 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/ZapCommand.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/ZapCommand.kt @@ -33,8 +33,8 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import okhttp3.OkHttpClient /** @@ -222,8 +222,8 @@ object ZapCommand { sats: Long, lnAddress: String, comment: String, - request: LnZapRequestEvent, - zapType: LnZapEvent.ZapType, + request: ZapRequestEvent, + zapType: ZapReceiptEvent.ZapType, timeoutMs: Long, settleWith: NDebit?, zappedEventId: HexKey? = null, @@ -300,7 +300,7 @@ object ZapCommand { sats: Long, comment: String, zappedEventId: HexKey, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, requests: List<ZapActions.ZapRequestForSplit>, timeoutMs: Long, settleWith: NDebit?, @@ -350,11 +350,11 @@ object ZapCommand { ) } - private fun parseZapType(args: Args): LnZapEvent.ZapType = + private fun parseZapType(args: Args): ZapReceiptEvent.ZapType = when { - args.bool("anon") -> LnZapEvent.ZapType.ANONYMOUS - args.bool("private") -> LnZapEvent.ZapType.PRIVATE - else -> LnZapEvent.ZapType.PUBLIC + args.bool("anon") -> ZapReceiptEvent.ZapType.ANONYMOUS + args.bool("private") -> ZapReceiptEvent.ZapType.PRIVATE + else -> ZapReceiptEvent.ZapType.PUBLIC } private suspend fun fetchLatestMetadata( diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankOperator.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankOperator.kt index c380072c06..057768d857 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankOperator.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankOperator.kt @@ -34,7 +34,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -45,7 +45,7 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.list.serviceProviders import com.vitorpamplona.quartz.nip85TrustedAssertions.list.tags.ProviderTypes import com.vitorpamplona.quartz.nip85TrustedAssertions.list.tags.ServiceProviderTag import com.vitorpamplona.quartz.nip85TrustedAssertions.list.tags.ServiceType -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.utils.TimeUtils /** @@ -90,8 +90,8 @@ object GrapeRankOperator { linkedMapOf<String, Any?>( "observer" to observer, "provider_pubkey" to rec.providerPubKey, - "cards" to ctx.store.count(Filter(kinds = listOf(ContactCardEvent.KIND), authors = listOf(rec.providerPubKey))), - "retractions" to ctx.store.count(Filter(kinds = listOf(DeletionEvent.KIND), authors = listOf(rec.providerPubKey))), + "cards" to ctx.store.count(Filter(kinds = listOf(UserAssertionEvent.KIND), authors = listOf(rec.providerPubKey))), + "retractions" to ctx.store.count(Filter(kinds = listOf(DeletionRequestEvent.KIND), authors = listOf(rec.providerPubKey))), ) } diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankPublish.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankPublish.kt index f57b4eb3ce..dff06fcc6f 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankPublish.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankPublish.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListEve import com.vitorpamplona.quartz.nip85TrustedAssertions.list.serviceProviders import com.vitorpamplona.quartz.nip85TrustedAssertions.list.tags.ProviderTypes import com.vitorpamplona.quartz.nip85TrustedAssertions.list.tags.ServiceProviderTag -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent /** * The transport + consumption sides of NIP-85: `graperank publish` pushes the @@ -169,12 +169,12 @@ object GrapeRankPublish { val provider = providerArg?.let { ctx.requireUserHex(it) } val cardFilter = Filter( - kinds = listOf(ContactCardEvent.KIND), + kinds = listOf(UserAssertionEvent.KIND), tags = mapOf("d" to listOf(user)), authors = provider?.let { listOf(it) }, ) - suspend fun localCards(): List<ContactCardEvent> = ctx.store.query<Event>(cardFilter).filterIsInstance<ContactCardEvent>() + suspend fun localCards(): List<UserAssertionEvent> = ctx.store.query<Event>(cardFilter).filterIsInstance<UserAssertionEvent>() var cards = localCards() if (refresh || cards.isEmpty()) { @@ -190,7 +190,7 @@ object GrapeRankPublish { cards .groupBy { it.pubKey } .mapNotNull { (_, list) -> list.maxByOrNull { it.createdAt } } - .sortedWith(compareByDescending<ContactCardEvent> { it.rank() ?: -1 }.thenByDescending { it.createdAt }) + .sortedWith(compareByDescending<UserAssertionEvent> { it.rank() ?: -1 }.thenByDescending { it.createdAt }) // A provider key this machine's operator master derived maps back to // the observer whose subjective view the rank expresses. @@ -236,7 +236,7 @@ object GrapeRankPublish { if (!ctx.anonymous) { providerListOf(ctx, ctx.identity.pubKeyHex) ?.serviceProviders() - ?.filter { it.service.kind == ContactCardEvent.KIND && (provider == null || it.pubkey == provider) } + ?.filter { it.service.kind == UserAssertionEvent.KIND && (provider == null || it.pubkey == provider) } ?.map { it.relayUrl } .orEmpty() } else { diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankScore.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankScore.kt index 34efcf4f86..e23b4a3b06 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankScore.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/graperank/GrapeRankScore.kt @@ -34,8 +34,8 @@ import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent import com.vitorpamplona.quartz.nip09Deletions.DeletionIndex +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import kotlin.math.roundToInt @@ -293,8 +293,8 @@ object GrapeRankScore { // Everything in the store already passed verifyAndStore, so mark the // deletions as verified and skip the redundant signature check. val deletions = DeletionIndex() - for (ev in ctx.store.query<Event>(Filter(kinds = listOf(DeletionEvent.KIND)))) { - if (ev is DeletionEvent) deletions.add(ev, wasVerified = true) + for (ev in ctx.store.query<Event>(Filter(kinds = listOf(DeletionRequestEvent.KIND)))) { + if (ev is DeletionRequestEvent) deletions.add(ev, wasVerified = true) } var dropped = 0 diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt index dbfb17605c..f5e80b7685 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt @@ -33,11 +33,11 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip02FollowList.tags.ContactTag -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent /** @@ -58,12 +58,12 @@ data class AccountBootstrapEvents( val userMetadata: MetadataEvent, val contactList: ContactListEvent, val nip65RelayList: AdvertisedRelayListEvent, - val dmRelayList: ChatMessageRelayListEvent, + val dmRelayList: DmRelayListEvent, val keyPackageRelayList: KeyPackageRelayListEvent, val searchRelayList: SearchRelayListEvent, val indexerRelayList: IndexerRelayListEvent, - val channelList: ChannelListEvent, - val relayFeedsList: RelayFeedsListEvent, + val channelList: PublicChatListEvent, + val relayFeedsList: FavoriteRelayListEvent, ) { /** All nine signed events in publication order. */ fun all(): List<com.vitorpamplona.quartz.nip01Core.core.Event> = @@ -102,13 +102,13 @@ fun bootstrapAccountEvents( signer = signer, ), nip65RelayList = AdvertisedRelayListEvent.create(DefaultNIP65List, signer), - dmRelayList = ChatMessageRelayListEvent.create(DefaultDMRelayList, signer), + dmRelayList = DmRelayListEvent.create(DefaultDMRelayList, signer), // MIP-00: advertise the default outbox relays as KeyPackage hosts // so other users can discover and fetch this account's KeyPackage // events without having to guess where they were published. keyPackageRelayList = KeyPackageRelayListEvent.create(DefaultNIP65RelaySet.toList(), signer), searchRelayList = SearchRelayListEvent.create(DefaultSearchRelayList.toList(), signer), indexerRelayList = IndexerRelayListEvent.create(DefaultIndexerRelayList.toList(), signer), - channelList = ChannelListEvent.create(emptyList(), DefaultChannels, signer), - relayFeedsList = RelayFeedsListEvent.create(DefaultGlobalRelays, signer), + channelList = PublicChatListEvent.create(emptyList(), DefaultChannels, signer), + relayFeedsList = FavoriteRelayListEvent.create(DefaultGlobalRelays, signer), ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActions.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActions.kt index 5c6bd6ecc9..d9a75e71d8 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActions.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActions.kt @@ -25,13 +25,13 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent /** * NIP-57 zap-request building + LN address extraction. * - * Returns a signed [LnZapRequestEvent] (kind:9734) — the artifact a caller + * Returns a signed [ZapRequestEvent] (kind:9734) — the artifact a caller * hands to a LNURL-pay callback to receive a BOLT11 invoice. * * **Caller responsibilities** that the Amethyst Android flow handles but @@ -86,10 +86,10 @@ object ZapActions { amountMillisats: Long, inboxRelays: Set<NormalizedRelayUrl>, comment: String = "", - zapType: LnZapEvent.ZapType = LnZapEvent.ZapType.PUBLIC, + zapType: ZapReceiptEvent.ZapType = ZapReceiptEvent.ZapType.PUBLIC, lnurl: String? = null, - ): LnZapRequestEvent = - LnZapRequestEvent.create( + ): ZapRequestEvent = + ZapRequestEvent.create( userHex = recipientPubkey, relays = inboxRelays, signer = signer, @@ -118,12 +118,12 @@ object ZapActions { amountMillisats: Long, inboxRelays: Set<NormalizedRelayUrl>, comment: String = "", - zapType: LnZapEvent.ZapType = LnZapEvent.ZapType.PUBLIC, + zapType: ZapReceiptEvent.ZapType = ZapReceiptEvent.ZapType.PUBLIC, toUserPubkey: HexKey? = null, pollOption: Int? = null, lnurl: String? = null, - ): LnZapRequestEvent = - LnZapRequestEvent.create( + ): ZapRequestEvent = + ZapRequestEvent.create( zappedEvent = zappedEvent, relays = inboxRelays, signer = signer, @@ -142,7 +142,7 @@ object ZapActions { data class ZapRequestForSplit( val recipient: ZapSplitResolver.Recipient, val amountMillisats: Long, - val request: LnZapRequestEvent, + val request: ZapRequestEvent, ) /** @@ -172,7 +172,7 @@ object ZapActions { lookupLnAddress: suspend (HexKey) -> String?, lookupInboxRelays: suspend (HexKey) -> Set<NormalizedRelayUrl> = { emptySet() }, comment: String = "", - zapType: LnZapEvent.ZapType = LnZapEvent.ZapType.PUBLIC, + zapType: ZapReceiptEvent.ZapType = ZapReceiptEvent.ZapType.PUBLIC, pollOption: Int? = null, ): List<ZapRequestForSplit> { val recipients = ZapSplitResolver.resolve(zappedEvent, lookupLnAddress) @@ -189,7 +189,7 @@ object ZapActions { val recipientInbox = recipient.pubkey?.let { lookupInboxRelays(it) }.orEmpty() val allRelays = senderInboxRelays + recipientInbox + authorInbox val request = - LnZapRequestEvent.create( + ZapRequestEvent.create( zappedEvent = zappedEvent, relays = allRelays, signer = signer, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/signers/NostrSignerPermissionLedger.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/signers/NostrSignerPermissionLedger.kt index 0991204ea0..1cfcd2f99e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/signers/NostrSignerPermissionLedger.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/connectedApps/signers/NostrSignerPermissionLedger.kt @@ -28,27 +28,27 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ExternalReactionEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentCommentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceReplyEvent import com.vitorpamplona.quartz.nipA4PublicMessages.PublicMessageEvent @@ -232,7 +232,7 @@ class NostrSignerPermissionLedger( PublicMessageEvent.KIND, // 24 — NIP-A4 public messages (plaintext, public) ChannelMessageEvent.KIND, // 42 — public chat messages PollResponseEvent.KIND, // 1018 — voting in a poll (additive, like a reaction) - FileHeaderEvent.KIND, // 1063 — NIP-94 file metadata (shares a file reference) + FileMetadataEvent.KIND, // 1063 — NIP-94 file metadata (shares a file reference) PollEvent.KIND, // 1068 — creating a poll (additive public content) CommentEvent.KIND, // 1111 — NIP-22 threaded comments (same risk as kind 1) VoiceEvent.KIND, // 1222 — voice messages (audio post, like a picture/video) @@ -243,12 +243,12 @@ class NostrSignerPermissionLedger( TorrentEvent.KIND, // 2003 — NIP-35 torrent announcements (additive public content) TorrentCommentEvent.KIND, // 2004 — NIP-35 torrent comments HighlightEvent.KIND, // 9802 — highlighted snippets shared publicly - LnZapRequestEvent.KIND, // 9734 — Lightning zap request; the payment itself still prompts - LongTextNoteEvent.KIND, // 30023 — NIP-23 long-form articles (addressable content) - StatusEvent.KIND, // 30315 — ephemeral user status / presence - WikiNoteEvent.KIND, // 30818 — NIP-54 wiki articles (addressable content) - VideoHorizontalEvent.KIND, // 34235 — addressable horizontal video (NIP-71) - VideoVerticalEvent.KIND, // 34236 — addressable vertical video (NIP-71) + ZapRequestEvent.KIND, // 9734 — Lightning zap request; the payment itself still prompts + LongFormContentEvent.KIND, // 30023 — NIP-23 long-form articles (addressable content) + UserStatusEvent.KIND, // 30315 — ephemeral user status / presence + WikiArticleEvent.KIND, // 30818 — NIP-54 wiki articles (addressable content) + AddressableNormalVideoEvent.KIND, // 34235 — addressable horizontal video (NIP-71) + AddressableShortVideoEvent.KIND, // 34236 — addressable vertical video (NIP-71) PublicationIndexEvent.KIND, // 30040 — NKBIP-01 publication index (addressable content) LearningResourceEvent.KIND, // 30142 — learning resources (addressable content) BlossomPieceIndexEvent.KIND, // 32176 — Blossom piece indexes (addressable content) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/FeedContentState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/FeedContentState.kt index 02767f31d0..550621707b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/FeedContentState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/FeedContentState.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.service.BasicBundledInsert import com.vitorpamplona.amethyst.commons.service.BasicBundledUpdate import com.vitorpamplona.amethyst.commons.util.equalImmutableLists -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.utils.flattenToSet import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList @@ -149,7 +149,7 @@ class FeedContentState( val oldNotesState = _feedContent.value if (localFilter is AdditiveFeedFilter && lastFeedKey == localFilter.feedKey()) { if (oldNotesState is FeedState.Loaded) { - val deletionEvents: List<DeletionEvent> = newItems.mapNotNull { it.event as? DeletionEvent } + val deletionEvents: List<DeletionRequestEvent> = newItems.mapNotNull { it.event as? DeletionRequestEvent } val oldList = if (deletionEvents.isEmpty()) { diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt index 29a82221cb..b100491b67 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt @@ -84,7 +84,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.tags.people.PTag import com.vitorpamplona.quartz.nip01Core.tags.people.pTags -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip18Reposts.quotes.QEventTag import com.vitorpamplona.quartz.nip18Reposts.quotes.quote import com.vitorpamplona.quartz.nip59Giftwrap.rumors.RumorAssembler @@ -740,8 +740,8 @@ class MarmotManager( persistOwn: Boolean = true, ): TextMessageBundle { require(targetEvents.isNotEmpty()) { "buildDeletionMessage: targetEvents must not be empty" } - val template = DeletionEvent.build(targetEvents) - val innerEvent = RumorAssembler.assembleRumor<DeletionEvent>(signer.pubKey, template) + val template = DeletionRequestEvent.build(targetEvents) + val innerEvent = RumorAssembler.assembleRumor<DeletionRequestEvent>(signer.pubKey, template) val outbound = buildGroupMessage(nostrGroupId, innerEvent) if (persistOwn) persistDecryptedMessage(nostrGroupId, innerEvent.toJson()) return TextMessageBundle(outbound = outbound, innerEvent = innerEvent) @@ -1502,7 +1502,7 @@ class MarmotManager( val authorOf = HashMap<HexKey, HexKey>(messages.size) val claims = ArrayList<Pair<HexKey, HexKey>>() for (event in messages) { - if (event.kind == DeletionEvent.KIND) { + if (event.kind == DeletionRequestEvent.KIND) { for (tag in event.tags) { if (tag.size >= 2 && tag[0] == "e") claims.add(tag[1] to event.pubKey) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/DvmHeartbeat.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/DvmHeartbeat.kt index 449decb3cd..dcbcefa483 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/DvmHeartbeat.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/DvmHeartbeat.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.filterIntoSet import com.vitorpamplona.amethyst.commons.model.nip90DVMs.DvmHeartbeatRegistry import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent import com.vitorpamplona.quartz.nip90Dvms.dvmHeartbeat.DvmHeartbeatEvent import com.vitorpamplona.quartz.utils.TimeUtils @@ -56,7 +56,7 @@ fun LocalCache.cachedDvmAnnouncements(limit: Int = 100): List<AppDefinitionEvent addressables .filterIntoSet(AppDefinitionEvent.KIND) { _, note -> (note.event as? AppDefinitionEvent)?.let { - it.appMetaData()?.subscription != true && it.includeKind(NIP90ContentDiscoveryRequestEvent.KIND) + it.appMetaData()?.subscription != true && it.includeKind(DvmContentDiscoveryRequestEvent.KIND) } == true }.mapNotNull { it.event as? AppDefinitionEvent } .sortedByDescending { it.createdAt } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/HomeFeedType.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/HomeFeedType.kt index eb2ebb6c06..204864b038 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/HomeFeedType.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/HomeFeedType.kt @@ -40,19 +40,19 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip64Chess.challenge.offer.LiveChessGameChallengeEvent import com.vitorpamplona.quartz.nip64Chess.end.LiveChessGameEndEvent import com.vitorpamplona.quartz.nip64Chess.game.ChessGameEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent @@ -80,10 +80,10 @@ enum class HomeFeedType( REPOSTS("reposts", listOf(RepostEvent.KIND, GenericRepostEvent.KIND)), COMMENTS("comments", listOf(CommentEvent.KIND)), PICTURES("pictures", listOf(PictureEvent.KIND)), - VIDEOS("videos", listOf(VideoNormalEvent.KIND, VideoHorizontalEvent.KIND)), - SHORTS("shorts", listOf(VideoShortEvent.KIND, VideoVerticalEvent.KIND)), - ARTICLES("articles", listOf(LongTextNoteEvent.KIND)), - WIKI("wiki", listOf(WikiNoteEvent.KIND)), + VIDEOS("videos", listOf(VideoNormalEvent.KIND, AddressableNormalVideoEvent.KIND)), + SHORTS("shorts", listOf(VideoShortEvent.KIND, AddressableShortVideoEvent.KIND)), + ARTICLES("articles", listOf(LongFormContentEvent.KIND)), + WIKI("wiki", listOf(WikiArticleEvent.KIND)), HIGHLIGHTS("highlights", listOf(HighlightEvent.KIND)), POLLS("polls", listOf(PollEvent.KIND, ZapPollEvent.KIND, PollResponseEvent.KIND)), CLASSIFIEDS("classifieds", listOf(ClassifiedsEvent.KIND)), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/IAccount.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/IAccount.kt index 6b1e4d1640..54d776c06e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/IAccount.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/IAccount.kt @@ -24,11 +24,11 @@ import com.vitorpamplona.amethyst.commons.model.marmotGroups.MarmotGroupList import com.vitorpamplona.amethyst.commons.model.privateChats.ChatroomList import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Request import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response import com.vitorpamplona.quartz.nip57Zaps.IPrivateZapsDecryptionCache @@ -40,9 +40,9 @@ import com.vitorpamplona.quartz.utils.DualCase * Used by Note.kt for checking NWC payment status. */ interface INwcSignerState { - suspend fun decryptResponse(event: LnZapPaymentResponseEvent): Response? + suspend fun decryptResponse(event: NwcResponseEvent): Response? - suspend fun decryptRequest(event: LnZapPaymentRequestEvent): Request? + suspend fun decryptRequest(event: NwcRequestEvent): Request? fun isNIP47Author(pubKey: String?): Boolean } @@ -127,7 +127,7 @@ interface IAccount { fun isAcceptable(note: Note): Boolean /** Send a NIP-04 encrypted direct message */ - suspend fun sendNip04PrivateMessage(eventTemplate: EventTemplate<PrivateDmEvent>) + suspend fun sendNip04PrivateMessage(eventTemplate: EventTemplate<EncryptedDmEvent>) /** Send a NIP-17 gift-wrapped direct message */ suspend fun sendNip17PrivateMessage(template: EventTemplate<ChatMessageEvent>) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt index 3dde3a6d1e..342e88fda1 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/Note.kt @@ -51,16 +51,16 @@ import com.vitorpamplona.quartz.nip28PublicChat.base.IsInPublicChatChannel import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitiveOrNSFW import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayInvoiceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayInvoiceSuccessResponse import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip56Reports.ReportType -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip59Giftwrap.HostStub import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent @@ -1038,7 +1038,7 @@ open class Note( } return anyAsync(zapPayments) { next -> - val zapResponseEvent = next.second?.event as? LnZapPaymentResponseEvent + val zapResponseEvent = next.second?.event as? NwcResponseEvent if (zapResponseEvent != null) { val response = account.nip47SignerState.decryptResponse(zapResponseEvent) @@ -1066,11 +1066,11 @@ open class Note( return false } - val parallelDecrypt = mutableListOf<Pair<LnZapRequestEvent, LnZapEvent>>() + val parallelDecrypt = mutableListOf<Pair<ZapRequestEvent, ZapReceiptEvent>>() zapEvents.forEach { next -> - val zapRequest = next.key.event as LnZapRequestEvent - val zapEvent = next.value?.event as? LnZapEvent + val zapRequest = next.key.event as ZapRequestEvent + val zapEvent = next.value?.event as? ZapReceiptEvent if (zapEvent != null) { if (!zapRequest.isPrivateZap()) { @@ -1227,7 +1227,7 @@ open class Note( // Regular Zap Receipts zaps.forEach { val noteEvent = it.value?.event - if (noteEvent is LnZapEvent) { + if (noteEvent is ZapReceiptEvent) { sumOfAmounts += noteEvent.amount ?: BigDecimal(0) } } @@ -1299,8 +1299,8 @@ open class Note( paymentResponse: Note?, signerState: INwcSignerState, ): InvoiceAmount? { - val nwcRequest = paymentRequest.event as? LnZapPaymentRequestEvent - val nwcResponse = paymentResponse?.event as? LnZapPaymentResponseEvent + val nwcRequest = paymentRequest.event as? NwcRequestEvent + val nwcResponse = paymentResponse?.event as? NwcResponseEvent return if (nwcRequest != null && nwcResponse != null) { processZapAmountFromResponse( @@ -1319,8 +1319,8 @@ open class Note( ) private suspend fun processZapAmountFromResponse( - nwcRequest: LnZapPaymentRequestEvent, - nwcResponse: LnZapPaymentResponseEvent, + nwcRequest: NwcRequestEvent, + nwcResponse: NwcResponseEvent, signerState: INwcSignerState, ): InvoiceAmount? { // if we can decrypt the reply @@ -1361,7 +1361,7 @@ open class Note( } val invoiceSet = LinkedHashSet<String>(zaps.size + zapPayments.size) - zaps.forEach { (it.value?.event as? LnZapEvent)?.lnInvoice()?.let { invoiceSet.add(it) } } + zaps.forEach { (it.value?.event as? ZapReceiptEvent)?.lnInvoice()?.let { invoiceSet.add(it) } } return zappedAmountCalculation( zapsAmount, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssembler.kt index e07c1c98f9..d75e4ab742 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssembler.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent @@ -183,7 +183,7 @@ class ThreadAssembler( */ fun Event?.anchorsItsOwnThread(): Boolean = when (this) { - is ReactionEvent, is LnZapEvent, is NutzapEvent, is OnchainZapEvent, is Bolt12ZapEvent -> true + is ReactionEvent, is ZapReceiptEvent, is NutzapEvent, is OnchainZapEvent, is Bolt12ZapEvent -> true else -> false } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/User.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/User.kt index ac221fef95..aaa614f854 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/User.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/User.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.metadata.UserMetadata import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.people.PTag -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip19Bech32.entities.NProfile import com.vitorpamplona.quartz.nip19Bech32.toNpub import com.vitorpamplona.quartz.nip61Nutzaps.info.NutzapInfoEvent @@ -76,7 +76,7 @@ class User( val nip65RelayListNote: Note = context.addressableNote(AdvertisedRelayListEvent.createAddress(pubkeyHex)) - val dmRelayListNote: Note = context.addressableNote(ChatMessageRelayListEvent.createAddress(pubkeyHex)) + val dmRelayListNote: Note = context.addressableNote(DmRelayListEvent.createAddress(pubkeyHex)) val nutzapInfoNote: Note = context.addressableNote(NutzapInfoEvent.createAddress(pubkeyHex)) @@ -114,7 +114,7 @@ class User( fun pubkeyDisplayHex() = pubkeyNpub().toShortDisplay(5) - fun dmInboxRelayList() = dmRelayListNote.event as? ChatMessageRelayListEvent + fun dmInboxRelayList() = dmRelayListNote.event as? DmRelayListEvent fun authorRelayList() = nip65RelayListNote.event as? AdvertisedRelayListEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt index dd348ce0da..f32456f1c1 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt @@ -32,18 +32,18 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.tags.dTag.dTag import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip13Pow.tags.PoWTag -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent import com.vitorpamplona.quartz.nip40Expiration.ExpirationTag import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletEvent @@ -93,18 +93,18 @@ enum class BackupEventType { ContactListEvent.KIND -> FOLLOW_LIST MuteListEvent.KIND -> MUTE_LIST AdvertisedRelayListEvent.KIND -> OUTBOX_INBOX_RELAYS - ChatMessageRelayListEvent.KIND -> DM_RELAYS + DmRelayListEvent.KIND -> DM_RELAYS KeyPackageRelayListEvent.KIND -> KEY_PACKAGE_RELAYS SearchRelayListEvent.KIND -> SEARCH_RELAYS IndexerRelayListEvent.KIND -> INDEXER_RELAYS - RelayFeedsListEvent.KIND -> RELAY_FEEDS + FavoriteRelayListEvent.KIND -> RELAY_FEEDS BlockedRelayListEvent.KIND -> BLOCKED_RELAYS TrustedRelayListEvent.KIND -> TRUSTED_RELAYS PrivateOutboxRelayListEvent.KIND -> PRIVATE_OUTBOX_RELAYS AppSpecificDataEvent.KIND -> APP_SETTINGS - ChannelListEvent.KIND -> PUBLIC_CHATS + PublicChatListEvent.KIND -> PUBLIC_CHATS CommunityListEvent.KIND -> COMMUNITIES - HashtagListEvent.KIND -> HASHTAGS + InterestListEvent.KIND -> HASHTAGS GeohashListEvent.KIND -> GEOHASHES FavoriteAlgoFeedsListEvent.KIND -> FAVORITE_ALGO_FEEDS EphemeralChatListEvent.KIND -> EPHEMERAL_CHATS diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/CachePruner.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/CachePruner.kt index 8f26268712..119f2ff33e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/CachePruner.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/CachePruner.kt @@ -35,19 +35,19 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUsers import com.vitorpamplona.quartz.nip03Timestamp.OtsEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.base.BaseDMGroupEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.quotes.taggedQuoteIds import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip40Expiration.isExpirationBefore import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.TimeUtils @@ -207,7 +207,7 @@ class CachePruner( val roomNip04Pruned = HashMap<NormalizedRelayUrl, Long>() // chatroom.nip04History is lazy — only touch (allocate) it when this room actually drops a // kind:4 message, so rooms that never paged conversation history pay nothing. - val roomNip04Floor = if (toBeRemoved.any { it.event is PrivateDmEvent }) chatroom.nip04History.floor else null + val roomNip04Floor = if (toBeRemoved.any { it.event is EncryptedDmEvent }) chatroom.nip04History.floor else null toBeRemoved.forEach { note -> when (val ev = note.event) { @@ -216,7 +216,7 @@ class CachePruner( val outerUntil = note.rumorHost?.createdAt ?: ev.createdAt if (outerUntil < giftWrapFloor) note.relays.forEach { giftWrapPruned.mergeMax(it, outerUntil) } } - is PrivateDmEvent -> { + is EncryptedDmEvent -> { val until = ev.createdAt if (accountNip04Floor != null && until < accountNip04Floor) note.relays.forEach { accountNip04Pruned.mergeMax(it, until) } if (roomNip04Floor != null && until < roomNip04Floor) note.relays.forEach { roomNip04Pruned.mergeMax(it, until) } @@ -317,8 +317,8 @@ class CachePruner( ( (note.event is TextNoteEvent && !note.isNewThread()) || note.event is ReactionEvent || - note.event is LnZapEvent || - note.event is LnZapRequestEvent || + note.event is ZapReceiptEvent || + note.event is ZapRequestEvent || note.event is ReportEvent || note.event is GenericRepostEvent ) && @@ -413,11 +413,11 @@ class CachePruner( } } - if (note is AddressableNote && noteEvent is ContactCardEvent) { + if (note is AddressableNote && noteEvent is UserAssertionEvent) { cache.getUserIfExists(noteEvent.aboutUser())?.cardsOrNull()?.removeCard(note) } - if (note is AddressableNote && noteEvent is StatusEvent) { + if (note is AddressableNote && noteEvent is UserStatusEvent) { note.author?.statusStateOrNull()?.removeStatus(note) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt index d4aaf2d354..1789346dcf 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt @@ -221,28 +221,28 @@ import com.vitorpamplona.quartz.nip01Core.tags.events.GenericETag import com.vitorpamplona.quartz.nip01Core.tags.events.taggedEvents import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip03Timestamp.OtsEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip09Deletions.DeletionIndex +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.BaseNoteEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.BaseRepostEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip18Reposts.quotes.taggedQuoteIds import com.vitorpamplona.quartz.nip19Bech32.isATag import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ExternalReactionEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelHideMessageEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMuteUserEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip29RelayGroups.GroupId import com.vitorpamplona.quartz.nip29RelayGroups.groupId @@ -251,19 +251,19 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupParticipantsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateInviteEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteEventEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.PutUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.RemoveUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.UpdatePinListEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.JoinRequestEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.LeaveRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupCreateInviteEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupDeleteEventEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupPutUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupRemoveUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupUpdatePinListEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import com.vitorpamplona.quartz.nip32Labeling.LabelEvent import com.vitorpamplona.quartz.nip34Git.grasp.UserGraspListEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent @@ -278,31 +278,31 @@ import com.vitorpamplona.quartz.nip35Torrents.TorrentCommentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip39ExtIdentities.ExternalIdentitiesEvent import com.vitorpamplona.quartz.nip40Expiration.isExpired import com.vitorpamplona.quartz.nip43RelayMembers.addMember.RelayAddMemberEvent import com.vitorpamplona.quartz.nip43RelayMembers.list.RelayMembershipListEvent import com.vitorpamplona.quartz.nip43RelayMembers.removeMember.RelayRemoveMemberEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent @@ -310,7 +310,7 @@ import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent @@ -320,13 +320,13 @@ import com.vitorpamplona.quartz.nip53LiveActivities.nestsServers.NestsServersEve import com.vitorpamplona.quartz.nip53LiveActivities.presence.MeetingRoomPresenceEvent import com.vitorpamplona.quartz.nip53LiveActivities.raid.LiveActivitiesRaidEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeAcceptanceEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeRequestEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.validate.LnZapReceiptValidator import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlEndpointResolver import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlForm @@ -335,7 +335,7 @@ import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip58Badges.profile.ProfileBadgesEvent import com.vitorpamplona.quartz.nip59Giftwrap.HasInnerEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.RootSiteEvent @@ -360,20 +360,20 @@ import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip66RelayMonitor.discovery.RelayDiscoveryEvent import com.vitorpamplona.quartz.nip66RelayMonitor.monitor.RelayMonitorEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip71Video.textTrack.TextTrackEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip87Ecash.cashu.CashuMintEvent import com.vitorpamplona.quartz.nip87Ecash.fedimint.FedimintEvent import com.vitorpamplona.quartz.nip87Ecash.recommendation.MintRecommendationEvent @@ -381,13 +381,13 @@ import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent import com.vitorpamplona.quartz.nip90Dvms.dvmHeartbeat.DvmHeartbeatEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.NIP90UserDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.NIP90UserDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.DvmUserDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.DvmUserDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip96FileStorage.config.FileServersEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceEvent @@ -502,7 +502,7 @@ open class EventCache : val bolt12ZapValidator = Bolt12ZapValidator() /** - * Resolver for LNURL provider metadata used by [consume]`(LnZapEvent)` to + * Resolver for LNURL provider metadata used by [consume]`(ZapReceiptEvent)` to * validate NIP-57 Appendix F. `null` skips the receipt-signer check (the * receipt is still accepted on signature verification alone — matches legacy * behavior); set this in app init so receipts can be verified against the @@ -1210,7 +1210,7 @@ open class EventCache : } fun consume( - event: LongTextNoteEvent, + event: LongFormContentEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -1298,7 +1298,7 @@ open class EventCache : } fun consume( - event: WikiNoteEvent, + event: WikiArticleEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -1347,7 +1347,7 @@ open class EventCache : event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) } } - is LongTextNoteEvent -> { + is LongFormContentEvent -> { event.tagsWithoutCitations().mapNotNull { checkGetOrCreateNote(it) } } @@ -1405,7 +1405,7 @@ open class EventCache : event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) } } - is LnZapEvent -> { + is ZapReceiptEvent -> { event.zappedPost().mapNotNull { checkGetOrCreateNote(it) } + event.taggedAddresses().map { getOrCreateAddressableNote(it) } + (event.zapRequest?.taggedAddresses()?.map { getOrCreateAddressableNote(it) } ?: emptyList()) @@ -1438,11 +1438,11 @@ open class EventCache : // The zapped event is carried in the kind:9321's `e` tags // (and optionally an `a` tag for addressables). Whichever // notes those resolve to receive the nutzap entry — - // analogous to how LnZapEvent flows into `addZap`. + // analogous to how ZapReceiptEvent flows into `addZap`. event.linkedEventIds().mapNotNull { checkGetOrCreateNote(it) } } - is LnZapRequestEvent -> { + is ZapRequestEvent -> { event.zappedPost().mapNotNull { checkGetOrCreateNote(it) } + event.taggedAddresses().map { getOrCreateAddressableNote(it) } } @@ -1456,7 +1456,7 @@ open class EventCache : event.awardDefinition().map { getOrCreateAddressableNote(it) } } - is PrivateDmEvent -> { + is EncryptedDmEvent -> { event.taggedEvents().mapNotNull { checkGetOrCreateNote(it) } } @@ -1557,7 +1557,7 @@ open class EventCache : } fun consume( - event: StatusEvent, + event: UserStatusEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -1577,7 +1577,7 @@ open class EventCache : fun AddressableEvent.toAddressableNote() = getOrCreateAddressableNote(address()) fun consume( - event: ContactCardEvent, + event: UserAssertionEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -1667,7 +1667,7 @@ open class EventCache : } fun consume( - event: DeletionEvent, + event: DeletionRequestEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -2245,13 +2245,13 @@ open class EventCache : /** NIP-29 relay-declared supported roles (kind 39003) → the group's role set. */ fun consume( - event: SupportedRolesEvent, + event: GroupRolesEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { val new = consumeBaseReplaceable(event, relay, wasVerified) if (relay != null && isRelaySignedGroupEvent(event, relay)) { - val latest = getOrCreateAddressableNote(event.address()).event as? SupportedRolesEvent + val latest = getOrCreateAddressableNote(event.address()).event as? GroupRolesEvent latest?.let { getOrCreateRelayGroupChannel(GroupId(it.groupId(), relay)).updateSupportedRoles(it) } } return new @@ -2661,7 +2661,7 @@ open class EventCache : ): Boolean = false fun consume( - event: LnZapEvent, + event: ZapReceiptEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -2687,7 +2687,7 @@ open class EventCache : val zapRequest = event.zapRequest?.id?.let { getNoteIfExists(it) } - if (zapRequest == null || zapRequest.event !is LnZapRequestEvent) { + if (zapRequest == null || zapRequest.event !is ZapRequestEvent) { Log.d("ZP") { "Zap Request not found. Unable to process Zap {${event.toJson()}}" } return false } @@ -2788,7 +2788,7 @@ open class EventCache : * zap target). Returns null if we have no metadata, or the user has neither * lud16 nor lud06. */ - private fun recipientLnurl(event: LnZapEvent): String? { + private fun recipientLnurl(event: ZapReceiptEvent): String? { val recipientPubkey = event.zappedAuthor().firstOrNull() ?: return null val user = getUserIfExists(recipientPubkey) ?: return null return user.lnAddress()?.takeIf { it.isNotBlank() } @@ -2925,7 +2925,7 @@ open class EventCache : } private fun attachZapToLiveActivityChannel( - event: LnZapEvent, + event: ZapReceiptEvent, note: Note, relay: NormalizedRelayUrl?, ) { @@ -2963,7 +2963,7 @@ open class EventCache : } fun consume( - event: LnZapRequestEvent, + event: ZapRequestEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -3166,7 +3166,7 @@ open class EventCache : } fun consume( - event: LnZapPaymentRequestEvent, + event: NwcRequestEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -3175,11 +3175,11 @@ open class EventCache : } fun consume( - event: LnZapPaymentRequestEvent, + event: NwcRequestEvent, zappedNote: Note?, wasVerified: Boolean, relay: NormalizedRelayUrl?, - onResponse: suspend (LnZapPaymentResponseEvent) -> Unit, + onResponse: suspend (NwcResponseEvent) -> Unit, ): Boolean { val note = getOrCreateNote(event.id) val author = getOrCreateUser(event.pubKey) @@ -3213,7 +3213,7 @@ open class EventCache : } fun consume( - event: LnZapPaymentResponseEvent, + event: NwcResponseEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean, ): Boolean { @@ -3285,7 +3285,7 @@ open class EventCache : return false } - fun getPeopleListNotesFor(user: User): List<AddressableNote> = addressables.filter(PeopleListEvent.KIND, user.pubkeyHex) + fun getPeopleListNotesFor(user: User): List<AddressableNote> = addressables.filter(FollowSetEvent.KIND, user.pubkeyHex) override fun markAsSeen( eventId: String, @@ -3584,7 +3584,7 @@ open class EventCache : is ChannelMetadataEvent -> consume(event, relay, wasVerified) is ChannelMuteUserEvent -> consume(event, relay, wasVerified) is CommunityPostApprovalEvent -> consume(event, relay, wasVerified) - is DeletionEvent -> consume(event, relay, wasVerified) + is DeletionRequestEvent -> consume(event, relay, wasVerified) is DraftWrapEvent -> consume(event, relay, wasVerified) is EphemeralChatEvent -> consume(event, relay, wasVerified) is GeohashChatEvent -> consume(event, relay, wasVerified) @@ -3595,7 +3595,7 @@ open class EventCache : // 39003 (relay-declared roles) is durable group state like 39000/39001/39002: // route it onto the channel so a moderation UI can offer the relay's role set. - is SupportedRolesEvent -> consume(event, relay, wasVerified) + is GroupRolesEvent -> consume(event, relay, wasVerified) is GenericRepostEvent -> consume(event, relay, wasVerified) is FileStorageEvent -> consume(event, relay, wasVerified) @@ -3627,26 +3627,26 @@ open class EventCache : } } - is LnZapEvent -> consume(event, relay, wasVerified) - is LnZapRequestEvent -> consume(event, relay, wasVerified) + is ZapReceiptEvent -> consume(event, relay, wasVerified) + is ZapRequestEvent -> consume(event, relay, wasVerified) is OnchainZapEvent -> consume(event, relay, wasVerified) is Bolt12ZapEvent -> consume(event, relay, wasVerified) - is LnZapPaymentRequestEvent -> consume(event, relay, wasVerified) - is LnZapPaymentResponseEvent -> consume(event, relay, wasVerified) - is LongTextNoteEvent -> consume(event, relay, wasVerified) + is NwcRequestEvent -> consume(event, relay, wasVerified) + is NwcResponseEvent -> consume(event, relay, wasVerified) + is LongFormContentEvent -> consume(event, relay, wasVerified) is MetadataEvent -> consume(event, relay, wasVerified) is NipTextEvent -> consume(event, relay, wasVerified) is OtsEvent -> consume(event, relay, wasVerified) is PollResponseEvent -> consume(event, relay, wasVerified) is ReactionEvent -> consume(event, relay, wasVerified) is LabelEvent -> consume(event, relay, wasVerified) - is ContactCardEvent -> consume(event, relay, wasVerified) + is UserAssertionEvent -> consume(event, relay, wasVerified) is ReportEvent -> consume(event, relay, wasVerified) is RepostEvent -> consume(event, relay, wasVerified) - is StatusEvent -> consume(event, relay, wasVerified) + is UserStatusEvent -> consume(event, relay, wasVerified) is TextNoteModificationEvent -> consume(event, relay, wasVerified) is ConcordChatEditEvent -> consume(event, relay, wasVerified) - is WikiNoteEvent -> consume(event, relay, wasVerified) + is WikiArticleEvent -> consume(event, relay, wasVerified) is PaymentTargetsEvent -> consume(event, relay, wasVerified) is ChatEvent -> { @@ -3671,7 +3671,7 @@ open class EventCache : // Buzz workspace kinds (block/buzz — the Buzz dialect of NIP-29). // Timeline kinds attach into the group's BuzzWorkspaceChannel; the // rest are stored for query/state. Kinds 9041/39005/49001 are absent - // on purpose: their numbers belong to GoalEvent, GroupPinnedEvent and + // on purpose: their numbers belong to ZapGoalEvent, GroupPinnedEvent and // a non-wire audit kind. Kind 20001 is shared with GeohashPresenceEvent // (BitChat); EventFactory routes it to PresenceUpdateEvent only when the // BitChat `g` tag is absent, and it is handled below with the ephemerals. @@ -3799,14 +3799,14 @@ open class EventCache : is BroadcastRelayListEvent, is BookmarkListEvent, is OldBookmarkListEvent, - is CalendarEvent, + is CalendarCollectionEvent, is CalendarDateSlotEvent, is CalendarTimeSlotEvent, is CalendarRSVPEvent, is CashuWalletEvent, is NutzapInfoEvent, - is ChannelListEvent, - is ChatMessageRelayListEvent, + is PublicChatListEvent, + is DmRelayListEvent, is Bolt12OfferListEvent, is ClassifiedsEvent, is FundraiserEvent, @@ -3825,7 +3825,7 @@ open class EventCache : DvmHeartbeatRegistry.record(event.address(), event.createdAt) } is EmojiPackEvent, - is EmojiPackSelectionEvent, + is EmojiListEvent, is EphemeralChatListEvent, // NIP-51 "simple groups" list (kind 10009): the user's joined NIP-29 groups + // servers. Replaceable like its sibling lists; RelayGroupListState reads it from the @@ -3840,7 +3840,7 @@ open class EventCache : is GroupParticipantsEvent, is ExternalIdentitiesEvent, is FileServersEvent, - is FollowListEvent, + is StarterPackEvent, is GeocacheListingEvent, is GeocacheCurationListEvent, is GeohashListEvent, @@ -3854,7 +3854,7 @@ open class EventCache : is NamedSiteEvent, is RootNappletEvent, is NamedNappletEvent, - is RelayFeedsListEvent, + is FavoriteRelayListEvent, is KeyPackageEvent, is KeyPackageRelayListEvent, is LiveChessGameChallengeEvent, @@ -3862,14 +3862,14 @@ open class EventCache : is LiveChessMoveEvent, is LiveChessGameEndEvent, is LiveChessDrawOfferEvent, - is HashtagListEvent, + is InterestListEvent, is FavoriteAlgoFeedsListEvent, is IndexerRelayListEvent, is InteractiveStoryPrologueEvent, is InteractiveStorySceneEvent, is InteractiveStoryReadingStateEvent, is InterestSetEvent, - is LabeledBookmarkListEvent, + is BookmarkSetEvent, is MeetingSpaceEvent, is MeetingRoomEvent, is MusicTrackEvent, @@ -3884,7 +3884,7 @@ open class EventCache : is ProfileBadgesEvent, is ProxyRelayListEvent, is PinListEvent, - is PeopleListEvent, + is FollowSetEvent, // Buzz addressable/replaceable state. is PersonaEvent, is TeamEvent, @@ -3904,8 +3904,8 @@ open class EventCache : is SoftwareApplicationEvent, is TrustedRelayListEvent, is TrustProviderListEvent, - is VideoHorizontalEvent, - is VideoVerticalEvent, + is AddressableNormalVideoEvent, + is AddressableShortVideoEvent, is TextTrackEvent, is VideoCollaborationEvent, is VideoCurationSetEvent, @@ -3953,21 +3953,21 @@ open class EventCache : // one-shot events the relay is authoritative for (it applies them and // republishes the 39000/39001/39002); we store them so they're queryable, // but we don't act on them client-side. - is PutUserEvent, - is RemoveUserEvent, - is EditMetadataEvent, - is DeleteEventEvent, - is UpdatePinListEvent, + is GroupPutUserEvent, + is GroupRemoveUserEvent, + is GroupEditMetadataEvent, + is GroupDeleteEventEvent, + is GroupUpdatePinListEvent, is DeleteGroupEvent, is CreateGroupEvent, - is CreateInviteEvent, - is JoinRequestEvent, - is LeaveRequestEvent, + is GroupCreateInviteEvent, + is GroupJoinRequestEvent, + is GroupLeaveRequestEvent, is FhirResourceEvent, - is FileHeaderEvent, + is FileMetadataEvent, is ProfileGalleryEntryEvent, is FileStorageHeaderEvent, - is GoalEvent, + is ZapGoalEvent, is GroupEvent, is GitIssueEvent, is GitReplyEvent, @@ -3980,13 +3980,13 @@ open class EventCache : is JesterEvent, is HighlightEvent, is PodcastEpisodeEvent, - is NIP90StatusEvent, - is NIP90ContentDiscoveryResponseEvent, - is NIP90ContentDiscoveryRequestEvent, - is NIP90UserDiscoveryResponseEvent, - is NIP90UserDiscoveryRequestEvent, + is DvmStatusEvent, + is DvmContentDiscoveryResponseEvent, + is DvmContentDiscoveryRequestEvent, + is DvmUserDiscoveryResponseEvent, + is DvmUserDiscoveryRequestEvent, is PictureEvent, - is PrivateDmEvent, + is EncryptedDmEvent, is PublicMessageEvent, is RequestToVanishEvent, is CodeSnippetEvent, @@ -4000,7 +4000,7 @@ open class EventCache : is GeocacheVerificationEvent, is RoadEventReportEvent, is RoadEventConfirmationEvent, - is SealedRumorEvent, + is SealEvent, is SoftwareAssetEvent, is ExternalReactionEvent, is ExternalCitationEvent, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip23LongContent/LongFormPublishAction.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip23LongContent/LongFormPublishAction.kt index f34b9a0792..4526e93e9c 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip23LongContent/LongFormPublishAction.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip23LongContent/LongFormPublishAction.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.commons.model.nip23LongContent import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtag -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.utils.TimeUtils /** @@ -42,7 +42,7 @@ object LongFormPublishAction { * @param tags List of hashtag topics * @param dTag Unique identifier for this addressable event (slug) * @param signer The NostrSigner to sign the event - * @return Signed LongTextNoteEvent ready to broadcast + * @return Signed LongFormContentEvent ready to broadcast * @throws IllegalStateException if signer is not writeable */ suspend fun publish( @@ -53,7 +53,7 @@ object LongFormPublishAction { tags: List<String>, dTag: String, signer: NostrSigner, - ): LongTextNoteEvent { + ): LongFormContentEvent { if (!signer.isWriteable()) { throw IllegalStateException("Cannot publish: signer is not writeable") } @@ -63,7 +63,7 @@ object LongFormPublishAction { } val template = - LongTextNoteEvent.build( + LongFormContentEvent.build( description = content, title = title, summary = summary, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListDecryptionCache.kt index e8f16823c9..702240aee3 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListDecryptionCache.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.amethyst.commons.model.nip28PublicChats import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.list.channelSet import com.vitorpamplona.quartz.nip28PublicChat.list.channels import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache @@ -29,13 +29,13 @@ import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache class PublicChatListDecryptionCache( val signer: NostrSigner, ) { - val cachedPrivateLists = PrivateTagArrayEventCache<ChannelListEvent>(signer) + val cachedPrivateLists = PrivateTagArrayEventCache<PublicChatListEvent>(signer) - fun cachedChannelSet(event: ChannelListEvent) = cachedPrivateLists.mergeTagListPrecached(event).channelSet() + fun cachedChannelSet(event: PublicChatListEvent) = cachedPrivateLists.mergeTagListPrecached(event).channelSet() - fun cachedChannels(event: ChannelListEvent) = cachedPrivateLists.mergeTagListPrecached(event).channels() + fun cachedChannels(event: PublicChatListEvent) = cachedPrivateLists.mergeTagListPrecached(event).channels() - suspend fun channelSet(event: ChannelListEvent) = cachedPrivateLists.mergeTagList(event).channelSet() + suspend fun channelSet(event: PublicChatListEvent) = cachedPrivateLists.mergeTagList(event).channelSet() - suspend fun channels(event: ChannelListEvent) = cachedPrivateLists.mergeTagList(event).channels() + suspend fun channels(event: PublicChatListEvent) = cachedPrivateLists.mergeTagList(event).channels() } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt index 2c59434441..1f70bcea4b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.list.tags.ChannelTag import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope @@ -44,9 +44,9 @@ import kotlinx.coroutines.flow.transformLatest import kotlinx.coroutines.launch interface PublicChatListRepository { - fun channelList(): ChannelListEvent? + fun channelList(): PublicChatListEvent? - fun updateChannelListTo(newChannelList: ChannelListEvent?) + fun updateChannelListTo(newChannelList: PublicChatListEvent?) } class PublicChatListState( @@ -59,14 +59,14 @@ class PublicChatListState( // Creates a long-term reference for this note so that the GC doesn't collect the note it self val publicChatListNote = cache.getOrCreateAddressableNote(getChannelListAddress()) - fun getChannelListAddress() = ChannelListEvent.createAddress(signer.pubKey) + fun getChannelListAddress() = PublicChatListEvent.createAddress(signer.pubKey) fun getChannelListFlow(): StateFlow<NoteState> = publicChatListNote.flow().metadata.stateFlow - fun getChannelList(): ChannelListEvent? = publicChatListNote.event as? ChannelListEvent + fun getChannelList(): PublicChatListEvent? = publicChatListNote.event as? PublicChatListEvent suspend fun publicChatListWithBackup(note: Note): Set<ChannelTag> { - val event = note.event as? ChannelListEvent ?: settings.channelList() + val event = note.event as? PublicChatListEvent ?: settings.channelList() return event?.let { decryptionCache.channelSet(it) } ?: emptySet() } @@ -111,32 +111,32 @@ class PublicChatListState( emptyList(), ) - suspend fun follow(channel: PublicChatChannel): ChannelListEvent { + suspend fun follow(channel: PublicChatChannel): PublicChatListEvent { val publicChatList = getChannelList() return if (publicChatList == null) { - ChannelListEvent.create(ChannelTag(channel.idHex, channel.relayHintUrl()), true, signer) + PublicChatListEvent.create(ChannelTag(channel.idHex, channel.relayHintUrl()), true, signer) } else { - ChannelListEvent.add(publicChatList, ChannelTag(channel.idHex, channel.relayHintUrl()), true, signer) + PublicChatListEvent.add(publicChatList, ChannelTag(channel.idHex, channel.relayHintUrl()), true, signer) } } - suspend fun follow(channels: List<PublicChatChannel>): ChannelListEvent { + suspend fun follow(channels: List<PublicChatChannel>): PublicChatListEvent { val publicChatList = getChannelList() val channelTags = channels.map { ChannelTag(it.idHex, it.relayHintUrl()) } return if (publicChatList == null) { - ChannelListEvent.create(channelTags, true, signer) + PublicChatListEvent.create(channelTags, true, signer) } else { - ChannelListEvent.add(publicChatList, channelTags, true, signer) + PublicChatListEvent.add(publicChatList, channelTags, true, signer) } } - suspend fun unfollow(channel: PublicChatChannel): ChannelListEvent? { + suspend fun unfollow(channel: PublicChatChannel): PublicChatListEvent? { val publicChatList = getChannelList() return if (publicChatList != null) { - ChannelListEvent.remove(publicChatList, ChannelTag(channel.idHex, channel.relayHintUrl()), signer) + PublicChatListEvent.remove(publicChatList, ChannelTag(channel.idHex, channel.relayHintUrl()), signer) } else { null } @@ -155,7 +155,7 @@ class PublicChatListState( Log.d("AccountRegisterObservers", "Channel List Collector Start") getChannelListFlow().collect { Log.d("AccountRegisterObservers") { "Channel List for ${signer.pubKey}" } - (it.note.event as? ChannelListEvent)?.let { + (it.note.event as? PublicChatListEvent)?.let { settings.updateChannelListTo(it) } } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt index 9c029296f8..d1009af4cc 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent import com.vitorpamplona.quartz.nip29RelayGroups.tags.GroupAdminTag import com.vitorpamplona.quartz.nip29RelayGroups.tags.RoleTag import com.vitorpamplona.quartz.utils.cache.LargeCache @@ -237,7 +237,7 @@ class RelayGroupChannel( updateChannelInfo() } - fun updateSupportedRoles(event: SupportedRolesEvent) { + fun updateSupportedRoles(event: GroupRolesEvent) { // Only newer definitions supersede; equal-or-older is dropped (no redundant emit). if (event.createdAt <= supportedRolesUpdatedAt) return supportedRoles = event.roles() diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt index decf5f345e..612e2c5673 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.aTag.taggedAddresses import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -55,13 +55,13 @@ class EmojiPackState( // Creates a long-term reference for this note so that the GC doesn't collect the note it self val emojiPackListNote = cache.getOrCreateAddressableNote(getEmojiPackSelectionAddress()) - fun getEmojiPackSelectionAddress() = EmojiPackSelectionEvent.createAddress(signer.pubKey) + fun getEmojiPackSelectionAddress() = EmojiListEvent.createAddress(signer.pubKey) - fun getEmojiPackSelection(): EmojiPackSelectionEvent? = emojiPackListNote.event as? EmojiPackSelectionEvent + fun getEmojiPackSelection(): EmojiListEvent? = emojiPackListNote.event as? EmojiListEvent fun getEmojiPackSelectionFlow(): StateFlow<NoteState> = emojiPackListNote.flow().metadata.stateFlow - fun convertEmojiSelectionPack(selection: EmojiPackSelectionEvent?): List<StateFlow<NoteState>>? = + fun convertEmojiSelectionPack(selection: EmojiListEvent?): List<StateFlow<NoteState>>? = selection?.taggedAddresses()?.map { cache .getOrCreateAddressableNote(it) @@ -73,7 +73,7 @@ class EmojiPackState( val flow: StateFlow<List<StateFlow<NoteState>>?> = getEmojiPackSelectionFlow() .transformLatest { - emit(convertEmojiSelectionPack(it.note.event as? EmojiPackSelectionEvent)) + emit(convertEmojiSelectionPack(it.note.event as? EmojiListEvent)) }.onStart { emit(convertEmojiSelectionPack(getEmojiPackSelection())) }.flowOn(Dispatchers.IO) @@ -143,7 +143,7 @@ class EmojiPackState( } } - suspend fun addEmojiPack(emojiPack: Note): EmojiPackSelectionEvent { + suspend fun addEmojiPack(emojiPack: Note): EmojiListEvent { val emojiPackEvent = emojiPack.event if (emojiPackEvent !is EmojiPackEvent) throw IllegalArgumentException("Note is not an EmojiPackEvent; cannot add to emoji list.") @@ -151,21 +151,21 @@ class EmojiPackState( val usersEmojiList = getEmojiPackSelection() return if (usersEmojiList == null) { - val template = EmojiPackSelectionEvent.build(listOf(eventHint)) + val template = EmojiListEvent.build(listOf(eventHint)) signer.sign(template) } else { - val template = EmojiPackSelectionEvent.add(usersEmojiList, eventHint) + val template = EmojiListEvent.add(usersEmojiList, eventHint) signer.sign(template) } } - suspend fun removeEmojiPack(emojiPack: Note): EmojiPackSelectionEvent? { + suspend fun removeEmojiPack(emojiPack: Note): EmojiListEvent? { val usersEmojiList = getEmojiPackSelection() ?: throw IllegalArgumentException("No emoji pack selection exists to remove from.") val emojiPackEvent = emojiPack.event if (emojiPackEvent !is EmojiPackEvent) return null - val template = EmojiPackSelectionEvent.remove(usersEmojiList, emojiPackEvent) + val template = EmojiListEvent.remove(usersEmojiList, emojiPackEvent) return signer.sign(template) } } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip38UserStatuses/UserStatusAction.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip38UserStatuses/UserStatusAction.kt index 0040e9e0d8..4fac63e096 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip38UserStatuses/UserStatusAction.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip38UserStatuses/UserStatusAction.kt @@ -23,38 +23,38 @@ package com.vitorpamplona.amethyst.commons.model.nip38UserStatuses import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent class UserStatusAction { companion object { suspend fun create( newStatus: String, signer: NostrSigner, - type: String = StatusEvent.GENERAL, - ): StatusEvent = StatusEvent.create(newStatus, type, signer = signer) + type: String = UserStatusEvent.GENERAL, + ): UserStatusEvent = UserStatusEvent.create(newStatus, type, signer = signer) suspend fun update( oldStatus: AddressableNote, newStatus: String, signer: NostrSigner, - ): StatusEvent { - val oldEvent = oldStatus.event as? StatusEvent ?: throw IllegalStateException("Tried to update a non-status event") + ): UserStatusEvent { + val oldEvent = oldStatus.event as? UserStatusEvent ?: throw IllegalStateException("Tried to update a non-status event") - return StatusEvent.update(oldEvent, newStatus, signer) + return UserStatusEvent.update(oldEvent, newStatus, signer) } suspend fun delete( oldStatus: AddressableNote, signer: NostrSigner, ): List<Event> { - val oldEvent = oldStatus.event as? StatusEvent ?: throw IllegalStateException("Tried to update a non-status event") + val oldEvent = oldStatus.event as? UserStatusEvent ?: throw IllegalStateException("Tried to update a non-status event") - val event = StatusEvent.clear(oldEvent, signer) + val event = UserStatusEvent.clear(oldEvent, signer) val deletion = signer.sign( - DeletionEvent.buildForVersionOnly(listOf(event)), + DeletionRequestEvent.buildForVersionOnly(listOf(event)), ) return listOf(event, deletion) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt index a1d0403978..0d36cb6391 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.muteList.tags.MuteTag import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag import com.vitorpamplona.quartz.nip51Lists.muteList.tags.WordTag -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO @@ -48,14 +48,14 @@ class BlockPeopleListState( // Creates a long-term reference for this note so that the GC doesn't collect the note it self val blockListNote = cache.getOrCreateAddressableNote(getBlockListAddress()) - fun getBlockListAddress() = PeopleListEvent.createBlockAddress(signer.pubKey) + fun getBlockListAddress() = FollowSetEvent.createBlockAddress(signer.pubKey) fun getBlockListFlow(): StateFlow<NoteState> = blockListNote.flow().metadata.stateFlow - fun getBlockList(): PeopleListEvent? = blockListNote.event as? PeopleListEvent + fun getBlockList(): FollowSetEvent? = blockListNote.event as? FollowSetEvent suspend fun blockListWithBackup(note: Note): List<MuteTag> { - val event = note.event as? PeopleListEvent + val event = note.event as? FollowSetEvent return event?.let { decryptionCache.usersAndWords(it) } ?: emptyList() } @@ -70,32 +70,32 @@ class BlockPeopleListState( emptyList(), ) - suspend fun hideUser(pubkeyHex: String): PeopleListEvent { + suspend fun hideUser(pubkeyHex: String): FollowSetEvent { val blockList = getBlockList() return if (blockList != null) { - PeopleListEvent.add( + FollowSetEvent.add( earlierVersion = blockList, person = UserTag(pubkeyHex), isPrivate = true, signer = signer, ) } else { - PeopleListEvent.create( - title = PeopleListEvent.BLOCK_LIST_D_TAG, + FollowSetEvent.create( + title = FollowSetEvent.BLOCK_LIST_D_TAG, person = UserTag(pubkeyHex), isPrivate = true, signer = signer, - dTag = PeopleListEvent.BLOCK_LIST_D_TAG, + dTag = FollowSetEvent.BLOCK_LIST_D_TAG, ) } } - suspend fun showUser(pubkeyHex: String): PeopleListEvent? { + suspend fun showUser(pubkeyHex: String): FollowSetEvent? { val blockList = getBlockList() return if (blockList != null) { - PeopleListEvent.remove( + FollowSetEvent.remove( earlierVersion = blockList, person = UserTag(pubkeyHex), signer = signer, @@ -105,11 +105,11 @@ class BlockPeopleListState( } } - suspend fun showWord(word: String): PeopleListEvent? { + suspend fun showWord(word: String): FollowSetEvent? { val blockList = getBlockList() return if (blockList != null) { - PeopleListEvent.remove( + FollowSetEvent.remove( earlierVersion = blockList, person = WordTag(word), signer = signer, @@ -119,20 +119,20 @@ class BlockPeopleListState( } } - suspend fun showUsers(pubkeys: List<String>): PeopleListEvent? { + suspend fun showUsers(pubkeys: List<String>): FollowSetEvent? { if (pubkeys.isEmpty()) return null val blockList = getBlockList() ?: return null - return PeopleListEvent.removeAll( + return FollowSetEvent.removeAll( earlierVersion = blockList, persons = pubkeys.map { UserTag(it) }, signer = signer, ) } - suspend fun showWords(words: List<String>): PeopleListEvent? { + suspend fun showWords(words: List<String>): FollowSetEvent? { if (words.isEmpty()) return null val blockList = getBlockList() ?: return null - return PeopleListEvent.removeAll( + return FollowSetEvent.removeAll( earlierVersion = blockList, persons = words.map { WordTag(it) }, signer = signer, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/hashtagLists/HashtagListDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/hashtagLists/HashtagListDecryptionCache.kt index 6aa9da1171..db80d69a1b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/hashtagLists/HashtagListDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/hashtagLists/HashtagListDecryptionCache.kt @@ -22,15 +22,15 @@ package com.vitorpamplona.amethyst.commons.model.nip51Lists.hashtagLists import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.hashtagList.hashtagSet class HashtagListDecryptionCache( val signer: NostrSigner, ) { - val cachedPrivateLists = PrivateTagArrayEventCache<HashtagListEvent>(signer) + val cachedPrivateLists = PrivateTagArrayEventCache<InterestListEvent>(signer) - fun cachedHashtags(event: HashtagListEvent) = cachedPrivateLists.mergeTagListPrecached(event).hashtagSet() + fun cachedHashtags(event: InterestListEvent) = cachedPrivateLists.mergeTagListPrecached(event).hashtagSet() - suspend fun hashtags(event: HashtagListEvent) = cachedPrivateLists.mergeTagList(event).hashtagSet() + suspend fun hashtags(event: InterestListEvent) = cachedPrivateLists.mergeTagList(event).hashtagSet() } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleListDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleListDecryptionCache.kt index e8f1af7638..e31ca57983 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleListDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleListDecryptionCache.kt @@ -27,34 +27,34 @@ import com.vitorpamplona.quartz.nip51Lists.muteList.mutedUsers import com.vitorpamplona.quartz.nip51Lists.muteList.mutedUsersAndWords import com.vitorpamplona.quartz.nip51Lists.muteList.mutedWordSet import com.vitorpamplona.quartz.nip51Lists.muteList.mutedWords -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent class PeopleListDecryptionCache( val signer: NostrSigner, ) { - val cachedPrivateLists = PrivateTagArrayEventCache<PeopleListEvent>(signer) + val cachedPrivateLists = PrivateTagArrayEventCache<FollowSetEvent>(signer) - fun cachedUsersAndWords(event: PeopleListEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedUsersAndWords() + fun cachedUsersAndWords(event: FollowSetEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedUsersAndWords() - fun cachedUsers(event: PeopleListEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedUsers() + fun cachedUsers(event: FollowSetEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedUsers() - fun cachedUserIdSet(event: PeopleListEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedUserIdSet() + fun cachedUserIdSet(event: FollowSetEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedUserIdSet() - fun cachedWords(event: PeopleListEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedWords() + fun cachedWords(event: FollowSetEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedWords() - fun cachedWordSet(event: PeopleListEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedWordSet() + fun cachedWordSet(event: FollowSetEvent) = cachedPrivateLists.mergeTagListPrecached(event).mutedWordSet() - suspend fun usersAndWords(event: PeopleListEvent) = cachedPrivateLists.mergeTagList(event).mutedUsersAndWords() + suspend fun usersAndWords(event: FollowSetEvent) = cachedPrivateLists.mergeTagList(event).mutedUsersAndWords() - suspend fun users(event: PeopleListEvent) = cachedPrivateLists.mergeTagList(event).mutedUsers() + suspend fun users(event: FollowSetEvent) = cachedPrivateLists.mergeTagList(event).mutedUsers() - suspend fun userIdSet(event: PeopleListEvent) = cachedPrivateLists.mergeTagList(event).mutedUserIdSet() + suspend fun userIdSet(event: FollowSetEvent) = cachedPrivateLists.mergeTagList(event).mutedUserIdSet() - suspend fun words(event: PeopleListEvent) = cachedPrivateLists.mergeTagList(event).mutedWords() + suspend fun words(event: FollowSetEvent) = cachedPrivateLists.mergeTagList(event).mutedWords() - suspend fun wordSet(event: PeopleListEvent) = cachedPrivateLists.mergeTagList(event).mutedWordSet() + suspend fun wordSet(event: FollowSetEvent) = cachedPrivateLists.mergeTagList(event).mutedWordSet() - suspend fun privateUsers(event: PeopleListEvent) = cachedPrivateLists.privateTags(event)?.mutedUsers() ?: emptyList() + suspend fun privateUsers(event: FollowSetEvent) = cachedPrivateLists.privateTags(event)?.mutedUsers() ?: emptyList() - suspend fun privateUserIdSet(event: PeopleListEvent) = cachedPrivateLists.privateTags(event)?.mutedUserIdSet() ?: emptySet() + suspend fun privateUserIdSet(event: FollowSetEvent) = cachedPrivateLists.privateTags(event)?.mutedUserIdSet() ?: emptySet() } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/relayFeeds/RelayFeedsListDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/relayFeeds/RelayFeedsListDecryptionCache.kt index 3d262d28b9..694897a993 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/relayFeeds/RelayFeedsListDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/relayFeeds/RelayFeedsListDecryptionCache.kt @@ -22,8 +22,8 @@ package com.vitorpamplona.amethyst.commons.model.nip51Lists.relayFeeds import com.vitorpamplona.amethyst.commons.model.nip51Lists.relayLists.GenericRelayListCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent class RelayFeedsListDecryptionCache( signer: NostrSigner, -) : GenericRelayListCache<RelayFeedsListEvent>(signer) +) : GenericRelayListCache<FavoriteRelayListEvent>(signer) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardDecryptionCache.kt index e6e5477791..61bb8a3705 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardDecryptionCache.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.amethyst.commons.model.toImmutableListOfLists import com.vitorpamplona.quartz.nip01Core.core.TagArray import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.users.petName import com.vitorpamplona.quartz.nip85TrustedAssertions.users.summary @@ -37,24 +37,24 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.users.summary class ContactCardDecryptionCache( val signer: NostrSigner, ) { - val cachedPrivateCards = PrivateTagArrayEventCache<ContactCardEvent>(signer, cacheSize = 100) + val cachedPrivateCards = PrivateTagArrayEventCache<UserAssertionEvent>(signer, cacheSize = 100) - suspend fun petName(event: ContactCardEvent) = cachedPrivateCards.mergeTagList(event).petName() + suspend fun petName(event: UserAssertionEvent) = cachedPrivateCards.mergeTagList(event).petName() - suspend fun summary(event: ContactCardEvent) = cachedPrivateCards.mergeTagList(event).summary() + suspend fun summary(event: UserAssertionEvent) = cachedPrivateCards.mergeTagList(event).summary() /** * The decrypted petname and summary plus the card's full decrypted tag list, * so renderers can resolve the NIP-30 `emoji` mappings stored alongside them. */ - suspend fun nickname(event: ContactCardEvent): Nickname? = cachedPrivateCards.mergeTagList(event).toNickname() + suspend fun nickname(event: UserAssertionEvent): Nickname? = cachedPrivateCards.mergeTagList(event).toNickname() /** * Synchronous variant that only reads an already-decrypted card, for use as * the immediate value of UI flows. Returns null until the suspend path has * decrypted the card once. */ - fun cachedNickname(event: ContactCardEvent): Nickname? = cachedPrivateCards.mergeTagListPrecached(event).toNickname() + fun cachedNickname(event: UserAssertionEvent): Nickname? = cachedPrivateCards.mergeTagListPrecached(event).toNickname() private fun TagArray.toNickname(): Nickname? { val name = petName() diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardsState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardsState.kt index f643429c5c..ce8635472b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardsState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardsState.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.nip30CustomEmojis.EmojiPackState import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.IO @@ -59,11 +59,11 @@ class ContactCardsState( ) { private val accountUser: User? by lazy { cache.getOrCreateUser(signer.pubKey) } - fun createCardAddress(target: HexKey): Address = ContactCardEvent.createAddress(signer.pubKey, target) + fun createCardAddress(target: HexKey): Address = UserAssertionEvent.createAddress(signer.pubKey, target) fun getCardNote(target: HexKey): AddressableNote = cache.getOrCreateAddressableNote(createCardAddress(target)) - fun getCard(target: HexKey): ContactCardEvent? = getCardNote(target).event as? ContactCardEvent + fun getCard(target: HexKey): UserAssertionEvent? = getCardNote(target).event as? UserAssertionEvent /** * The account's own card about [target], as attached to the target user's @@ -71,7 +71,7 @@ class ContactCardsState( * per-user cache (like `metadata()` does) so a card arriving later is seen. */ @OptIn(ExperimentalCoroutinesApi::class) - fun myCardFlow(target: User): Flow<ContactCardEvent?> = + fun myCardFlow(target: User): Flow<UserAssertionEvent?> = target .cards() .receivedCards @@ -82,7 +82,7 @@ class ContactCardsState( ?.flow() ?.metadata ?.stateFlow - ?.map { it.note.event as? ContactCardEvent } + ?.map { it.note.event as? UserAssertionEvent } ?: flowOf(null) } @@ -110,7 +110,7 @@ class ContactCardsState( ?.receivedCards ?.value ?.get(accountUser) - ?.event as? ContactCardEvent ?: return null + ?.event as? UserAssertionEvent ?: return null return decryptionCache.cachedNickname(card) } @@ -145,12 +145,12 @@ class ContactCardsState( target: HexKey, petName: String?, summary: String?, - ): ContactCardEvent { + ): UserAssertionEvent { val emojis = emojiPacks.findEmojiTags(listOfNotNull(petName, summary).joinToString(" ")) val existing = getCard(target) return if (existing != null) { signer.sign( - ContactCardEvent.updatePetNameAndSummary( + UserAssertionEvent.updatePetNameAndSummary( earlierVersion = existing, petName = petName, summary = summary, @@ -159,7 +159,7 @@ class ContactCardsState( ), ) } else { - ContactCardEvent.create( + UserAssertionEvent.create( targetUser = target, petName = petName, summary = summary, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserCardsCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserCardsCache.kt index 5077850035..afe53a380b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserCardsCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserCardsCache.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.UserDependencies import com.vitorpamplona.amethyst.commons.relays.EOSERelayList import com.vitorpamplona.amethyst.commons.util.PlatformNumberFormatter -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO import kotlinx.coroutines.flow.MutableStateFlow @@ -104,7 +104,7 @@ class UserCardsCache : UserDependencies { emit(null) } }.map { - (it?.note?.event as? ContactCardEvent)?.rank() + (it?.note?.event as? UserAssertionEvent)?.rank() }.flowOn(Dispatchers.IO) private val formatter = PlatformNumberFormatter() @@ -132,7 +132,7 @@ class UserCardsCache : UserDependencies { emit(null) } }.map { - val value = (it?.note?.event as? ContactCardEvent)?.followerCount() + val value = (it?.note?.event as? UserAssertionEvent)?.followerCount() if (value != null && value > 0) { formatter.format(value.toLong()) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreview.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreview.kt index aa3502cc0b..55d278e140 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreview.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreview.kt @@ -22,12 +22,12 @@ package com.vitorpamplona.amethyst.commons.model.privateChats import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip51Lists.PrivateReplaceableTagArrayEvent import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent /** @@ -44,11 +44,11 @@ import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent */ fun Event.hasEncryptedContent(): Boolean = when (this) { - is PrivateDmEvent -> true + is EncryptedDmEvent -> true is DraftWrapEvent -> true - is SealedRumorEvent -> true + is SealEvent -> true is GiftWrapEvent -> true - is LnZapRequestEvent -> isPrivateZap() + is ZapRequestEvent -> isPrivateZap() // Every NIP-51 list keeps its private members as a NIP-44 payload in `content`. The two // base classes cover all ~30 list kinds, present and future, which is the point: naming // them one at a time is how kind 30005 came to print its own ciphertext on screen. @@ -105,7 +105,7 @@ fun chatPreviewOf( if (!canDecrypt) return ChatPreview.Undecryptable // A kind:4 addressed to neither me nor from me can't be opened with my key, ever. - if (event is PrivateDmEvent && myPubKey != null && !event.isIncluded(myPubKey)) { + if (event is EncryptedDmEvent && myPubKey != null && !event.isIncluded(myPubKey)) { return ChatPreview.Undecryptable } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/Chatroom.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/Chatroom.kt index b197e44971..61c493964c 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/Chatroom.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/Chatroom.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.amethyst.commons.util.WeakReference import com.vitorpamplona.amethyst.commons.util.withLock import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.paging.RelayLoadingCursors -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip14Subject.subject import com.vitorpamplona.quartz.nip17Dm.base.BaseDMGroupEvent import kotlinx.coroutines.channels.BufferOverflow @@ -151,8 +151,8 @@ class Chatroom : NotesGatherer { } else { // Old conversation, keep the last one. sorted.take(1).toSet() - } + sorted.filter { it.flowSet?.isInUse() ?: false } + sorted.filter { it.event !is PrivateDmEvent && it.event !is BaseDMGroupEvent } - // Both DM protocols are pruned by the recency rule above: NIP-04 (PrivateDmEvent) and NIP-17 + } + sorted.filter { it.flowSet?.isInUse() ?: false } + sorted.filter { it.event !is EncryptedDmEvent && it.event !is BaseDMGroupEvent } + // Both DM protocols are pruned by the recency rule above: NIP-04 (EncryptedDmEvent) and NIP-17 // (BaseDMGroupEvent rumors — ChatMessageEvent / file headers). Anything else that ever lands in a // room is kept. The caller realigns the per-relay download window for the dropped messages so // they can be paged again later (see LocalCache.pruneOldMessages + RelayLoadingCursors.rewindTo). diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/UsingRelayUnwrapper.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/UsingRelayUnwrapper.kt index 195c303fdb..c0824d52d2 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/UsingRelayUnwrapper.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/UsingRelayUnwrapper.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.utils.mapOfSet import kotlinx.coroutines.flow.Flow @@ -49,7 +49,7 @@ class UsingRelayUnwrapper { val relays = when (val noteEvent = outboxNote.note.event) { is AdvertisedRelayListEvent -> noteEvent.relaysNorm() - is ChatMessageRelayListEvent -> noteEvent.relays() + is DmRelayListEvent -> noteEvent.relays() else -> emptySet() } @@ -81,7 +81,7 @@ class UsingRelayUnwrapper { users .map { pubkeyHex -> cache - .getOrCreateAddressableNote(ChatMessageRelayListEvent.createAddress(pubkeyHex)) + .getOrCreateAddressableNote(DmRelayListEvent.createAddress(pubkeyHex)) .flow() .metadata.stateFlow.value }.toTypedArray() @@ -100,7 +100,7 @@ class UsingRelayUnwrapper { note.flow().metadata.stateFlow } + users.map { pubkeyHex -> - val note = cache.getOrCreateAddressableNote(ChatMessageRelayListEvent.createAddress(pubkeyHex)) + val note = cache.getOrCreateAddressableNote(DmRelayListEvent.createAddress(pubkeyHex)) note.flow().metadata.stateFlow } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt index eaf06a32b7..d48e5704a0 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt @@ -35,11 +35,11 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.Mute import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -61,8 +61,8 @@ class NoteFeedFlow( outboxRelays: Set<NormalizedRelayUrl>, ): IFeedTopNavFilter = when (noteEvent) { - is PeopleListEvent -> { - if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) { + is FollowSetEvent -> { + if (noteEvent.dTag() == FollowSetEvent.BLOCK_LIST_D_TAG) { MutedAuthorsByOutboxTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), blockedRelays) } else { AuthorsByOutboxTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), blockedRelays) @@ -73,7 +73,7 @@ class NoteFeedFlow( MutedAuthorsByOutboxTopNavFilter(caches.muteListCache.cachedUserIdSet(noteEvent), blockedRelays) } - is FollowListEvent -> { + is StarterPackEvent -> { AuthorsByOutboxTopNavFilter(noteEvent.followIdSet(), blockedRelays) } @@ -81,7 +81,7 @@ class NoteFeedFlow( AllCommunitiesTopNavFilter(caches.communityListCache.cachedCommunityIdSet(noteEvent), blockedRelays) } - is HashtagListEvent -> { + is InterestListEvent -> { HashtagTopNavFilter(caches.hashtagCache.cachedHashtags(noteEvent), outboxRelays) } @@ -108,8 +108,8 @@ class NoteFeedFlow( outboxRelays: Set<NormalizedRelayUrl>, ) { when (noteEvent) { - is PeopleListEvent -> { - if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) { + is FollowSetEvent -> { + if (noteEvent.dTag() == FollowSetEvent.BLOCK_LIST_D_TAG) { emit(MutedAuthorsByOutboxTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), blockedRelays)) } else { emit(AuthorsByOutboxTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), blockedRelays)) @@ -120,7 +120,7 @@ class NoteFeedFlow( emit(MutedAuthorsByOutboxTopNavFilter(caches.muteListCache.mutedUserIdSet(noteEvent), blockedRelays)) } - is FollowListEvent -> { + is StarterPackEvent -> { emit(AuthorsByOutboxTopNavFilter(noteEvent.followIdSet(), blockedRelays)) } @@ -128,7 +128,7 @@ class NoteFeedFlow( emit(AllCommunitiesTopNavFilter(caches.communityListCache.communityIdSet(noteEvent), blockedRelays)) } - is HashtagListEvent -> { + is InterestListEvent -> { emit(HashtagTopNavFilter(caches.hashtagCache.hashtags(noteEvent), outboxRelays)) } @@ -160,8 +160,8 @@ class NoteFeedFlow( proxyRelays: Set<NormalizedRelayUrl>, ): IFeedTopNavFilter = when (noteEvent) { - is PeopleListEvent -> { - if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) { + is FollowSetEvent -> { + if (noteEvent.dTag() == FollowSetEvent.BLOCK_LIST_D_TAG) { MutedAuthorsByProxyTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), proxyRelays) } else { AuthorsByProxyTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), proxyRelays) @@ -172,7 +172,7 @@ class NoteFeedFlow( MutedAuthorsByProxyTopNavFilter(caches.muteListCache.cachedUserIdSet(noteEvent), proxyRelays) } - is FollowListEvent -> { + is StarterPackEvent -> { AuthorsByProxyTopNavFilter(noteEvent.followIdSet(), proxyRelays) } @@ -180,7 +180,7 @@ class NoteFeedFlow( AllCommunitiesTopNavFilter(caches.communityListCache.cachedCommunityIdSet(noteEvent), blockedRelays) } - is HashtagListEvent -> { + is InterestListEvent -> { HashtagTopNavFilter(caches.hashtagCache.cachedHashtags(noteEvent), proxyRelays) } @@ -207,8 +207,8 @@ class NoteFeedFlow( proxyRelays: Set<NormalizedRelayUrl>, ) { when (noteEvent) { - is PeopleListEvent -> { - if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) { + is FollowSetEvent -> { + if (noteEvent.dTag() == FollowSetEvent.BLOCK_LIST_D_TAG) { emit(MutedAuthorsByProxyTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), proxyRelays)) } else { emit(AuthorsByProxyTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), proxyRelays)) @@ -219,7 +219,7 @@ class NoteFeedFlow( emit(MutedAuthorsByProxyTopNavFilter(caches.muteListCache.mutedUserIdSet(noteEvent), proxyRelays)) } - is FollowListEvent -> { + is StarterPackEvent -> { emit(AuthorsByProxyTopNavFilter(noteEvent.followIdSet(), proxyRelays)) } @@ -227,7 +227,7 @@ class NoteFeedFlow( emit(AllCommunitiesTopNavFilter(caches.communityListCache.communityIdSet(noteEvent), blockedRelays)) } - is HashtagListEvent -> { + is InterestListEvent -> { emit(HashtagTopNavFilter(caches.hashtagCache.hashtags(noteEvent), proxyRelays)) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/HashtagSpamCheck.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/HashtagSpamCheck.kt index d704e81e7a..e72e8201ee 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/HashtagSpamCheck.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/HashtagSpamCheck.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.commons.moderation import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hasMoreHashtagsThan -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent /** * Pure decision: should this note be collapsed because it abuses hashtag `t` tags? @@ -46,7 +46,7 @@ object HashtagSpamCheck { ): Boolean { if (!enabled) return false if (displayedEvent == null) return false - if (displayedEvent.kind == LongTextNoteEvent.KIND) return false + if (displayedEvent.kind == LongFormContentEvent.KIND) return false if (authorPubkey != null && authorPubkey in exemptKeys) return false return displayedEvent.tags.hasMoreHashtagsThan(threshold) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt index 1d911cd5bc..1147d8eeaf 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.commons.moderation.notifications import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent @@ -60,7 +60,7 @@ object NotificationKinds { val SUBSCRIPTION_KINDS: List<Int> = listOf( TextNoteEvent.KIND, // 1 — mentions + replies - PrivateDmEvent.KIND, // 4 — NIP-04 legacy DM + EncryptedDmEvent.KIND, // 4 — NIP-04 legacy DM RepostEvent.KIND, // 6 ReactionEvent.KIND, // 7 ChatMessageEvent.KIND, // 14 — NIP-17 DM rumor (rarely arrives raw; gift-wrap is more common) @@ -69,7 +69,7 @@ object NotificationKinds { CommentEvent.KIND, // 1111 — NIP-22 threaded comment GiftWrapEvent.KIND, // 1059 — NIP-17 gift-wrapped DM NutzapEvent.KIND, // 9321 — NIP-61 Cashu nutzap - LnZapEvent.KIND, // 9735 — NIP-57 zap receipt + ZapReceiptEvent.KIND, // 9735 — NIP-57 zap receipt OnchainZapEvent.KIND, // 8333 — onchain zap Bolt12ZapEvent.KIND, // 9736 — NIP-B1 BOLT12 zap // NIP-17 file-header messages (encrypted file DMs) @@ -114,7 +114,7 @@ object NotificationKinds { // Own events never notify — except zap receipts (LnZap/Nutzap/Onchain) // which are signed by the LNURL provider or the payer, not by us. if (event.pubKey == myPubKeyHex && - event !is LnZapEvent && + event !is ZapReceiptEvent && event !is NutzapEvent && event !is OnchainZapEvent && event !is Bolt12ZapEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRelayCleartext.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRelayCleartext.kt index 9cbee53bd1..8bd8d29085 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRelayCleartext.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRelayCleartext.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip04Dm.crypto.EncryptedInfo -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip44Encryption.Nip44v2 /** NAP-RELAY read boundary: encrypted event content is decrypted or withheld, never exposed. */ @@ -56,7 +56,7 @@ object NappletRelayCleartext { } fun isEncrypted(event: Event): Boolean = - event is PrivateDmEvent || + event is EncryptedDmEvent || EncryptedInfo.isNIP04(event.content) || isNip44V2(event.content) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt index 5244802c74..6026a0bba8 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt @@ -28,16 +28,16 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip53LiveActivities.nestsServers.NestsServersEvent @@ -51,7 +51,7 @@ val BasicAccountInfoKinds = MetadataEvent.KIND, ContactListEvent.KIND, AdvertisedRelayListEvent.KIND, - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, KeyPackageRelayListEvent.KIND, SearchRelayListEvent.KIND, FileServersEvent.KIND, @@ -66,10 +66,10 @@ val BasicAccountInfoKinds2 = BroadcastRelayListEvent.KIND, IndexerRelayListEvent.KIND, ProxyRelayListEvent.KIND, - HashtagListEvent.KIND, + InterestListEvent.KIND, GeohashListEvent.KIND, TrustProviderListEvent.KIND, - RelayFeedsListEvent.KIND, + FavoriteRelayListEvent.KIND, InterestSetEvent.KIND, // NIP-51 "simple groups" list (kind 10009), matching the sibling NIP-51 lists above. SimpleGroupListEvent.KIND, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt index 285fa83cb4..5d4a10c7a8 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent @@ -37,7 +37,7 @@ val ReportsAndBookmarksFromKeyKinds = ReportEvent.KIND, BookmarkListEvent.KIND, OldBookmarkListEvent.KIND, - LabeledBookmarkListEvent.KIND, + BookmarkSetEvent.KIND, PinListEvent.KIND, RequestToVanishEvent.KIND, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt index 1e9840ef13..fc0436f6a0 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt @@ -26,24 +26,24 @@ import com.vitorpamplona.quartz.experimental.ephemChat.list.EphemeralChatListEve import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent import com.vitorpamplona.quartz.nip58Badges.profile.ProfileBadgesEvent val FollowAndMutesFromKeyKinds = listOf( - PeopleListEvent.KIND, - FollowListEvent.KIND, + FollowSetEvent.KIND, + StarterPackEvent.KIND, MuteListEvent.KIND, AcceptedBadgeSetEvent.KIND, ProfileBadgesEvent.KIND, - EmojiPackSelectionEvent.KIND, + EmojiListEvent.KIND, EphemeralChatListEvent.KIND, - ChannelListEvent.KIND, + PublicChatListEvent.KIND, ) fun filterFollowsAndMutesFromKey( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/nip01Notifications/FilterNotificationsToPubkey.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/nip01Notifications/FilterNotificationsToPubkey.kt index 9cdd3a11c6..a341e4f78c 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/nip01Notifications/FilterNotificationsToPubkey.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/nip01Notifications/FilterNotificationsToPubkey.kt @@ -48,12 +48,12 @@ import com.vitorpamplona.quartz.nip34Git.status.GitStatusAppliedEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusClosedEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusDraftEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusOpenEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip64Chess.challenge.accept.LiveChessGameAcceptEvent import com.vitorpamplona.quartz.nip64Chess.move.LiveChessMoveEvent @@ -79,7 +79,7 @@ val GroupNotificationKinds = PollResponseEvent.KIND, RepostEvent.KIND, GenericRepostEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, Bolt12ZapEvent.KIND, ReportEvent.KIND, ) @@ -90,7 +90,7 @@ val SummaryKinds = ReactionEvent.KIND, RepostEvent.KIND, GenericRepostEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND, ) @@ -98,7 +98,7 @@ val SummaryKinds = val NotificationsPerKeyKinds = listOf( ReportEvent.KIND, - LnZapPaymentResponseEvent.KIND, + NwcResponseEvent.KIND, ChannelMessageEvent.KIND, EphemeralChatEvent.KIND, BadgeAwardEvent.KIND, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt index 87df5fba9c..237c08b2f9 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt @@ -26,9 +26,9 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.dTag.DTag -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent -val ContactCardKindList = listOf(ContactCardEvent.KIND) +val ContactCardKindList = listOf(UserAssertionEvent.KIND) /** * Kind:30382 cards *about* [targets], written by [trustedAccounts] (the account diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarKinds.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarKinds.kt index 80846f47b5..9842410406 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarKinds.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/calendars/CalendarKinds.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.commons.relayClient.calendars import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent // Appointments are the only kinds shown in the main calendar feed/views. RSVPs and @@ -34,6 +34,6 @@ val AllCalendarKinds = listOf( CalendarTimeSlotEvent.KIND, CalendarDateSlotEvent.KIND, - CalendarEvent.KIND, + CalendarCollectionEvent.KIND, CalendarRSVPEvent.KIND, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterGoalForLiveActivity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterGoalForLiveActivity.kt index 66f6929113..2468f528f6 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterGoalForLiveActivity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterGoalForLiveActivity.kt @@ -25,8 +25,8 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent @@ -50,7 +50,7 @@ fun filterGoalForLiveActivities( filter = ExplainedFilter( purpose = SubPurpose.LIVE_CHAT, - kinds = listOf(GoalEvent.KIND), + kinds = listOf(ZapGoalEvent.KIND), ids = listOf(goalId), limit = 1, ), @@ -60,7 +60,7 @@ fun filterGoalForLiveActivities( filter = ExplainedFilter( purpose = SubPurpose.LIVE_CHAT, - kinds = listOf(LnZapEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND), + kinds = listOf(ZapReceiptEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND), tags = mapOf("e" to listOf(goalId)), limit = 200, since = since?.get(relay)?.time, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToLiveStream.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToLiveStream.kt index a065038175..5ae7424389 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToLiveStream.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterMessagesToLiveStream.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip53LiveActivities.raid.LiveActivitiesRaidEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent @@ -47,7 +47,7 @@ fun filterMessagesToLiveActivities( LiveActivitiesChatMessageEvent.KIND, LiveActivitiesRaidEvent.KIND, LiveActivitiesClipEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuilders.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuilders.kt index 94135ea335..3b3b5226f2 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuilders.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuilders.kt @@ -55,7 +55,7 @@ import com.vitorpamplona.quartz.buzz.workflow.WorkflowTriggeredEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip29RelayGroups.GroupId @@ -63,8 +63,8 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteEventEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupDeleteEventEvent import com.vitorpamplona.quartz.nip29RelayGroups.tags.GroupIdTag import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.GroupTag import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent @@ -89,7 +89,7 @@ val RELAY_GROUP_METADATA_KINDS = GroupMetadataEvent.KIND, GroupAdminsEvent.KIND, GroupMembersEvent.KIND, - SupportedRolesEvent.KIND, + GroupRolesEvent.KIND, ) /** @@ -224,9 +224,9 @@ val RELAY_GROUP_ALL_TIMELINE_KINDS = RELAY_GROUP_TIMELINE_KINDS + BUZZ_RELAY_GRO */ val RELAY_GROUP_AUX_KINDS = listOf( - DeletionEvent.KIND, + DeletionRequestEvent.KIND, ReactionEvent.KIND, - DeleteEventEvent.KIND, + GroupDeleteEventEvent.KIND, ) /** How many aux events a channel replays on subscribe. Bounds the backfill; live delivery is unbounded. */ diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/FilterCommunityPosts.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/FilterCommunityPosts.kt index ef795c5880..fa00fd2524 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/FilterCommunityPosts.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/communities/FilterCommunityPosts.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent @@ -42,7 +42,7 @@ val CommunityPostKinds = RepostEvent.KIND, GenericRepostEvent.KIND, ClassifiedsEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, CommunityPostApprovalEvent.KIND, AttestationEvent.KIND, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/diagnostics/DmRelayDiagnosticsLogger.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/diagnostics/DmRelayDiagnosticsLogger.kt index f1ecab2c10..0eaa25ad91 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/diagnostics/DmRelayDiagnosticsLogger.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/diagnostics/DmRelayDiagnosticsLogger.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.commands.toClient.OkMessage import com.vitorpamplona.quartz.nip01Core.relay.commands.toRelay.AuthCmd import com.vitorpamplona.quartz.nip01Core.relay.commands.toRelay.Command import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.EphemeralGiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.utils.Log @@ -171,7 +171,7 @@ class DmRelayDiagnosticsLogger( // The kinds a DM-path REQ carries: NIP-17 gift wraps (1059 + 21059) and NIP-04 legacy DMs // (4). Matched exactly against the filter's "kinds" array — never as a substring of the whole // command, since a pubkey hex or timestamp can incidentally contain "1059" or "4". - private val DM_KINDS = setOf(GiftWrapEvent.KIND, EphemeralGiftWrapEvent.KIND, PrivateDmEvent.KIND) + private val DM_KINDS = setOf(GiftWrapEvent.KIND, EphemeralGiftWrapEvent.KIND, EncryptedDmEvent.KIND) private val KINDS_ARRAY = Regex("\"kinds\":\\[([0-9,\\s]*)]") diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAllCommunities.kt index ff5958375f..bd4233d7fa 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAllCommunities.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent fun filterLongFormAllCommunities( @@ -47,7 +47,7 @@ fun filterLongFormAllCommunities( tags = mapOf( "a" to communityList, - "k" to listOf(LongTextNoteEvent.KIND.toString()), + "k" to listOf(LongFormContentEvent.KIND.toString()), ), limit = 30, since = since, @@ -60,7 +60,7 @@ fun filterLongFormAllCommunities( ExplainedFilter( purpose = SubPurpose.DISCOVER_FEED, tags = mapOf("k" to listOf("5300"), "a" to communityList), - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), limit = 30, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAuthors.kt index e9b4eab6ae..14275756c6 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByAuthors.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent fun filterLongFormAuthors( relay: NormalizedRelayUrl, @@ -43,7 +43,7 @@ fun filterLongFormAuthors( ExplainedFilter( purpose = SubPurpose.DISCOVER_FEED, authors = authorList, - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), limit = 200, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByCommunity.kt index a93b476ab0..57a6f6a430 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByCommunity.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent fun filterLongFormByCommunity( @@ -48,7 +48,7 @@ fun filterLongFormByCommunity( tags = mapOf( "a" to listOf(community), - "k" to listOf(LongTextNoteEvent.KIND.toString()), + "k" to listOf(LongFormContentEvent.KIND.toString()), ), limit = 30, since = since, @@ -62,7 +62,7 @@ fun filterLongFormByCommunity( purpose = SubPurpose.DISCOVER_FEED, authors = authors, tags = mapOf("k" to listOf("5300"), "a" to listOf(community)), - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), limit = 30, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByGeohash.kt index cd35d75baa..5b86dbcb4e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByGeohash.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent fun filterLongFormByGeohash( relay: NormalizedRelayUrl, @@ -44,7 +44,7 @@ fun filterLongFormByGeohash( filter = ExplainedFilter( purpose = SubPurpose.DISCOVER_FEED, - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), tags = mapOf("g" to geoHashes), limit = 100, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByHashtag.kt index e857cd1b62..adefda859e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormByHashtag.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtagAlts -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent fun filterLongFormByHashtag( relay: NormalizedRelayUrl, @@ -44,7 +44,7 @@ fun filterLongFormByHashtag( filter = ExplainedFilter( purpose = SubPurpose.DISCOVER_FEED, - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), tags = mapOf("t" to hashtags), limit = 200, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormGlobal.kt index 67b266a7ab..78219f6a18 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip23LongForm/FilterLongFormGlobal.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.utils.TimeUtils fun filterLongFormGlobal( @@ -42,7 +42,7 @@ fun filterLongFormGlobal( filter = ExplainedFilter( purpose = SubPurpose.DISCOVER_FEED, - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), limit = 100, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt index b59a5bec9c..714813a311 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent fun filterFollowSetsAllCommunities( @@ -48,7 +48,7 @@ fun filterFollowSetsAllCommunities( tags = mapOf( "a" to communityList, - "k" to listOf(FollowListEvent.KIND.toString()), + "k" to listOf(StarterPackEvent.KIND.toString()), ), limit = 300, since = since, @@ -61,7 +61,7 @@ fun filterFollowSetsAllCommunities( ExplainedFilter( purpose = SubPurpose.FOLLOW_LISTS, tags = mapOf("k" to listOf("5300"), "a" to communityList), - kinds = listOf(FollowListEvent.KIND), + kinds = listOf(StarterPackEvent.KIND), limit = 300, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt index 0fc3c986d5..bcb5f3d944 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent fun filterFollowSetsAuthors( relay: NormalizedRelayUrl, @@ -43,7 +43,7 @@ fun filterFollowSetsAuthors( ExplainedFilter( purpose = SubPurpose.FOLLOW_LISTS, authors = authorList, - kinds = listOf(FollowListEvent.KIND), + kinds = listOf(StarterPackEvent.KIND), limit = 300, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt index 095ab751ed..65483bc063 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent fun filterFollowSetsByCommunity( @@ -48,7 +48,7 @@ fun filterFollowSetsByCommunity( tags = mapOf( "a" to listOf(community), - "k" to listOf(FollowListEvent.KIND.toString()), + "k" to listOf(StarterPackEvent.KIND.toString()), ), limit = 300, since = since, @@ -62,7 +62,7 @@ fun filterFollowSetsByCommunity( purpose = SubPurpose.FOLLOW_LISTS, authors = authors, tags = mapOf("k" to listOf("5300"), "a" to listOf(community)), - kinds = listOf(FollowListEvent.KIND), + kinds = listOf(StarterPackEvent.KIND), limit = 300, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt index f671ba36b7..8973d4358d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent fun filterFollowSetsByGeohash( relay: NormalizedRelayUrl, @@ -43,7 +43,7 @@ fun filterFollowSetsByGeohash( filter = ExplainedFilter( purpose = SubPurpose.FOLLOW_LISTS, - kinds = listOf(FollowListEvent.KIND), + kinds = listOf(StarterPackEvent.KIND), tags = mapOf("g" to geoHashes), limit = 300, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt index bc53534f50..21749a61e7 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtagAlts -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent fun filterFollowSetsByHashtag( relay: NormalizedRelayUrl, @@ -44,7 +44,7 @@ fun filterFollowSetsByHashtag( filter = ExplainedFilter( purpose = SubPurpose.FOLLOW_LISTS, - kinds = listOf(FollowListEvent.KIND), + kinds = listOf(StarterPackEvent.KIND), tags = mapOf("t" to hashtags), limit = 300, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt index a853b22722..c62c7bf76e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent fun filterFollowSetsGlobal( relays: GlobalTopNavPerRelayFilterSet, @@ -41,7 +41,7 @@ fun filterFollowSetsGlobal( filter = ExplainedFilter( purpose = SubPurpose.FOLLOW_LISTS, - kinds = listOf(FollowListEvent.KIND), + kinds = listOf(StarterPackEvent.KIND), limit = 100, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToAddresses.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToAddresses.kt index 25ad0322a1..0aadb128d6 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToAddresses.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToAddresses.kt @@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.experimental.videoCollaboration.VideoCollaborati import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent @@ -51,7 +51,7 @@ val RepliesAndReactionsToAddressesKinds1 = RepostEvent.KIND, GenericRepostEvent.KIND, ReportEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, Bolt12ZapEvent.KIND, ZapPollEvent.KIND, CommentEvent.KIND, @@ -88,7 +88,7 @@ val RootScopedRepliesToAddressesKinds = val DeletionKindList = listOf( - DeletionEvent.KIND, + DeletionRequestEvent.KIND, ) val TextNoteKindList = listOf(TextNoteEvent.KIND) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToNotes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToNotes.kt index 11c723a879..ea59b16521 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToNotes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/event/watchers/FilterRepliesAndReactionsToNotes.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip03Timestamp.OtsEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent @@ -46,11 +46,11 @@ import com.vitorpamplona.quartz.nip34Git.status.GitStatusDraftEvent import com.vitorpamplona.quartz.nip34Git.status.GitStatusOpenEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentCommentEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent import com.vitorpamplona.quartz.utils.mapOfSet @@ -62,7 +62,7 @@ val RepliesAndReactionsKinds = RepostEvent.KIND, GenericRepostEvent.KIND, ReportEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND, OtsEvent.KIND, @@ -89,9 +89,9 @@ val RootScopedRepliesKinds = val RepliesAndReactionsKinds2 = listOf( - DeletionEvent.KIND, - NIP90ContentDiscoveryResponseEvent.KIND, - NIP90StatusEvent.KIND, + DeletionRequestEvent.KIND, + DvmContentDiscoveryResponseEvent.KIND, + DvmStatusEvent.KIND, TorrentCommentEvent.KIND, GitReplyEvent.KIND, // NIP-34 status events (1630/1631/1632/1633). Rooted at the target diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/FilterPostsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/FilterPostsByGeohash.kt index 102d73791a..63bf3ed5bc 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/FilterPostsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/geohash/FilterPostsByGeohash.kt @@ -34,9 +34,9 @@ import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip73ExternalIds.location.GeohashId import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent @@ -49,7 +49,7 @@ val PostsByGeohashKinds = listOf( TextNoteEvent.KIND, ChannelMessageEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, PollEvent.KIND, ZapPollEvent.KIND, ClassifiedsEvent.KIND, @@ -60,7 +60,7 @@ val PostsByGeohashKinds = MusicPlaylistEvent.KIND, PodcastEpisodeEvent.KIND, PodcastMetadataEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, RoadEventReportEvent.KIND, RoadEventConfirmationEvent.KIND, GeocacheListingEvent.KIND, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByGeohashes.kt index 90bdc83585..ed72bcacfb 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByGeohashes.kt @@ -33,13 +33,13 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceEvent @@ -49,10 +49,10 @@ val HomePostsByGeohashKinds = TextNoteEvent.KIND, RepostEvent.KIND, GenericRepostEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, ClassifiedsEvent.KIND, HighlightEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, CommentEvent.KIND, VoiceEvent.KIND, AttestationEvent.KIND, @@ -60,8 +60,8 @@ val HomePostsByGeohashKinds = PictureEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, ) fun filterHomePostsByGeohashes( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByHashtags.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByHashtags.kt index 6983457805..ee76335ea9 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByHashtags.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip01Core/FilterHomePostsByHashtags.kt @@ -36,13 +36,13 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceEvent @@ -52,12 +52,12 @@ val HomePostsBuHashtagsKinds = TextNoteEvent.KIND, RepostEvent.KIND, GenericRepostEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, ClassifiedsEvent.KIND, HighlightEvent.KIND, AudioHeaderEvent.KIND, CommentEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, NipTextEvent.KIND, VoiceEvent.KIND, AttestationEvent.KIND, @@ -65,8 +65,8 @@ val HomePostsBuHashtagsKinds = PictureEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, ) fun filterHomePostsByHashtags( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip65Follows/FilterHomePostsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip65Follows/FilterHomePostsByAuthors.kt index d7daaa94c4..e9d27d4d9f 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip65Follows/FilterHomePostsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip65Follows/FilterHomePostsByAuthors.kt @@ -40,19 +40,19 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip64Chess.challenge.offer.LiveChessGameChallengeEvent import com.vitorpamplona.quartz.nip64Chess.end.LiveChessGameEndEvent import com.vitorpamplona.quartz.nip64Chess.game.ChessGameEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent @@ -67,18 +67,18 @@ val HomePostsNewThreadKinds1 = RepostEvent.KIND, GenericRepostEvent.KIND, ClassifiedsEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, HighlightEvent.KIND, ZapPollEvent.KIND, PollEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, AttestationEvent.KIND, NipTextEvent.KIND, PictureEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, ) val HomePostsNewThreadKinds2 = diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip72Communities/FilterHomePostsFromCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip72Communities/FilterHomePostsFromCommunities.kt index 096432af97..64e9a2f66d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip72Communities/FilterHomePostsFromCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip72Communities/FilterHomePostsFromCommunities.kt @@ -30,13 +30,13 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent @@ -45,11 +45,11 @@ import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent val HomePostsFromCommunityKinds = listOf( TextNoteEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, ClassifiedsEvent.KIND, HighlightEvent.KIND, PollEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, NipTextEvent.KIND, CommunityPostApprovalEvent.KIND, CommentEvent.KIND, @@ -57,8 +57,8 @@ val HomePostsFromCommunityKinds = PictureEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, ) /** The same set, as the `k` tag values a NIP-72 post approval carries. */ diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIds.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIds.kt index d8dbc554ab..6f575ea96d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIds.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIds.kt @@ -28,8 +28,8 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent /** * Builds relay REQ filters for a favorite-DVM home feed. @@ -112,8 +112,8 @@ private fun responseListenFilter( purpose = SubPurpose.HOME_FEED, kinds = listOf( - NIP90ContentDiscoveryResponseEvent.KIND, - NIP90StatusEvent.KIND, + DvmContentDiscoveryResponseEvent.KIND, + DvmStatusEvent.KIND, ), tags = mapOf("e" to requestIds), limit = 10 * requestIds.size, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAllCommunities.kt index c8b32bae95..f6461946c2 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAllCommunities.kt @@ -27,20 +27,20 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent val LongsFromCommunityKinds = listOf( VideoNormalEvent.KIND, - VideoHorizontalEvent.KIND, + AddressableNormalVideoEvent.KIND, ) val LongsFromCommunityKindsStr = listOf( VideoNormalEvent.KIND.toString(), - VideoHorizontalEvent.KIND.toString(), + AddressableNormalVideoEvent.KIND.toString(), ) fun filterLongsFromAllCommunities( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAuthors.kt index 2c365f4fbd..179349b97b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByAuthors.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent fun filterLongsByAuthors( @@ -44,7 +44,7 @@ fun filterLongsByAuthors( ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, authors = authorList, - kinds = listOf(VideoNormalEvent.KIND, VideoHorizontalEvent.KIND), + kinds = listOf(VideoNormalEvent.KIND, AddressableNormalVideoEvent.KIND), limit = 200, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByGeohashes.kt index 8cf5096e02..9c0d605be8 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByGeohashes.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent fun filterLongsByGeohashes( @@ -42,7 +42,7 @@ fun filterLongsByGeohashes( filter = ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, - kinds = listOf(VideoNormalEvent.KIND, VideoHorizontalEvent.KIND), + kinds = listOf(VideoNormalEvent.KIND, AddressableNormalVideoEvent.KIND), tags = mapOf("g" to geotags.sorted()), limit = 100, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByHashtag.kt index 85e2eee01b..956bd69436 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsByHashtag.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent fun filterLongsByHashtag( @@ -40,7 +40,7 @@ fun filterLongsByHashtag( filter = ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, - kinds = listOf(VideoNormalEvent.KIND, VideoHorizontalEvent.KIND), + kinds = listOf(VideoNormalEvent.KIND, AddressableNormalVideoEvent.KIND), tags = mapOf("t" to hashtags.toList()), limit = 200, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsGlobal.kt index c538f86362..e9378496a7 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/longs/FilterLongsGlobal.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.utils.TimeUtils @@ -43,7 +43,7 @@ fun filterLongsGlobal( filter = ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, - kinds = listOf(VideoNormalEvent.KIND, VideoHorizontalEvent.KIND), + kinds = listOf(VideoNormalEvent.KIND, AddressableNormalVideoEvent.KIND), limit = 200, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/GiftWrapDecryptor.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/GiftWrapDecryptor.kt index cf19417ca5..4b9d7a8bc4 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/GiftWrapDecryptor.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/GiftWrapDecryptor.kt @@ -22,25 +22,25 @@ package com.vitorpamplona.amethyst.commons.relayClient.nip17Dm import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent /** * Fully decrypt a NIP-59 gift wrap down to the inner rumor. * * A gift wrap carries two encryption layers: - * kind:1059 [GiftWrapEvent] → kind:13 [SealedRumorEvent] → the rumor. + * kind:1059 [GiftWrapEvent] → kind:13 [SealEvent] → the rumor. * * [GiftWrapEvent.unwrapOrNull] peels only the outer layer. Every non-Android * consumer that looks at the rumor directly (the CLI's `dm list`, the desktop * chat receive path, the Marmot welcome ingest in commons) needs both peels. * - * If the inner content isn't a [SealedRumorEvent] (malformed, or a future + * If the inner content isn't a [SealEvent] (malformed, or a future * NIP-59 variant that wraps a rumor directly), the outer unwrap result is * returned as-is so callers can still route on kind. Either unwrap returning * null propagates as null. */ suspend fun GiftWrapEvent.unwrapAndUnsealOrNull(signer: NostrSigner): Event? { val inner = unwrapOrNull(signer) ?: return null - return if (inner is SealedRumorEvent) inner.unsealOrNull(signer) else inner + return if (inner is SealEvent) inner.unsealOrNull(signer) else inner } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip47WalletConnect/FilterNWCPaymentsFromRequests.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip47WalletConnect/FilterNWCPaymentsFromRequests.kt index 815746628b..b4a468d7b2 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip47WalletConnect/FilterNWCPaymentsFromRequests.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip47WalletConnect/FilterNWCPaymentsFromRequests.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.commons.relayClient.nip47WalletConnect import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent // The request event id (#e) is a unique 32-byte identifier — sufficient on // its own to match a spec-compliant kind-23195 response. We deliberately keep @@ -43,7 +43,7 @@ fun filterNWCPaymentsFromRequests( fromUsers: Set<HexKey>, ): Filter = Filter( - kinds = listOf(LnZapPaymentResponseEvent.KIND), + kinds = listOf(NwcResponseEvent.KIND), tags = mapOf( "e" to paymentRequests.sorted(), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt index 022f5cb712..1ebb50c63b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt @@ -29,9 +29,9 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent val UserProfileListKinds = @@ -39,9 +39,9 @@ val UserProfileListKinds = BookmarkListEvent.KIND, OldBookmarkListEvent.KIND, PinListEvent.KIND, - PeopleListEvent.KIND, - FollowListEvent.KIND, - HashtagListEvent.KIND, + FollowSetEvent.KIND, + StarterPackEvent.KIND, + InterestListEvent.KIND, AppRecommendationEvent.KIND, PaymentTargetsEvent.KIND, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMedia.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMedia.kt index 5d689fbb15..46d26ab82c 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMedia.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileMedia.kt @@ -29,17 +29,17 @@ import com.vitorpamplona.quartz.experimental.profileGallery.ProfileGalleryEntryE import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent val UserProfileMediaKinds = listOf( PictureEvent.KIND, ProfileGalleryEntryEvent.KIND, - VideoVerticalEvent.KIND, - VideoHorizontalEvent.KIND, + AddressableShortVideoEvent.KIND, + AddressableNormalVideoEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfilePosts.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfilePosts.kt index a00b67bce8..ef9fe01388 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfilePosts.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfilePosts.kt @@ -40,11 +40,11 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentCommentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.RootSiteEvent import com.vitorpamplona.quartz.nip5dNapplets.NamedNappletEvent @@ -60,10 +60,10 @@ val UserProfilePostKinds1 = TextNoteEvent.KIND, GenericRepostEvent.KIND, RepostEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, PollEvent.KIND, HighlightEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, VoiceEvent.KIND, PublicMessageEvent.KIND, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileZapReceived.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileZapReceived.kt index 8d5ab4790b..af26c39476 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileZapReceived.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileZapReceived.kt @@ -26,11 +26,11 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent -val UserProfileZapReceiverKinds = listOf(LnZapEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND) +val UserProfileZapReceiverKinds = listOf(ZapReceiptEvent.KIND, OnchainZapEvent.KIND, Bolt12ZapEvent.KIND) fun filterUserProfileZapsReceived( cache: ICacheProvider, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/FilterPostsByRelay.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/FilterPostsByRelay.kt index becd8b7779..a6fc642406 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/FilterPostsByRelay.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/relay/FilterPostsByRelay.kt @@ -34,10 +34,10 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent @@ -48,12 +48,12 @@ val PostsByRelayKinds = listOf( TextNoteEvent.KIND, ChannelMessageEvent.KIND, - LongTextNoteEvent.KIND, + LongFormContentEvent.KIND, PollEvent.KIND, LiveActivitiesChatMessageEvent.KIND, ClassifiedsEvent.KIND, HighlightEvent.KIND, - WikiNoteEvent.KIND, + WikiArticleEvent.KIND, CommentEvent.KIND, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAllCommunities.kt index 18bcd8b0fa..9d420b8e6d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAllCommunities.kt @@ -27,20 +27,20 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent val ShortsFromCommunityKinds = listOf( VideoShortEvent.KIND, - VideoVerticalEvent.KIND, + AddressableShortVideoEvent.KIND, ) val ShortsFromCommunityKindsStr = listOf( VideoShortEvent.KIND.toString(), - VideoVerticalEvent.KIND.toString(), + AddressableShortVideoEvent.KIND.toString(), ) fun filterShortsFromAllCommunities( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAuthors.kt index 24bca3c574..e671e6a37f 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByAuthors.kt @@ -28,8 +28,8 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent fun filterShortsByAuthors( relay: NormalizedRelayUrl, @@ -44,7 +44,7 @@ fun filterShortsByAuthors( ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, authors = authorList, - kinds = listOf(VideoShortEvent.KIND, VideoVerticalEvent.KIND), + kinds = listOf(VideoShortEvent.KIND, AddressableShortVideoEvent.KIND), limit = 200, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByGeohashes.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByGeohashes.kt index c9afffb742..36345aa08e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByGeohashes.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByGeohashes.kt @@ -26,8 +26,8 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent fun filterShortsByGeohashes( relay: NormalizedRelayUrl, @@ -42,7 +42,7 @@ fun filterShortsByGeohashes( filter = ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, - kinds = listOf(VideoShortEvent.KIND, VideoVerticalEvent.KIND), + kinds = listOf(VideoShortEvent.KIND, AddressableShortVideoEvent.KIND), tags = mapOf("g" to geotags.sorted()), limit = 100, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByHashtag.kt index dfe7382fe8..16cb6c6dcb 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsByHashtag.kt @@ -26,8 +26,8 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent fun filterShortsByHashtag( relay: NormalizedRelayUrl, @@ -40,7 +40,7 @@ fun filterShortsByHashtag( filter = ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, - kinds = listOf(VideoShortEvent.KIND, VideoVerticalEvent.KIND), + kinds = listOf(VideoShortEvent.KIND, AddressableShortVideoEvent.KIND), tags = mapOf("t" to hashtags.toList()), limit = 200, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsGlobal.kt index ee0c14a2b1..ece2a170e2 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/shorts/FilterShortsGlobal.kt @@ -25,8 +25,8 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.utils.TimeUtils fun filterShortsGlobal( @@ -43,7 +43,7 @@ fun filterShortsGlobal( filter = ExplainedFilter( purpose = SubPurpose.MEDIA_FEED, - kinds = listOf(VideoShortEvent.KIND, VideoVerticalEvent.KIND), + kinds = listOf(VideoShortEvent.KIND, AddressableShortVideoEvent.KIND), limit = 200, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByAuthors.kt index 5eda45cb9b..1483c10824 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByAuthors.kt @@ -26,10 +26,10 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.application.SoftwareApplicationEvent -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.SoftwareReleaseEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent fun filterSoftwareAppsByAuthors( relay: NormalizedRelayUrl, @@ -44,7 +44,7 @@ fun filterSoftwareAppsByAuthors( ExplainedFilter( purpose = SubPurpose.ADD_ONS, authors = authorList, - kinds = listOf(SoftwareApplicationEvent.KIND, SoftwareReleaseEvent.KIND), + kinds = listOf(SoftwareApplicationEvent.KIND, ReleaseArtifactSetEvent.KIND), limit = 200, since = since, ), diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByHashtag.kt index 638eee590e..00ff7c3723 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsByHashtag.kt @@ -25,10 +25,10 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.application.SoftwareApplicationEvent -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.SoftwareReleaseEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtagAlts +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent fun filterSoftwareAppsByHashtag( relay: NormalizedRelayUrl, @@ -45,7 +45,7 @@ fun filterSoftwareAppsByHashtag( filter = ExplainedFilter( purpose = SubPurpose.TAG_FEED, - kinds = listOf(SoftwareApplicationEvent.KIND, SoftwareReleaseEvent.KIND), + kinds = listOf(SoftwareApplicationEvent.KIND, ReleaseArtifactSetEvent.KIND), tags = mapOf("t" to expanded), limit = 200, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsGlobal.kt index ed54dbf12d..c72a5c6ac1 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/softwareapps/FilterSoftwareAppsGlobal.kt @@ -25,10 +25,10 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.application.SoftwareApplicationEvent -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.SoftwareReleaseEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.normalizeRelayUrl +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent // zapstore's relay indexes the entire software-app catalog (NIP-82), so the // global Apps feed always queries it in addition to the user's own relays — @@ -57,7 +57,7 @@ fun filterSoftwareAppsGlobal( filter = ExplainedFilter( purpose = SubPurpose.ADD_ONS, - kinds = listOf(SoftwareApplicationEvent.KIND, SoftwareReleaseEvent.KIND), + kinds = listOf(SoftwareApplicationEvent.KIND, ReleaseArtifactSetEvent.KIND), // Keep the limit < 100. Relays such as zapstore's score filter // specificity and treat a limit >= 100 (or none) as too vague, // rejecting the whole REQ with "filters are too vague". diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/FilterUserMetadataForKey.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/FilterUserMetadataForKey.kt index db874ab832..0d1290113d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/FilterUserMetadataForKey.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/FilterUserMetadataForKey.kt @@ -32,8 +32,8 @@ import com.vitorpamplona.quartz.nip01Core.hints.HintIndexer import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip39ExtIdentities.ExternalIdentitiesEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.NutzapInfoEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -44,9 +44,9 @@ val UserMetadataForKeyKinds = listOf( MetadataEvent.KIND, ExternalIdentitiesEvent.KIND, - StatusEvent.KIND, + UserStatusEvent.KIND, AdvertisedRelayListEvent.KIND, - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, KeyPackageRelayListEvent.KIND, PaymentTargetsEvent.KIND, Bolt12OfferListEvent.KIND, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/FeedBasis.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/FeedBasis.kt index a6d9bd3de3..17c4b31bdb 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/FeedBasis.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/FeedBasis.kt @@ -22,11 +22,11 @@ package com.vitorpamplona.amethyst.commons.relayClient.video import com.vitorpamplona.quartz.experimental.nip95.header.FileStorageHeaderEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent // The media types the video/shorts feeds will admit. HLS playlists are in here because a // blossom-hosted manifest is `https://host/<sha256>` with no extension at all, so the MIME is the @@ -57,8 +57,8 @@ val SUPPORTED_VIDEO_FEED_MIME_TYPES_SET = SUPPORTED_VIDEO_FEED_MIME_TYPES.toSet( val PictureAndVideoKinds = listOf( PictureEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, ) @@ -66,12 +66,12 @@ val PictureAndVideoKinds = val PictureAndVideoKTags = listOf( PictureEvent.KIND.toString(), - VideoHorizontalEvent.KIND.toString(), - VideoVerticalEvent.KIND.toString(), + AddressableNormalVideoEvent.KIND.toString(), + AddressableShortVideoEvent.KIND.toString(), VideoNormalEvent.KIND.toString(), VideoShortEvent.KIND.toString(), ) -val PictureAndVideoLegacyKinds = listOf(FileHeaderEvent.KIND, FileStorageHeaderEvent.KIND) -val PictureAndVideoLegacyKTags = listOf(FileHeaderEvent.KIND.toString(), FileStorageHeaderEvent.KIND.toString()) +val PictureAndVideoLegacyKinds = listOf(FileMetadataEvent.KIND, FileStorageHeaderEvent.KIND) +val PictureAndVideoLegacyKTags = listOf(FileMetadataEvent.KIND.toString(), FileStorageHeaderEvent.KIND.toString()) val LegacyMimeTypes = SUPPORTED_VIDEO_FEED_MIME_TYPES val LegacyMimeTypeMap = mapOf("m" to LegacyMimeTypes) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByAllCommunities.kt index 530b8a2d2c..81bebc33d5 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/video/nip72Communities/FilterPictureAndVideoByAllCommunities.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.experimental.nip95.header.FileStorageHeaderEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent fun filterPictureAndVideoAllCommunities( relay: NormalizedRelayUrl, @@ -80,7 +80,7 @@ fun filterPictureAndVideoAllCommunities( tags = mapOf( "a" to communityList, - "k" to listOf(FileHeaderEvent.KIND.toString(), FileStorageHeaderEvent.KIND.toString()), + "k" to listOf(FileMetadataEvent.KIND.toString(), FileStorageHeaderEvent.KIND.toString()), ), limit = 200, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt index 6a61907b8c..34b7ce090f 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt @@ -27,29 +27,29 @@ import com.vitorpamplona.quartz.experimental.music.track.MusicTrackEvent import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.application.SoftwareApplicationEvent import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.RootSiteEvent import com.vitorpamplona.quartz.nip5dNapplets.NamedNappletEvent import com.vitorpamplona.quartz.nip5dNapplets.RootNappletEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent @@ -93,7 +93,7 @@ object KindRegistry { val aliases: Map<String, List<Int>> = mapOf( "note" to listOf(TextNoteEvent.KIND), - "article" to listOf(LongTextNoteEvent.KIND), + "article" to listOf(LongFormContentEvent.KIND), // No `repost` or `profile` here on purpose: both name kinds in // [RenderableKinds.NEVER_IN_RESULTS], so the chip drew and the list stayed empty // forever. `kind:profile` was the worse of the two — it pinned the scope to Notes, @@ -101,7 +101,7 @@ object KindRegistry { "channel" to listOf(ChannelCreateEvent.KIND, ChannelMetadataEvent.KIND), "live" to listOf(LiveActivitiesEvent.KIND, MeetingSpaceEvent.KIND, MeetingRoomEvent.KIND), "community" to listOf(CommunityDefinitionEvent.KIND), - "wiki" to listOf(WikiNoteEvent.KIND), + "wiki" to listOf(WikiArticleEvent.KIND), "classified" to listOf(ClassifiedsEvent.KIND), "geocache" to listOf(GeocacheListingEvent.KIND), "highlight" to listOf(HighlightEvent.KIND), @@ -109,7 +109,7 @@ object KindRegistry { // The kinds the app's own feeds are windows onto, so a screen that seeds its search // gets a chip a reader recognises instead of a bare number. "picture" to listOf(PictureEvent.KIND), - "video" to listOf(VideoNormalEvent.KIND, VideoShortEvent.KIND, VideoHorizontalEvent.KIND, VideoVerticalEvent.KIND), + "video" to listOf(VideoNormalEvent.KIND, VideoShortEvent.KIND, AddressableNormalVideoEvent.KIND, AddressableShortVideoEvent.KIND), "nsite" to listOf(RootSiteEvent.KIND, NamedSiteEvent.KIND), "napplet" to listOf(RootNappletEvent.KIND, NamedNappletEvent.KIND), "emoji" to listOf(EmojiPackEvent.KIND), @@ -123,15 +123,15 @@ object KindRegistry { "podcast" to listOf(PodcastMetadataEvent.KIND), "episode" to listOf(Podcasting20EpisodeEvent.KIND), "software" to listOf(SoftwareApplicationEvent.KIND), - "followpack" to listOf(FollowListEvent.KIND), + "followpack" to listOf(StarterPackEvent.KIND), "zappoll" to listOf(ZapPollEvent.KIND), // `video` is every video kind; these name the two the app gives their own feeds. - "stories" to listOf(VideoHorizontalEvent.KIND, VideoVerticalEvent.KIND), - "short" to listOf(VideoVerticalEvent.KIND), - "longvideo" to listOf(VideoHorizontalEvent.KIND), + "stories" to listOf(AddressableNormalVideoEvent.KIND, AddressableShortVideoEvent.KIND), + "short" to listOf(AddressableShortVideoEvent.KIND), + "longvideo" to listOf(AddressableNormalVideoEvent.KIND), // The slots on a calendar, and the calendars that collect them. "calendar" to listOf(CalendarTimeSlotEvent.KIND, CalendarDateSlotEvent.KIND), - "calendarset" to listOf(CalendarEvent.KIND), + "calendarset" to listOf(CalendarCollectionEvent.KIND), ) val pseudoKinds: Set<String> = setOf("reply", "media") @@ -148,11 +148,11 @@ object KindRegistry { val presets: Map<String, ContentPreset> = mapOf( "Notes" to ContentPreset(kinds = listOf(TextNoteEvent.KIND)), - "Articles" to ContentPreset(kinds = listOf(LongTextNoteEvent.KIND)), + "Articles" to ContentPreset(kinds = listOf(LongFormContentEvent.KIND)), "Media" to ContentPreset(pseudoKind = "media"), "Channels" to ContentPreset(kinds = listOf(ChannelCreateEvent.KIND, ChannelMetadataEvent.KIND)), "Communities" to ContentPreset(kinds = listOf(CommunityDefinitionEvent.KIND)), - "Wiki" to ContentPreset(kinds = listOf(WikiNoteEvent.KIND)), + "Wiki" to ContentPreset(kinds = listOf(WikiArticleEvent.KIND)), "Polls" to ContentPreset(kinds = listOf(PollEvent.KIND)), ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt index b5be14e927..214e789056 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt @@ -33,12 +33,12 @@ import com.vitorpamplona.quartz.experimental.nns.NNSEvent import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent @@ -47,18 +47,18 @@ import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.RootSiteEvent @@ -66,17 +66,17 @@ import com.vitorpamplona.quartz.nip5dNapplets.NamedNappletEvent import com.vitorpamplona.quartz.nip5dNapplets.RootNappletEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipA4PublicMessages.PublicMessageEvent import com.vitorpamplona.quartz.nipC0CodeSnippets.CodeSnippetEvent @@ -141,15 +141,15 @@ object RenderableKinds { setOf( MetadataEvent.KIND, ContactListEvent.KIND, - DeletionEvent.KIND, + DeletionRequestEvent.KIND, RepostEvent.KIND, ReactionEvent.KIND, GenericRepostEvent.KIND, RequestToVanishEvent.KIND, - FileHeaderEvent.KIND, + FileMetadataEvent.KIND, CommunityPostApprovalEvent.KIND, - LnZapRequestEvent.KIND, - LnZapEvent.KIND, + ZapRequestEvent.KIND, + ZapReceiptEvent.KIND, AppSpecificDataEvent.KIND, ) @@ -166,8 +166,8 @@ object RenderableKinds { TextNoteEvent.KIND, CommentEvent.KIND, PublicMessageEvent.KIND, - LongTextNoteEvent.KIND, - WikiNoteEvent.KIND, + LongFormContentEvent.KIND, + WikiArticleEvent.KIND, HighlightEvent.KIND, CodeSnippetEvent.KIND, NipTextEvent.KIND, @@ -175,8 +175,8 @@ object RenderableKinds { PictureEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, // A video list has a card of its own, so by the rule the omission list states — in // ALL when Amethyst can render it — it belongs in the window. Its title and // description are what Quartz indexes, which is exactly what a reader would search. @@ -202,15 +202,15 @@ object RenderableKinds { MeetingRoomEvent.KIND, // communities and lists CommunityDefinitionEvent.KIND, - PeopleListEvent.KIND, - FollowListEvent.KIND, + FollowSetEvent.KIND, + StarterPackEvent.KIND, BookmarkListEvent.KIND, OldBookmarkListEvent.KIND, PinListEvent.KIND, // calendar CalendarDateSlotEvent.KIND, CalendarTimeSlotEvent.KIND, - CalendarEvent.KIND, + CalendarCollectionEvent.KIND, // marketplace, apps, code and sites ClassifiedsEvent.KIND, SoftwareApplicationEvent.KIND, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorter.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorter.kt index 0c1884976f..e1e4734441 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorter.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorter.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.util.KmpLock import com.vitorpamplona.amethyst.commons.util.sortedBySnapshot import com.vitorpamplona.amethyst.commons.util.withLock import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.utils.currentTimeSeconds object SearchResultSorter { @@ -66,7 +66,7 @@ object SearchResultSorter { } // Article title boost - if (event is LongTextNoteEvent) { + if (event is LongFormContentEvent) { val title = event.title()?.lowercase() if (title != null) { if (title.contains(query)) { diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/nwc/NwcPaymentTracker.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/nwc/NwcPaymentTracker.kt index 94ba2218d7..697e71a1cd 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/nwc/NwcPaymentTracker.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/nwc/NwcPaymentTracker.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.commons.service.nwc import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.utils.concurrent.ConcurrentMap import kotlin.concurrent.atomics.AtomicInt import kotlin.concurrent.atomics.ExperimentalAtomicApi @@ -60,7 +60,7 @@ class NwcPaymentTracker { class PendingRequest( val expectedServicePubkey: HexKey, val zappedNote: Note?, - val onResponse: suspend (LnZapPaymentResponseEvent) -> Unit, + val onResponse: suspend (NwcResponseEvent) -> Unit, ) { // Number of kind-23195 events that targeted this request id with the // right `e` tag but the wrong author. Surfaced to the UI when a @@ -74,7 +74,7 @@ class NwcPaymentTracker { /** * Registers a pending payment request. * - * @param requestId Event ID of the LnZapPaymentRequestEvent + * @param requestId Event ID of the NwcRequestEvent * @param expectedServicePubkey Wallet service pubkey from the request's `p` tag * @param zappedNote The note being zapped (null if not a zap payment) * @param onResponse Callback invoked when response arrives @@ -83,7 +83,7 @@ class NwcPaymentTracker { requestId: HexKey, expectedServicePubkey: HexKey, zappedNote: Note?, - onResponse: suspend (LnZapPaymentResponseEvent) -> Unit, + onResponse: suspend (NwcResponseEvent) -> Unit, ) { awaitingRequests[requestId] = PendingRequest(expectedServicePubkey, zappedNote, onResponse) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPolicy.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPolicy.kt index d4c0da8079..042127051c 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPolicy.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/service/pow/PoWPolicy.kt @@ -30,13 +30,13 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent @@ -116,7 +116,7 @@ object PoWPolicy { setOf( MetadataEvent.KIND, ContactListEvent.KIND, - LnZapRequestEvent.KIND, // blocks the invoice fetch + ZapRequestEvent.KIND, // blocks the invoice fetch OtsEvent.KIND, // machine-generated companion events DraftWrapEvent.KIND, // re-signed on a 1s debounce while typing ) @@ -141,7 +141,7 @@ object PoWPolicy { TextNoteEvent.KIND -> PoWCategory.SHORT_NOTES CommentEvent.KIND -> PoWCategory.COMMENTS ReportEvent.KIND -> PoWCategory.REPORTS - LongTextNoteEvent.KIND, HighlightEvent.KIND -> PoWCategory.LONG_FORM + LongFormContentEvent.KIND, HighlightEvent.KIND -> PoWCategory.LONG_FORM VoiceEvent.KIND, VoiceReplyEvent.KIND -> PoWCategory.VOICE RepostEvent.KIND, GenericRepostEvent.KIND -> PoWCategory.REPOSTS ReactionEvent.KIND -> PoWCategory.REACTIONS diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/LiveStreamTopZappersViewModel.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/LiveStreamTopZappersViewModel.kt index 9c698f36d9..17e06618e1 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/LiveStreamTopZappersViewModel.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/LiveStreamTopZappersViewModel.kt @@ -30,8 +30,8 @@ import com.vitorpamplona.amethyst.commons.nip53LiveActivities.LiveActivityTopZap import com.vitorpamplona.amethyst.commons.nip53LiveActivities.TopZapperEntry import com.vitorpamplona.amethyst.commons.nip53LiveActivities.ZapContribution import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.utils.toLongValue import kotlinx.coroutines.Dispatchers @@ -163,7 +163,7 @@ class LiveStreamTopZappersViewModel( private fun contributionFromStreamZap(note: Note): ZapContribution? = when (val ev = note.event) { - is LnZapEvent -> { + is ZapReceiptEvent -> { val request = ev.zapRequest ?: return null val sats = ev.amount()?.toLongValue() ?: return null ZapContribution(note.idHex, request.pubKey, request.isAnonTagged(), sats) @@ -179,12 +179,12 @@ class LiveStreamTopZappersViewModel( zapRequestNote: Note, receiptNote: Note?, ): ZapContribution? { - val receiptEv = receiptNote?.event as? LnZapEvent ?: return null - val request = zapRequestNote.event as? LnZapRequestEvent ?: return null + val receiptEv = receiptNote?.event as? ZapReceiptEvent ?: return null + val request = zapRequestNote.event as? ZapRequestEvent ?: return null val sats = receiptEv.amount()?.toLongValue() ?: return null return ZapContribution(receiptNote.idHex, request.pubKey, request.isAnonTagged(), sats) } } /** True for both public anonymous and NIP-57 private zaps (any `anon` tag, empty or encrypted). */ -private fun LnZapRequestEvent.isAnonTagged(): Boolean = tags.any { it.isNotEmpty() && it[0] == "anon" } +private fun ZapRequestEvent.isAnonTagged(): Boolean = tags.any { it.isNotEmpty() && it[0] == "anon" } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsState.kt index ce0267fb9e..09af0fb088 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsState.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.amethyst.commons.viewmodels import androidx.compose.runtime.Immutable -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.utils.toLongValue @@ -49,13 +49,13 @@ data class RoomZap( ) { companion object { /** - * Project a kind-9735 [LnZapEvent] into a [RoomZap]. The + * Project a kind-9735 [ZapReceiptEvent] into a [RoomZap]. The * source pubkey is the embedded kind-9734 request author — * the actual zapper — NOT the receipt's own `pubKey`, which * is the lnurl service provider's signing key. Falls back to * the receipt issuer only when the request can't be parsed. */ - fun from(event: LnZapEvent): RoomZap = + fun from(event: ZapReceiptEvent): RoomZap = RoomZap( eventId = event.id, sourcePubkey = event.zapRequest?.pubKey ?: event.pubKey, @@ -95,7 +95,7 @@ class RoomZapsAggregator { /** Apply one zap and return the post-evict snapshot. */ fun apply( - event: LnZapEvent, + event: ZapReceiptEvent, nowSec: Long, windowSec: Long, ): Map<String, List<RoomZap>> = apply(RoomZap.from(event), nowSec, windowSec) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/PrivateNoteFactoryTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/PrivateNoteFactoryTest.kt index 29e8d2617e..b18e2da18e 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/PrivateNoteFactoryTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/PrivateNoteFactoryTest.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip01Core.tags.people.PTag import com.vitorpamplona.quartz.nip01Core.tags.people.pTags -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.NIP17Factory import kotlinx.coroutines.test.runTest @@ -85,12 +85,12 @@ class PrivateNoteFactoryTest { val result = NIP17Factory().createDeletionNIP17( - template = DeletionEvent.build(listOf(reaction)), + template = DeletionRequestEvent.build(listOf(reaction)), to = listOf(bobSigner.pubKey), signer = aliceSigner, ) - assertEquals(DeletionEvent.KIND, result.msg.kind) + assertEquals(DeletionRequestEvent.KIND, result.msg.kind) assertEquals( setOf(aliceSigner.pubKey, bobSigner.pubKey), result.wraps.mapNotNull { it.recipientPubKey() }.toSet(), @@ -101,7 +101,7 @@ class PrivateNoteFactoryTest { val rumor = bobWrap.unwrapAndUnsealOrNull(bobSigner) assertNotNull(rumor, "recipient must be able to unwrap and unseal the deletion") - assertEquals(DeletionEvent.KIND, rumor.kind) + assertEquals(DeletionRequestEvent.KIND, rumor.kind) assertEquals(aliceSigner.pubKey, rumor.pubKey, "deletions only apply when the author matches") assertTrue(rumor.sig.isEmpty(), "the deletion travels as an unsigned rumor") assertTrue( diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActionsTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActionsTest.kt index eaa21809b1..e738de8961 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActionsTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/actions/ZapActionsTest.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.utils.Secp256k1Instance import kotlinx.coroutines.test.runTest import kotlin.test.Test @@ -108,7 +108,7 @@ class ZapActionsTest { amountMillisats = 21_000L, inboxRelays = setOf(relay), comment = "thanks!", - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, lnurl = "lnurl1example", ) @@ -133,7 +133,7 @@ class ZapActionsTest { recipientPubkey = recipientPubkey, amountMillisats = 1_000L, inboxRelays = setOf(relay), - zapType = LnZapEvent.ZapType.ANONYMOUS, + zapType = ZapReceiptEvent.ZapType.ANONYMOUS, ) assertTrue( @@ -152,7 +152,7 @@ class ZapActionsTest { recipientPubkey = recipientPubkey, amountMillisats = 1_000L, inboxRelays = setOf(relay), - zapType = LnZapEvent.ZapType.PRIVATE, + zapType = ZapReceiptEvent.ZapType.PRIVATE, ) // NIP-57 PRIVATE zaps use an ephemeral key derived from diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt index 5bed98dc6f..04c4a0cacd 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/ThreadAssemblerTest.kt @@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.hints.HintIndexer import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse @@ -75,7 +75,7 @@ class ThreadAssemblerTest { private val zap = Note(zapId).apply { - event = LnZapEvent(zapId, authorKey, 1001, arrayOf(arrayOf("e", originalId), arrayOf("p", authorKey)), "", sig) + event = ZapReceiptEvent(zapId, authorKey, 1001, arrayOf(arrayOf("e", originalId), arrayOf("p", authorKey)), "", sig) replyTo = listOf(original) } diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt index 35c6013608..d050ab8e93 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.amethyst.commons.model.privateChats -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent @@ -40,7 +40,7 @@ class ChatPreviewTest { private fun privateDm( author: String = other, recipient: String = me, - ) = PrivateDmEvent( + ) = EncryptedDmEvent( id = "dm".padEnd(64, '0'), pubKey = author, createdAt = 1_000, diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt index 52ce93b5e1..f9aee77c88 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt @@ -21,14 +21,14 @@ package com.vitorpamplona.amethyst.commons.moderation.notifications import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import kotlin.test.Test @@ -116,8 +116,8 @@ class NotificationKindsTest { ) } - private fun zapReceipt(pTag: String = me): LnZapEvent = - LnZapEvent( + private fun zapReceipt(pTag: String = me): ZapReceiptEvent = + ZapReceiptEvent( id = "zap".padEnd(64, '0'), pubKey = "lnurl_provider".padEnd(64, '0'), createdAt = 1_000, @@ -142,8 +142,8 @@ class NotificationKindsTest { private fun privateDm( author: String, pTag: String = me, - ): PrivateDmEvent = - PrivateDmEvent( + ): EncryptedDmEvent = + EncryptedDmEvent( id = "dm".padEnd(64, '0'), pubKey = author, createdAt = 1_000, @@ -303,7 +303,7 @@ class NotificationKindsTest { val expected = setOf( TextNoteEvent.KIND, - PrivateDmEvent.KIND, + EncryptedDmEvent.KIND, RepostEvent.KIND, ReactionEvent.KIND, GenericRepostEvent.KIND, @@ -311,7 +311,7 @@ class NotificationKindsTest { CommentEvent.KIND, GiftWrapEvent.KIND, NutzapEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, ) val actual = NotificationKinds.SUBSCRIPTION_KINDS.toSet() assertTrue(actual.containsAll(expected), "expected subset missing from SUBSCRIPTION_KINDS") diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt index a5d33e5a23..aa5d930cff 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt @@ -43,7 +43,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll @@ -137,7 +137,7 @@ class NappletBrokerTest { fromPublicKey: HexKey, ): String = throw NotImplementedError() - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt index 8f439de480..d0f61a9ad3 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.builder.OnchainZapBuilder import com.vitorpamplona.quartz.nipBCOnchainZaps.chain.BitcoinAddressTx import com.vitorpamplona.quartz.nipBCOnchainZaps.chain.BitcoinTx @@ -228,7 +228,7 @@ class OnchainZapSenderTest { fromPublicKey: HexKey, ) = inner.nip44Decrypt(ciphertext, fromPublicKey) - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = inner.decryptZapEvent(event) + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = inner.decryptZapEvent(event) override suspend fun deriveKey(nonce: HexKey): HexKey = inner.deriveKey(nonce) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupStateTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupStateTest.kt index d0ef97fdf9..5a410492c9 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupStateTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/FilterRelayGroupStateTest.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse @@ -51,7 +51,7 @@ class FilterRelayGroupStateTest { GroupMetadataEvent.KIND, GroupAdminsEvent.KIND, GroupMembersEvent.KIND, - SupportedRolesEvent.KIND, + GroupRolesEvent.KIND, ) private val pinKinds = listOf(GroupPinnedEvent.KIND) diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuildersTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuildersTest.kt index f7f85e742f..56c53c075d 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuildersTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/channel/relayGroup/RelayGroupFilterBuildersTest.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.buzz.forum.ForumCommentEvent import com.vitorpamplona.quartz.buzz.forum.ForumPostEvent import com.vitorpamplona.quartz.nip01Core.relay.client.pool.FiltersChanged import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip29RelayGroups.GroupId @@ -32,8 +32,8 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteEventEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupDeleteEventEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.GroupTag import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent @@ -187,7 +187,7 @@ class RelayGroupFilterBuildersTest { val filter = buildRelayGroupAuxFilter(GroupId("g1", relayA), 42L) assertEquals(relayA, filter.relay) - assertEquals(listOf(DeletionEvent.KIND, ReactionEvent.KIND, DeleteEventEvent.KIND), filter.filter.kinds) + assertEquals(listOf(DeletionRequestEvent.KIND, ReactionEvent.KIND, GroupDeleteEventEvent.KIND), filter.filter.kinds) assertEquals(listOf("g1"), filter.filter.tags!!["h"]) assertEquals(42L, filter.filter.since) assertEquals(RELAY_GROUP_AUX_LIMIT, filter.filter.limit) @@ -293,7 +293,7 @@ class RelayGroupFilterBuildersTest { @Test fun `directory kinds are 39000-39003 and exclude the pin list`() { assertEquals( - listOf(GroupMetadataEvent.KIND, GroupAdminsEvent.KIND, GroupMembersEvent.KIND, SupportedRolesEvent.KIND), + listOf(GroupMetadataEvent.KIND, GroupAdminsEvent.KIND, GroupMembersEvent.KIND, GroupRolesEvent.KIND), RELAY_GROUP_DIRECTORY_KINDS, ) assertFalse(RELAY_GROUP_DIRECTORY_KINDS.contains(GroupPinnedEvent.KIND), "the directory doesn't fetch each group's pins") diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/HomeMediaKindCoverageTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/HomeMediaKindCoverageTest.kt index c51e367053..813879a187 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/HomeMediaKindCoverageTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/HomeMediaKindCoverageTest.kt @@ -26,10 +26,10 @@ import com.vitorpamplona.amethyst.commons.relayClient.home.nip65Follows.HomePost import com.vitorpamplona.amethyst.commons.relayClient.home.nip72Communities.HomePostsFromCommunityKinds import com.vitorpamplona.amethyst.commons.relayClient.home.nip72Communities.HomePostsFromCommunityKindsStr import com.vitorpamplona.quartz.nip68Picture.PictureEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -46,8 +46,8 @@ class HomeMediaKindCoverageTest { PictureEvent.KIND, VideoNormalEvent.KIND, VideoShortEvent.KIND, - VideoHorizontalEvent.KIND, - VideoVerticalEvent.KIND, + AddressableNormalVideoEvent.KIND, + AddressableShortVideoEvent.KIND, ) private fun assertCarriesMedia( diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIdsTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIdsTest.kt index fd94ee87ee..5376b735b3 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIdsTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/home/nip90AlgoFeeds/FilterHomePostsByAlgoFeedIdsTest.kt @@ -23,8 +23,8 @@ package com.vitorpamplona.amethyst.commons.relayClient.home.nip90AlgoFeeds import com.vitorpamplona.amethyst.commons.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilter import com.vitorpamplona.amethyst.commons.model.topNavFeeds.favoriteAlgoFeeds.FavoriteAlgoFeedTopNavPerRelayFilterSet import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -83,7 +83,7 @@ class FilterHomePostsByAlgoFeedIdsTest { val listen = filters.single() assertEquals(dvmRelay, listen.relay) assertEquals( - listOf(NIP90ContentDiscoveryResponseEvent.KIND, NIP90StatusEvent.KIND), + listOf(DvmContentDiscoveryResponseEvent.KIND, DvmStatusEvent.KIND), listen.filter.kinds, ) val eTag = listen.filter.tags?.get("e") diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorterTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorterTest.kt index 96217a9904..0afcf06b9e 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorterTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchResultSorterTest.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.metadata.UserMetadata -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -51,14 +51,14 @@ class SearchResultSorterTest { createdAt: Long, content: String = "", title: String? = null, - ): LongTextNoteEvent { + ): LongFormContentEvent { val tags = if (title != null) { arrayOf(arrayOf("title", title)) } else { emptyArray() } - return LongTextNoteEvent( + return LongFormContentEvent( id = id, pubKey = "abc123def456abc123def456abc123def456abc123def456abc123def456abcd", createdAt = createdAt, diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchSeedTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchSeedTest.kt index 2d1ed9f50f..5cc5a7bf18 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchSeedTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/search/SearchSeedTest.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.commons.search import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.quartz.nip01Core.core.Address -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import kotlinx.collections.immutable.persistentListOf import kotlin.test.Test @@ -46,7 +46,7 @@ class SearchSeedTest { @Test fun aKindWindowArrivesAsTheSameKinds() { - val seed = SearchSeed.ofKinds(LongTextNoteEvent.KIND) + val seed = SearchSeed.ofKinds(LongFormContentEvent.KIND) assertEquals("kind:article", QuerySerializer.serialize(seed)) assertEquals(seed, throughTheField(seed)) } @@ -196,7 +196,7 @@ class SearchSeedTest { assertTrue(SearchQuery(scopes = persistentListOf(ExternalScope("isbn", "123"))).pinsToNotes) assertTrue(SearchQuery(groups = persistentListOf("abc")).pinsToNotes) // Every seeded feed window pins it too. - assertTrue(SearchSeed.ofKinds(LongTextNoteEvent.KIND).pinsToNotes) + assertTrue(SearchSeed.ofKinds(LongFormContentEvent.KIND).pinsToNotes) } @Test diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsStateTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsStateTest.kt index bc67bc0981..6ac9dc3d7d 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsStateTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/RoomZapsStateTest.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.amethyst.commons.viewmodels -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull @@ -46,13 +46,13 @@ class RoomZapsStateTest { to: String?, createdAt: Long, id: String = (nextEventId++).toString(16).padStart(64, '0'), - ): LnZapEvent { + ): ZapReceiptEvent { val tags = buildList<Array<String>> { add(arrayOf("a", "30312:host:room")) if (to != null) add(arrayOf("p", to)) }.toTypedArray() - return LnZapEvent( + return ZapReceiptEvent( id = id, pubKey = from, createdAt = createdAt, diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt index 99def91987..e26b1471d1 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt @@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.tags.aTag.aTag -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip60Cashu.bdhke.Bdhke import com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent import com.vitorpamplona.quartz.nip60Cashu.history.SpendingDirection @@ -195,7 +195,7 @@ class CashuWalletOps( * bails when it has no shared mint or no P2PK pubkey. This is the * durable signal. * 2. NIP-09 delete the now-empty kind:10019 by its address coordinate - * (DeletionEvent.build adds the `a` tag automatically because the + * (DeletionRequestEvent.build adds the `a` tag automatically because the * event is replaceable) so relays that DO honor deletions drop it * entirely. Deletions are optional on Nostr, which is why step 1 * runs first as the fallback. @@ -209,7 +209,7 @@ class CashuWalletOps( val emptyEvent = signer.sign(emptyTemplate) publish(emptyEvent) - val delTemplate = DeletionEvent.build(listOf(emptyEvent)) + val delTemplate = DeletionRequestEvent.build(listOf(emptyEvent)) val delEvent = signer.sign(delTemplate) publish(delEvent) } @@ -230,7 +230,7 @@ class CashuWalletOps( suspend fun deleteWallet(walletEvent: CashuWalletEvent) { stopNutzaps() - val delTemplate = DeletionEvent.build(listOf(walletEvent)) + val delTemplate = DeletionRequestEvent.build(listOf(walletEvent)) val delEvent = signer.sign(delTemplate) publish(delEvent) } @@ -286,7 +286,7 @@ class CashuWalletOps( * fired anyway; running it twice on a missing event is harmless. */ suspend fun cancelMintQuote(quoteEvent: CashuMintQuoteEvent) { - val delTemplate = DeletionEvent.build(listOf(quoteEvent)) + val delTemplate = DeletionRequestEvent.build(listOf(quoteEvent)) val delEvent = signer.sign(delTemplate) publish(delEvent) } @@ -363,7 +363,7 @@ class CashuWalletOps( publish(historyEvent) // NIP-09 delete the now-fulfilled quote event. - val delTemplate = DeletionEvent.build(listOf(quoteEvent)) + val delTemplate = DeletionRequestEvent.build(listOf(quoteEvent)) val delEvent = signer.sign(delTemplate) publish(delEvent) @@ -527,11 +527,11 @@ class CashuWalletOps( } // NIP-09 delete the source token events. Per spec, also need k=7375 tag, - // which DeletionEvent.build adds automatically from the source event kind. + // which DeletionRequestEvent.build adds automatically from the source event kind. val deleteEvent = run { val toDelete = selected.map { it.event } + listOfNotNull(prePaidChangeEvent.takeIf { finalChangeEvent != null }) - val delTemplate = DeletionEvent.build(toDelete) + val delTemplate = DeletionRequestEvent.build(toDelete) signer.sign(delTemplate).also { publish(it) } } @@ -598,7 +598,7 @@ class CashuWalletOps( val deleteEvent = run { - val template = DeletionEvent.build(selected.map { it.event }) + val template = DeletionRequestEvent.build(selected.map { it.event }) signer.sign(template).also { publish(it) } } @@ -769,7 +769,7 @@ class CashuWalletOps( // NIP-09 delete the source token events. val deleteEvent = run { - val template = DeletionEvent.build(selected.map { it.event }) + val template = DeletionRequestEvent.build(selected.map { it.event }) signer.sign(template).also { publish(it) } @@ -1001,7 +1001,7 @@ class CashuWalletOps( entry.content.proofs.any { states[it.secret] == ProofState.SPENT } } if (stale.isEmpty()) return emptyList() - val delTemplate = DeletionEvent.build(stale.map { it.event }) + val delTemplate = DeletionRequestEvent.build(stale.map { it.event }) publish(signer.sign(delTemplate)) return stale.map { it.event } } @@ -1046,7 +1046,7 @@ class CashuWalletOps( val signed = signer.sign(template) publish(signed) - val delTemplate = DeletionEvent.build(entries.map { it.event }) + val delTemplate = DeletionRequestEvent.build(entries.map { it.event }) val delEvent = signer.sign(delTemplate) publish(delEvent) @@ -1088,7 +1088,7 @@ class CashuWalletOps( * kind:38000 is parameterized-replaceable — a delete with an `a` tag * pointing at the address coordinate (kind:pubkey:dTag) drops all * versions on compliant relays. We also include the original event id - * via DeletionEvent.build so relays that only track by event id still + * via DeletionRequestEvent.build so relays that only track by event id still * remove it. MintRecommendationEvent doesn't extend AddressableEvent * today, so we compute and add the `a` tag ourselves. */ @@ -1099,7 +1099,7 @@ class CashuWalletOps( // d-tag still get a NIP-09 `e`-only delete (the default build path). val dTag = event.dTag() val template = - DeletionEvent.build(listOf(event)) { + DeletionRequestEvent.build(listOf(event)) { if (dTag != null) aTag(Address(event.kind, event.pubKey, dTag)) } val delEvent = signer.sign(template) @@ -1497,14 +1497,14 @@ data class MeltCompleted( val paidAmount: Long, val fees: Long, val historyEvent: CashuSpendingHistoryEvent, - val deleteEvent: DeletionEvent, + val deleteEvent: DeletionRequestEvent, val newTokenEvent: CashuTokenEvent?, ) data class SendTokenCompleted( val cashuToken: String, val amount: Long, - val deleteEvent: DeletionEvent, + val deleteEvent: DeletionRequestEvent, val keepEvent: CashuTokenEvent?, val historyEvent: CashuSpendingHistoryEvent, ) @@ -1519,7 +1519,7 @@ data class RedeemCompleted( data class NutzapSent( val nutzapEvent: NutzapEvent, val keepEvent: CashuTokenEvent?, - val deleteEvent: DeletionEvent, + val deleteEvent: DeletionRequestEvent, val historyEvent: CashuSpendingHistoryEvent, val amount: Long, ) diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExport.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExport.kt index ecf32fda47..2c5e7b579b 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExport.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExport.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.commons.model.nip52Calendar import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import java.time.Instant import java.time.LocalDate import java.time.ZoneOffset @@ -71,7 +71,7 @@ object IcsExport { * haven't been fetched from relays yet. */ fun calendarToIcs( - calendar: CalendarEvent, + calendar: CalendarCollectionEvent, memberEvents: List<Pair<Address, Any>>, nowSeconds: Long, ): String { @@ -110,7 +110,7 @@ object IcsExport { return safeFilename(title ?: address.dTag) + ".ics" } - fun calendarFilename(calendar: CalendarEvent): String = safeFilename(calendar.title() ?: "calendar") + ".ics" + fun calendarFilename(calendar: CalendarCollectionEvent): String = safeFilename(calendar.title() ?: "calendar") + ".ics" private fun safeFilename(raw: String): String = raw diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip57Zaps/ZapAction.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip57Zaps/ZapAction.kt index 34e116b43b..0066a7ed89 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip57Zaps/ZapAction.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/model/nip57Zaps/ZapAction.kt @@ -24,8 +24,8 @@ import com.vitorpamplona.amethyst.commons.service.lnurl.LightningAddressResolver import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent /** * Handles NIP-57 zap requests and invoice fetching. @@ -66,7 +66,7 @@ object ZapAction { relays: Set<NormalizedRelayUrl>, signer: NostrSigner, resolver: LightningAddressResolver, - zapType: LnZapEvent.ZapType = LnZapEvent.ZapType.PUBLIC, + zapType: ZapReceiptEvent.ZapType = ZapReceiptEvent.ZapType.PUBLIC, onProgress: (Float) -> Unit = {}, ): ZapResult { if (!signer.isWriteable()) { @@ -76,7 +76,7 @@ object ZapAction { // Create zap request using quartz factory val zapRequest = try { - LnZapRequestEvent.create( + ZapRequestEvent.create( zappedEvent = targetEvent, relays = relays, signer = signer, @@ -120,7 +120,7 @@ object ZapAction { relays: Set<NormalizedRelayUrl>, signer: NostrSigner, resolver: LightningAddressResolver, - zapType: LnZapEvent.ZapType = LnZapEvent.ZapType.PUBLIC, + zapType: ZapReceiptEvent.ZapType = ZapReceiptEvent.ZapType.PUBLIC, onProgress: (Float) -> Unit = {}, ): ZapResult { if (!signer.isWriteable()) { @@ -130,7 +130,7 @@ object ZapAction { // Create zap request for user val zapRequest = try { - LnZapRequestEvent.create( + ZapRequestEvent.create( userHex = userPubHex, relays = relays, signer = signer, diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/LightningAddressResolver.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/LightningAddressResolver.kt index 5acca96399..a675147433 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/LightningAddressResolver.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/LightningAddressResolver.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.commons.service.lnurl import com.fasterxml.jackson.databind.ObjectMapper import com.vitorpamplona.quartz.lightning.LnInvoiceUtil import com.vitorpamplona.quartz.lightning.Lud06 -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlEndpointCache import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlEndpointInfo import kotlinx.coroutines.Dispatchers @@ -94,7 +94,7 @@ class LightningAddressResolver( lnAddress: String, milliSats: Long, message: String = "", - zapRequest: LnZapRequestEvent? = null, + zapRequest: ZapRequestEvent? = null, onProgress: (Float) -> Unit = {}, ): Result = withContext(Dispatchers.IO) { @@ -209,7 +209,7 @@ class LightningAddressResolver( callbackUrl: String, milliSats: Long, message: String, - zapRequest: LnZapRequestEvent?, + zapRequest: ZapRequestEvent?, ): String? = withContext(Dispatchers.IO) { try { diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/OkHttpLnurlEndpointResolver.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/OkHttpLnurlEndpointResolver.kt index dd162f881c..2755642c0f 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/OkHttpLnurlEndpointResolver.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/service/lnurl/OkHttpLnurlEndpointResolver.kt @@ -32,7 +32,7 @@ import okhttp3.coroutines.executeAsync import kotlin.coroutines.cancellation.CancellationException /** - * OkHttp-backed [LnurlEndpointResolver]. Used by `LocalCache.consume(LnZapEvent)` + * OkHttp-backed [LnurlEndpointResolver]. Used by `LocalCache.consume(ZapReceiptEvent)` * to look up a recipient's LNURL provider's `nostrPubkey` when validating an * incoming zap receipt (NIP-57 Appendix F). * diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt index 80ad79160f..faf5d970f1 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt @@ -629,7 +629,7 @@ class NestViewModel( * same window so the visual cadence matches the React button. */ fun onZapEvent( - event: com.vitorpamplona.quartz.nip57Zaps.LnZapEvent, + event: com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent, nowSec: Long, windowSec: Long = REACTION_WINDOW_SEC, ) { diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotEditsAndSystemRowsTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotEditsAndSystemRowsTest.kt index 6e27962957..e2ea1de62e 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotEditsAndSystemRowsTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotEditsAndSystemRowsTest.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.marmot.mip01Groups.MarmotGroupData import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import kotlinx.coroutines.runBlocking import kotlin.test.Test import kotlin.test.assertEquals @@ -130,7 +130,7 @@ class MarmotEditsAndSystemRowsTest { val forged = MarmotAppEvent.build( pubKey = impostor, - kind = DeletionEvent.KIND, + kind = DeletionRequestEvent.KIND, content = "", createdAt = 1_800_000_000L, tags = arrayOf(arrayOf("e", mine.innerEvent.id)), @@ -168,7 +168,7 @@ class MarmotEditsAndSystemRowsTest { val forged = MarmotAppEvent.build( pubKey = f.signer.pubKey, - kind = DeletionEvent.KIND, + kind = DeletionRequestEvent.KIND, content = "", createdAt = 1_800_000_000L, tags = arrayOf(arrayOf("e", absent)), diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExportTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExportTest.kt index f6e5ec7e81..11cdde002e 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExportTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip52Calendar/IcsExportTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.commons.model.nip52Calendar import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -181,7 +181,7 @@ class IcsExportTest { sig = "sig", ) val calendar = - CalendarEvent( + CalendarCollectionEvent( id = "cal", pubKey = "pub", createdAt = 0L, diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/DivineVideoInteropTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/DivineVideoInteropTest.kt index c476dab342..db2424d860 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/DivineVideoInteropTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/DivineVideoInteropTest.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.credits.CreditTarget import com.vitorpamplona.quartz.nip71Video.credits.VideoCredit import com.vitorpamplona.quartz.nip71Video.textTrack.TextTrackEvent @@ -86,20 +86,20 @@ class DivineVideoInteropTest { fun aShortVideoIsAnAddressableVerticalVideo() { val event = Event.fromJson(video) - assertTrue(event is VideoVerticalEvent) + assertTrue(event is AddressableShortVideoEvent) // The address must come from the `d` tag: an `a` tag elsewhere on the network points at // `34236:<pubkey>:<d>`, and a class on the wrong base would split the cache in two. assertEquals( "34236:4d7dccc0a5116daa057348ef79c573873cddd9eff066fc6a5f3d37e8264afbeb:c855df3d07ba963e9097d5a151b0c14a0a3d494e4ff9b04a389bc0b5f5c16862", (event as AddressableEvent).address().toValue(), ) - assertEquals("Xmas Already??", (event as VideoVerticalEvent).title()) + assertEquals("Xmas Already??", (event as AddressableShortVideoEvent).title()) assertEquals(6, event.duration()) } @Test fun theBlossomUrlIsPlayedAsAVideoDespiteHavingNoFileExtension() { - val track = (Event.fromJson(video) as VideoVerticalEvent).selectVideoTrack() + val track = (Event.fromJson(video) as AddressableShortVideoEvent).selectVideoTrack() assertNotNull(track) assertEquals("https://media.divine.video/c855df3d07ba963e9097d5a151b0c14a0a3d494e4ff9b04a389bc0b5f5c16862", track!!.url) @@ -125,7 +125,7 @@ class DivineVideoInteropTest { // itself. LocalCache.computeReplyTo has no branch for video events, so this never turns // the post into a reply — which would drop it out of the home feed and thread it under // whatever video the audio came from. - val event = Event.fromJson(video) as VideoVerticalEvent + val event = Event.fromJson(video) as AddressableShortVideoEvent val audio = event.tags.first { it[0] == "e" } assertEquals("218af5fc90d66a16ce273f00a4e412a71443441c04c67d1e34ff99c654871d3d", audio[1]) @@ -136,7 +136,7 @@ class DivineVideoInteropTest { fun captionsComeFromTheTextTrackTagsAndNotTheAudioPointer() { // textTrack() used to run ETag::parse, so it returned the `e` tags instead — on this // event, the reused-soundtrack pointer, which is not a caption track at all. - val tracks = (Event.fromJson(video) as VideoVerticalEvent).textTrack() + val tracks = (Event.fromJson(video) as AddressableShortVideoEvent).textTrack() assertEquals(2, tracks.size) // Divine publishes the same track twice: the WebVTT file on Blossom, and the addressable @@ -153,7 +153,7 @@ class DivineVideoInteropTest { @Test fun theTwoFormsOfTheSameCaptionTrackCollapseIntoOne() { - val video = Event.fromJson(video) as VideoVerticalEvent + val video = Event.fromJson(video) as AddressableShortVideoEvent val refs = video.captionTracks() // One `text-track` is directly loadable, the other has to be fetched first. @@ -230,7 +230,7 @@ class DivineVideoInteropTest { @Test fun creditsReadTheMarkerWhicheverSlotItIsIn() { // divine-mobile: ["p", <pubkey>, <relay>, "inspired-by"] and ["e", <id>, <relay>, "audio"]. - val credits = (Event.fromJson(videoWithCredits) as VideoVerticalEvent).credits() + val credits = (Event.fromJson(videoWithCredits) as AddressableShortVideoEvent).credits() val person = credits.filterIsInstance<VideoCredit>().first { it.target is CreditTarget.Person } assertEquals("0db19e8f1b13e03cd07379edd37a71f07b08a4fb5e7eac222ba1d2c823807075", (person.target as CreditTarget.Person).pubKey) @@ -250,7 +250,7 @@ class DivineVideoInteropTest { // divine-web's collaborator invite writes ["p", <pubkey>, "<role>"] — no relay hint at all, // so the slot PTag reads for a hint holds the label instead. val invite = - VideoVerticalEvent( + AddressableShortVideoEvent( id = "a".repeat(64), pubKey = "b".repeat(64), createdAt = 1789666628, @@ -269,7 +269,7 @@ class DivineVideoInteropTest { // No marker means nothing is being credited — printing "references <id>" for a stray // threading tag would invent an attribution the publisher never made. val stray = - VideoVerticalEvent( + AddressableShortVideoEvent( id = "a".repeat(64), pubKey = "b".repeat(64), createdAt = 1789666628, diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/VideoTrackSelectionTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/VideoTrackSelectionTest.kt index 0a7453ddc8..e92f88c732 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/VideoTrackSelectionTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/model/nip71Video/VideoTrackSelectionTest.kt @@ -20,8 +20,8 @@ */ package com.vitorpamplona.amethyst.commons.model.nip71Video +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoMeta -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip94FileMetadata.tags.DimensionTag import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -36,7 +36,7 @@ class VideoTrackSelectionTest { private val hls = "application/vnd.apple.mpegurl" private fun event(vararg metas: VideoMeta) = - VideoVerticalEvent( + AddressableShortVideoEvent( id = "bfe2f2244fefc7cebc7b2eae825495f99dabb4649ee3f90ab1fa33bcd1e9bb9f", pubKey = "3b6187c08b9dd5617150ea047e788a0fdd44b4394cb5566cba76f683ddc027d2", createdAt = 1780894816, diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/DmInboxRelayResolverOutboxTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/DmInboxRelayResolverOutboxTest.kt index 417ef9478d..d539f693fc 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/DmInboxRelayResolverOutboxTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/relayClient/nip17Dm/DmInboxRelayResolverOutboxTest.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.SubscriptionListener import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals @@ -60,11 +60,11 @@ class DmInboxRelayResolverOutboxTest { ) private fun dm10050(inbox: List<NormalizedRelayUrl>) = - ChatMessageRelayListEvent( + DmRelayListEvent( id = "c".repeat(64), pubKey = peer, createdAt = 1_700_000_050, - tags = ChatMessageRelayListEvent.createTagArray(inbox), + tags = DmRelayListEvent.createTagArray(inbox), content = "", sig = dummySig(), ) @@ -115,7 +115,7 @@ class DmInboxRelayResolverOutboxTest { // Indexer knows WHERE the peer writes (10002) but not their 10050. client.scriptEvent(AdvertisedRelayListEvent.KIND, indexer, listOf(outbox10002(listOf(peerOutbox)))) // The peer's own write relay serves their 10050. - client.scriptEvent(ChatMessageRelayListEvent.KIND, peerOutbox, listOf(dm10050(listOf(peerDmInbox)))) + client.scriptEvent(DmRelayListEvent.KIND, peerOutbox, listOf(dm10050(listOf(peerDmInbox)))) val resolver = DmInboxRelayResolver( @@ -136,7 +136,7 @@ class DmInboxRelayResolverOutboxTest { runBlocking { val client = ScriptedClient() // No 10002 on the indexer; the write relay is only known from cache. - client.scriptEvent(ChatMessageRelayListEvent.KIND, peerOutbox, listOf(dm10050(listOf(peerDmInbox)))) + client.scriptEvent(DmRelayListEvent.KIND, peerOutbox, listOf(dm10050(listOf(peerDmInbox)))) val resolver = DmInboxRelayResolver( diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt index 10293574a4..5c27c8c828 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -589,7 +589,7 @@ class NestViewModelTest { fromPublicKey: String, ): String = error("not used") - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = error("not used") + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = error("not used") override suspend fun deriveKey(nonce: String): String = error("not used") diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip17Dm/ui/IncognitoBadge.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip17Dm/ui/IncognitoBadge.kt index 2c7269e112..d0af55cff6 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip17Dm/ui/IncognitoBadge.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip17Dm/ui/IncognitoBadge.kt @@ -29,11 +29,11 @@ import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.ui.theme.IncognitoIconModifier import com.vitorpamplona.amethyst.commons.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent @Composable fun IncognitoBadge(baseNote: Note) { - if (baseNote.event is PrivateDmEvent) { + if (baseNote.event is EncryptedDmEvent) { Icon( symbol = MaterialSymbols.NoEncryption, contentDescription = null, diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/CalendarCollectionCard.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/CalendarCollectionCard.kt index ba22fa6639..6066ad2cab 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/CalendarCollectionCard.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/note/CalendarCollectionCard.kt @@ -41,12 +41,12 @@ import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.calendar_collection_count import com.vitorpamplona.amethyst.commons.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.commons.ui.theme.replyModifier -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import org.jetbrains.compose.resources.pluralStringResource /** Card for a NIP-52 calendar collection (kind 31924): title, description, and event count. */ @Composable -fun CalendarCollectionCard(event: CalendarEvent) { +fun CalendarCollectionCard(event: CalendarCollectionEvent) { val title = remember(event) { event.title() } val eventCount = remember(event) { event.calendarEventAddresses().size } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt index c3aa87d9c9..a25cac2394 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt @@ -167,7 +167,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.relay.sockets.okhttp.BasicOkHttpWebSocket import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent @@ -1817,7 +1817,7 @@ fun MainContent( kinds = listOf( AdvertisedRelayListEvent.KIND, - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, SearchRelayListEvent.KIND, BlockedRelayListEvent.KIND, BlossomServersEvent.KIND, @@ -1845,7 +1845,7 @@ fun MainContent( // dmInboxRelaysStrict, self-copy resolution) alongside // accountRelays' persisted copy. if (event is AdvertisedRelayListEvent || - event is ChatMessageRelayListEvent || + event is DmRelayListEvent || event is BlossomServersEvent || event is MuteListEvent ) { @@ -1877,7 +1877,7 @@ fun MainContent( kinds = listOf( AdvertisedRelayListEvent.KIND, - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, SearchRelayListEvent.KIND, BlockedRelayListEvent.KIND, BlossomServersEvent.KIND, @@ -1926,7 +1926,7 @@ fun MainContent( // Process into chatroomList based on event type when (event) { - is com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent -> { + is com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent -> { iAccount.chatroomList.addMessage( event.chatroomKey(iAccount.pubKey), note, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt index 1d201d6c6c..39db2557dd 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt @@ -44,7 +44,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.aTag.taggedAddresses import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip18Reposts.quotes.QAddressableTag @@ -52,17 +52,17 @@ import com.vitorpamplona.quartz.nip18Reposts.quotes.QEventTag import com.vitorpamplona.quartz.nip18Reposts.quotes.taggedQuotes import com.vitorpamplona.quartz.nip19Bech32.decodePublicKeyAsHexOrNull import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent @@ -310,11 +310,11 @@ class DesktopLocalCache : ICacheProvider { consumeReaction(event, relay) } - is LnZapRequestEvent -> { + is ZapRequestEvent -> { consumeZapRequest(event, relay) } - is LnZapEvent -> { + is ZapReceiptEvent -> { consumeZap(event, relay) } @@ -330,7 +330,7 @@ class DesktopLocalCache : ICacheProvider { consumeContactList(event) } - is LongTextNoteEvent -> { + is LongFormContentEvent -> { consumeLongTextNote(event, relay) } @@ -342,7 +342,7 @@ class DesktopLocalCache : ICacheProvider { consumeOldBookmarkList(event) } - is FollowListEvent -> { + is StarterPackEvent -> { consumeFollowList(event) } @@ -354,7 +354,7 @@ class DesktopLocalCache : ICacheProvider { consumeAdvertisedRelayList(event, relay) } - is ChatMessageRelayListEvent -> { + is DmRelayListEvent -> { consumeChatMessageRelayList(event, relay) } @@ -436,7 +436,7 @@ class DesktopLocalCache : ICacheProvider { * the event stream because the UI doesn't render kind 10050s directly. */ private fun consumeChatMessageRelayList( - event: ChatMessageRelayListEvent, + event: DmRelayListEvent, relay: NormalizedRelayUrl?, ): Boolean { val addressableNote = getOrCreateAddressableNote(event.address()) @@ -586,10 +586,10 @@ class DesktopLocalCache : ICacheProvider { /** * Consumes a kind 9734 zap request event. - * Must be consumed before the corresponding LnZapEvent (kind 9735). + * Must be consumed before the corresponding ZapReceiptEvent (kind 9735). */ private fun consumeZapRequest( - event: LnZapRequestEvent, + event: ZapRequestEvent, relay: NormalizedRelayUrl?, ): Boolean { val note = getOrCreateNote(event.id) @@ -605,7 +605,7 @@ class DesktopLocalCache : ICacheProvider { * Links zap to target notes via the embedded zap request. */ private fun consumeZap( - event: LnZapEvent, + event: ZapReceiptEvent, relay: NormalizedRelayUrl?, ): Boolean { val note = getOrCreateNote(event.id) @@ -739,7 +739,7 @@ class DesktopLocalCache : ICacheProvider { * Creates Note in cache like TextNoteEvent. */ private fun consumeLongTextNote( - event: LongTextNoteEvent, + event: LongFormContentEvent, relay: NormalizedRelayUrl?, ): Boolean { val note = getOrCreateNote(event.id) @@ -788,7 +788,7 @@ class DesktopLocalCache : ICacheProvider { private val _followPackVersion = MutableStateFlow(0L) val followPackVersion: StateFlow<Long> = _followPackVersion.asStateFlow() - private fun consumeFollowList(event: FollowListEvent): Boolean { + private fun consumeFollowList(event: StarterPackEvent): Boolean { val address = event.address() val addressableNote = getOrCreateAddressableNote(address) val author = getOrCreateUser(event.pubKey) @@ -883,14 +883,14 @@ class DesktopLocalCache : ICacheProvider { } /** - * Snapshot all 39089 (FollowListEvent) addressable notes currently in cache. + * Snapshot all 39089 (StarterPackEvent) addressable notes currently in cache. * Use [followPackVersion] to drive reactive recomputation. */ - fun snapshotFollowPacks(): List<FollowListEvent> { - val out = mutableListOf<FollowListEvent>() + fun snapshotFollowPacks(): List<StarterPackEvent> { + val out = mutableListOf<StarterPackEvent>() addressableNotes.forEach { _, note -> val ev = note.event - if (ev is FollowListEvent) out.add(ev) + if (ev is StarterPackEvent) out.add(ev) } return out } @@ -908,10 +908,10 @@ class DesktopLocalCache : ICacheProvider { * @return true if event was processed, false if already seen */ fun consume( - event: LnZapPaymentRequestEvent, + event: NwcRequestEvent, zappedNote: Note?, relay: NormalizedRelayUrl?, - onResponse: suspend (LnZapPaymentResponseEvent) -> Unit, + onResponse: suspend (NwcResponseEvent) -> Unit, wasVerified: Boolean = false, ): Boolean { if (!wasVerified && !justVerify(event)) return false @@ -945,7 +945,7 @@ class DesktopLocalCache : ICacheProvider { */ @OptIn(DelicateCoroutinesApi::class) fun consume( - event: LnZapPaymentResponseEvent, + event: NwcResponseEvent, relay: NormalizedRelayUrl?, wasVerified: Boolean = false, ): Boolean { diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/feeds/DesktopFeedFilters.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/feeds/DesktopFeedFilters.kt index 2dba33235d..9e0830cebe 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/feeds/DesktopFeedFilters.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/feeds/DesktopFeedFilters.kt @@ -35,9 +35,9 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent private fun isFeedNote(event: Event?): Boolean = @@ -317,11 +317,11 @@ class DesktopReadsFeedFilter( override fun feed(): List<Note> = cache.notes - .filterIntoSet { _, note -> note.event is LongTextNoteEvent && !note.isHiddenFor(hidden()) } + .filterIntoSet { _, note -> note.event is LongFormContentEvent && !note.isHiddenFor(hidden()) } .sortedWith(DefaultFeedOrder) .take(limit()) - override fun applyFilter(newItems: Set<Note>): Set<Note> = newItems.filterTo(HashSet()) { it.event is LongTextNoteEvent && !it.isHiddenFor(hidden()) } + override fun applyFilter(newItems: Set<Note>): Set<Note> = newItems.filterTo(HashSet()) { it.event is LongFormContentEvent && !it.isHiddenFor(hidden()) } override fun sort(items: Set<Note>): List<Note> = items.sortedWith(DefaultFeedOrder) @@ -342,7 +342,7 @@ class DesktopNotificationFeedFilter( setOf( TextNoteEvent.KIND, ReactionEvent.KIND, - LnZapEvent.KIND, + ZapReceiptEvent.KIND, ) } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt index bcae97ce02..440f4aee46 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.desktop.cache.DesktopLocalCache import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent data class BulkFollowPreview( val totalMembers: Int, @@ -52,7 +52,7 @@ object BulkFollowAction { * cached metadata (so the bulk-follow always carries relay hints). */ fun computePreview( - pack: FollowListEvent, + pack: StarterPackEvent, cache: DesktopLocalCache, currentFollows: Set<HexKey>, myPubkey: HexKey, @@ -101,7 +101,7 @@ object BulkFollowAction { /** Unfollows every pack member that the user currently follows. */ suspend fun commitUnfollowAll( - pack: FollowListEvent, + pack: StarterPackEvent, iAccount: DesktopIAccount, relayManager: RelayConnectionManager, cache: DesktopLocalCache, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt index 0e11b07b30..d08cf586f1 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.amethyst.desktop.followpacks import com.vitorpamplona.quartz.nip01Core.core.Address -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent /** * Lightweight helpers for follow-pack viewing actions. @@ -30,12 +30,12 @@ import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent */ object FollowPackEditor { /** Encodes the pack as a `nostr:naddr1…` URI for sharing via clipboard. */ - fun toShareUri(pack: FollowListEvent): String { + fun toShareUri(pack: StarterPackEvent): String { val naddr = com.vitorpamplona.quartz.nip19Bech32.entities .NAddress .create( - kind = FollowListEvent.KIND, + kind = StarterPackEvent.KIND, pubKeyHex = pack.pubKey, dTag = pack.dTag(), relays = emptyList(), @@ -44,5 +44,5 @@ object FollowPackEditor { } /** Address coordinate (e.g. "39089:<pubkey>:<dTag>") — stable identity. */ - fun aTag(pack: FollowListEvent): String = Address.assemble(FollowListEvent.KIND, pack.pubKey, pack.dTag()) + fun aTag(pack: StarterPackEvent): String = Address.assemble(StarterPackEvent.KIND, pack.pubKey, pack.dTag()) } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt index cb506f3282..baac2023fc 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.SubscriptionListener import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay @@ -81,7 +81,7 @@ class FollowPacksState( } /** All 39089 events currently in the cache. Recomputes on cache change. */ - val allPacks: StateFlow<List<FollowListEvent>> = + val allPacks: StateFlow<List<StarterPackEvent>> = cache.followPackVersion .map { cache.snapshotFollowPacks().sortedByDescending { it.createdAt } } .stateIn( @@ -91,7 +91,7 @@ class FollowPacksState( ) /** Packs authored by accounts the user follows. Top-3 for sidebar. */ - val followedAuthorsPacks: StateFlow<List<FollowListEvent>> = + val followedAuthorsPacks: StateFlow<List<StarterPackEvent>> = combine(allPacks, followedAuthors) { packs, followed -> packs.filter { it.pubKey in followed } }.stateIn( @@ -104,7 +104,7 @@ class FollowPacksState( * Sidebar top-3: own packs + packs by people user follows. * Falls back to most-recent-from-relays when user has no follow-derived packs. */ - val sidebarTopPacks: StateFlow<List<FollowListEvent>> = + val sidebarTopPacks: StateFlow<List<StarterPackEvent>> = followedAuthorsPacks .map { followedPacks -> if (followedPacks.isNotEmpty()) { @@ -128,8 +128,8 @@ class FollowPacksState( private val recentlyShown = ArrayDeque<String>(5) - private val featuredPackInternal = MutableStateFlow<FollowListEvent?>(null) - val featuredPack: StateFlow<FollowListEvent?> = featuredPackInternal.asStateFlow() + private val featuredPackInternal = MutableStateFlow<StarterPackEvent?>(null) + val featuredPack: StateFlow<StarterPackEvent?> = featuredPackInternal.asStateFlow() init { // Recompute featured on cache or shuffle change. @@ -147,7 +147,7 @@ class FollowPacksState( shuffleTickInternal.value++ } - private fun pickRandom(packs: List<FollowListEvent>): FollowListEvent? { + private fun pickRandom(packs: List<StarterPackEvent>): StarterPackEvent? { if (packs.isEmpty()) return null val candidates = packs.filter { it.address().toValue() !in recentlyShown } val pool = if (candidates.isEmpty()) packs else candidates @@ -182,7 +182,7 @@ class FollowPacksState( relayManager.subscribeOnRelay( relay = relay, subId = "$SUB_ID-${relay.url.hashCode()}", - filters = listOf(Filter(kinds = listOf(FollowListEvent.KIND), limit = 200)), + filters = listOf(Filter(kinds = listOf(StarterPackEvent.KIND), limit = 200)), onEvent = { event, r -> cache.consume(event, r) }, ) // Suppress unused variable warning @@ -193,5 +193,5 @@ class FollowPacksState( } /** Returns hashtags present on this pack, lowercase + deduped. */ - fun hashtagsFor(pack: FollowListEvent): List<String> = pack.hashtags().map { it.lowercase() }.distinct() + fun hashtagsFor(pack: StarterPackEvent): List<String> = pack.hashtags().map { it.lowercase() }.distinct() } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt index 13a34faf40..ad675bc830 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt @@ -71,7 +71,7 @@ import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.amethyst.desktop.ui.ZapFeedback import com.vitorpamplona.amethyst.desktop.ui.live.LivesSection -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.coroutines.launch import java.awt.Toolkit import java.awt.datatransfer.StringSelection @@ -280,7 +280,7 @@ fun DiscoverScreen( @Composable private fun MiniPackThumb( - pack: FollowListEvent, + pack: StarterPackEvent, onClick: () -> Unit, ) { val title = pack.title()?.ifBlank { null } ?: "Untitled pack" diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt index d5ffe5d4e5..16f8d6b122 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt @@ -42,7 +42,7 @@ import com.vitorpamplona.amethyst.desktop.followpacks.BulkFollowAction import com.vitorpamplona.amethyst.desktop.followpacks.BulkFollowPreview import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -54,7 +54,7 @@ import kotlinx.coroutines.launch */ @Composable fun FollowAllConfirmDialog( - pack: FollowListEvent, + pack: StarterPackEvent, iAccount: DesktopIAccount, cache: DesktopLocalCache, relayManager: RelayConnectionManager, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt index 60ed6c4164..4dfd5696ad 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt @@ -53,7 +53,7 @@ import com.vitorpamplona.amethyst.desktop.followpacks.FollowPackEditor import com.vitorpamplona.amethyst.desktop.followpacks.FollowPacksState import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip19Bech32.decodePublicKeyAsHexOrNull -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent /** * Search-all view for follow packs. @@ -138,10 +138,10 @@ fun FollowPackBrowseAllScreen( } private fun filter( - packs: List<FollowListEvent>, + packs: List<StarterPackEvent>, raw: String, cache: DesktopLocalCache, -): List<FollowListEvent> { +): List<StarterPackEvent> { val q = raw.lowercase() val asHex: HexKey? = decodePublicKeyAsHexOrNull(raw) return packs.filter { pack -> diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt index a3c78d9a1e..5a0524f2ab 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt @@ -62,7 +62,7 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.ui.components.UserAvatar import com.vitorpamplona.amethyst.desktop.cache.DesktopLocalCache import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent /** * Stack of overlapping circular avatars for pack members. @@ -143,7 +143,7 @@ fun FollowPackAvatarStack( */ @Composable fun FollowPackHeroCard( - pack: FollowListEvent, + pack: StarterPackEvent, cache: DesktopLocalCache, onFollowAll: () -> Unit, onShare: () -> Unit, @@ -284,7 +284,7 @@ fun FollowPackChipRail( */ @Composable fun FollowPackRow( - pack: FollowListEvent, + pack: StarterPackEvent, cache: DesktopLocalCache, onClick: () -> Unit, modifier: Modifier = Modifier, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt index ae07b1d85d..b7f82a76b3 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt @@ -68,7 +68,7 @@ import com.vitorpamplona.amethyst.desktop.followpacks.subscribeMetadataFor import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import kotlinx.coroutines.launch /** @@ -94,7 +94,7 @@ fun FollowPackDetailScreen( @Suppress("UNUSED_VARIABLE") val metadataVersion by cache.metadataVersion.collectAsState() - val pack: FollowListEvent? = + val pack: StarterPackEvent? = remember(addressTag, allPacks) { allPacks.firstOrNull { FollowPackEditor.aTag(it) == addressTag } } @@ -208,7 +208,7 @@ fun FollowPackDetailScreen( @Composable private fun PackHeroDetail( - pack: FollowListEvent, + pack: StarterPackEvent, cache: DesktopLocalCache, onFollowAll: () -> Unit, onShare: () -> Unit, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt index 3a1bc3f9b6..255e223ef7 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt @@ -58,7 +58,7 @@ import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress as NAddressEntity /** @@ -81,7 +81,7 @@ fun RenderFollowPackCard( val packVersion by cache.followPackVersion.collectAsState() val aTag = remember(address) { Address.assemble(address.kind, address.author, address.dTag) } - val pack: FollowListEvent? = + val pack: StarterPackEvent? = remember(packVersion, aTag) { cache.snapshotFollowPacks().firstOrNull { FollowPackEditor.aTag(it) == aTag } } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopAccountRelays.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopAccountRelays.kt index 6a911cb6af..ef8963f466 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopAccountRelays.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopAccountRelays.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -45,7 +45,7 @@ import java.util.prefs.Preferences * simpler relay management. * * On Android, Account.dmRelays aggregates: - * - DmRelayListState (ChatMessageRelayListEvent, kind 10050) + * - DmRelayListState (DmRelayListEvent, kind 10050) * - Nip65RelayListState (NIP-65 advertised relays) * - PrivateStorageRelayListState * - LocalRelayListState @@ -119,8 +119,8 @@ class DesktopAccountRelays( private fun loadFromPersistence() { // Load DM relays from event or URL cache - val dmEvent = loadEvent(ChatMessageRelayListEvent.KIND) - if (dmEvent is ChatMessageRelayListEvent) { + val dmEvent = loadEvent(DmRelayListEvent.KIND) + if (dmEvent is DmRelayListEvent) { _dmRelayList.value = dmEvent.relays().toSet() lastDmCreatedAt.set(dmEvent.createdAt) } else { @@ -160,8 +160,8 @@ class DesktopAccountRelays( true } - ChatMessageRelayListEvent.KIND -> { - if (event is ChatMessageRelayListEvent && event.createdAt >= lastDmCreatedAt.get()) { + DmRelayListEvent.KIND -> { + if (event is DmRelayListEvent && event.createdAt >= lastDmCreatedAt.get()) { lastDmCreatedAt.set(event.createdAt) val relays = event.relays().toSet() _dmRelayList.value = relays diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopDmRelayState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopDmRelayState.kt index 3a193f95ec..9bd76f9ef6 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopDmRelayState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopDmRelayState.kt @@ -33,7 +33,7 @@ import kotlinx.coroutines.flow.stateIn * Desktop equivalent of DmInboxRelayState. * * Aggregates DM inbox relays from multiple sources: - * - DM relay list (NIP-17 ChatMessageRelayListEvent, kind 10050) + * - DM relay list (NIP-17 DmRelayListEvent, kind 10050) * - Connected relays (fallback when no DM-specific relays are configured) * * On Android, the full Account class manages four relay sources: diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt index 81356eadc7..b298746177 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.model.nip51Lists.muteList.MuteListDecr import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleListDecryptionCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.utils.DualCase import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -43,7 +43,7 @@ import kotlinx.coroutines.flow.stateIn * Desktop mute/block state holder. * * Assembles the user's NIP-51 mute list (kind 10000, [MuteListEvent]) and the - * legacy block people list (kind 30000 `d=mute`, [PeopleListEvent]) into a single + * legacy block people list (kind 30000 `d=mute`, [FollowSetEvent]) into a single * [LiveHiddenUsers] value that [com.vitorpamplona.amethyst.desktop.model.DesktopIAccount] * feeds to [com.vitorpamplona.amethyst.commons.model.Note.isHiddenFor]. * @@ -69,7 +69,7 @@ class DesktopHiddenUsersState( // Strong refs so the GC keeps these addressable notes (and their decrypt caches) alive. private val muteListNote = cache.getOrCreateAddressableNote(MuteListEvent.createAddress(signer.pubKey)) - private val blockListNote = cache.getOrCreateAddressableNote(PeopleListEvent.createBlockAddress(signer.pubKey)) + private val blockListNote = cache.getOrCreateAddressableNote(FollowSetEvent.createBlockAddress(signer.pubKey)) /** Session-only user hides (e.g. "hide this spammer" without persisting a mute). */ val transientHiddenUsers = MutableStateFlow<Set<String>>(emptySet()) @@ -79,7 +79,7 @@ class DesktopHiddenUsersState( private suspend fun assemble( muteEvent: MuteListEvent?, - blockEvent: PeopleListEvent?, + blockEvent: FollowSetEvent?, transient: Set<String>, showSensitive: Boolean?, ): LiveHiddenUsers { @@ -118,7 +118,7 @@ class DesktopHiddenUsersState( ) { muteState, blockState, transient, showSensitive -> assemble( muteState.note.event as? MuteListEvent, - blockState.note.event as? PeopleListEvent, + blockState.note.event as? FollowSetEvent, transient, showSensitive, ) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopIAccount.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopIAccount.kt index e68f95c233..b1c29e32ee 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopIAccount.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopIAccount.kt @@ -46,12 +46,12 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.NIP17Factory import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Request import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent @@ -222,9 +222,9 @@ class DesktopIAccount( override val nip47SignerState: INwcSignerState = object : INwcSignerState { - override suspend fun decryptResponse(event: LnZapPaymentResponseEvent): Response? = null + override suspend fun decryptResponse(event: NwcResponseEvent): Response? = null - override suspend fun decryptRequest(event: LnZapPaymentRequestEvent): Request? = null + override suspend fun decryptRequest(event: NwcRequestEvent): Request? = null override fun isNIP47Author(pubKey: String?): Boolean = false } @@ -249,7 +249,7 @@ class DesktopIAccount( return !note.isHiddenFor(hiddenUsersState.flow.value) } - override suspend fun sendNip04PrivateMessage(eventTemplate: EventTemplate<PrivateDmEvent>) { + override suspend fun sendNip04PrivateMessage(eventTemplate: EventTemplate<EncryptedDmEvent>) { if (!isWriteable()) return val signedEvent = signer.sign(eventTemplate) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopRelayListMutator.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopRelayListMutator.kt index d704b2b7d6..07dfb77539 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopRelayListMutator.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopRelayListMutator.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relays.health.RelayRemovalResult import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import kotlinx.coroutines.async @@ -80,7 +80,7 @@ class DesktopRelayListMutator( async { runCatching { val newRelays = (dmRelays - url).toList() - val event = ChatMessageRelayListEvent.create(newRelays, signer) + val event = DmRelayListEvent.create(newRelays, signer) accountRelays.consumePublishedEvent(event) relayManager.broadcastToAll(event) }.fold(onSuccess = { null }, onFailure = { RelayListKind.DmInbox }) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt index 4fcd463061..514d85b0b2 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt @@ -29,8 +29,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip47WalletConnect.Nip47Client import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceSuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.IErrorResponseLike import com.vitorpamplona.quartz.nip47WalletConnect.rpc.MakeInvoiceSuccessResponse @@ -93,7 +93,7 @@ class NwcPaymentHandler( // Create payment request event val requestEvent = - LnZapPaymentRequestEvent.create( + NwcRequestEvent.create( lnInvoice = bolt11, walletServicePubkey = nwcConnection.pubKeyHex, signer = nwcSigner, @@ -126,7 +126,7 @@ class NwcPaymentHandler( suspendCancellableCoroutine { continuation -> val filter = Filter( - kinds = listOf(LnZapPaymentResponseEvent.KIND), + kinds = listOf(NwcResponseEvent.KIND), authors = listOf(nwcConnection.pubKeyHex), tags = mapOf("e" to listOf(requestId)), ) @@ -138,7 +138,7 @@ class NwcPaymentHandler( subId = subId, filters = listOf(filter), onEvent = { event, relay -> - if (event is LnZapPaymentResponseEvent && event.requestId() == requestId) { + if (event is NwcResponseEvent && event.requestId() == requestId) { // Move verify + cache mutation + decrypt off the relay's // WebSocket reader thread; Schnorr verify is non-trivial // CPU work and shouldn't block frame parsing. @@ -313,7 +313,7 @@ class NwcPaymentHandler( suspendCancellableCoroutine { continuation -> val filter = Filter( - kinds = listOf(LnZapPaymentResponseEvent.KIND), + kinds = listOf(NwcResponseEvent.KIND), authors = listOf(nwcConnection.pubKeyHex), tags = mapOf("e" to listOf(requestId)), ) @@ -325,7 +325,7 @@ class NwcPaymentHandler( subId = subId, filters = listOf(filter), onEvent = { event, _ -> - if (event is LnZapPaymentResponseEvent && event.requestId() == requestId) { + if (event is NwcResponseEvent && event.requestId() == requestId) { @OptIn(kotlinx.coroutines.DelicateCoroutinesApi::class) kotlinx.coroutines.GlobalScope.launch(kotlinx.coroutines.Dispatchers.IO) { if (!localCache.justVerify(event)) return@launch diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt index 78c1cffa71..d72846949e 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt @@ -310,7 +310,7 @@ class DesktopRelaySubscriptionsCoordinator( ), // Zap receipts (kind 9735) targeting these notes Filter( - kinds = listOf(com.vitorpamplona.quartz.nip57Zaps.LnZapEvent.KIND), + kinds = listOf(com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent.KIND), tags = mapOf("e" to noteIds), ), // Reposts (kind 6) targeting these notes diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterBuilders.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterBuilders.kt index 525013809f..0b2d354bdd 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterBuilders.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterBuilders.kt @@ -447,7 +447,7 @@ object FilterBuilders { limit: Int? = null, ): Filter = Filter( - kinds = listOf(9735), // LnZapEvent.KIND + kinds = listOf(9735), // ZapReceiptEvent.KIND tags = mapOf("e" to eventIds), limit = limit, ) @@ -517,7 +517,7 @@ object FilterBuilders { since: Long? = null, ): Filter = Filter( - kinds = listOf(4), // PrivateDmEvent.KIND + kinds = listOf(4), // EncryptedDmEvent.KIND tags = mapOf("p" to listOf(pubKeyHex)), limit = limit, since = since, @@ -537,7 +537,7 @@ object FilterBuilders { since: Long? = null, ): Filter = Filter( - kinds = listOf(4), // PrivateDmEvent.KIND + kinds = listOf(4), // EncryptedDmEvent.KIND authors = listOf(pubKeyHex), limit = limit, since = since, @@ -569,7 +569,7 @@ object FilterBuilders { */ fun dmRelayList(pubKeyHex: String): Filter = Filter( - kinds = listOf(10050), // ChatMessageRelayListEvent.KIND + kinds = listOf(10050), // DmRelayListEvent.KIND authors = listOf(pubKeyHex), limit = 1, ) @@ -588,7 +588,7 @@ object FilterBuilders { until: Long? = null, ): Filter = Filter( - kinds = listOf(30023), // LongTextNoteEvent.KIND + kinds = listOf(30023), // LongFormContentEvent.KIND limit = limit, since = since, until = until, @@ -606,7 +606,7 @@ object FilterBuilders { dTag: String, ): Filter = Filter( - kinds = listOf(30023), // LongTextNoteEvent.KIND + kinds = listOf(30023), // LongFormContentEvent.KIND authors = listOf(pubkey), tags = mapOf("d" to listOf(dTag)), limit = 1, @@ -628,7 +628,7 @@ object FilterBuilders { until: Long? = null, ): Filter = Filter( - kinds = listOf(30023), // LongTextNoteEvent.KIND + kinds = listOf(30023), // LongFormContentEvent.KIND authors = authors, limit = limit, since = since, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterDMs.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterDMs.kt index 9ab82738b8..e9f52e6115 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterDMs.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/FilterDMs.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.EphemeralGiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent @@ -50,7 +50,7 @@ object FilterDMs { limit: Int? = null, ): Filter = Filter( - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), tags = mapOf("p" to listOf(userPubKeyHex)), since = since, limit = limit, @@ -70,7 +70,7 @@ object FilterDMs { limit: Int? = null, ): Filter = Filter( - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), authors = listOf(userPubKeyHex), since = since, limit = limit, @@ -96,14 +96,14 @@ object FilterDMs { return listOf( // Messages TO me from conversation participants Filter( - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), authors = conversationPubKeys.toList(), tags = mapOf("p" to listOf(userPubKeyHex)), since = since, ), // Messages FROM me to conversation participants Filter( - kinds = listOf(PrivateDmEvent.KIND), + kinds = listOf(EncryptedDmEvent.KIND), authors = listOf(userPubKeyHex), tags = mapOf("p" to conversationPubKeys.toList()), since = since, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ArticleReaderScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ArticleReaderScreen.kt index 8092de6e4e..4a97e66179 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ArticleReaderScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ArticleReaderScreen.kt @@ -91,11 +91,11 @@ import com.vitorpamplona.amethyst.desktop.subscriptions.rememberSubscription import com.vitorpamplona.amethyst.desktop.ui.highlights.ArticleHighlightsPanel import com.vitorpamplona.amethyst.desktop.ui.highlights.HighlightAnnotationDialog import com.vitorpamplona.quartz.nip18Reposts.RepostEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlinx.coroutines.launch import java.text.DateFormat import java.util.Date @@ -144,7 +144,7 @@ fun ArticleReaderScreen( val dTag = parsed?.third // Article state - var article by remember(addressTag) { mutableStateOf<LongTextNoteEvent?>(null) } + var article by remember(addressTag) { mutableStateOf<LongFormContentEvent?>(null) } var eoseReceived by remember(addressTag) { mutableStateOf(false) } // Zoom level for article text @@ -212,7 +212,7 @@ fun ArticleReaderScreen( filters = listOf(FilterBuilders.longFormByAddress(pubkey, dTag)), relays = configuredRelays, onEvent = { event, _, _, _ -> - if (event is LongTextNoteEvent) { + if (event is LongFormContentEvent) { // Keep the most recent version val current = article if (current == null || event.createdAt > current.createdAt) { @@ -246,7 +246,7 @@ fun ArticleReaderScreen( relays = configuredRelays, eventIds = eventIds, onEvent = { event, _, _, _ -> - if (event is LnZapEvent) { + if (event is ZapReceiptEvent) { val receipt = event.toZapReceipt(localCache) ?: return@createZapsSubscription if (zapReceipts.none { it.createdAt == receipt.createdAt && it.senderPubKey == receipt.senderPubKey }) { zapReceipts = zapReceipts + receipt diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt index 34cdbcfae5..9d4c62415b 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt @@ -102,7 +102,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.poll.tags.PollType import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent @@ -168,9 +168,9 @@ data class ZapReceipt( ) /** - * Converts an LnZapEvent to a ZapReceipt for display. + * Converts an ZapReceiptEvent to a ZapReceipt for display. */ -fun LnZapEvent.toZapReceipt(localCache: DesktopLocalCache): ZapReceipt? { +fun ZapReceiptEvent.toZapReceipt(localCache: DesktopLocalCache): ZapReceipt? { val senderPubKey = zappedRequestAuthor() ?: return null val amountSats = amount?.toLong() ?: return null @@ -484,7 +484,7 @@ fun ZapReceiptsPopup( val name = user?.toBestDisplayName() ?: pubKey.take(12) val pictureUrl = user?.profilePicture() val amount = - (receipt?.event as? LnZapEvent)?.amount?.toLong() + (receipt?.event as? ZapReceiptEvent)?.amount?.toLong() ?: return@mapNotNull null val message = request.event?.content?.ifBlank { null } ZapEntry(pubKey, pictureUrl, name, amount, message) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt index 4bdb8f1083..3791bfcfbf 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NotificationsScreen.kt @@ -87,7 +87,7 @@ import com.vitorpamplona.amethyst.desktop.ui.notifications.NotificationGroup import com.vitorpamplona.amethyst.desktop.ui.notifications.groupNotifications import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.hexToByteArrayOrNull -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent @@ -97,7 +97,7 @@ import com.vitorpamplona.quartz.nip19Bech32.toNpub import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent @@ -157,7 +157,7 @@ sealed class NotificationItem( val NotificationItem.effectiveAuthorPubKey: String get() = when (val e = event) { - is LnZapEvent -> e.zapRequest?.pubKey ?: e.pubKey + is ZapReceiptEvent -> e.zapRequest?.pubKey ?: e.pubKey else -> event.pubKey } @@ -169,7 +169,7 @@ private fun classifyNotification(event: Event): NotificationItem? = when (event) { is ReactionEvent -> NotificationItem.Reaction(event, event.createdAt, event.content) is RepostEvent, is GenericRepostEvent -> NotificationItem.Repost(event, event.createdAt) - is LnZapEvent -> NotificationItem.Zap(event, event.createdAt, event.amount?.toLong()) + is ZapReceiptEvent -> NotificationItem.Zap(event, event.createdAt, event.amount?.toLong()) // Nutzaps: treat like a zap; sats amount extraction requires the Cashu // token proof and is deferred to when Desktop renders zap detail. is NutzapEvent -> NotificationItem.Zap(event, event.createdAt, null) @@ -186,7 +186,7 @@ private fun classifyNotification(event: Event): NotificationItem? = // NIP-28 channel messages read like public mentions. is ChannelMessageEvent -> NotificationItem.Mention(event, event.createdAt) // DMs (NIP-04 legacy + NIP-17 gift-wrap + rumor + file-header). - is PrivateDmEvent, + is EncryptedDmEvent, is ChatMessageEvent, is GiftWrapEvent, is ChatMessageEncryptedFileHeaderEvent, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt index 96a44b0cee..42fd5cfb90 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/ReadsScreen.kt @@ -67,7 +67,7 @@ import com.vitorpamplona.amethyst.desktop.subscriptions.createFollowingLongFormF import com.vitorpamplona.amethyst.desktop.subscriptions.createLongFormFeedSubscription import com.vitorpamplona.amethyst.desktop.subscriptions.rememberSubscription import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import java.text.DateFormat import java.util.Date @@ -83,7 +83,7 @@ private fun formatDate(timestamp: Long): String = dateFormat.format(Date(timesta */ @Composable fun LongFormCard( - event: LongTextNoteEvent, + event: LongFormContentEvent, localCache: DesktopLocalCache, onAuthorClick: (String) -> Unit = {}, onClick: () -> Unit = {}, @@ -185,9 +185,9 @@ fun ReadsScreen( val eventState = remember { - EventCollectionState<LongTextNoteEvent>( + EventCollectionState<LongFormContentEvent>( getId = { it.id }, - sortComparator = compareByDescending<LongTextNoteEvent> { it.publishedAt() ?: it.createdAt }.thenBy { it.id }, + sortComparator = compareByDescending<LongFormContentEvent> { it.publishedAt() ?: it.createdAt }.thenBy { it.id }, maxSize = 100, scope = scope, ) @@ -204,10 +204,10 @@ fun ReadsScreen( LaunchedEffect(Unit) { val cached = localCache.notes.filterIntoSet { _, note -> - note.event is LongTextNoteEvent + note.event is LongFormContentEvent } cached.forEach { note -> - (note.event as? LongTextNoteEvent)?.let { eventState.addItem(it) } + (note.event as? LongFormContentEvent)?.let { eventState.addItem(it) } } if (cached.isNotEmpty()) eoseReceivedCount++ } @@ -249,7 +249,7 @@ fun ReadsScreen( relays = connectedRelays, onEvent = { event, _, relay, _ -> subscriptionsCoordinator?.consumeEvent(event, relay) - if (event is LongTextNoteEvent) { + if (event is LongFormContentEvent) { eventState.addItem(event) } }, @@ -266,7 +266,7 @@ fun ReadsScreen( followedUsers = followedUsers.toList(), onEvent = { event, _, relay, _ -> subscriptionsCoordinator?.consumeEvent(event, relay) - if (event is LongTextNoteEvent) { + if (event is LongFormContentEvent) { eventState.addItem(event) } }, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt index bf08ddbbc2..7264e2d71b 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt @@ -117,7 +117,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip19Bech32.toNpub -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip39ExtIdentities.ExternalIdentitiesEvent import com.vitorpamplona.quartz.nip39ExtIdentities.GitHubIdentity import com.vitorpamplona.quartz.nip39ExtIdentities.MastodonIdentity @@ -125,9 +125,9 @@ import com.vitorpamplona.quartz.nip39ExtIdentities.TwitterIdentity import com.vitorpamplona.quartz.nip39ExtIdentities.identityClaims import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.EventBookmark -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent @@ -231,7 +231,7 @@ fun UserProfileScreen( var showProfileReportDialog by remember(pubKeyHex) { mutableStateOf(false) } var showAddToListMenu by remember(pubKeyHex) { mutableStateOf(false) } val followPacksState = LocalFollowPacksState.current - val followPacks by (followPacksState?.allPacks ?: MutableStateFlow(emptyList<FollowListEvent>())).collectAsState() + val followPacks by (followPacksState?.allPacks ?: MutableStateFlow(emptyList<StarterPackEvent>())).collectAsState() val profileHidden by (iAccount?.hiddenUsers ?: kotlinx.coroutines.flow.MutableStateFlow(com.vitorpamplona.amethyst.commons.model.LiveHiddenUsers.EMPTY)).collectAsState() val isUserMuted = profileHidden.isUserHidden(pubKeyHex) @@ -351,7 +351,7 @@ fun UserProfileScreen( var selectedTab by remember { mutableStateOf(0) } var lightboxState by remember { mutableStateOf<LightboxState?>(null) } val pictureEvents = remember { mutableStateListOf<PictureEvent>() } - val articleEvents = remember { mutableStateListOf<LongTextNoteEvent>() } + val articleEvents = remember { mutableStateListOf<LongFormContentEvent>() } val highlightEvents = remember { mutableStateListOf<HighlightEvent>() } // Followers / Following user lists (pubkeys) and the profile's relay list. @@ -361,7 +361,7 @@ fun UserProfileScreen( var relayList by remember(pubKeyHex) { mutableStateOf<List<Triple<String, Boolean, Boolean>>>(emptyList()) } // Zaps received: raw zap receipts, aggregated per zapper (pubkey → total sats). - val zapEvents = remember(pubKeyHex) { mutableStateListOf<LnZapEvent>() } + val zapEvents = remember(pubKeyHex) { mutableStateListOf<ZapReceiptEvent>() } var zapAmounts by remember(pubKeyHex) { mutableStateOf<List<Pair<String, BigDecimal>>>(emptyList()) } var zapTotalSats by remember(pubKeyHex) { mutableStateOf(BigDecimal.ZERO) } @@ -559,13 +559,13 @@ fun UserProfileScreen( listOf( FilterBuilders.byAuthors( authors = listOf(pubKeyHex), - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), limit = 50, ), ), relays = connectedRelays, onEvent = { event, _, _, _ -> - if (event is LongTextNoteEvent && articleEvents.none { it.id == event.id }) { + if (event is LongFormContentEvent && articleEvents.none { it.id == event.id }) { articleEvents.add(event) } }, @@ -710,13 +710,13 @@ fun UserProfileScreen( listOf( FilterBuilders.byPTags( pubKeys = listOf(pubKeyHex), - kinds = listOf(LnZapEvent.KIND), + kinds = listOf(ZapReceiptEvent.KIND), limit = 500, ), ), relays = connectedRelays, onEvent = { event, _, _, _ -> - if (event is LnZapEvent && zapEvents.none { it.id == event.id }) { + if (event is ZapReceiptEvent && zapEvents.none { it.id == event.id }) { zapEvents.add(event) } }, @@ -971,7 +971,7 @@ fun UserProfileScreen( scope.launch { try { val updated = - FollowListEvent.add( + StarterPackEvent.add( pack, UserTag(pubKeyHex, null), acct.signer, @@ -1447,7 +1447,7 @@ fun UserProfileScreen( } } else { items( - articleEvents.sortedWith(compareByDescending<LongTextNoteEvent> { it.publishedAt() ?: it.createdAt }.thenBy { it.id }), + articleEvents.sortedWith(compareByDescending<LongFormContentEvent> { it.publishedAt() ?: it.createdAt }.thenBy { it.id }), key = { "art-${it.id}" }, ) { article -> LongFormCard( @@ -1455,7 +1455,7 @@ fun UserProfileScreen( localCache = localCache, onAuthorClick = { onNavigateToProfile(article.pubKey) }, onClick = { - val addressTag = "${LongTextNoteEvent.KIND}:${article.pubKey}:${article.dTag()}" + val addressTag = "${LongFormContentEvent.KIND}:${article.pubKey}:${article.dTag()}" onNavigateToArticle(addressTag) }, ) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt index 1c3fc89cf5..c34aea979b 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatPane.kt @@ -125,7 +125,7 @@ import com.vitorpamplona.amethyst.desktop.ui.media.QualitySelectorChip import com.vitorpamplona.amethyst.desktop.ui.note.DesktopRichText import com.vitorpamplona.amethyst.desktop.ui.note.RichTextCallbacks import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.NIP17Factory import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent @@ -714,7 +714,7 @@ private fun MessageWithReactions( LaunchedEffect(note.idHex, event) { decryptedContent = when (event) { - is PrivateDmEvent -> { + is EncryptedDmEvent -> { try { event.decryptContent(account.signer) } catch (_: Exception) { @@ -776,7 +776,7 @@ private fun MessageWithReactions( ) { // Encryption badge when (event) { - is PrivateDmEvent -> { + is EncryptedDmEvent -> { Icon( MaterialSymbols.LockOpen, contentDescription = "NIP-04 (legacy)", @@ -947,7 +947,7 @@ private fun MessageReplyContext( preview = when (val e = parent.event) { is ChatMessageEncryptedFileHeaderEvent -> "📎 Attachment" - is PrivateDmEvent -> + is EncryptedDmEvent -> try { e.decryptContent(account.signer) } catch (_: Exception) { @@ -1076,7 +1076,7 @@ private fun ReplyPreviewBar( preview = when (event) { is ChatMessageEncryptedFileHeaderEvent -> "📎 Attachment" - is PrivateDmEvent -> + is EncryptedDmEvent -> try { event.decryptContent(account.signer) } catch (_: Exception) { diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt index 2b18254d14..34873597ac 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/ChatroomListState.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.SubscriptionListener import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -138,7 +138,7 @@ class ChatroomListState( private suspend fun decryptPreview(event: com.vitorpamplona.quartz.nip01Core.core.Event?): String { if (event == null) return "" return when (event) { - is PrivateDmEvent -> { + is EncryptedDmEvent -> { decryptedContentCache.getOrPut(event.id) { try { event.decryptContent(account.signer) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/composer/GifResult.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/composer/GifResult.kt index f8eaa49707..302b3651dd 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/composer/GifResult.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/chats/composer/GifResult.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.desktop.ui.chats.composer import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.accessories.fetchAll import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent /** A single GIF result surfaced from a NIP-94 (kind 1063) metadata event. */ data class GifResult( @@ -47,7 +47,7 @@ suspend fun searchGifs( val trimmed = query.trim() val filter = Filter( - kinds = listOf(FileHeaderEvent.KIND), + kinds = listOf(FileMetadataEvent.KIND), tags = mapOf("m" to listOf("image/gif")), limit = limitPerRelay, search = trimmed.ifBlank { null }, @@ -59,7 +59,7 @@ suspend fun searchGifs( runCatching { client.fetchAll(relay, filter, idleTimeoutMs = 8_000L) } .getOrDefault(emptyList()) for (event in events) { - val fileHeader = event as? FileHeaderEvent ?: continue + val fileHeader = event as? FileMetadataEvent ?: continue val url = fileHeader.url() ?: continue raw.add(GifResult(url = url, description = fileHeader.content)) } diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt index 62f67372bb..6c6e49ad14 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt @@ -376,7 +376,7 @@ private fun RenderBechSegment( .NAddress .parse(segment.segmentText) } - if (naddr != null && naddr.kind == com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent.KIND) { + if (naddr != null && naddr.kind == com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent.KIND) { val followPacks = com.vitorpamplona.amethyst.desktop.ui.deck.LocalFollowPacksState.current val relayManager = com.vitorpamplona.amethyst.desktop.ui.deck.LocalRelayManager.current if (localCache != null && relayManager != null && followPacks != null) { diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/notifications/DesktopNotificationAutoDispatcher.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/notifications/DesktopNotificationAutoDispatcher.kt index 23981aab22..6ec6fd2e7c 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/notifications/DesktopNotificationAutoDispatcher.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/notifications/DesktopNotificationAutoDispatcher.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.amethyst.commons.moderation.notifications.nowEpochSecon import com.vitorpamplona.amethyst.commons.moderation.notifications.sanitizeForToast import com.vitorpamplona.amethyst.desktop.cache.DesktopLocalCache import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.zap.OnchainZapEvent @@ -178,14 +178,14 @@ class DesktopNotificationAutoDispatcher( when (event) { is ReactionEvent -> NotifKind.REACTION is RepostEvent, is GenericRepostEvent -> NotifKind.REPOST - is LnZapEvent, is NutzapEvent, is OnchainZapEvent -> NotifKind.ZAP + is ZapReceiptEvent, is NutzapEvent, is OnchainZapEvent -> NotifKind.ZAP is TextNoteEvent -> { val isReply = event.tags.any { it.size > 1 && it[0] == "e" } if (isReply) NotifKind.REPLY else NotifKind.MENTION } is CommentEvent -> NotifKind.REPLY is ChannelMessageEvent -> NotifKind.MENTION - is PrivateDmEvent, + is EncryptedDmEvent, is ChatMessageEvent, is GiftWrapEvent, is ChatMessageEncryptedFileHeaderEvent, @@ -199,7 +199,7 @@ class DesktopNotificationAutoDispatcher( ): NotificationSpec { val effectivePubKey = when (event) { - is LnZapEvent -> event.zapRequest?.pubKey ?: event.pubKey + is ZapReceiptEvent -> event.zapRequest?.pubKey ?: event.pubKey else -> event.pubKey } val displayName = @@ -207,7 +207,7 @@ class DesktopNotificationAutoDispatcher( ?: "Someone" val amountText = - (event as? LnZapEvent)?.amount?.let { " ${it.toLong() / 1000} sats" } ?: "" + (event as? ZapReceiptEvent)?.amount?.let { " ${it.toLong() / 1000} sats" } ?: "" val title = when (kind) { diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/relay/DmRelayEditor.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/relay/DmRelayEditor.kt index e4063ffaf2..86673cc80b 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/relay/DmRelayEditor.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/relay/DmRelayEditor.kt @@ -57,7 +57,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import kotlinx.coroutines.delay import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch @@ -181,7 +181,7 @@ fun DmRelayEditor( } scope.launch { try { - val event = ChatMessageRelayListEvent.create(localRelays.toList(), signer) + val event = DmRelayListEvent.create(localRelays.toList(), signer) onPublish(event) onDmRelaysUpdated(localRelays.toSet()) savedMessage = "Published ${localRelays.size} relay(s)" diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/search/SearchResultsList.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/search/SearchResultsList.kt index c225256ee4..3b0fab764f 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/search/SearchResultsList.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/search/SearchResultsList.kt @@ -69,7 +69,7 @@ import com.vitorpamplona.amethyst.desktop.ui.note.NoteCard import com.vitorpamplona.amethyst.desktop.ui.note.SpamCheckedNoteRender import com.vitorpamplona.amethyst.desktop.ui.note.WoTBadge import com.vitorpamplona.amethyst.desktop.ui.rememberDisplayData -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent @Composable @@ -96,9 +96,9 @@ fun SearchResultsList( // Group notes by kind val textNotes = notes.filter { it.kind == 1 } - val articles = notes.filter { it.kind == LongTextNoteEvent.KIND } + val articles = notes.filter { it.kind == LongFormContentEvent.KIND } val polls = notes.filter { it.kind == PollEvent.KIND } - val otherNotes = notes.filter { it.kind != 1 && it.kind != LongTextNoteEvent.KIND && it.kind != PollEvent.KIND } + val otherNotes = notes.filter { it.kind != 1 && it.kind != LongFormContentEvent.KIND && it.kind != PollEvent.KIND } // Per-section collapsed state (absent = expanded) val collapsedSections = remember { mutableStateMapOf<String, Boolean>() } diff --git a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopDmRelayListConsumeTest.kt b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopDmRelayListConsumeTest.kt index 8d0cbd22ce..ee625359b3 100644 --- a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopDmRelayListConsumeTest.kt +++ b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopDmRelayListConsumeTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.desktop.cache import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull @@ -50,7 +50,7 @@ class DesktopDmRelayListConsumeTest { signer: NostrSignerSync, relays: List<NormalizedRelayUrl> = dmInbox, createdAt: Long = 1_700_000_000, - ): ChatMessageRelayListEvent = ChatMessageRelayListEvent.create(relays, signer, createdAt) + ): DmRelayListEvent = DmRelayListEvent.create(relays, signer, createdAt) @Test fun `consume routes kind 10050 into the User model`() { diff --git a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandlerTest.kt b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandlerTest.kt index 752deaf576..28ef0d7dc8 100644 --- a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandlerTest.kt +++ b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandlerTest.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceSuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.MakeInvoiceSuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.NwcTransaction @@ -157,8 +157,8 @@ class NwcPaymentHandlerTest { // -- Response event structure -- @Test - fun `LnZapPaymentResponseEvent has correct KIND`() { - assertEquals(23195, LnZapPaymentResponseEvent.KIND) + fun `NwcResponseEvent has correct KIND`() { + assertEquals(23195, NwcResponseEvent.KIND) } // -- PayInvoiceSuccessResponse structure -- diff --git a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcRpcIntegrationTest.kt b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcRpcIntegrationTest.kt index ce6bf5f8a5..04d1f2e080 100644 --- a/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcRpcIntegrationTest.kt +++ b/desktopApp/src/jvmTest/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcRpcIntegrationTest.kt @@ -25,8 +25,8 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip47WalletConnect.Nip47Client -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceSuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.MakeInvoiceMethod @@ -66,7 +66,7 @@ class NwcRpcIntegrationTest { val requestEvent = client.payInvoice("lnbc50n1pjtest...") // Verify request event structure - assertEquals(LnZapPaymentRequestEvent.KIND, requestEvent.kind) + assertEquals(NwcRequestEvent.KIND, requestEvent.kind) assertTrue(requestEvent.content.isNotBlank()) // Wallet decrypts the request @@ -82,7 +82,7 @@ class NwcRpcIntegrationTest { val requestEvent = client.getBalance() // Verify it's a valid NWC request - assertEquals(LnZapPaymentRequestEvent.KIND, requestEvent.kind) + assertEquals(NwcRequestEvent.KIND, requestEvent.kind) // Wallet decrypts and verifies method type val decrypted = requestEvent.decryptRequest(walletSigner) @@ -90,7 +90,7 @@ class NwcRpcIntegrationTest { // Wallet builds encrypted response val responseEvent = - LnZapPaymentResponseEvent.createResponse( + NwcResponseEvent.createResponse( response = GetBalanceSuccessResponse( result = GetBalanceSuccessResponse.GetBalanceResult(balance = 125_000), @@ -100,7 +100,7 @@ class NwcRpcIntegrationTest { ) // Verify response event structure - assertEquals(LnZapPaymentResponseEvent.KIND, responseEvent.kind) + assertEquals(NwcResponseEvent.KIND, responseEvent.kind) assertEquals(requestEvent.id, responseEvent.requestId()) // Client decrypts response @@ -124,7 +124,7 @@ class NwcRpcIntegrationTest { // Wallet responds with invoice val fakeInvoice = "lnbc500n1pjgenerated..." val responseEvent = - LnZapPaymentResponseEvent.createResponse( + NwcResponseEvent.createResponse( response = MakeInvoiceSuccessResponse( result = @@ -153,7 +153,7 @@ class NwcRpcIntegrationTest { val requestEvent = client.payInvoice("lnbc100n1...") val responseEvent = - LnZapPaymentResponseEvent.createResponse( + NwcResponseEvent.createResponse( response = PayInvoiceSuccessResponse( result = @@ -183,7 +183,7 @@ class NwcRpcIntegrationTest { // Build a request and verify it works val requestEvent = client.getBalance() - assertEquals(LnZapPaymentRequestEvent.KIND, requestEvent.kind) + assertEquals(NwcRequestEvent.KIND, requestEvent.kind) // Wallet can decrypt it val decrypted = requestEvent.decryptRequest(walletSigner) diff --git a/geode/src/test/kotlin/com/vitorpamplona/geode/ConcordPlaneKeyDeletionTest.kt b/geode/src/test/kotlin/com/vitorpamplona/geode/ConcordPlaneKeyDeletionTest.kt index 15c5fcd7a1..051c1736f8 100644 --- a/geode/src/test/kotlin/com/vitorpamplona/geode/ConcordPlaneKeyDeletionTest.kt +++ b/geode/src/test/kotlin/com/vitorpamplona/geode/ConcordPlaneKeyDeletionTest.kt @@ -34,7 +34,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent import com.vitorpamplona.quartz.utils.RandomInstance import com.vitorpamplona.quartz.utils.TimeUtils @@ -177,7 +177,7 @@ class ConcordPlaneKeyDeletionTest { // The banned member still derives `plane`, and every wrap above IS authored by it — so // this kind-5 satisfies a same-author check. It must still be refused. - val deletion = planeSigner().sign(DeletionEvent.build(history, createdAt = now + 10)) + val deletion = planeSigner().sign(DeletionRequestEvent.build(history, createdAt = now + 10)) assertEquals(true, client.publishAndConfirm(deletion, setOf(relayUrl)), "the relay accepts the event itself") assertEquals( @@ -230,7 +230,7 @@ class ConcordPlaneKeyDeletionTest { assertEquals(true, client.publishAndConfirm(addressedWrap, setOf(relayUrl))) assertEquals(1, query(Filter(ids = listOf(addressedWrap.id))).size) - val deletion = mallory.sign(DeletionEvent.build(listOf(addressedWrap), createdAt = now + 1)) + val deletion = mallory.sign(DeletionRequestEvent.build(listOf(addressedWrap), createdAt = now + 1)) assertEquals(true, client.publishAndConfirm(deletion, setOf(relayUrl))) assertEquals( diff --git a/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSettleBenchmark.kt b/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSettleBenchmark.kt index 46e4b7a1ca..5f229740d9 100644 --- a/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSettleBenchmark.kt +++ b/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSettleBenchmark.kt @@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.accessories.negentropySet import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync import com.vitorpamplona.quartz.nip01Core.store.sqlite.EventStore -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.runBlocking @@ -81,7 +81,7 @@ class DeletionSettleBenchmark : RelayClientTest() { // The last K are the ones we deleted locally. val deleted = notes.takeLast(k) val kept = notes.dropLast(k) - val deletions = deleted.map { signer.sign(DeletionEvent.build(listOf(it), createdAt = it.createdAt + 1)) } + val deletions = deleted.map { signer.sign(DeletionRequestEvent.build(listOf(it), createdAt = it.createdAt + 1)) } // Relay holds all N notes; we hold the N-K we didn't delete, plus the K kind-5s. defaultRelay.preload(notes) diff --git a/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSyncTest.kt b/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSyncTest.kt index f3a7ef4306..22b07e8be7 100644 --- a/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSyncTest.kt +++ b/geode/src/test/kotlin/com/vitorpamplona/geode/DeletionSyncTest.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip01Core.store.IdAndTime import com.vitorpamplona.quartz.nip01Core.store.deletionsCovering import com.vitorpamplona.quartz.nip01Core.store.sqlite.EventStore import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent import kotlinx.coroutines.runBlocking @@ -69,7 +69,7 @@ class DeletionSyncTest : RelayClientTest() { fun idBasedDeletionCoversByETag() = runBlocking { val target = note("delete me") - val deletion = signer.sign(DeletionEvent.build(listOf(target), createdAt = target.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(target), createdAt = target.createdAt + 1)) store.insert(deletion) assertEquals(listOf(deletion.id), store.deletionsCovering(listOf(target), here).map { it.id }) @@ -82,7 +82,7 @@ class DeletionSyncTest : RelayClientTest() { runBlocking { val contacts = ContactListEvent.createFromScratch(emptyList(), null, signer) // Address-only deletion (no `e` tag) → only the `a`-tag path can match it. - val delAddr = signer.sign(DeletionEvent.buildAddressOnly(listOf(contacts), createdAt = contacts.createdAt + 1)) + val delAddr = signer.sign(DeletionRequestEvent.buildAddressOnly(listOf(contacts), createdAt = contacts.createdAt + 1)) store.insert(delAddr) assertEquals( @@ -93,7 +93,7 @@ class DeletionSyncTest : RelayClientTest() { // NIP-09 cutoff: a deletion OLDER than the event does not delete it. val stale = EventStore(null) - stale.insert(signer.sign(DeletionEvent.buildAddressOnly(listOf(contacts), createdAt = contacts.createdAt - 1))) + stale.insert(signer.sign(DeletionRequestEvent.buildAddressOnly(listOf(contacts), createdAt = contacts.createdAt - 1))) assertTrue(stale.deletionsCovering(listOf(contacts), here).isEmpty(), "an older address deletion does not cover") stale.close() } @@ -129,7 +129,7 @@ class DeletionSyncTest : RelayClientTest() { fun sendsCoveringDeletionSoRelayRemovesTheNote() = runBlocking { val target = note("delete me e2e") - val deletion = signer.sign(DeletionEvent.build(listOf(target), createdAt = target.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(target), createdAt = target.createdAt + 1)) // Relay holds the note; we already deleted it locally (hold only the kind-5). defaultRelay.preload(listOf(target)) @@ -163,7 +163,7 @@ class DeletionSyncTest : RelayClientTest() { fun appliesRelaysDeletionSoLocalRemovesTheNote() = runBlocking { val target = note("delete me down") - val deletion = signer.sign(DeletionEvent.build(listOf(target), createdAt = target.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(target), createdAt = target.createdAt + 1)) // Relay already applied the deletion → holds only the kind-5. defaultRelay.preload(listOf(target, deletion)) @@ -190,7 +190,7 @@ class DeletionSyncTest : RelayClientTest() { val ourEvents = local.store.query<Event>(Filter(ids = diff.haveIds)) val relayDeletions = deletionsCovering(ourEvents, defaultRelayUrl) { f -> defaultRelay.store.query<Event>(f) } assertEquals(listOf(deletion.id), relayDeletions.map { it.id }) - relayDeletions.filterIsInstance<DeletionEvent>().forEach { local.store.insert(it) } + relayDeletions.filterIsInstance<DeletionRequestEvent>().forEach { local.store.insert(it) } assertTrue( local.store.query<Event>(Filter(ids = listOf(target.id))).isEmpty(), @@ -206,7 +206,7 @@ class DeletionSyncTest : RelayClientTest() { fun settleSendsOurDeletionUp() = runBlocking { val target = note("settle up") - val deletion = signer.sign(DeletionEvent.build(listOf(target), createdAt = target.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(target), createdAt = target.createdAt + 1)) val localStore = EventStore(null) localStore.insert(target) localStore.insert(deletion) // deletes target locally, keeps the kind-5 @@ -239,7 +239,7 @@ class DeletionSyncTest : RelayClientTest() { fun settleAppliesRelayDeletionDown() = runBlocking { val target = note("settle down") - val deletion = signer.sign(DeletionEvent.build(listOf(target), createdAt = target.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(target), createdAt = target.createdAt + 1)) defaultRelay.preload(listOf(target, deletion)) // relay deletes target, keeps the kind-5 val localStore = EventStore(null) localStore.insert(target) diff --git a/geode/src/test/kotlin/com/vitorpamplona/geode/Nip01ComplianceTest.kt b/geode/src/test/kotlin/com/vitorpamplona/geode/Nip01ComplianceTest.kt index 7f69de4c89..9326acbb7f 100644 --- a/geode/src/test/kotlin/com/vitorpamplona/geode/Nip01ComplianceTest.kt +++ b/geode/src/test/kotlin/com/vitorpamplona/geode/Nip01ComplianceTest.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED import kotlinx.coroutines.runBlocking @@ -350,7 +350,7 @@ class Nip01ComplianceTest : RelayClientTest() { /** * Addressable events (kind 30000-39999, NIP-01 §"Kinds") are replaced - * by `(pubkey, kind, d)`. Uses a real signed [LongTextNoteEvent] because + * by `(pubkey, kind, d)`. Uses a real signed [LongFormContentEvent] because * the SQLite store dispatches on the typed `AddressableEvent` subclass * to extract the d-tag — synthetic plain `Event`s aren't recognised. */ @@ -358,15 +358,15 @@ class Nip01ComplianceTest : RelayClientTest() { fun parameterizedReplaceableEventsKeepNewestPerDTag() = runBlocking { val signer = NostrSignerSync(KeyPair()) - val v1 = signer.sign(LongTextNoteEvent.build("old", "title", dTag = "list-a", createdAt = 100)) - val v2 = signer.sign(LongTextNoteEvent.build("new", "title", dTag = "list-a", createdAt = 200)) - val v3 = signer.sign(LongTextNoteEvent.build("list-b", "title", dTag = "list-b", createdAt = 100)) + val v1 = signer.sign(LongFormContentEvent.build("old", "title", dTag = "list-a", createdAt = 100)) + val v2 = signer.sign(LongFormContentEvent.build("new", "title", dTag = "list-a", createdAt = 200)) + val v3 = signer.sign(LongFormContentEvent.build("list-b", "title", dTag = "list-b", createdAt = 100)) preload(v1, v2, v3) val (events, _) = client.collectUntilEose( defaultRelayUrl, - Filter(kinds = listOf(LongTextNoteEvent.KIND), authors = listOf(signer.pubKey)), + Filter(kinds = listOf(LongFormContentEvent.KIND), authors = listOf(signer.pubKey)), ) assertEquals(2, events.size) diff --git a/geode/src/test/kotlin/com/vitorpamplona/geode/Nip09DeletionTest.kt b/geode/src/test/kotlin/com/vitorpamplona/geode/Nip09DeletionTest.kt index 914da8e385..03336f4779 100644 --- a/geode/src/test/kotlin/com/vitorpamplona/geode/Nip09DeletionTest.kt +++ b/geode/src/test/kotlin/com/vitorpamplona/geode/Nip09DeletionTest.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -123,7 +123,7 @@ class Nip09DeletionTest { runBlocking { val signer = NostrSignerSync(KeyPair()) val note = signer.sign(TextNoteEvent.build("delete me")) - val deletion = signer.sign(DeletionEvent.build(listOf(note), createdAt = note.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(note), createdAt = note.createdAt + 1)) // Publish original, confirm it's stored. assertEquals(true, client.publishAndConfirm(note, setOf(relayUrl))) @@ -139,12 +139,12 @@ class Nip09DeletionTest { runBlocking { val signer = NostrSignerSync(KeyPair()) val note = signer.sign(TextNoteEvent.build("a")) - val deletion = signer.sign(DeletionEvent.build(listOf(note), createdAt = note.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(note), createdAt = note.createdAt + 1)) client.publishAndConfirm(note, setOf(relayUrl)) client.publishAndConfirm(deletion, setOf(relayUrl)) - val results = query(Filter(kinds = listOf(DeletionEvent.KIND), authors = listOf(signer.pubKey))) + val results = query(Filter(kinds = listOf(DeletionRequestEvent.KIND), authors = listOf(signer.pubKey))) assertEquals(1, results.size) assertEquals(deletion.id, results[0].id) } @@ -154,7 +154,7 @@ class Nip09DeletionTest { runBlocking { val signer = NostrSignerSync(KeyPair()) val note = signer.sign(TextNoteEvent.build("once-upon-a-time")) - val deletion = signer.sign(DeletionEvent.build(listOf(note), createdAt = note.createdAt + 1)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(note), createdAt = note.createdAt + 1)) client.publishAndConfirm(note, setOf(relayUrl)) client.publishAndConfirm(deletion, setOf(relayUrl)) @@ -178,7 +178,7 @@ class Nip09DeletionTest { // kind-5 event itself (it's just an event), but the SQL DELETE // is owner-scoped, so Alice's event survives. val malloryDelete = - mallory.sign(DeletionEvent.build(listOf(aliceNote), createdAt = aliceNote.createdAt + 1)) + mallory.sign(DeletionRequestEvent.build(listOf(aliceNote), createdAt = aliceNote.createdAt + 1)) client.publishAndConfirm(malloryDelete, setOf(relayUrl)) assertEquals( diff --git a/quartz/CLIENT.md b/quartz/CLIENT.md index 99338a8821..0b03c120ab 100644 --- a/quartz/CLIENT.md +++ b/quartz/CLIENT.md @@ -460,9 +460,9 @@ Common event kinds you'll work with: | 0 | NIP-01 | `MetadataEvent` | User metadata (name, picture, about) | | 1 | NIP-01 | `TextNoteEvent` | Text note (short post) | | 3 | NIP-02 | `ContactListEvent` | Contact list / follow list | -| 4 | NIP-04 | `PrivateDmEvent` | Encrypted direct message | +| 4 | NIP-04 | `EncryptedDmEvent` | Encrypted direct message | | 7 | NIP-25 | `ReactionEvent` | Reaction (like, emoji) | -| 30023 | NIP-23 | `LongTextNoteEvent` | Long-form content (articles) | +| 30023 | NIP-23 | `LongFormContentEvent` | Long-form content (articles) | ## Multi-Relay Subscriptions diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/EventSigCheck.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/EventSigCheck.kt index 7b53776a8f..3bac4762e7 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/EventSigCheck.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip01Core/EventSigCheck.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.crypto.verifyId import com.vitorpamplona.quartz.nip01Core.crypto.verifySignature import com.vitorpamplona.quartz.nip01Core.relay.commands.toClient.EventMessage import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.utils.EventFactory import org.junit.Assert.assertEquals @@ -139,7 +139,7 @@ class EventSigCheck { @Test fun checkSerializationLargeZap() { val event = - EventFactory.create<LnZapEvent>( + EventFactory.create<ZapReceiptEvent>( id = "e7f09fddf39fc6cb604708b6af7b4d4adbb07b412847ebb004064040fe8c4b1e", pubKey = "79f00d3f5a19ec806189fcab03c1be4ff81d18ee4f653c88fac41fe03570f432", createdAt = 1728921077, diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt index d588554f74..e3e0232e4f 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetInfoMethod import kotlinx.coroutines.test.runTest @@ -47,7 +47,7 @@ class LnZapPaymentRequestNip44EventTest { val request = GetBalanceMethod.create() val event = - LnZapPaymentRequestEvent.createRequest( + NwcRequestEvent.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, @@ -71,7 +71,7 @@ class LnZapPaymentRequestNip44EventTest { val request = GetInfoMethod.create() val event = - LnZapPaymentRequestEvent.createRequest( + NwcRequestEvent.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapTests.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapTests.kt index 367c45a736..232e0f9708 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapTests.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapTests.kt @@ -92,13 +92,13 @@ class PrivateZapTests { ) val privateZapRequest = - LnZapRequestEvent.create( + ZapRequestEvent.create( zappedEvent = poll, relays = setOf(RelayUrlNormalizer.normalize("wss://relay.damus.io/")), signer = loggedIn, pollOption = 0, message = "", - zapType = LnZapEvent.ZapType.PRIVATE, + zapType = ZapReceiptEvent.ZapType.PRIVATE, toUserPubHex = null, ) @@ -151,7 +151,7 @@ class PrivateZapTests { ) val privateZapRequest = - LnZapRequestEvent.create( + ZapRequestEvent.create( zappedEvent = textNote, relays = setOf( @@ -162,7 +162,7 @@ class PrivateZapTests { signer = loggedIn, pollOption = null, message = "test", - zapType = LnZapEvent.ZapType.PRIVATE, + zapType = ZapReceiptEvent.ZapType.PRIVATE, toUserPubHex = null, ) diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt index 47455faeb5..ebdd83efbc 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip59GiftWraps/GiftWrapEventTest.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.PTag import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser import com.vitorpamplona.quartz.nip17Dm.NIP17Factory import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.utils.Hex import kotlinx.coroutines.test.runTest @@ -65,7 +65,7 @@ class GiftWrapEventTest { val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) } eventsReceiverGets.forEach { val event = it.unwrapThrowing(receiver) - if (event is SealedRumorEvent) { + if (event is SealEvent) { val innerData = event.unsealThrowing(receiver) assertEquals(message, innerData.content) } else { @@ -77,7 +77,7 @@ class GiftWrapEventTest { val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) } eventsSenderGets.forEach { val event = it.unwrapThrowing(sender) - if (event is SealedRumorEvent) { + if (event is SealEvent) { val innerData = event.unsealThrowing(sender) assertEquals(message, innerData.content) } else { @@ -118,7 +118,7 @@ class GiftWrapEventTest { val eventsReceiverGets = events.wraps.filter { it.isTaggedUser(receiver.pubKey) } eventsReceiverGets.forEach { val event = it.unwrapThrowing(receiver) - if (event is SealedRumorEvent) { + if (event is SealEvent) { val innerData = event.unsealThrowing(receiver) assertEquals(message, innerData.content) } else { @@ -131,7 +131,7 @@ class GiftWrapEventTest { val eventsSenderGets = events.wraps.filter { it.isTaggedUser(sender.pubKey) } eventsSenderGets.forEach { val event = it.unwrapThrowing(sender) - if (event is SealedRumorEvent) { + if (event is SealEvent) { val innerData = event.unsealThrowing(sender) assertEquals(message, innerData.content) } else { @@ -155,7 +155,7 @@ class GiftWrapEventTest { ) // MsgFor the Receiver val encMsgFromSenderToReceiver = - SealedRumorEvent.create( + SealEvent.create( event = senderMessage, encryptTo = receiver.pubKey, signer = sender, @@ -184,7 +184,7 @@ class GiftWrapEventTest { // MsgFor the Sender val encMsgFromSenderToSender = - SealedRumorEvent.create( + SealEvent.create( event = senderMessage, encryptTo = sender.pubKey, signer = sender, @@ -221,10 +221,10 @@ class GiftWrapEventTest { assertNotNull(giftWrapToReceiver) val unwrappedMsgForSenderBySender = giftWrapToSender.unwrapThrowing(sender) - assertEquals(SealedRumorEvent.KIND, unwrappedMsgForSenderBySender.kind) - assertTrue(unwrappedMsgForSenderBySender is SealedRumorEvent) + assertEquals(SealEvent.KIND, unwrappedMsgForSenderBySender.kind) + assertTrue(unwrappedMsgForSenderBySender is SealEvent) - if (unwrappedMsgForSenderBySender is SealedRumorEvent) { + if (unwrappedMsgForSenderBySender is SealEvent) { val unwrappedRumorToSenderBySender = unwrappedMsgForSenderBySender.unsealThrowing(sender) assertEquals("Hi There!", unwrappedRumorToSenderBySender.content) @@ -242,10 +242,10 @@ class GiftWrapEventTest { } val unwrappedMsgForReceiverByReceiver = giftWrapToReceiver.unwrapThrowing(receiver) - assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverByReceiver.kind) - assertTrue(unwrappedMsgForReceiverByReceiver is SealedRumorEvent) + assertEquals(SealEvent.KIND, unwrappedMsgForReceiverByReceiver.kind) + assertTrue(unwrappedMsgForReceiverByReceiver is SealEvent) - if (unwrappedMsgForReceiverByReceiver is SealedRumorEvent) { + if (unwrappedMsgForReceiverByReceiver is SealEvent) { val unwrappedRumorToReceiverByReceiver = unwrappedMsgForReceiverByReceiver.unsealThrowing(receiver) assertEquals("Hi There!", unwrappedRumorToReceiverByReceiver.content) @@ -273,7 +273,7 @@ class GiftWrapEventTest { ) val msgFromSenderToReceiverA = - SealedRumorEvent.create( + SealEvent.create( event = senderMessage, encryptTo = receiverA.pubKey, signer = sender, @@ -302,7 +302,7 @@ class GiftWrapEventTest { assertEquals(giftWrapForReceiverA.recipientPubKey(), receiverA.pubKey) val msgFromSenderToReceiverB = - SealedRumorEvent.create( + SealEvent.create( event = senderMessage, encryptTo = receiverB.pubKey, signer = sender, @@ -331,7 +331,7 @@ class GiftWrapEventTest { assertEquals(giftWrapForReceiverB.recipientPubKey(), receiverB.pubKey) val msgFromSenderToSender = - SealedRumorEvent.create( + SealEvent.create( event = senderMessage, encryptTo = sender.pubKey, signer = sender, @@ -371,9 +371,9 @@ class GiftWrapEventTest { assertNotNull(giftWrapForReceiverB) val unwrappedMsgForSenderBySender = giftWrapToSender.unwrapThrowing(sender) - assertEquals(SealedRumorEvent.KIND, unwrappedMsgForSenderBySender.kind) + assertEquals(SealEvent.KIND, unwrappedMsgForSenderBySender.kind) - if (unwrappedMsgForSenderBySender is SealedRumorEvent) { + if (unwrappedMsgForSenderBySender is SealEvent) { unwrappedMsgForSenderBySender.unsealOrNull(receiverA)?.let { _ -> fail() } @@ -399,9 +399,9 @@ class GiftWrapEventTest { } val unwrappedMsgForReceiverAByReceiverA = giftWrapForReceiverA.unwrapThrowing(receiverA) - assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverAByReceiverA.kind) + assertEquals(SealEvent.KIND, unwrappedMsgForReceiverAByReceiverA.kind) - if (unwrappedMsgForReceiverAByReceiverA is SealedRumorEvent) { + if (unwrappedMsgForReceiverAByReceiverA is SealEvent) { val unwrappedRumorToReceiverAByReceiverA = unwrappedMsgForReceiverAByReceiverA.unsealThrowing(receiverA) assertEquals("Who is going to the party tonight?", unwrappedRumorToReceiverAByReceiverA.content) @@ -426,9 +426,9 @@ class GiftWrapEventTest { } val unwrappedMsgForReceiverBByReceiverB = giftWrapForReceiverB.unwrapThrowing(receiverB) - assertEquals(SealedRumorEvent.KIND, unwrappedMsgForReceiverBByReceiverB.kind) + assertEquals(SealEvent.KIND, unwrappedMsgForReceiverBByReceiverB.kind) - if (unwrappedMsgForReceiverBByReceiverB is SealedRumorEvent) { + if (unwrappedMsgForReceiverBByReceiverB is SealEvent) { unwrappedMsgForReceiverBByReceiverB.unsealOrNull(receiverA)?.let { unwrappedRumorToReceiverBByReceiverA -> fail() } @@ -617,7 +617,7 @@ class GiftWrapEventTest { assertEquals(signer.pubKey, wrap.recipientPubKey()) val event = wrap.unwrapThrowing(signer) - return if (event is SealedRumorEvent) { + return if (event is SealEvent) { event.unsealThrowing(signer) } else { println(event.toJson()) diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/requests/DecryptZapRequest.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/requests/DecryptZapRequest.kt index cdd96dc214..1e74fa6b8f 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/requests/DecryptZapRequest.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/requests/DecryptZapRequest.kt @@ -24,12 +24,12 @@ import android.content.Intent import androidx.core.net.toUri import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip55AndroidSigner.api.CommandType -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent class DecryptZapRequest { companion object { fun assemble( - event: LnZapRequestEvent, + event: ZapRequestEvent, loggedInUser: HexKey, packageName: String, ): Intent { diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt index 2da61eba2a..c5d1a6c388 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip55AndroidSigner.api.ZapEventDecryptionResult import com.vitorpamplona.quartz.nip55AndroidSigner.client.handlers.BackgroundRequestHandler import com.vitorpamplona.quartz.nip55AndroidSigner.client.handlers.ForegroundRequestHandler import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent class NostrSignerExternal( pubKey: HexKey, @@ -163,7 +163,7 @@ class NostrSignerExternal( throw convertExceptions("Could not derive key", result) } - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent { + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent { if (!event.isPrivateZap()) throw SignerExceptions.NothingToDecrypt() val result = backgroundQuery.decryptZapEvent(event) ?: foregroundQuery.decryptZapEvent(event) diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/BackgroundRequestHandler.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/BackgroundRequestHandler.kt index d6d7cec689..941d9a8c5e 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/BackgroundRequestHandler.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/BackgroundRequestHandler.kt @@ -40,7 +40,7 @@ import com.vitorpamplona.quartz.nip55AndroidSigner.api.background.queries.Nip44D import com.vitorpamplona.quartz.nip55AndroidSigner.api.background.queries.Nip44EncryptQuery import com.vitorpamplona.quartz.nip55AndroidSigner.api.background.queries.SignPsbtQuery import com.vitorpamplona.quartz.nip55AndroidSigner.api.background.queries.SignQuery -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent class BackgroundRequestHandler( loggedInUser: HexKey, @@ -81,7 +81,7 @@ class BackgroundRequestHandler( fromPubKey: HexKey, ) = nip44Decrypt.query(ciphertext, fromPubKey) as? SignerResult.RequestAddressed<DecryptionResult> - fun decryptZapEvent(event: LnZapRequestEvent) = decryptZap.query(event) as? SignerResult.RequestAddressed<ZapEventDecryptionResult> + fun decryptZapEvent(event: ZapRequestEvent) = decryptZap.query(event) as? SignerResult.RequestAddressed<ZapEventDecryptionResult> fun deriveKey(nonce: HexKey) = deriveKey.query(nonce) as? SignerResult.RequestAddressed<DerivationResult> diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/ForegroundRequestHandler.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/ForegroundRequestHandler.kt index 78841f3172..0d695c61c0 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/ForegroundRequestHandler.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/handlers/ForegroundRequestHandler.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip55AndroidSigner.api.foreground.intents.respon import com.vitorpamplona.quartz.nip55AndroidSigner.api.foreground.intents.responses.Nip44EncryptResponse import com.vitorpamplona.quartz.nip55AndroidSigner.api.foreground.intents.responses.SignPsbtResponse import com.vitorpamplona.quartz.nip55AndroidSigner.api.foreground.intents.responses.SignResponse -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent class ForegroundRequestHandler( val loggedInUser: HexKey, @@ -86,7 +86,7 @@ class ForegroundRequestHandler( parser = Nip44DecryptResponse::parse, ) - suspend fun decryptZapEvent(event: LnZapRequestEvent) = + suspend fun decryptZapEvent(event: ZapRequestEvent) = launcher.launchWaitAndParse( requestIntentBuilder = { DecryptZapRequest.assemble(event, loggedInUser, packageName) }, parser = DecryptZapResponse::parse, diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/README.md b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/README.md index cd8bc2c7ac..e1d2491c59 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/README.md +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/README.md @@ -121,7 +121,7 @@ root as a pinned message. Covered by `nip29RelayGroups/PinEventsTest`. | Kind | Buzz class | Incumbent (registered) | |---|---|---| -| 9041 | `moderation.ModerationUnbanEvent` | `nip75ZapGoals.GoalEvent` | +| 9041 | `moderation.ModerationUnbanEvent` | `nip75ZapGoals.ZapGoalEvent` | | 49001 | `media.MediaUploadEvent` | — (Buzz's own `kind.rs` marks 49001 "Not a relay event kind") | | 30078 | `rsReadState` (helpers) | `nip78AppData.AppSpecificDataEvent` (NIP-RS reuses 30078) | diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEvent.kt index 7823ddea73..ee3dac4e73 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEvent.kt @@ -35,8 +35,8 @@ import com.vitorpamplona.quartz.utils.TimeUtils * `buzz-sdk/src/builders.rs::build_moderation_unban`. * * WARNING — KIND COLLISION: `9041` is also - * [com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent]'s kind in Quartz. This class MUST NOT - * be registered in `utils/EventFactory.kt` (the NIP-75 GoalEvent owns 9041 there). Buzz + * [com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent]'s kind in Quartz. This class MUST NOT + * be registered in `utils/EventFactory.kt` (the NIP-75 ZapGoalEvent owns 9041 there). Buzz * relays dispatch moderation commands by connection context, not by the shared `EventFactory` * kind switch, so leaving 9041 unregistered is correct — construct/parse this type explicitly. */ @@ -53,7 +53,7 @@ class ModerationUnbanEvent( fun target() = tags.moderationTarget() companion object { - /** Kind 9041 — COLLIDES with NIP-75 GoalEvent. Do not register in EventFactory. */ + /** Kind 9041 — COLLIDES with NIP-75 ZapGoalEvent. Do not register in EventFactory. */ const val KIND = 9041 fun build( diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/concord/cord05Invites/ConcordDirectInvite.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/concord/cord05Invites/ConcordDirectInvite.kt index 910eaedb68..f4b1277a9e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/concord/cord05Invites/ConcordDirectInvite.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/concord/cord05Invites/ConcordDirectInvite.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip59Giftwrap.rumors.RumorAssembler -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent /** @@ -57,7 +57,7 @@ object ConcordDirectInvite { createdAt: Long, ): GiftWrapEvent { val rumor = RumorAssembler.assembleRumor<Event>(senderSigner.pubKey, createdAt, KIND, emptyArray(), json(invite)) - val seal = SealedRumorEvent.create(rumor, recipientPubKey, senderSigner, createdAt = createdAt) + val seal = SealEvent.create(rumor, recipientPubKey, senderSigner, createdAt = createdAt) // Wrap with a random ephemeral key, adding the ["k","3313"] index tag. val wrapSigner = NostrSignerInternal(KeyPair()) @@ -80,7 +80,7 @@ object ConcordDirectInvite { recipientSigner: NostrSigner, ): CommunityInvite? { val seal = wrap.unwrapOrNull(recipientSigner) ?: return null - if (seal !is SealedRumorEvent) return null + if (seal !is SealEvent) return null val rumor = seal.unsealOrNull(recipientSigner) ?: return null if (rumor.kind != KIND) return null return ConcordJson.decodeOrNull<CommunityInvite>(rumor.content) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/assistant/CurationCopy.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/assistant/CurationCopy.kt index bb6d37a238..2245686765 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/assistant/CurationCopy.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/assistant/CurationCopy.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.events.ETag import com.vitorpamplona.quartz.nip01Core.tags.hashtags.HashtagTag import com.vitorpamplona.quartz.nip01Core.tags.kinds.KindTag import com.vitorpamplona.quartz.nip01Core.tags.people.PTag -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.utils.TimeUtils import com.vitorpamplona.quartz.utils.sha256.sha256 @@ -109,7 +109,7 @@ object CurationCopy { fun buildRemoval( copy: AddressableListItemEvent, createdAt: Long = TimeUtils.now(), - ) = eventTemplate<DeletionEvent>(DeletionEvent.KIND, "", createdAt) { + ) = eventTemplate<DeletionRequestEvent>(DeletionRequestEvent.KIND, "", createdAt) { add(ATag.assemble(copy.address(), null)) add(ETag.assemble(copy.id, null, null)) add(KindTag.assemble(AddressableListItemEvent.KIND)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankCrawler.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankCrawler.kt index 4cba6e0c9f..628df753e7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankCrawler.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankCrawler.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.store.IEventStore import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -951,7 +951,7 @@ class GrapeRankCrawler( // deleter-must-be-author check the caller runs rejects it. val chunkIds = authorChunk.flatMap { idsByAuthor[it].orEmpty() } for (idChunk in chunkIds.chunked(AUTHORS_PER_FILTER)) { - add(Filter(kinds = listOf(DeletionEvent.KIND), authors = authorChunk, tags = mapOf("e" to idChunk))) + add(Filter(kinds = listOf(DeletionRequestEvent.KIND), authors = authorChunk, tags = mapOf("e" to idChunk))) } } } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisher.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisher.kt index 89b90b79a4..bad314d356 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisher.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisher.kt @@ -29,8 +29,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.store.IEventStore -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.users.followerCount import com.vitorpamplona.quartz.nip85TrustedAssertions.users.hops import com.vitorpamplona.quartz.nip85TrustedAssertions.users.rank @@ -45,7 +45,7 @@ import kotlinx.coroutines.coroutineScope import kotlin.coroutines.cancellation.CancellationException /** - * Persists a set of GrapeRank scores as NIP-85 kind:30382 [ContactCardEvent] + * Persists a set of GrapeRank scores as NIP-85 kind:30382 [UserAssertionEvent] * trusted assertions in the local [IEventStore] — the durable, reusable form of a * score run — and pushes that local card set out to the operator's relays on * demand. The store is the source of truth; the two halves are separable: @@ -168,10 +168,10 @@ class GrapeRankPublisher( idleTimeoutMs: Long = 30_000L, publishTimeoutSecs: Long = 15, ): SyncResult { - val cards = store.query<Event>(Filter(kinds = listOf(ContactCardEvent.KIND), authors = listOf(providerPubkey))) - val deletions = store.query<Event>(Filter(kinds = listOf(DeletionEvent.KIND), authors = listOf(providerPubkey))) + val cards = store.query<Event>(Filter(kinds = listOf(UserAssertionEvent.KIND), authors = listOf(providerPubkey))) + val deletions = store.query<Event>(Filter(kinds = listOf(DeletionRequestEvent.KIND), authors = listOf(providerPubkey))) - val filter = Filter(kinds = listOf(ContactCardEvent.KIND, DeletionEvent.KIND), authors = listOf(providerPubkey)) + val filter = Filter(kinds = listOf(UserAssertionEvent.KIND, DeletionRequestEvent.KIND), authors = listOf(providerPubkey)) val groups = NegentropyStoreSync( client = client, @@ -214,10 +214,10 @@ class GrapeRankPublisher( * store. Locally-retracted cards never show up — inserting their kind:5 * removed them — so a target can be re-carded later without fighting a ghost. */ - private suspend fun existingCards(providerPubkey: HexKey): Map<HexKey, ContactCardEvent> = + private suspend fun existingCards(providerPubkey: HexKey): Map<HexKey, UserAssertionEvent> = store - .query<Event>(Filter(kinds = listOf(ContactCardEvent.KIND), authors = listOf(providerPubkey))) - .filterIsInstance<ContactCardEvent>() + .query<Event>(Filter(kinds = listOf(UserAssertionEvent.KIND), authors = listOf(providerPubkey))) + .filterIsInstance<UserAssertionEvent>() .groupBy { it.aboutUser() } .mapNotNull { (target, cards) -> val t = target.ifBlank { return@mapNotNull null } @@ -230,7 +230,7 @@ class GrapeRankPublisher( * produces no new signature; a missing tag reads null and so differs from a * desired non-null value (the one-time migration onto the new tags). */ - private fun cardValues(card: ContactCardEvent): Triple<Int?, Int?, Int?> = Triple(card.rank(), card.followerCount(), card.hops()) + private fun cardValues(card: UserAssertionEvent): Triple<Int?, Int?, Int?> = Triple(card.rank(), card.followerCount(), card.hops()) /** The (rank, followers, hops) triple a [ScoredCard] would write. */ private fun desiredValues(card: ScoredCard): Triple<Int?, Int?, Int?> = Triple(card.rank, card.followers, card.hops) @@ -254,7 +254,7 @@ class GrapeRankPublisher( batch .map { card -> async(Dispatchers.Default) { - ContactCardEvent.create( + UserAssertionEvent.create( targetUser = card.target, signer = signer, createdAt = createdAt, @@ -285,13 +285,13 @@ class GrapeRankPublisher( */ private suspend fun insertRetractions( signer: NostrSigner, - cards: List<ContactCardEvent>, + cards: List<UserAssertionEvent>, createdAt: Long, ): Int { if (cards.isEmpty()) return 0 var retracted = 0 for (chunk in cards.chunked(DELETE_PER_EVENT)) { - val deletion = signer.sign(DeletionEvent.build(chunk, createdAt)) + val deletion = signer.sign(DeletionRequestEvent.build(chunk, createdAt)) if (insertQuietly(deletion)) retracted += chunk.size } return retracted diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt index a8932e8ec0..088ad5934a 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt @@ -24,22 +24,24 @@ import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.tags.AppI import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.tags.VersionTag import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.hasTagWithContent +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent /** * NIP-82 reuses kind 30063 which was already taken by NIP-51's - * `ReleaseArtifactSetEvent`. Both are valid; they coexist on the wire. + * [ReleaseArtifactSetEvent]. Both are valid; they coexist on the wire and the + * same class parses both. * * We disambiguate by inspecting the tag set: a NIP-82 Software Release MUST * carry both `i` (app identifier) and `version` tags. NIP-51 release artifact * sets do not. */ fun Event.isNip82SoftwareRelease() = - kind == SoftwareReleaseEvent.KIND && + kind == ReleaseArtifactSetEvent.KIND && tags.hasTagWithContent(AppIdTag.TAG_NAME) && tags.hasTagWithContent(VersionTag.TAG_NAME) /** - * Reinterprets `this` as a [SoftwareReleaseEvent]. Use [isNip82SoftwareRelease] + * Reinterprets `this` as a [ReleaseArtifactSetEvent]. Use [isNip82SoftwareRelease] * to gate the call. */ -fun Event.asSoftwareRelease() = SoftwareReleaseEvent(id, pubKey, createdAt, tags, content, sig) +fun Event.asSoftwareRelease() = this as? ReleaseArtifactSetEvent ?: ReleaseArtifactSetEvent(id, pubKey, createdAt, tags, content, sig) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt index e48460d7c7..86712d1400 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt @@ -20,91 +20,15 @@ */ package com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release -import androidx.compose.runtime.Immutable -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.SoftwareAssetEvent -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.tags.AssetTag -import com.vitorpamplona.quartz.nip01Core.core.BaseAddressableEvent -import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder -import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle -import com.vitorpamplona.quartz.nip01Core.hints.EventHintProvider -import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate -import com.vitorpamplona.quartz.nip01Core.tags.dTag.dTag -import com.vitorpamplona.quartz.nip50Search.IndexableFieldVisitor -import com.vitorpamplona.quartz.nip50Search.SearchableEvent -import com.vitorpamplona.quartz.utils.TimeUtils +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent /** - * NIP-82 Software Release (kind 30063). - * - * A parameterizable replaceable event grouping a set of [SoftwareAssetEvent]s - * under a named release version. The `d` tag is `<app-id>@<version>` and the - * event's `created_at` must be the release date. - * - * NOTE: kind 30063 was also used by NIP-51 `ReleaseArtifactSetEvent`. This - * experimental NIP-82 event is intentionally not registered in `EventFactory` - * to avoid colliding with the existing registration. Callers can instantiate - * or wrap [SoftwareReleaseEvent] directly when they know the event is a NIP-82 - * release. + * NIP-82 software releases share kind 30063 with NIP-51 release artifact sets, and + * [ReleaseArtifactSetEvent] now parses both. This used to be a second class for the same + * kind that `EventFactory` never built. */ -@Immutable -class SoftwareReleaseEvent( - id: HexKey, - pubKey: HexKey, - createdAt: Long, - tags: Array<Array<String>>, - content: String, - sig: HexKey, -) : BaseAddressableEvent(id, pubKey, createdAt, KIND, tags, content, sig), - EventHintProvider, - SearchableEvent { - // content carries the release notes (free-text). NOTE: kind 30063 collides - // with NIP-51 ReleaseArtifactSetEvent, which is what EventFactory builds for - // stored events — so in practice this override is not exercised at runtime. - override fun indexableContent() = content - - // The read path: the same fields indexableContent() joins, handed over without - // building the joined string a scan would throw away. - override fun forEachIndexableField(visitor: IndexableFieldVisitor) { - visitor.visit(content) - } - - override fun eventHints() = tags.mapNotNull(AssetTag::parseAsHint) - - override fun linkedEventIds() = tags.mapNotNull(AssetTag::parseId) - - fun appId() = tags.appId() - - fun version() = tags.version() - - fun channel() = tags.channel() - - fun assets() = tags.assets() - - companion object { - const val KIND = 30063 - - /** NIP-82 requires `d = <app-id>@<version>`. */ - fun buildDTag( - appId: String, - version: String, - ) = "$appId@$version" - - fun build( - appId: String, - version: String, - channel: String, - assets: List<EventHintBundle<SoftwareAssetEvent>>, - releaseNotes: String = "", - createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<SoftwareReleaseEvent>.() -> Unit = {}, - ) = eventTemplate(KIND, releaseNotes, createdAt) { - dTag(buildDTag(appId, version)) - appId(appId) - version(version) - channel(channel) - assets(assets) - initializer() - } - } -} +@Deprecated( + "Kind 30063 is parsed by ReleaseArtifactSetEvent, which also exposes the NIP-82 fields. Use ReleaseArtifactSetEvent.buildSoftwareRelease to build one.", + ReplaceWith("ReleaseArtifactSetEvent", "com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent"), +) +typealias SoftwareReleaseEvent = ReleaseArtifactSetEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/TagArrayBuilderExt.kt index 42d9195f63..25801b8d75 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/TagArrayBuilderExt.kt @@ -27,13 +27,14 @@ import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.tags.Chan import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.tags.VersionTag import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent -fun TagArrayBuilder<SoftwareReleaseEvent>.appId(appId: String) = addUnique(AppIdTag.assemble(appId)) +fun TagArrayBuilder<ReleaseArtifactSetEvent>.appId(appId: String) = addUnique(AppIdTag.assemble(appId)) -fun TagArrayBuilder<SoftwareReleaseEvent>.version(version: String) = addUnique(VersionTag.assemble(version)) +fun TagArrayBuilder<ReleaseArtifactSetEvent>.version(version: String) = addUnique(VersionTag.assemble(version)) -fun TagArrayBuilder<SoftwareReleaseEvent>.channel(channel: String) = addUnique(ChannelTag.assemble(channel)) +fun TagArrayBuilder<ReleaseArtifactSetEvent>.channel(channel: String) = addUnique(ChannelTag.assemble(channel)) -fun TagArrayBuilder<SoftwareReleaseEvent>.asset(asset: EventHintBundle<SoftwareAssetEvent>) = add(AssetTag.assemble(asset)) +fun TagArrayBuilder<ReleaseArtifactSetEvent>.asset(asset: EventHintBundle<SoftwareAssetEvent>) = add(AssetTag.assemble(asset)) -fun TagArrayBuilder<SoftwareReleaseEvent>.assets(assets: List<EventHintBundle<SoftwareAssetEvent>>) = addAll(AssetTag.assemble(assets)) +fun TagArrayBuilder<ReleaseArtifactSetEvent>.assets(assets: List<EventHintBundle<SoftwareAssetEvent>>) = addAll(AssetTag.assemble(assets)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/publications/PublicationSectionRef.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/publications/PublicationSectionRef.kt index c28219fe8b..bb264bc95f 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/publications/PublicationSectionRef.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/publications/PublicationSectionRef.kt @@ -28,8 +28,8 @@ import com.vitorpamplona.quartz.nip01Core.core.Tag import com.vitorpamplona.quartz.nip01Core.core.TagArray import com.vitorpamplona.quartz.nip01Core.core.has import com.vitorpamplona.quartz.nip01Core.core.isValid -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent /** * One entry in a kind-30040 publication's table of contents. @@ -72,8 +72,8 @@ data class PublicationSectionRef( setOf( PublicationContentEvent.KIND, PublicationIndexEvent.KIND, - LongTextNoteEvent.KIND, - WikiNoteEvent.KIND, + LongFormContentEvent.KIND, + WikiArticleEvent.KIND, NipTextEvent.KIND, ) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt index b1ff7a9483..fd07f11def 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt @@ -88,8 +88,8 @@ import com.vitorpamplona.quartz.marmot.mip05PushNotifications.TokenRequestEvent import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip03Timestamp.OtsEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip15Marketplace.auction.AuctionEvent import com.vitorpamplona.quartz.nip15Marketplace.bid.BidEvent @@ -99,35 +99,35 @@ import com.vitorpamplona.quartz.nip15Marketplace.product.ProductEvent import com.vitorpamplona.quartz.nip15Marketplace.stall.StallEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ExternalReactionEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelHideMessageEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMuteUserEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupParticipantsEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateInviteEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteEventEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.PutUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.RemoveUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.JoinRequestEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.LeaveRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupCreateInviteEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupDeleteEventEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupPutUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupRemoveUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import com.vitorpamplona.quartz.nip32Labeling.LabelEvent import com.vitorpamplona.quartz.nip34Git.grasp.UserGraspListEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent @@ -141,7 +141,7 @@ import com.vitorpamplona.quartz.nip35Torrents.TorrentCommentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip39ExtIdentities.ExternalIdentitiesEvent import com.vitorpamplona.quartz.nip42RelayAuth.RelayAuthEvent import com.vitorpamplona.quartz.nip43RelayMembers.addMember.RelayAddMemberEvent @@ -151,10 +151,10 @@ import com.vitorpamplona.quartz.nip43RelayMembers.leaveRequest.RelayLeaveRequest import com.vitorpamplona.quartz.nip43RelayMembers.list.RelayMembershipListEvent import com.vitorpamplona.quartz.nip43RelayMembers.removeMember.RelayRemoveMemberEvent import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcInfoEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcNotificationEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.appCurationSet.AppCurationSetEvent @@ -162,26 +162,26 @@ import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSet import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent import com.vitorpamplona.quartz.nip51Lists.gitAuthorList.GitAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.gitRepositoryList.GitRepositoryListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiAuthorList.GoodWikiAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiRelayList.GoodWikiRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.kindMuteSet.KindMuteSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaFollowList.MediaFollowListEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent @@ -189,7 +189,7 @@ import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent @@ -199,19 +199,19 @@ import com.vitorpamplona.quartz.nip53LiveActivities.nestsServers.NestsServersEve import com.vitorpamplona.quartz.nip53LiveActivities.presence.MeetingRoomPresenceEvent import com.vitorpamplona.quartz.nip53LiveActivities.raid.LiveActivitiesRaidEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeAcceptanceEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeRequestEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip58Badges.profile.ProfileBadgesEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.EphemeralGiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent @@ -238,15 +238,15 @@ import com.vitorpamplona.quartz.nip66RelayMonitor.discovery.RelayDiscoveryEvent import com.vitorpamplona.quartz.nip66RelayMonitor.monitor.RelayMonitorEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip69P2pOrderEvents.P2POrderEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent import com.vitorpamplona.quartz.nip72ModCommunities.rules.CommunityRulesEvent -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nip78AppData.AppDataEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent @@ -255,7 +255,7 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.addressables.AddressableA import com.vitorpamplona.quartz.nip85TrustedAssertions.events.EventAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.externalIds.ExternalIdAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip87Ecash.cashu.CashuMintEvent import com.vitorpamplona.quartz.nip87Ecash.fedimint.FedimintEvent import com.vitorpamplona.quartz.nip87Ecash.recommendation.MintRecommendationEvent @@ -263,46 +263,46 @@ import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.contentSearch.NIP90ContentSearchRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.contentSearch.NIP90ContentSearchResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.eventCount.NIP90EventCountRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventCount.NIP90EventCountResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.NIP90EventPowDelegationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.NIP90EventPowDelegationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.NIP90EventPublishScheduleRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.NIP90EventPublishScheduleResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.NIP90EventTimestampingRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.NIP90EventTimestampingResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.NIP90ImageGenerationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.NIP90ImageGenerationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.NIP90ImageToVideoRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.NIP90ImageToVideoResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.NIP90MalwareScanRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.NIP90MalwareScanResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.opReturn.NIP90OpReturnRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.opReturn.NIP90OpReturnResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.NIP90PeopleSearchRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.NIP90PeopleSearchResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent -import com.vitorpamplona.quartz.nip90Dvms.summarization.NIP90SummarizationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.summarization.NIP90SummarizationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.textExtraction.NIP90TextExtractionRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.textExtraction.NIP90TextExtractionResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.textGeneration.NIP90TextGenerationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.textGeneration.NIP90TextGenerationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.NIP90TextToSpeechRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.NIP90TextToSpeechResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.translation.NIP90TranslationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.translation.NIP90TranslationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.NIP90UserDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.NIP90UserDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.videoConversion.NIP90VideoConversionRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.videoConversion.NIP90VideoConversionResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.NIP90VideoTranslationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.NIP90VideoTranslationResponseEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.contentSearch.DvmContentSearchRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentSearch.DvmContentSearchResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.eventCount.DvmEventCountRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventCount.DvmEventCountResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.DvmEventPowDelegationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.DvmEventPowDelegationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.DvmEventPublishScheduleRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.DvmEventPublishScheduleResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.DvmEventTimestampingRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.DvmEventTimestampingResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.DvmImageGenerationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.DvmImageGenerationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.DvmImageToVideoRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.DvmImageToVideoResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.DvmMalwareScanRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.DvmMalwareScanResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.opReturn.DvmOpReturnRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.opReturn.DvmOpReturnResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.DvmPeopleSearchRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.DvmPeopleSearchResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent +import com.vitorpamplona.quartz.nip90Dvms.summarization.DvmSummarizationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.summarization.DvmSummarizationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.textExtraction.DvmTextExtractionRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.textExtraction.DvmTextExtractionResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.textGeneration.DvmTextGenerationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.textGeneration.DvmTextGenerationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.DvmTextToSpeechRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.DvmTextToSpeechResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.translation.DvmTranslationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.translation.DvmTranslationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.DvmUserDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.DvmUserDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.videoConversion.DvmVideoConversionRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.videoConversion.DvmVideoConversionResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.DvmVideoTranslationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.DvmVideoTranslationResponseEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip96FileStorage.config.FileServersEvent import com.vitorpamplona.quartz.nip98HttpAuth.HTTPAuthorizationEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent @@ -387,12 +387,12 @@ object KindNames { BookmarkListEvent.KIND to KindName("Bookmark List", "51"), OldBookmarkListEvent.KIND to KindName("Old Bookmark List", "51"), CalendarDateSlotEvent.KIND to KindName("Day Appointment", "52"), - CalendarEvent.KIND to KindName("Calendar", "52"), + CalendarCollectionEvent.KIND to KindName("Calendar", "52"), CalendarTimeSlotEvent.KIND to KindName("Appointment", "52"), CalendarRSVPEvent.KIND to KindName("Appt RSVP", "52"), ChessGameEvent.KIND to KindName("Chess Games", "64"), JesterEvent.KIND to KindName("Chess Auth", "64"), - RelayFeedsListEvent.KIND to KindName("Favorite Relays", "51"), + FavoriteRelayListEvent.KIND to KindName("Favorite Relays", "51"), LiveChessGameChallengeEvent.KIND to KindName("Chess Challenges", "64"), LiveChessGameAcceptEvent.KIND to KindName("Chess Game Accept", "64"), LiveChessMoveEvent.KIND to KindName("Chess Move", "64"), @@ -400,13 +400,13 @@ object KindNames { LiveChessDrawOfferEvent.KIND to KindName("Chess Draw Offer", "64"), ChannelCreateEvent.KIND to KindName("Channel Definition", "28"), ChannelHideMessageEvent.KIND to KindName("Channel Hide Msg", "28"), - ChannelListEvent.KIND to KindName("Channel List", "28"), + PublicChatListEvent.KIND to KindName("Channel List", "28"), ChannelMessageEvent.KIND to KindName("Channel Message", "28"), ChannelMetadataEvent.KIND to KindName("Channel Metadata", "28"), ChannelMuteUserEvent.KIND to KindName("Channel Mute User", "28"), ChatMessageEncryptedFileHeaderEvent.KIND to KindName("DM File", "17"), ChatMessageEvent.KIND to KindName("DM Message", "17"), - ChatMessageRelayListEvent.KIND to KindName("DM Relays", "17"), + DmRelayListEvent.KIND to KindName("DM Relays", "17"), ClassifiedsEvent.KIND to KindName("Classifieds", "99"), CommentEvent.KIND to KindName("Comments", "22"), GeocacheListingEvent.KIND to KindName("Geocache", "CC"), @@ -417,19 +417,19 @@ object KindNames { CommunityListEvent.KIND to KindName("Community List", "72"), CommunityPostApprovalEvent.KIND to KindName("Community Post", "72"), ContactListEvent.KIND to KindName("Follow List", "02"), - DeletionEvent.KIND to KindName("Deletions", "09"), + DeletionRequestEvent.KIND to KindName("Deletions", "09"), DraftWrapEvent.KIND to KindName("Drafts", "37"), EmojiPackEvent.KIND to KindName("Emoji Packs", "30"), - EmojiPackSelectionEvent.KIND to KindName("Emoji Pack List", "30"), + EmojiListEvent.KIND to KindName("Emoji Pack List", "30"), EphemeralChatEvent.KIND to KindName("Ephemeral Chat", null), EphemeralChatListEvent.KIND to KindName("Ephemeral Chatrooms", null), - FileHeaderEvent.KIND to KindName("File Headers", "94"), + FileMetadataEvent.KIND to KindName("File Headers", "94"), ProfileGalleryEntryEvent.KIND to KindName("Profile Gallery", null), FileServersEvent.KIND to KindName("File Servers", "96"), FileStorageEvent.KIND to KindName("Blob Data", null), FileStorageHeaderEvent.KIND to KindName("Blob Headers", null), FhirResourceEvent.KIND to KindName("Medical Data", null), - FollowListEvent.KIND to KindName("Follow Packs", "51"), + StarterPackEvent.KIND to KindName("Follow Packs", "51"), GenericRepostEvent.KIND to KindName("Reposts (16)", "18"), GeohashListEvent.KIND to KindName("Geohash Follows", "51"), GiftWrapEvent.KIND to KindName("GiftWraps", "59"), @@ -438,23 +438,23 @@ object KindNames { GitPatchEvent.KIND to KindName("Git Patch", "34"), GitRepositoryEvent.KIND to KindName("Git Repo", "34"), GitReplyEvent.KIND to KindName("Git Reply", "34"), - GoalEvent.KIND to KindName("Zap Goals", "75"), - HashtagListEvent.KIND to KindName("Hashtag Follows", "51"), + ZapGoalEvent.KIND to KindName("Zap Goals", "75"), + InterestListEvent.KIND to KindName("Hashtag Follows", "51"), HighlightEvent.KIND to KindName("Highlights", "84"), HTTPAuthorizationEvent.KIND to KindName("Http Auth", "98"), IndexerRelayListEvent.KIND to KindName("Index Relay List", "51"), InteractiveStoryPrologueEvent.KIND to KindName("Adventure Prologue", null), InteractiveStorySceneEvent.KIND to KindName("Adventure Scene", null), InteractiveStoryReadingStateEvent.KIND to KindName("Adventure Reading", null), - LabeledBookmarkListEvent.KIND to KindName("Named Bookmarks", "51"), + BookmarkSetEvent.KIND to KindName("Named Bookmarks", "51"), LiveActivitiesChatMessageEvent.KIND to KindName("Live Chats", "53"), LiveActivitiesEvent.KIND to KindName("Live Streams", "53"), - LnZapEvent.KIND to KindName("Zaps", "57"), - LnZapPaymentRequestEvent.KIND to KindName("NWC Request", "47"), - LnZapPaymentResponseEvent.KIND to KindName("NWC Response", "47"), + ZapReceiptEvent.KIND to KindName("Zaps", "57"), + NwcRequestEvent.KIND to KindName("NWC Request", "47"), + NwcResponseEvent.KIND to KindName("NWC Response", "47"), LnZapPrivateEvent.KIND to KindName("Private Zaps", "57"), - LnZapRequestEvent.KIND to KindName("Zap Req", "57"), - LongTextNoteEvent.KIND to KindName("Blogs", "23"), + ZapRequestEvent.KIND to KindName("Zap Req", "57"), + LongFormContentEvent.KIND to KindName("Blogs", "23"), MeetingRoomEvent.KIND to KindName("Meeting Room", "53"), MeetingRoomPresenceEvent.KIND to KindName("Room Presence", "53"), MeetingSpaceEvent.KIND to KindName("Meeting Space", "53"), @@ -463,14 +463,14 @@ object KindNames { NNSEvent.KIND to KindName("NNS", null), NipTextEvent.KIND to KindName("NIP", null), NostrConnectEvent.KIND to KindName("Nostr Connect", "46"), - NIP90StatusEvent.KIND to KindName("DVM Status", "90"), - NIP90ContentDiscoveryRequestEvent.KIND to KindName("DVM Content Req", "90"), - NIP90ContentDiscoveryResponseEvent.KIND to KindName("DVM Content Resp", "90"), - NIP90UserDiscoveryRequestEvent.KIND to KindName("DVM User Req", "90"), - NIP90UserDiscoveryResponseEvent.KIND to KindName("DVM User Resp", "90"), + DvmStatusEvent.KIND to KindName("DVM Status", "90"), + DvmContentDiscoveryRequestEvent.KIND to KindName("DVM Content Req", "90"), + DvmContentDiscoveryResponseEvent.KIND to KindName("DVM Content Resp", "90"), + DvmUserDiscoveryRequestEvent.KIND to KindName("DVM User Req", "90"), + DvmUserDiscoveryResponseEvent.KIND to KindName("DVM User Resp", "90"), OtsEvent.KIND to KindName("OTS", "03"), PaymentTargetsEvent.KIND to KindName("PayTo", null), - PeopleListEvent.KIND to KindName("People Lists", "51"), + FollowSetEvent.KIND to KindName("People Lists", "51"), ProfileBadgesEvent.KIND to KindName("Profile Badges", "58"), PictureEvent.KIND to KindName("Pictures", "68"), WorkoutRecordEvent.KIND to KindName("Workouts", null), @@ -478,12 +478,12 @@ object KindNames { ZapPollEvent.KIND to KindName("Zap Poll", null), PollEvent.KIND to KindName("Poll", "88"), PollResponseEvent.KIND to KindName("Poll Response", "88"), - PrivateDmEvent.KIND to KindName("NIP-04 DMs", "04"), + EncryptedDmEvent.KIND to KindName("NIP-04 DMs", "04"), PrivateOutboxRelayListEvent.KIND to KindName("Private Relays", "37"), ProxyRelayListEvent.KIND to KindName("Proxy Relays", "51"), PublicMessageEvent.KIND to KindName("Public Message", "A4"), ReactionEvent.KIND to KindName("Reactions", "25"), - ContactCardEvent.KIND to KindName("Contact Card", "85"), + UserAssertionEvent.KIND to KindName("Contact Card", "85"), RelayAuthEvent.KIND to KindName("Relay Auth", "42"), RelayDiscoveryEvent.KIND to KindName("Relay Discovery", "66"), RelayMonitorEvent.KIND to KindName("Relay Monitor Announcement", "66"), @@ -491,24 +491,24 @@ object KindNames { ReportEvent.KIND to KindName("Reports", "56"), RepostEvent.KIND to KindName("Reposts", "18"), RequestToVanishEvent.KIND to KindName("User Delete", "62"), - SealedRumorEvent.KIND to KindName("Seals", "59"), + SealEvent.KIND to KindName("Seals", "59"), SearchRelayListEvent.KIND to KindName("Search Relays", "50"), - StatusEvent.KIND to KindName("User Status", "38"), + UserStatusEvent.KIND to KindName("User Status", "38"), TextNoteEvent.KIND to KindName("Notes", "10"), TextNoteModificationEvent.KIND to KindName("Edits", null), TorrentEvent.KIND to KindName("Torrents", "35"), TorrentCommentEvent.KIND to KindName("Torrent Comments", "35"), TrustedRelayListEvent.KIND to KindName("Trusted Relays", "51"), TrustProviderListEvent.KIND to KindName("Trusted Providers", "85"), - VideoHorizontalEvent.KIND to KindName("Video (Repl)", "71"), - VideoVerticalEvent.KIND to KindName("Shorts (Repl)", "71"), + AddressableNormalVideoEvent.KIND to KindName("Video (Repl)", "71"), + AddressableShortVideoEvent.KIND to KindName("Shorts (Repl)", "71"), VideoNormalEvent.KIND to KindName("Video", "71"), VideoShortEvent.KIND to KindName("Shorts", "71"), VoiceEvent.KIND to KindName("Voice Msg", "A0"), VoiceReplyEvent.KIND to KindName("Voice Reply", "A0"), WakeUpEvent.KIND to KindName("WakeUp", null), WebBookmarkEvent.KIND to KindName("Web Bookmark", "B0"), - WikiNoteEvent.KIND to KindName("Wiki", "54"), + WikiArticleEvent.KIND to KindName("Wiki", "54"), WikiMergeRequestEvent.KIND to KindName("Wiki Merge Request", "54"), WikiMergeAcceptanceEvent.KIND to KindName("Wiki Merge Accepted", null), WikiRedirectEvent.KIND to KindName("Wiki Redirect", "54"), @@ -544,41 +544,41 @@ object KindNames { LabelEvent.KIND to KindName("Label", "32"), SoftwareAssetEvent.KIND to KindName("Software Asset", "82"), AdminCommandEvent.KIND to KindName("Nests Admin Command", null), - NIP90TextExtractionRequestEvent.KIND to KindName("DVM Text Extraction Req", "90"), - NIP90SummarizationRequestEvent.KIND to KindName("DVM Summarization Req", "90"), - NIP90TranslationRequestEvent.KIND to KindName("DVM Translation Req", "90"), - NIP90TextGenerationRequestEvent.KIND to KindName("DVM Text Generation Req", "90"), - NIP90ImageGenerationRequestEvent.KIND to KindName("DVM Image Generation Req", "90"), + DvmTextExtractionRequestEvent.KIND to KindName("DVM Text Extraction Req", "90"), + DvmSummarizationRequestEvent.KIND to KindName("DVM Summarization Req", "90"), + DvmTranslationRequestEvent.KIND to KindName("DVM Translation Req", "90"), + DvmTextGenerationRequestEvent.KIND to KindName("DVM Text Generation Req", "90"), + DvmImageGenerationRequestEvent.KIND to KindName("DVM Image Generation Req", "90"), NappletSnapshotEvent.KIND to KindName("Napplet Snapshot", "5D"), - NIP90VideoConversionRequestEvent.KIND to KindName("DVM Video Conversion Req", "90"), - NIP90VideoTranslationRequestEvent.KIND to KindName("DVM Video Translation Req", "90"), - NIP90ImageToVideoRequestEvent.KIND to KindName("DVM Image To Video Req", "90"), - NIP90TextToSpeechRequestEvent.KIND to KindName("DVM Text To Speech Req", "90"), - NIP90ContentSearchRequestEvent.KIND to KindName("DVM Content Search Req", "90"), - NIP90PeopleSearchRequestEvent.KIND to KindName("DVM People Search Req", "90"), - NIP90EventCountRequestEvent.KIND to KindName("DVM Event Count Req", "90"), - NIP90MalwareScanRequestEvent.KIND to KindName("DVM Malware Scan Req", "90"), - NIP90EventTimestampingRequestEvent.KIND to KindName("DVM Timestamping Req", "90"), - NIP90OpReturnRequestEvent.KIND to KindName("DVM OpReturn Req", "90"), - NIP90EventPublishScheduleRequestEvent.KIND to KindName("DVM Publish Schedule Req", "90"), - NIP90EventPowDelegationRequestEvent.KIND to KindName("DVM PoW Delegation Req", "90"), - NIP90TextExtractionResponseEvent.KIND to KindName("DVM Text Extraction Resp", "90"), - NIP90SummarizationResponseEvent.KIND to KindName("DVM Summarization Resp", "90"), - NIP90TranslationResponseEvent.KIND to KindName("DVM Translation Resp", "90"), - NIP90TextGenerationResponseEvent.KIND to KindName("DVM Text Generation Resp", "90"), - NIP90ImageGenerationResponseEvent.KIND to KindName("DVM Image Generation Resp", "90"), - NIP90VideoConversionResponseEvent.KIND to KindName("DVM Video Conversion Resp", "90"), - NIP90VideoTranslationResponseEvent.KIND to KindName("DVM Video Translation Resp", "90"), - NIP90ImageToVideoResponseEvent.KIND to KindName("DVM Image To Video Resp", "90"), - NIP90TextToSpeechResponseEvent.KIND to KindName("DVM Text To Speech Resp", "90"), - NIP90ContentSearchResponseEvent.KIND to KindName("DVM Content Search Resp", "90"), - NIP90PeopleSearchResponseEvent.KIND to KindName("DVM People Search Resp", "90"), - NIP90EventCountResponseEvent.KIND to KindName("DVM Event Count Resp", "90"), - NIP90MalwareScanResponseEvent.KIND to KindName("DVM Malware Scan Resp", "90"), - NIP90EventTimestampingResponseEvent.KIND to KindName("DVM Timestamping Resp", "90"), - NIP90OpReturnResponseEvent.KIND to KindName("DVM OpReturn Resp", "90"), - NIP90EventPublishScheduleResponseEvent.KIND to KindName("DVM Publish Schedule Resp", "90"), - NIP90EventPowDelegationResponseEvent.KIND to KindName("DVM PoW Delegation Resp", "90"), + DvmVideoConversionRequestEvent.KIND to KindName("DVM Video Conversion Req", "90"), + DvmVideoTranslationRequestEvent.KIND to KindName("DVM Video Translation Req", "90"), + DvmImageToVideoRequestEvent.KIND to KindName("DVM Image To Video Req", "90"), + DvmTextToSpeechRequestEvent.KIND to KindName("DVM Text To Speech Req", "90"), + DvmContentSearchRequestEvent.KIND to KindName("DVM Content Search Req", "90"), + DvmPeopleSearchRequestEvent.KIND to KindName("DVM People Search Req", "90"), + DvmEventCountRequestEvent.KIND to KindName("DVM Event Count Req", "90"), + DvmMalwareScanRequestEvent.KIND to KindName("DVM Malware Scan Req", "90"), + DvmEventTimestampingRequestEvent.KIND to KindName("DVM Timestamping Req", "90"), + DvmOpReturnRequestEvent.KIND to KindName("DVM OpReturn Req", "90"), + DvmEventPublishScheduleRequestEvent.KIND to KindName("DVM Publish Schedule Req", "90"), + DvmEventPowDelegationRequestEvent.KIND to KindName("DVM PoW Delegation Req", "90"), + DvmTextExtractionResponseEvent.KIND to KindName("DVM Text Extraction Resp", "90"), + DvmSummarizationResponseEvent.KIND to KindName("DVM Summarization Resp", "90"), + DvmTranslationResponseEvent.KIND to KindName("DVM Translation Resp", "90"), + DvmTextGenerationResponseEvent.KIND to KindName("DVM Text Generation Resp", "90"), + DvmImageGenerationResponseEvent.KIND to KindName("DVM Image Generation Resp", "90"), + DvmVideoConversionResponseEvent.KIND to KindName("DVM Video Conversion Resp", "90"), + DvmVideoTranslationResponseEvent.KIND to KindName("DVM Video Translation Resp", "90"), + DvmImageToVideoResponseEvent.KIND to KindName("DVM Image To Video Resp", "90"), + DvmTextToSpeechResponseEvent.KIND to KindName("DVM Text To Speech Resp", "90"), + DvmContentSearchResponseEvent.KIND to KindName("DVM Content Search Resp", "90"), + DvmPeopleSearchResponseEvent.KIND to KindName("DVM People Search Resp", "90"), + DvmEventCountResponseEvent.KIND to KindName("DVM Event Count Resp", "90"), + DvmMalwareScanResponseEvent.KIND to KindName("DVM Malware Scan Resp", "90"), + DvmEventTimestampingResponseEvent.KIND to KindName("DVM Timestamping Resp", "90"), + DvmOpReturnResponseEvent.KIND to KindName("DVM OpReturn Resp", "90"), + DvmEventPublishScheduleResponseEvent.KIND to KindName("DVM Publish Schedule Resp", "90"), + DvmEventPowDelegationResponseEvent.KIND to KindName("DVM PoW Delegation Resp", "90"), CashuMintQuoteEvent.KIND to KindName("Cashu Mint Quote", "60"), CashuTokenEvent.KIND to KindName("Cashu Token", "60"), CashuSpendingHistoryEvent.KIND to KindName("Cashu History", "60"), @@ -587,15 +587,15 @@ object KindNames { OnchainZapEvent.KIND to KindName("Onchain Zap", "BC"), Bolt12ZapEvent.KIND to KindName("Bolt12 Zap", "B1"), Bolt12OfferListEvent.KIND to KindName("Bolt12 Offers", "B1"), - PutUserEvent.KIND to KindName("Group Put User", "29"), - RemoveUserEvent.KIND to KindName("Group Remove User", "29"), - EditMetadataEvent.KIND to KindName("Group Edit Metadata", "29"), - DeleteEventEvent.KIND to KindName("Group Delete Event", "29"), + GroupPutUserEvent.KIND to KindName("Group Put User", "29"), + GroupRemoveUserEvent.KIND to KindName("Group Remove User", "29"), + GroupEditMetadataEvent.KIND to KindName("Group Edit Metadata", "29"), + GroupDeleteEventEvent.KIND to KindName("Group Delete Event", "29"), CreateGroupEvent.KIND to KindName("Group Create", "29"), DeleteGroupEvent.KIND to KindName("Group Delete", "29"), - CreateInviteEvent.KIND to KindName("Group Create Invite", "29"), - JoinRequestEvent.KIND to KindName("Group Join Request", "29"), - LeaveRequestEvent.KIND to KindName("Group Leave Request", "29"), + GroupCreateInviteEvent.KIND to KindName("Group Create Invite", "29"), + GroupJoinRequestEvent.KIND to KindName("Group Join Request", "29"), + GroupLeaveRequestEvent.KIND to KindName("Group Leave Request", "29"), NutzapEvent.KIND to KindName("Nutzap", "61"), SimpleGroupListEvent.KIND to KindName("Group List", "51"), ExternalIdentitiesEvent.KIND to KindName("External Identities", "39"), @@ -668,7 +668,7 @@ object KindNames { GroupMetadataEvent.KIND to KindName("Group Metadata", "29"), GroupAdminsEvent.KIND to KindName("Group Admins", "29"), GroupMembersEvent.KIND to KindName("Group Members", "29"), - SupportedRolesEvent.KIND to KindName("Group Roles", "29"), + GroupRolesEvent.KIND to KindName("Group Roles", "29"), GroupParticipantsEvent.KIND to KindName("Group Participants", "29"), MediaStarterPackEvent.KIND to KindName("Media Starter Pack", "51"), ) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotWelcomeSender.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotWelcomeSender.kt index 051aaf9742..d83d539c10 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotWelcomeSender.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotWelcomeSender.kt @@ -50,7 +50,7 @@ data class WelcomeDelivery( * * Delivery pipeline: * Welcome bytes → base64 → WelcomeEvent (kind:444, unsigned rumor) - * → SealedRumorEvent (kind:13, encrypted with sender's key) + * → SealEvent (kind:13, encrypted with sender's key) * → GiftWrapEvent (kind:1059, encrypted with ephemeral key) */ class MarmotWelcomeSender( diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/RecipientRelayFetcher.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/RecipientRelayFetcher.kt index 846b6c1237..56d268fda5 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/RecipientRelayFetcher.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/RecipientRelayFetcher.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.accessories.fetchAll import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent /** @@ -100,7 +100,7 @@ object RecipientRelayFetcher { Filter( kinds = listOf( - ChatMessageRelayListEvent.KIND, + DmRelayListEvent.KIND, KeyPackageRelayListEvent.KIND, AdvertisedRelayListEvent.KIND, ), @@ -113,7 +113,7 @@ object RecipientRelayFetcher { idleTimeoutMs = idleTimeoutMs, ) - var dm: ChatMessageRelayListEvent? = null + var dm: DmRelayListEvent? = null var kp: KeyPackageRelayListEvent? = null var nip65: AdvertisedRelayListEvent? = null for (event in events) { @@ -122,7 +122,7 @@ object RecipientRelayFetcher { // route someone else's wrapped welcome to the wrong inbox. if (event.pubKey != pubKey) continue when (event) { - is ChatMessageRelayListEvent -> { + is DmRelayListEvent -> { if (dm == null || event.createdAt > dm.createdAt) dm = event } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/KeyPackageRelayListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/KeyPackageRelayListEvent.kt index e9eb595b97..3f98a91dec 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/KeyPackageRelayListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip00KeyPackages/KeyPackageRelayListEvent.kt @@ -42,7 +42,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils * Replaceable event that advertises which relays hold this user's MLS KeyPackages. * Other clients query this to discover where to fetch KeyPackages for group invitations. * - * Uses the same "relay" tag format as NIP-17's ChatMessageRelayListEvent (kind 10050) + * Uses the same "relay" tag format as NIP-17's DmRelayListEvent (kind 10050) * but serves a different purpose: KeyPackage discovery vs DM inbox routing. */ @Immutable diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt index 6ee4406313..2f4cc00f48 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor import com.vitorpamplona.quartz.nip59Giftwrap.rumors.RumorAssembler -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.utils.TimeUtils @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils * * The delivery flow: * WelcomeEvent (unsigned rumor, kind:444) - * → SealedRumorEvent (kind:13, encrypted with sender's key) + * → SealEvent (kind:13, encrypted with sender's key) * → GiftWrapEvent (kind:1059, encrypted with ephemeral key to recipient) * * CRITICAL: The Commit that adds the new member MUST be confirmed by relays @@ -64,7 +64,7 @@ object WelcomeGiftWrap { ): GiftWrapEvent { // Step 1: Build the WelcomeEvent template directly as an unsigned rumor. // Per NIP-59 rumors MUST have an empty sig field, so we skip the outer - // signature entirely and let the SealedRumorEvent carry authorship. + // signature entirely and let the SealEvent carry authorship. val welcomeTemplate = WelcomeEvent.build( welcomeBase64 = welcomeBase64, @@ -82,7 +82,7 @@ object WelcomeGiftWrap { // Step 2: Create a Rumor from the unsigned event and seal it (kind:13) val rumor = Rumor.create(welcomeRumor) val sealedRumor = - SealedRumorEvent.create( + SealEvent.create( rumor = rumor, encryptTo = recipientPubKey, signer = signer, diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjection.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjection.kt index 58c3ecc6ff..df861928f5 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjection.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjection.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.store.ObservableEventStore import com.vitorpamplona.quartz.nip01Core.store.ObservableEventStore.StoreChange import com.vitorpamplona.quartz.nip01Core.store.owner -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip40Expiration.isExpirationBefore import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent import com.vitorpamplona.quartz.utils.SortedList @@ -156,7 +156,7 @@ class EventStoreProjection<T : Event>( // NIP-09 / NIP-62 side effects come first — a deletion event // that arrives at the same instant as a matching event still // removes its targets. - if (event is DeletionEvent) { + if (event is DeletionRequestEvent) { if (handleDeletion(event)) changed = true } if (event is RequestToVanishEvent && event.shouldVanishFrom(store.relay)) { @@ -260,7 +260,7 @@ class EventStoreProjection<T : Event>( return changed } - private fun handleDeletion(deletion: DeletionEvent): Boolean { + private fun handleDeletion(deletion: DeletionRequestEvent): Boolean { var changed = false // NIP-09 by id, only if the deletion's author owns the target. diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientNegentropyDeletionSettleExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientNegentropyDeletionSettleExt.kt index 67e770f1de..48ec8f2474 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientNegentropyDeletionSettleExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/accessories/NostrClientNegentropyDeletionSettleExt.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.store.IEventStore import com.vitorpamplona.quartz.nip01Core.store.deletionsCovering -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent /** * Outcome of a [negentropySettleDeletions] run. @@ -129,7 +129,7 @@ suspend fun INostrClient.negentropySettleDeletions( for (chunk in diff.haveIds.chunked(batchSize)) { val ours = store.query<Event>(Filter(ids = chunk)) val relayDeletions = deletionsCovering(ours, relay) { f -> fetchAll(relay, f, idleTimeoutMs) } - for (del in relayDeletions.filterIsInstance<DeletionEvent>()) { + for (del in relayDeletions.filterIsInstance<DeletionRequestEvent>()) { if (del.verify() && appliedDown.add(del.id)) { store.insert(del) resolved++ diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt index 70836a44b9..b87513ce80 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip04Dm.crypto.EncryptedInfo import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent abstract class NostrSigner( pubKey: HexKey, @@ -67,7 +67,7 @@ abstract class NostrSigner( fromPublicKey: HexKey, ): String - abstract suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent + abstract suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent abstract suspend fun deriveKey(nonce: HexKey): HexKey diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt index b308afbd06..acb512e5c6 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CancellationException class NostrSignerInternal( @@ -89,7 +89,7 @@ class NostrSignerInternal( // always ready override fun hasForegroundSupport() = true - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent { + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent { if (!event.isPrivateZap()) throw SignerExceptions.NothingToDecrypt() return runWrapErrors { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt index 9ca2935bf5..90566d4e7c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt @@ -31,8 +31,8 @@ import com.vitorpamplona.quartz.nip04Dm.crypto.EncryptedInfo import com.vitorpamplona.quartz.nip04Dm.crypto.Nip04 import com.vitorpamplona.quartz.nip44Encryption.Nip44 import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.PrivateZapRequestBuilder +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.psbt.Psbt import com.vitorpamplona.quartz.nipBCOnchainZaps.psbt.PsbtSigner @@ -62,7 +62,7 @@ class NostrSignerSync( kind: Int, tags: Array<Array<String>>, ): Boolean = - kind == LnZapRequestEvent.KIND && + kind == ZapRequestEvent.KIND && tags.any { t -> t.size > 1 && t[0] == "anon" && t[1].isBlank() } fun <T : Event> signNormal( @@ -129,7 +129,7 @@ class NostrSignerSync( ) } - fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = PrivateZapRequestBuilder().decryptZapEvent(event, this) + fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = PrivateZapRequestBuilder().decryptZapEvent(event, this) /** * NIP-BC `sign_psbt`: sign the key-path P2TR inputs of [psbtHex] this key diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/EventStoreDeletionsExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/EventStoreDeletionsExt.kt index 0c5a8203dc..ba070507e1 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/EventStoreDeletionsExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/EventStoreDeletionsExt.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.core.isAddressable import com.vitorpamplona.quartz.nip01Core.core.isReplaceable import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent /** The addressable/replaceable coordinate of [event] as a NIP-01 `a`-tag value. */ @@ -68,15 +68,15 @@ suspend fun deletionsCovering( val covering = LinkedHashMap<HexKey, Event>() // 1. id-based NIP-09: a kind-5 `e`-tagging an event's id. - query(Filter(kinds = listOf(DeletionEvent.KIND), tags = mapOf("e" to events.map { it.id }))) + query(Filter(kinds = listOf(DeletionRequestEvent.KIND), tags = mapOf("e" to events.map { it.id }))) .forEach { covering[it.id] = it } // 2. address-based NIP-09: a kind-5 `a`-tagging an event's coordinate, cutoff-checked. val byAddress = events.filter { it.kind.isAddressable() || it.kind.isReplaceable() }.groupBy(::addressValue) if (byAddress.isNotEmpty()) { - query(Filter(kinds = listOf(DeletionEvent.KIND), tags = mapOf("a" to byAddress.keys.toList()))) + query(Filter(kinds = listOf(DeletionRequestEvent.KIND), tags = mapOf("a" to byAddress.keys.toList()))) .forEach { del -> - if (del !is DeletionEvent) return@forEach + if (del !is DeletionRequestEvent) return@forEach for (addr in del.deleteAddresses()) { val hit = byAddress[addr.toValue()] ?: continue if (hit.any { it.createdAt <= del.createdAt }) { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionRequestModule.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionRequestModule.kt index 448296a4ae..880e1f4630 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionRequestModule.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionRequestModule.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.isAddressable import com.vitorpamplona.quartz.nip01Core.core.isReplaceable -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent class DeletionRequestModule( val hasher: (db: SQLiteConnection) -> TagNameValueHasher, @@ -83,7 +83,7 @@ class DeletionRequestModule( event: Event, db: SQLiteConnection, ): Int { - if (event !is DeletionEvent) return 0 + if (event !is DeletionRequestEvent) return 0 val idValues = event.deleteEventIds() val addresses = event.deleteAddresses() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt index e57e7c0882..9f267c3d6c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.quartz.nip01Core.store.IEventStore import com.vitorpamplona.quartz.nip01Core.store.IdAndTime import com.vitorpamplona.quartz.nip01Core.store.RawEvent import com.vitorpamplona.quartz.nip01Core.store.RejectionReason -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip40Expiration.isExpired import com.vitorpamplona.quartz.nip50Search.strippingSearchExtensions import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent @@ -349,7 +349,7 @@ class SQLiteEventStore( invalidateAll = true return } - if (event is DeletionEvent && deletedRows > 0) { + if (event is DeletionRequestEvent && deletedRows > 0) { // Only a kind-5 that actually removed rows costs a rebuild. // The common case — a delete broadcast for events this relay // never stored — deletes nothing and records as a plain row, diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/PrivateDMCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/PrivateDMCache.kt index 84ad273dfc..18b9c6a075 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/PrivateDMCache.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/PrivateDMCache.kt @@ -23,14 +23,14 @@ package com.vitorpamplona.quartz.nip04Dm import androidx.collection.LruCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.caches.DecryptCache -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent class PrivateDMCache( signer: NostrSigner, ) { private val decryptionCache = - object : LruCache<PrivateDmEvent, PrivateDMDecryptCache>(10000) { - override fun create(key: PrivateDmEvent): PrivateDMDecryptCache? { + object : LruCache<EncryptedDmEvent, PrivateDMDecryptCache>(10000) { + override fun create(key: EncryptedDmEvent): PrivateDMDecryptCache? { val canDecrypt = key.isIncluded(signer.pubKey) return if (key.content.isNotBlank() && canDecrypt) { PrivateDMDecryptCache(signer) @@ -40,16 +40,16 @@ class PrivateDMCache( } } - fun cachedDM(event: PrivateDmEvent): String? = decryptionCache[event]?.cached() + fun cachedDM(event: EncryptedDmEvent): String? = decryptionCache[event]?.cached() - suspend fun decryptDM(event: PrivateDmEvent) = decryptionCache[event]?.decrypt(event) + suspend fun decryptDM(event: EncryptedDmEvent) = decryptionCache[event]?.decrypt(event) } class PrivateDMDecryptCache( signer: NostrSigner, -) : DecryptCache<PrivateDmEvent, String>(signer) { +) : DecryptCache<EncryptedDmEvent, String>(signer) { override suspend fun decryptAndParse( - event: PrivateDmEvent, + event: EncryptedDmEvent, signer: NostrSigner, ) = event.decryptContent(signer) } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/PrivateDmEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/EncryptedDmEvent.kt similarity index 92% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/PrivateDmEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/EncryptedDmEvent.kt index 9b774e3c49..fc5ec3dd8e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/PrivateDmEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/EncryptedDmEvent.kt @@ -42,7 +42,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.collections.immutable.persistentSetOf @Immutable -class PrivateDmEvent( +class EncryptedDmEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -124,10 +124,10 @@ class PrivateDmEvent( toUser: PTag, message: String, imetas: List<IMetaTag>? = null, - replyingTo: EventHintBundle<PrivateDmEvent>? = null, + replyingTo: EventHintBundle<EncryptedDmEvent>? = null, createdAt: Long = TimeUtils.now(), signer: NostrSigner, - initializer: TagArrayBuilder<PrivateDmEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<EncryptedDmEvent>.() -> Unit = {}, ) = eventTemplate( kind = KIND, description = @@ -147,9 +147,15 @@ class PrivateDmEvent( to: PTag, message: String, imetas: List<IMetaTag>? = null, - replyingTo: EventHintBundle<PrivateDmEvent>?, + replyingTo: EventHintBundle<EncryptedDmEvent>?, createdAt: Long = TimeUtils.now(), signer: NostrSigner, ) = signer.sign(build(to, message, imetas, replyingTo, createdAt, signer)) } } + +@Deprecated( + "Renamed to EncryptedDmEvent. NIP-04 names kind 4 the encrypted direct message.", + ReplaceWith("EncryptedDmEvent", "com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent"), +) +typealias PrivateDmEvent = EncryptedDmEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/TagArrayBuilderExt.kt index 06d7a5e0b7..8a9d4559ab 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip04Dm/messages/TagArrayBuilderExt.kt @@ -26,6 +26,6 @@ import com.vitorpamplona.quartz.nip01Core.tags.events.EventReference import com.vitorpamplona.quartz.nip10Notes.tags.MarkedETag import com.vitorpamplona.quartz.nip10Notes.tags.toMarkedETag -fun TagArrayBuilder<PrivateDmEvent>.reply(tag: EventReference) = add(MarkedETag.assemble(tag.eventId, tag.relayHint, MarkedETag.MARKER.REPLY, tag.author)) +fun TagArrayBuilder<EncryptedDmEvent>.reply(tag: EventReference) = add(MarkedETag.assemble(tag.eventId, tag.relayHint, MarkedETag.MARKER.REPLY, tag.author)) -fun TagArrayBuilder<PrivateDmEvent>.reply(tag: EventHintBundle<PrivateDmEvent>) = add(tag.toMarkedETag(MarkedETag.MARKER.REPLY).toTagArray()) +fun TagArrayBuilder<EncryptedDmEvent>.reply(tag: EventHintBundle<EncryptedDmEvent>) = add(tag.toMarkedETag(MarkedETag.MARKER.REPLY).toTagArray()) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionIndex.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionIndex.kt index a26c716af2..93099829a4 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionIndex.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionIndex.kt @@ -45,10 +45,10 @@ class DeletionIndex { // stores a set of id OR atags (kind:pubkey:dtag) by pubkey with the created at of the deletion event. // Anything newer than the date should not be deleted. - private val deletedReferencesBefore = LargeCache<DeletionRequest, DeletionEvent>() + private val deletedReferencesBefore = LargeCache<DeletionRequest, DeletionRequestEvent>() fun add( - event: DeletionEvent, + event: DeletionRequestEvent, wasVerified: Boolean, ): Boolean { var atLeastOne = false @@ -74,7 +74,7 @@ class DeletionIndex { private fun add( ref: String, byPubKey: HexKey, - deletionEvent: DeletionEvent, + deletionEvent: DeletionRequestEvent, wasVerified: Boolean, ): Boolean { val key = DeletionRequest(ref, byPubKey) @@ -89,7 +89,7 @@ class DeletionIndex { return false } - fun hasBeenDeletedBy(event: Event): DeletionEvent? { + fun hasBeenDeletedBy(event: Event): DeletionRequestEvent? { deletedReferencesBefore.get(DeletionRequest(event.id, event.pubKey))?.let { return it } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionRequestEvent.kt similarity index 90% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionRequestEvent.kt index ec2f1de70a..b3aad126d8 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip09Deletions/DeletionRequestEvent.kt @@ -44,7 +44,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.pTagIds import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class DeletionEvent( +class DeletionRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -80,7 +80,7 @@ class DeletionEvent( fun build( deleteEvents: List<Event>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<DeletionEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DeletionRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { deleteEvents.forEach { eTag(ETag(it.id)) @@ -98,7 +98,7 @@ class DeletionEvent( fun buildAddressOnly( deleteEvents: List<Event>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<DeletionEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DeletionRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { deleteEvents.forEach { if (it is AddressableEvent) { @@ -115,7 +115,7 @@ class DeletionEvent( fun buildForVersionOnly( deleteEvents: List<Event>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<DeletionEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DeletionRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { deleteEvents.forEach { pTag(PTag(it.pubKey)) @@ -128,3 +128,9 @@ class DeletionEvent( } } } + +@Deprecated( + "Renamed to DeletionRequestEvent. NIP-09 names kind 5 the event deletion request.", + ReplaceWith("DeletionRequestEvent", "com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent"), +) +typealias DeletionEvent = DeletionRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/BaseThreadedEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/BaseThreadedEvent.kt index b8379fb628..a1f57456d9 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/BaseThreadedEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip10Notes/BaseThreadedEvent.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.tags.aTag.taggedATags import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers import com.vitorpamplona.quartz.nip10Notes.tags.MarkedETag -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.utils.lastNotNullOfOrNull @@ -90,7 +90,7 @@ open class BaseThreadedEvent( val tagAddresses = taggedATags() .filter { aTag -> - aTag.kind != CommunityDefinitionEvent.KIND && (kind != WikiNoteEvent.KIND || aTag.kind != WikiNoteEvent.KIND) && (kind != NipTextEvent.KIND || aTag.kind != NipTextEvent.KIND) + aTag.kind != CommunityDefinitionEvent.KIND && (kind != WikiArticleEvent.KIND || aTag.kind != WikiArticleEvent.KIND) && (kind != NipTextEvent.KIND || aTag.kind != NipTextEvent.KIND) // removes forks from itself. }.map { it.toTag() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt index de180cdbb6..3e9e00597d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip13Pow.miner.PoWMiner import com.vitorpamplona.quartz.nip13Pow.tags.PoWTag import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent /** * A [NostrSigner] decorator that mines a NIP-13 proof of work into the unsigned @@ -98,7 +98,7 @@ class PoWNostrSigner( fromPublicKey: HexKey, ): String = signer.nip44Decrypt(ciphertext, fromPublicKey) - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = signer.decryptZapEvent(event) + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = signer.decryptZapEvent(event) override suspend fun deriveKey(nonce: HexKey): HexKey = signer.deriveKey(nonce) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/NIP17Factory.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/NIP17Factory.kt index 5b8284f329..605ce5df89 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/NIP17Factory.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/NIP17Factory.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUserIds -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag import com.vitorpamplona.quartz.nip40Expiration.expiration import com.vitorpamplona.quartz.nip46RemoteSigner.signer.NostrSignerRemote -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapTemplateConversion import com.vitorpamplona.quartz.utils.mapNotNullAsync @@ -88,7 +88,7 @@ class NIP17Factory { AddressedSeal( recipient = next, seal = - SealedRumorEvent.create( + SealEvent.create( event = event, encryptTo = next, expirationDelta = innerExpDelta, @@ -169,7 +169,7 @@ class NIP17Factory { val build: suspend () -> GiftWrapEvent = { GiftWrapEvent.create( event = - SealedRumorEvent.create( + SealEvent.create( event = event, encryptTo = next, expirationDelta = innerExpDelta, @@ -258,7 +258,7 @@ class NIP17Factory { * it would e-tag the private rumor id onto public relays. */ suspend fun createDeletionNIP17( - template: EventTemplate<DeletionEvent>, + template: EventTemplate<DeletionRequestEvent>, to: List<HexKey>, signer: NostrSigner, ): Result { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/settings/ChatMessageRelayListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/settings/DmRelayListEvent.kt similarity index 86% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/settings/ChatMessageRelayListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/settings/DmRelayListEvent.kt index da8184c850..c66c51610b 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/settings/ChatMessageRelayListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip17Dm/settings/DmRelayListEvent.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayListDiff import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class ChatMessageRelayListEvent( +class DmRelayListEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -47,7 +47,7 @@ class ChatMessageRelayListEvent( ) : BaseReplaceableEvent(id, pubKey, createdAt, KIND, tags, content, sig), DiffableEvent<RelayListDiff> { override fun diffFrom(older: Event): RelayListDiff? { - if (older !is ChatMessageRelayListEvent || older.pubKey != pubKey) return null + if (older !is DmRelayListEvent || older.pubKey != pubKey) return null return RelayListDiff(ListDiff.of(older.relays(), relays(), { it }), ContentChange.NONE) } @@ -71,11 +71,11 @@ class ChatMessageRelayListEvent( .toTypedArray() suspend fun updateRelayList( - earlierVersion: ChatMessageRelayListEvent, + earlierVersion: DmRelayListEvent, relays: List<NormalizedRelayUrl>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): ChatMessageRelayListEvent { + ): DmRelayListEvent { val tags = earlierVersion.tags .filter(RelayTag::notMatch) @@ -89,12 +89,18 @@ class ChatMessageRelayListEvent( relays: List<NormalizedRelayUrl>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): ChatMessageRelayListEvent = signer.sign(createdAt, KIND, createTagArray(relays), "") + ): DmRelayListEvent = signer.sign(createdAt, KIND, createTagArray(relays), "") fun create( relays: List<NormalizedRelayUrl>, signer: NostrSignerSync, createdAt: Long = TimeUtils.now(), - ): ChatMessageRelayListEvent = signer.sign(createdAt, KIND, createTagArray(relays), "") + ): DmRelayListEvent = signer.sign(createdAt, KIND, createTagArray(relays), "") } } + +@Deprecated( + "Renamed to DmRelayListEvent. NIP-17 kind 10050 is the relay list to receive DMs.", + ReplaceWith("DmRelayListEvent", "com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent"), +) +typealias ChatMessageRelayListEvent = DmRelayListEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/LongTextNoteEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/LongFormContentEvent.kt similarity index 94% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/LongTextNoteEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/LongFormContentEvent.kt index 501b0ea929..b4bc6a5cc6 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/LongTextNoteEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/LongFormContentEvent.kt @@ -56,7 +56,7 @@ import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @Immutable -class LongTextNoteEvent( +class LongFormContentEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -162,7 +162,7 @@ class LongTextNoteEvent( publishedAt: Long? = null, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<LongTextNoteEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<LongFormContentEvent>.() -> Unit = {}, ) = eventTemplate(KIND, description, createdAt) { dTag(dTag) @@ -175,3 +175,9 @@ class LongTextNoteEvent( } } } + +@Deprecated( + "Renamed to LongFormContentEvent. NIP-23 names kind 30023 long-form content.", + ReplaceWith("LongFormContentEvent", "com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent"), +) +typealias LongTextNoteEvent = LongFormContentEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/TagArrayBuilderExt.kt index be24865911..174d59c9d0 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip23LongContent/TagArrayBuilderExt.kt @@ -26,10 +26,10 @@ import com.vitorpamplona.quartz.nip23LongContent.tags.PublishedAtTag import com.vitorpamplona.quartz.nip23LongContent.tags.SummaryTag import com.vitorpamplona.quartz.nip23LongContent.tags.TitleTag -fun TagArrayBuilder<LongTextNoteEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) +fun TagArrayBuilder<LongFormContentEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) -fun TagArrayBuilder<LongTextNoteEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) +fun TagArrayBuilder<LongFormContentEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) -fun TagArrayBuilder<LongTextNoteEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) +fun TagArrayBuilder<LongFormContentEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) -fun TagArrayBuilder<LongTextNoteEvent>.publishedAt(publishedAt: Long) = addUnique(PublishedAtTag.assemble(publishedAt)) +fun TagArrayBuilder<LongFormContentEvent>.publishedAt(publishedAt: Long) = addUnique(PublishedAtTag.assemble(publishedAt)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/ChannelListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListEvent.kt similarity index 89% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/ChannelListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListEvent.kt index 27f84bb63c..08cdbbb345 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/ChannelListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListEvent.kt @@ -42,7 +42,7 @@ import com.vitorpamplona.quartz.nip51Lists.removeParsing import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class ChannelListEvent( +class PublicChatListEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -53,7 +53,7 @@ class ChannelListEvent( DiffableEvent<ChannelListDiff>, EventHintProvider { override fun diffFrom(older: Event): ChannelListDiff? { - if (older !is ChannelListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null + if (older !is PublicChatListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null return ChannelListDiff( ListDiff.of(older.tags.channels(), tags.channels(), { it.eventId }, { a, b -> a.relay == b.relay }), privateItemsChangeFrom(older), @@ -87,7 +87,7 @@ class ChannelListEvent( isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): ChannelListEvent = + ): PublicChatListEvent = if (isPrivate) { create( publicChannels = emptyList(), @@ -105,7 +105,7 @@ class ChannelListEvent( } suspend fun add( - earlierVersion: ChannelListEvent, + earlierVersion: PublicChatListEvent, channel: ChannelTag, isPrivate: Boolean, signer: NostrSigner, @@ -119,12 +119,12 @@ class ChannelListEvent( ) suspend fun add( - earlierVersion: ChannelListEvent, + earlierVersion: PublicChatListEvent, channels: List<ChannelTag>, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): ChannelListEvent = + ): PublicChatListEvent = if (isPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() resign( @@ -143,11 +143,11 @@ class ChannelListEvent( } suspend fun remove( - earlierVersion: ChannelListEvent, + earlierVersion: PublicChatListEvent, channel: ChannelTag, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): ChannelListEvent { + ): PublicChatListEvent { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() return resign( privateTags = privateTags.removeParsing(ChannelTag::parseId, channel.eventId), @@ -174,14 +174,14 @@ class ChannelListEvent( tags: TagArray, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): ChannelListEvent = signer.sign(createdAt, KIND, tags, content) + ): PublicChatListEvent = signer.sign(createdAt, KIND, tags, content) suspend fun create( publicChannels: List<ChannelTag> = emptyList(), privateChannels: List<ChannelTag> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): ChannelListEvent { + ): PublicChatListEvent { val template = build(publicChannels, privateChannels, signer, createdAt) return signer.sign(template) } @@ -191,7 +191,7 @@ class ChannelListEvent( privateChannels: List<ChannelTag> = emptyList(), signer: NostrSignerSync, createdAt: Long = TimeUtils.now(), - ): ChannelListEvent { + ): PublicChatListEvent { val privateTagArray = privateChannels.map { it.toTagArray() }.toTypedArray() val publicTagArray = publicChannels.map { it.toTagArray() }.toTypedArray() return signer.signNip51List(createdAt, KIND, publicTagArray, privateTagArray) @@ -202,8 +202,8 @@ class ChannelListEvent( privateChannels: List<ChannelTag> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<ChannelListEvent>.() -> Unit = {}, - ) = eventTemplate<ChannelListEvent>( + initializer: TagArrayBuilder<PublicChatListEvent>.() -> Unit = {}, + ) = eventTemplate<PublicChatListEvent>( kind = KIND, description = PrivateTagsInContent.encryptNip44(privateChannels.map { it.toTagArray() }.toTypedArray(), signer), createdAt = createdAt, @@ -214,3 +214,9 @@ class ChannelListEvent( } } } + +@Deprecated( + "Renamed to PublicChatListEvent. NIP-51 names kind 10005 the public chats list.", + ReplaceWith("PublicChatListEvent", "com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent"), +) +typealias ChannelListEvent = PublicChatListEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/TagArrayBuilderExt.kt index a26e2947f4..fd2acae60b 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/TagArrayBuilderExt.kt @@ -26,9 +26,9 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.events.ETag import com.vitorpamplona.quartz.nip28PublicChat.list.tags.ChannelTag -fun TagArrayBuilder<ChannelListEvent>.followChat( +fun TagArrayBuilder<PublicChatListEvent>.followChat( eventId: HexKey, relayUrl: NormalizedRelayUrl, ) = addUnique(ETag.assemble(eventId, relayUrl, null)) -fun TagArrayBuilder<ChannelListEvent>.channels(rooms: List<ChannelTag>) = addAll(rooms.map { it.toTagArray() }) +fun TagArrayBuilder<PublicChatListEvent>.channels(rooms: List<ChannelTag>) = addAll(rooms.map { it.toTagArray() }) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/GroupPinnedEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/GroupPinnedEvent.kt index a15aa5f589..aa3a653e01 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/GroupPinnedEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/GroupPinnedEvent.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils /** * NIP-29 relay-signed list of a group's pinned messages (kind 39005). The relay - * regenerates it from the accepted [com.vitorpamplona.quartz.nip29RelayGroups.moderation.UpdatePinListEvent] + * regenerates it from the accepted [com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupUpdatePinListEvent] * (kind 9010) moderation actions, so this is the read side clients render — the * source of truth for which messages are pinned and in what display order. * diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/SupportedRolesEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/GroupRolesEvent.kt similarity index 83% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/SupportedRolesEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/GroupRolesEvent.kt index 5efe39736b..9673adce52 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/SupportedRolesEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/metadata/GroupRolesEvent.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.tags.RoleTag import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class SupportedRolesEvent( +class GroupRolesEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -49,7 +49,7 @@ class SupportedRolesEvent( groupId: String, roles: List<RoleTag>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<SupportedRolesEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupRolesEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { dTag(groupId) addAll(RoleTag.assemble(roles)) @@ -57,3 +57,9 @@ class SupportedRolesEvent( } } } + +@Deprecated( + "Renamed to GroupRolesEvent. NIP-29 names kind 39003 the group roles. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupRolesEvent", "com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent"), +) +typealias SupportedRolesEvent = GroupRolesEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/CreateInviteEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupCreateInviteEvent.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/CreateInviteEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupCreateInviteEvent.kt index 6b5ce7f322..ad4fedd9f8 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/CreateInviteEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupCreateInviteEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class CreateInviteEvent( +class GroupCreateInviteEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -47,7 +47,7 @@ class CreateInviteEvent( groupId: String, code: String, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<CreateInviteEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupCreateInviteEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { groupId(groupId) inviteCode(code) @@ -55,3 +55,9 @@ class CreateInviteEvent( } } } + +@Deprecated( + "Renamed to GroupCreateInviteEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupCreateInviteEvent", "com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupCreateInviteEvent"), +) +typealias CreateInviteEvent = GroupCreateInviteEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/DeleteEventEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupDeleteEventEvent.kt similarity index 84% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/DeleteEventEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupDeleteEventEvent.kt index 25ebd16183..342c1cba71 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/DeleteEventEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupDeleteEventEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class DeleteEventEvent( +class GroupDeleteEventEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -50,7 +50,7 @@ class DeleteEventEvent( eventIds: List<HexKey>, previousEvents: List<String> = emptyList(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<DeleteEventEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupDeleteEventEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { groupId(groupId) eventIds.forEach { add(arrayOf("e", it)) } @@ -59,3 +59,9 @@ class DeleteEventEvent( } } } + +@Deprecated( + "Renamed to GroupDeleteEventEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupDeleteEventEvent", "com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupDeleteEventEvent"), +) +typealias DeleteEventEvent = GroupDeleteEventEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/EditMetadataEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupEditMetadataEvent.kt similarity index 92% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/EditMetadataEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupEditMetadataEvent.kt index 76d0b93ac1..1944ace1a7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/EditMetadataEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupEditMetadataEvent.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip50Search.SearchableEvent import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class EditMetadataEvent( +class GroupEditMetadataEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -97,7 +97,7 @@ class EditMetadataEvent( visibility: String? = null, archived: Boolean? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<EditMetadataEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupEditMetadataEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { groupId(groupId) name?.let { add(arrayOf("name", it)) } @@ -116,3 +116,9 @@ class EditMetadataEvent( } } } + +@Deprecated( + "Renamed to GroupEditMetadataEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupEditMetadataEvent", "com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent"), +) +typealias EditMetadataEvent = GroupEditMetadataEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/PutUserEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupPutUserEvent.kt similarity index 88% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/PutUserEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupPutUserEvent.kt index d2f9382413..6faf482d43 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/PutUserEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupPutUserEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class PutUserEvent( +class GroupPutUserEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -62,7 +62,7 @@ class PutUserEvent( previousEvents: List<String> = emptyList(), buzzRole: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<PutUserEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupPutUserEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { groupId(groupId) pubKeysWithRoles.forEach { (pubKey, roles) -> @@ -74,3 +74,9 @@ class PutUserEvent( } } } + +@Deprecated( + "Renamed to GroupPutUserEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupPutUserEvent", "com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupPutUserEvent"), +) +typealias PutUserEvent = GroupPutUserEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/RemoveUserEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupRemoveUserEvent.kt similarity index 84% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/RemoveUserEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupRemoveUserEvent.kt index 09d7ea35fb..9a690605ee 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/RemoveUserEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupRemoveUserEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class RemoveUserEvent( +class GroupRemoveUserEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -50,7 +50,7 @@ class RemoveUserEvent( pubKeys: List<HexKey>, previousEvents: List<String> = emptyList(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<RemoveUserEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupRemoveUserEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { groupId(groupId) pubKeys.forEach { userPubKey(it) } @@ -59,3 +59,9 @@ class RemoveUserEvent( } } } + +@Deprecated( + "Renamed to GroupRemoveUserEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupRemoveUserEvent", "com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupRemoveUserEvent"), +) +typealias RemoveUserEvent = GroupRemoveUserEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/UpdatePinListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupUpdatePinListEvent.kt similarity index 85% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/UpdatePinListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupUpdatePinListEvent.kt index 9a53d7e7cc..fe224d5d21 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/UpdatePinListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/moderation/GroupUpdatePinListEvent.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils * kind-39005 [com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent]. */ @Immutable -class UpdatePinListEvent( +class GroupUpdatePinListEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -54,7 +54,7 @@ class UpdatePinListEvent( groupId: String, pinnedEventIds: List<HexKey>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<UpdatePinListEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupUpdatePinListEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { groupId(groupId) pinnedEventIds.forEach { add(arrayOf("e", it)) } @@ -62,3 +62,9 @@ class UpdatePinListEvent( } } } + +@Deprecated( + "Renamed to GroupUpdatePinListEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupUpdatePinListEvent", "com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupUpdatePinListEvent"), +) +typealias UpdatePinListEvent = GroupUpdatePinListEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/JoinRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/GroupJoinRequestEvent.kt similarity index 84% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/JoinRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/GroupJoinRequestEvent.kt index 2db9b25108..86953702f6 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/JoinRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/GroupJoinRequestEvent.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.moderation.inviteCode import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class JoinRequestEvent( +class GroupJoinRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -50,7 +50,7 @@ class JoinRequestEvent( reason: String = "", inviteCode: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<JoinRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupJoinRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, reason, createdAt) { groupId(groupId) inviteCode?.let { inviteCode(it) } @@ -58,3 +58,9 @@ class JoinRequestEvent( } } } + +@Deprecated( + "Renamed to GroupJoinRequestEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupJoinRequestEvent", "com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent"), +) +typealias JoinRequestEvent = GroupJoinRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/LeaveRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/GroupLeaveRequestEvent.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/LeaveRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/GroupLeaveRequestEvent.kt index 429750cc61..574c5cc38d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/LeaveRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/request/GroupLeaveRequestEvent.kt @@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.moderation.groupId import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class LeaveRequestEvent( +class GroupLeaveRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -46,10 +46,16 @@ class LeaveRequestEvent( groupId: String, reason: String = "", createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<LeaveRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<GroupLeaveRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, reason, createdAt) { groupId(groupId) initializer() } } } + +@Deprecated( + "Renamed to GroupLeaveRequestEvent. NIP-29 group events carry the Group prefix to keep them apart from NIP-43 relay membership events.", + ReplaceWith("GroupLeaveRequestEvent", "com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent"), +) +typealias LeaveRequestEvent = GroupLeaveRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/EmojiPackSelectionEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/EmojiListEvent.kt similarity index 85% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/EmojiPackSelectionEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/EmojiListEvent.kt index 774f834730..1d2a17c5b6 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/EmojiPackSelectionEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/EmojiListEvent.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class EmojiPackSelectionEvent( +class EmojiListEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -61,20 +61,20 @@ class EmojiPackSelectionEvent( fun createAddressTag(pubKey: HexKey) = Address.assemble(KIND, pubKey, FIXED_D_TAG) fun add( - currentSelection: EmojiPackSelectionEvent, + currentSelection: EmojiListEvent, packToAdd: EventHintBundle<EmojiPackEvent>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<EmojiPackSelectionEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<EmojiListEvent>.() -> Unit = {}, ) = eventUpdate(currentSelection, createdAt) { pack(packToAdd.toATag()) initializer() } fun remove( - currentSelection: EmojiPackSelectionEvent, + currentSelection: EmojiListEvent, packToRemove: EmojiPackEvent, createdAt: Long = TimeUtils.now(), - updater: TagArrayBuilder<EmojiPackSelectionEvent>.() -> Unit = {}, + updater: TagArrayBuilder<EmojiListEvent>.() -> Unit = {}, ) = eventUpdate(currentSelection, createdAt) { removePack(packToRemove.address()) updater() @@ -83,10 +83,16 @@ class EmojiPackSelectionEvent( fun build( listOfEmojiPacks: List<EventHintBundle<EmojiPackEvent>>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<EmojiPackSelectionEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<EmojiListEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { packs(listOfEmojiPacks.map { it.toATag() }) initializer() } } } + +@Deprecated( + "Renamed to EmojiListEvent. NIP-51 names kind 10030 the user emoji list.", + ReplaceWith("EmojiListEvent", "com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent"), +) +typealias EmojiPackSelectionEvent = EmojiListEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/TagArrayBuilderExt.kt index c97a08a7fb..455d33dfef 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip30CustomEmoji/selection/TagArrayBuilderExt.kt @@ -27,8 +27,8 @@ import com.vitorpamplona.quartz.nip01Core.tags.aTag.aTag import com.vitorpamplona.quartz.nip01Core.tags.aTag.aTags import com.vitorpamplona.quartz.nip01Core.tags.aTag.removeAddress -fun TagArrayBuilder<EmojiPackSelectionEvent>.pack(tag: ATag) = aTag(tag) +fun TagArrayBuilder<EmojiListEvent>.pack(tag: ATag) = aTag(tag) -fun TagArrayBuilder<EmojiPackSelectionEvent>.packs(tags: List<ATag>) = aTags(tags) +fun TagArrayBuilder<EmojiListEvent>.packs(tags: List<ATag>) = aTags(tags) -fun TagArrayBuilder<EmojiPackSelectionEvent>.removePack(address: Address) = removeAddress(address) +fun TagArrayBuilder<EmojiListEvent>.removePack(address: Address) = removeAddress(address) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip38UserStatus/StatusEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip38UserStatus/UserStatusEvent.kt similarity index 90% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip38UserStatus/StatusEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip38UserStatus/UserStatusEvent.kt index 1ddc25cbc9..db4faeae99 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip38UserStatus/StatusEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip38UserStatus/UserStatusEvent.kt @@ -34,7 +34,7 @@ import com.vitorpamplona.quartz.nip50Search.SearchableEvent import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class StatusEvent( +class UserStatusEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -70,7 +70,7 @@ class StatusEvent( emojiTags: List<EmojiUrlTag>? = null, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): StatusEvent { + ): UserStatusEvent { val tags = mutableListOf<Array<String>>() tags.add(arrayOf("d", type)) @@ -85,23 +85,29 @@ class StatusEvent( } suspend fun update( - event: StatusEvent, + event: UserStatusEvent, newStatus: String, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): StatusEvent { + ): UserStatusEvent { val tags = event.tags return signer.sign(createdAt, KIND, tags, newStatus) } suspend fun clear( - event: StatusEvent, + event: UserStatusEvent, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): StatusEvent { + ): UserStatusEvent { val msg = "" val tags = event.tags.filter { it.size > 1 && it[0] == "d" } return signer.sign(createdAt, KIND, tags.toTypedArray(), msg) } } } + +@Deprecated( + "Renamed to UserStatusEvent. NIP-38 names kind 30315 the user status.", + ReplaceWith("UserStatusEvent", "com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent"), +) +typealias StatusEvent = UserStatusEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt index 5ca77a0410..f58bd0ad69 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt @@ -41,7 +41,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestPing import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestSign import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.utils.Hex import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope @@ -325,7 +325,7 @@ class NostrSignerRemote( throw convertExceptions("Could not get public key", result) } - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent { + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent { TODO("Not yet implemented") } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Client.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Client.kt index 4ee11947c6..acee4cec7c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Client.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Client.kt @@ -27,10 +27,10 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcInfoEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcNotificationEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.CancelHoldInvoiceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBudgetMethod @@ -115,7 +115,7 @@ class Nip47Client( suspend fun payInvoice( bolt11: String, amount: Long? = null, - ): LnZapPaymentRequestEvent = + ): NwcRequestEvent = buildRequest( if (amount != null) { PayInvoiceMethod.create(bolt11, amount) @@ -132,17 +132,17 @@ class Nip47Client( pubkey: String, preimage: String? = null, tlvRecords: List<TlvRecord>? = null, - ): LnZapPaymentRequestEvent = buildRequest(PayKeysendMethod.create(amount, pubkey, preimage, tlvRecords)) + ): NwcRequestEvent = buildRequest(PayKeysendMethod.create(amount, pubkey, preimage, tlvRecords)) /** * Builds a get_balance request event. */ - suspend fun getBalance(): LnZapPaymentRequestEvent = buildRequest(GetBalanceMethod.create()) + suspend fun getBalance(): NwcRequestEvent = buildRequest(GetBalanceMethod.create()) /** * Builds a get_info request event. */ - suspend fun getInfo(): LnZapPaymentRequestEvent = buildRequest(GetInfoMethod.create()) + suspend fun getInfo(): NwcRequestEvent = buildRequest(GetInfoMethod.create()) /** * Builds a make_invoice request event. @@ -152,17 +152,17 @@ class Nip47Client( description: String? = null, descriptionHash: String? = null, expiry: Long? = null, - ): LnZapPaymentRequestEvent = buildRequest(MakeInvoiceMethod.create(amount, description, descriptionHash, expiry)) + ): NwcRequestEvent = buildRequest(MakeInvoiceMethod.create(amount, description, descriptionHash, expiry)) /** * Builds a lookup_invoice request event by payment hash. */ - suspend fun lookupInvoiceByHash(paymentHash: String): LnZapPaymentRequestEvent = buildRequest(LookupInvoiceMethod.createByHash(paymentHash)) + suspend fun lookupInvoiceByHash(paymentHash: String): NwcRequestEvent = buildRequest(LookupInvoiceMethod.createByHash(paymentHash)) /** * Builds a lookup_invoice request event by BOLT11 invoice. */ - suspend fun lookupInvoiceByInvoice(invoice: String): LnZapPaymentRequestEvent = buildRequest(LookupInvoiceMethod.createByInvoice(invoice)) + suspend fun lookupInvoiceByInvoice(invoice: String): NwcRequestEvent = buildRequest(LookupInvoiceMethod.createByInvoice(invoice)) /** * Builds a list_transactions request event. @@ -174,17 +174,17 @@ class Nip47Client( offset: Int? = null, unpaid: Boolean? = null, type: String? = null, - ): LnZapPaymentRequestEvent = buildRequest(ListTransactionsMethod.create(from, until, limit, offset, unpaid, type)) + ): NwcRequestEvent = buildRequest(ListTransactionsMethod.create(from, until, limit, offset, unpaid, type)) /** * Builds a get_budget request event. */ - suspend fun getBudget(): LnZapPaymentRequestEvent = buildRequest(GetBudgetMethod.create()) + suspend fun getBudget(): NwcRequestEvent = buildRequest(GetBudgetMethod.create()) /** * Builds a sign_message request event. */ - suspend fun signMessage(message: String): LnZapPaymentRequestEvent = buildRequest(SignMessageMethod.create(message)) + suspend fun signMessage(message: String): NwcRequestEvent = buildRequest(SignMessageMethod.create(message)) /** * Builds a make_hold_invoice request event. @@ -196,24 +196,24 @@ class Nip47Client( descriptionHash: String? = null, expiry: Long? = null, minCltvExpiryDelta: Int? = null, - ): LnZapPaymentRequestEvent = buildRequest(MakeHoldInvoiceMethod.create(amount, paymentHash, description, descriptionHash, expiry, minCltvExpiryDelta)) + ): NwcRequestEvent = buildRequest(MakeHoldInvoiceMethod.create(amount, paymentHash, description, descriptionHash, expiry, minCltvExpiryDelta)) /** * Builds a cancel_hold_invoice request event. */ - suspend fun cancelHoldInvoice(paymentHash: String): LnZapPaymentRequestEvent = buildRequest(CancelHoldInvoiceMethod.create(paymentHash)) + suspend fun cancelHoldInvoice(paymentHash: String): NwcRequestEvent = buildRequest(CancelHoldInvoiceMethod.create(paymentHash)) /** * Builds a settle_hold_invoice request event. */ - suspend fun settleHoldInvoice(preimage: String): LnZapPaymentRequestEvent = buildRequest(SettleHoldInvoiceMethod.create(preimage)) + suspend fun settleHoldInvoice(preimage: String): NwcRequestEvent = buildRequest(SettleHoldInvoiceMethod.create(preimage)) /** * Builds a request event from any [Request] object. * This is the low-level method used by all convenience methods above. */ - suspend fun buildRequest(request: Request): LnZapPaymentRequestEvent = - LnZapPaymentRequestEvent.createRequest( + suspend fun buildRequest(request: Request): NwcRequestEvent = + NwcRequestEvent.createRequest( request = request, walletServicePubkey = walletPubKeyHex, signer = signer, @@ -225,7 +225,7 @@ class Nip47Client( /** * Decrypts and parses a response event from the wallet. */ - suspend fun parseResponse(event: LnZapPaymentResponseEvent): Response = event.decrypt(signer) + suspend fun parseResponse(event: NwcResponseEvent): Response = event.decrypt(signer) /** * Decrypts and parses a notification event from the wallet. @@ -240,7 +240,7 @@ class Nip47Client( */ fun responseFilter(requestEventId: HexKey): Filter = Filter( - kinds = listOf(LnZapPaymentResponseEvent.KIND), + kinds = listOf(NwcResponseEvent.KIND), authors = listOf(walletPubKeyHex), tags = mapOf("e" to listOf(requestEventId)), ) @@ -251,7 +251,7 @@ class Nip47Client( */ fun allResponsesFilter(since: Long? = null): Filter = Filter( - kinds = listOf(LnZapPaymentResponseEvent.KIND), + kinds = listOf(NwcResponseEvent.KIND), authors = listOf(walletPubKeyHex), tags = mapOf("p" to listOf(signer.pubKey)), since = since, diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Server.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Server.kt index 739351ca16..da7baebe4c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Server.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/Nip47Server.kt @@ -23,10 +23,10 @@ package com.vitorpamplona.quartz.nip47WalletConnect import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcInfoEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcNotificationEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceSuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBudgetSuccessResponse import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetInfoSuccessResponse @@ -105,7 +105,7 @@ class Nip47Server( /** * Decrypts and parses an incoming client request. */ - suspend fun parseRequest(event: LnZapPaymentRequestEvent): Request = event.decryptRequest(signer) + suspend fun parseRequest(event: NwcRequestEvent): Request = event.decryptRequest(signer) // --- Response builders --- @@ -114,9 +114,9 @@ class Nip47Server( */ suspend fun buildResponse( response: Response, - requestEvent: LnZapPaymentRequestEvent, - ): LnZapPaymentResponseEvent = - LnZapPaymentResponseEvent.createResponse( + requestEvent: NwcRequestEvent, + ): NwcResponseEvent = + NwcResponseEvent.createResponse( response = response, requestEvent = requestEvent, signer = signer, @@ -127,11 +127,11 @@ class Nip47Server( * Builds an error response for any method. */ suspend fun respondError( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, code: NwcErrorCode, message: String, resultType: String? = null, - ): LnZapPaymentResponseEvent { + ): NwcResponseEvent { val method = resultType ?: requestEvent.decryptRequest(signer).method ?: NwcMethod.PAY_INVOICE return buildResponse(NwcErrorResponse(method, NwcError(code, message)), requestEvent) } @@ -140,10 +140,10 @@ class Nip47Server( * Builds a pay_invoice success response. */ suspend fun respondPayInvoice( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, preimage: String? = null, feesPaid: Long? = null, - ): LnZapPaymentResponseEvent = + ): NwcResponseEvent = buildResponse( PayInvoiceSuccessResponse(PayInvoiceSuccessResponse.PayInvoiceResultParams(preimage, feesPaid)), requestEvent, @@ -153,10 +153,10 @@ class Nip47Server( * Builds a pay_keysend success response. */ suspend fun respondPayKeysend( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, preimage: String? = null, feesPaid: Long? = null, - ): LnZapPaymentResponseEvent = + ): NwcResponseEvent = buildResponse( PayKeysendSuccessResponse(PayKeysendSuccessResponse.PayKeysendResult(preimage, feesPaid)), requestEvent, @@ -166,9 +166,9 @@ class Nip47Server( * Builds a get_balance success response. */ suspend fun respondGetBalance( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, balance: Long, - ): LnZapPaymentResponseEvent = + ): NwcResponseEvent = buildResponse( GetBalanceSuccessResponse(GetBalanceSuccessResponse.GetBalanceResult(balance)), requestEvent, @@ -178,7 +178,7 @@ class Nip47Server( * Builds a get_info success response. */ suspend fun respondGetInfo( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, alias: String? = null, color: String? = null, pubkey: String? = null, @@ -188,7 +188,7 @@ class Nip47Server( methods: List<String>? = null, notifications: List<String>? = null, lud16: String? = null, - ): LnZapPaymentResponseEvent = + ): NwcResponseEvent = buildResponse( GetInfoSuccessResponse( GetInfoSuccessResponse.GetInfoResult( @@ -211,26 +211,26 @@ class Nip47Server( * Builds a make_invoice success response. */ suspend fun respondMakeInvoice( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, transaction: NwcTransaction, - ): LnZapPaymentResponseEvent = buildResponse(MakeInvoiceSuccessResponse(transaction), requestEvent) + ): NwcResponseEvent = buildResponse(MakeInvoiceSuccessResponse(transaction), requestEvent) /** * Builds a lookup_invoice success response. */ suspend fun respondLookupInvoice( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, transaction: NwcTransaction, - ): LnZapPaymentResponseEvent = buildResponse(LookupInvoiceSuccessResponse(transaction), requestEvent) + ): NwcResponseEvent = buildResponse(LookupInvoiceSuccessResponse(transaction), requestEvent) /** * Builds a list_transactions success response. */ suspend fun respondListTransactions( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, transactions: List<NwcTransaction>, totalCount: Long? = null, - ): LnZapPaymentResponseEvent = + ): NwcResponseEvent = buildResponse( ListTransactionsSuccessResponse( ListTransactionsSuccessResponse.ListTransactionsResult(transactions, totalCount), @@ -242,12 +242,12 @@ class Nip47Server( * Builds a get_budget success response. */ suspend fun respondGetBudget( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, usedBudget: Long? = null, totalBudget: Long? = null, renewsAt: Long? = null, renewalPeriod: String? = null, - ): LnZapPaymentResponseEvent = + ): NwcResponseEvent = buildResponse( GetBudgetSuccessResponse( GetBudgetSuccessResponse.GetBudgetResult(usedBudget, totalBudget, renewsAt, renewalPeriod), @@ -259,10 +259,10 @@ class Nip47Server( * Builds a sign_message success response. */ suspend fun respondSignMessage( - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, message: String, signature: String, - ): LnZapPaymentResponseEvent = + ): NwcResponseEvent = buildResponse( SignMessageSuccessResponse(SignMessageSuccessResponse.SignMessageResult(message, signature)), requestEvent, @@ -317,7 +317,7 @@ class Nip47Server( */ fun requestsFilter(since: Long? = null): Filter = Filter( - kinds = listOf(LnZapPaymentRequestEvent.KIND), + kinds = listOf(NwcRequestEvent.KIND), tags = mapOf("p" to listOf(signer.pubKey)), since = since, ) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/README.md b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/README.md index 0d372e1a49..7ee4df5c25 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/README.md +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/README.md @@ -92,8 +92,8 @@ nip47WalletConnect/ ├── NwcErrorCode.kt # Error codes enum + NwcError ├── NwcTransaction.kt # Transaction, state, budget, TLV models ├── NwcInfoEvent.kt # Kind 13194 — wallet capabilities -├── LnZapPaymentRequestEvent.kt # Kind 23194 — client → wallet request -├── LnZapPaymentResponseEvent.kt # Kind 23195 — wallet → client response +├── NwcRequestEvent.kt # Kind 23194 — client → wallet request +├── NwcResponseEvent.kt # Kind 23195 — wallet → client response ├── NwcNotificationEvent.kt # Kind 23197 — wallet → client notification ├── NostrWalletConnectRequestCache.kt # Request decryption cache ├── NostrWalletConnectResponseCache.kt # Response decryption cache @@ -107,8 +107,8 @@ nip47WalletConnect/ | Kind | Class | Direction | Purpose | |-------|------------------------------|-----------------|----------------------| | 13194 | `NwcInfoEvent` | Wallet → Relay | Service capabilities | -| 23194 | `LnZapPaymentRequestEvent` | Client → Wallet | NWC request | -| 23195 | `LnZapPaymentResponseEvent` | Wallet → Client | NWC response | +| 23194 | `NwcRequestEvent` | Client → Wallet | NWC request | +| 23195 | `NwcResponseEvent` | Wallet → Client | NWC response | | 23196 | `NwcNotificationEvent` | Wallet → Client | Notification (NIP-04, legacy) | | 23197 | `NwcNotificationEvent` | Wallet → Client | Notification (NIP-44) | @@ -161,7 +161,7 @@ val clientSigner = NostrSignerInternal( ```kotlin val balanceRequest = GetBalanceMethod.create() -val event = LnZapPaymentRequestEvent.createRequest( +val event = NwcRequestEvent.createRequest( request = balanceRequest, walletServicePubkey = nwcConfig.pubKeyHex, signer = clientSigner, @@ -172,7 +172,7 @@ val event = LnZapPaymentRequestEvent.createRequest( To use NIP-44 encryption instead of NIP-04: ```kotlin -val event = LnZapPaymentRequestEvent.createRequest( +val event = NwcRequestEvent.createRequest( request = GetInfoMethod.create(), walletServicePubkey = nwcConfig.pubKeyHex, signer = clientSigner, @@ -238,7 +238,7 @@ val request: Request = requestEvent.decryptRequest(walletSigner) val balanceResponse = GetBalanceSuccessResponse( GetBalanceSuccessResponse.GetBalanceResult(balance = 2100000L) ) -val responseEvent = LnZapPaymentResponseEvent.createResponse( +val responseEvent = NwcResponseEvent.createResponse( response = balanceResponse, requestEvent = requestEvent, signer = walletSigner, @@ -249,7 +249,7 @@ val errorResponse = NwcErrorResponse( resultType = NwcMethod.PAY_INVOICE, error = NwcError(NwcErrorCode.INSUFFICIENT_BALANCE, "Not enough funds"), ) -val errorEvent = LnZapPaymentResponseEvent.createResponse( +val errorEvent = NwcResponseEvent.createResponse( response = errorResponse, requestEvent = requestEvent, signer = walletSigner, diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectRequestCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectRequestCache.kt index 59a160871f..b76e0320ac 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectRequestCache.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectRequestCache.kt @@ -23,15 +23,15 @@ package com.vitorpamplona.quartz.nip47WalletConnect.cache import androidx.collection.LruCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.caches.DecryptCache -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Request class NostrWalletConnectRequestCache( signer: NostrSigner, ) { private val decryptionCache = - object : LruCache<LnZapPaymentRequestEvent, NWCRequestDecryptCache>(50) { - override fun create(key: LnZapPaymentRequestEvent): NWCRequestDecryptCache? = + object : LruCache<NwcRequestEvent, NWCRequestDecryptCache>(50) { + override fun create(key: NwcRequestEvent): NWCRequestDecryptCache? = if (key.content.isNotBlank() && key.canDecrypt(signer)) { NWCRequestDecryptCache(signer) } else { @@ -39,16 +39,16 @@ class NostrWalletConnectRequestCache( } } - fun cachedRequest(event: LnZapPaymentRequestEvent): Request? = decryptionCache[event]?.cached() + fun cachedRequest(event: NwcRequestEvent): Request? = decryptionCache[event]?.cached() - suspend fun decryptRequest(event: LnZapPaymentRequestEvent) = decryptionCache[event]?.decrypt(event) + suspend fun decryptRequest(event: NwcRequestEvent) = decryptionCache[event]?.decrypt(event) } class NWCRequestDecryptCache( signer: NostrSigner, -) : DecryptCache<LnZapPaymentRequestEvent, Request>(signer) { +) : DecryptCache<NwcRequestEvent, Request>(signer) { override suspend fun decryptAndParse( - event: LnZapPaymentRequestEvent, + event: NwcRequestEvent, signer: NostrSigner, ) = event.decryptRequest(signer) } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectResponseCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectResponseCache.kt index c291c2c988..818b1041dc 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectResponseCache.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/cache/NostrWalletConnectResponseCache.kt @@ -23,15 +23,15 @@ package com.vitorpamplona.quartz.nip47WalletConnect.cache import androidx.collection.LruCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.caches.DecryptCache -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response class NostrWalletConnectResponseCache( signer: NostrSigner, ) { private val decryptionCache = - object : LruCache<LnZapPaymentResponseEvent, NWCResponseDecryptCache>(50) { - override fun create(key: LnZapPaymentResponseEvent): NWCResponseDecryptCache? = + object : LruCache<NwcResponseEvent, NWCResponseDecryptCache>(50) { + override fun create(key: NwcResponseEvent): NWCResponseDecryptCache? = if (key.content.isNotBlank() && key.canDecrypt(signer)) { NWCResponseDecryptCache(signer) } else { @@ -39,16 +39,16 @@ class NostrWalletConnectResponseCache( } } - fun cachedResponse(event: LnZapPaymentResponseEvent): Response? = decryptionCache[event]?.cached() + fun cachedResponse(event: NwcResponseEvent): Response? = decryptionCache[event]?.cached() - suspend fun decryptResponse(event: LnZapPaymentResponseEvent) = decryptionCache[event]?.decrypt(event) + suspend fun decryptResponse(event: NwcResponseEvent) = decryptionCache[event]?.decrypt(event) } class NWCResponseDecryptCache( signer: NostrSigner, -) : DecryptCache<LnZapPaymentResponseEvent, Response>(signer) { +) : DecryptCache<NwcResponseEvent, Response>(signer) { override suspend fun decryptAndParse( - event: LnZapPaymentResponseEvent, + event: NwcResponseEvent, signer: NostrSigner, ) = event.decrypt(signer) } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/LnZapPaymentRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/NwcRequestEvent.kt similarity index 91% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/LnZapPaymentRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/NwcRequestEvent.kt index 010ebbef74..fc549558fc 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/LnZapPaymentRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/NwcRequestEvent.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Request import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class LnZapPaymentRequestEvent( +class NwcRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -64,7 +64,7 @@ class LnZapPaymentRequestEvent( signer: NostrSigner, createdAt: Long = TimeUtils.now(), useNip44: Boolean = false, - ): LnZapPaymentRequestEvent = + ): NwcRequestEvent = createRequest( PayInvoiceMethod.create(lnInvoice), walletServicePubkey, @@ -79,7 +79,7 @@ class LnZapPaymentRequestEvent( signer: NostrSigner, createdAt: Long = TimeUtils.now(), useNip44: Boolean = false, - ): LnZapPaymentRequestEvent { + ): NwcRequestEvent { val serializedRequest = OptimizedJsonMapper.toJson(request) val tags = @@ -100,3 +100,9 @@ class LnZapPaymentRequestEvent( } } } + +@Deprecated( + "Renamed to NwcRequestEvent. Kind 23194 is the generic NIP-47 wallet request, not only a zap payment.", + ReplaceWith("NwcRequestEvent", "com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent"), +) +typealias LnZapPaymentRequestEvent = NwcRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/LnZapPaymentResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/NwcResponseEvent.kt similarity index 90% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/LnZapPaymentResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/NwcResponseEvent.kt index 88b6519e95..7c8769191a 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/LnZapPaymentResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/events/NwcResponseEvent.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class LnZapPaymentResponseEvent( +class NwcResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -69,11 +69,11 @@ class LnZapPaymentResponseEvent( */ suspend fun createResponse( response: Response, - requestEvent: LnZapPaymentRequestEvent, + requestEvent: NwcRequestEvent, signer: NostrSigner, useNip44: Boolean = false, createdAt: Long = TimeUtils.now(), - ): LnZapPaymentResponseEvent { + ): NwcResponseEvent { val serializedResponse = OptimizedJsonMapper.toJson(response) val clientPubkey = requestEvent.pubKey @@ -95,3 +95,9 @@ class LnZapPaymentResponseEvent( } } } + +@Deprecated( + "Renamed to NwcResponseEvent. Kind 23195 is the generic NIP-47 wallet response, not only a zap payment.", + ReplaceWith("NwcResponseEvent", "com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent"), +) +typealias LnZapPaymentResponseEvent = NwcResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/rpc/NwcTransactionMetadata.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/rpc/NwcTransactionMetadata.kt index d5fca147f8..4a8d5dbf98 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/rpc/NwcTransactionMetadata.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/rpc/NwcTransactionMetadata.kt @@ -179,7 +179,7 @@ class NwcTransactionMetadata( * * NIP-57 sets a zap invoice's `description_hash` to the sha256 of the raw * JSON the LNURL callback received in `nostr=`, and that is - * `LnZapRequestEvent.toJson()` — the exact string used here. A wallet can + * `ZapRequestEvent.toJson()` — the exact string used here. A wallet can * therefore bind this stored event to the invoice it labels, which is what * turns "the client says it paid X" into something the wallet checked. * diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt index 97fcb8b7cb..e6176a77fb 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt @@ -56,11 +56,11 @@ import com.vitorpamplona.quartz.nip15Marketplace.marketplace.MarketplaceEvent import com.vitorpamplona.quartz.nip15Marketplace.product.ProductEvent import com.vitorpamplona.quartz.nip15Marketplace.stall.StallEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent import com.vitorpamplona.quartz.nip32Labeling.LabelEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent @@ -71,24 +71,24 @@ import com.vitorpamplona.quartz.nip51Lists.appCurationSet.AppCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.RootSiteEvent @@ -100,13 +100,13 @@ import com.vitorpamplona.quartz.nip69P2pOrderEvents.P2POrderEvent import com.vitorpamplona.quartz.nip71Video.AddressableVideoEvent import com.vitorpamplona.quartz.nip71Video.RegularVideoEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent import com.vitorpamplona.quartz.nipB0WebBookmarks.WebBookmarkEvent import com.vitorpamplona.quartz.nipC0CodeSnippets.CodeSnippetEvent @@ -158,11 +158,11 @@ object SearchFieldExtractor { } } - is LongTextNoteEvent -> { + is LongFormContentEvent -> { tiers(event, event.title(), event.summary(), event.content) } - is WikiNoteEvent -> { + is WikiArticleEvent -> { tiers(event, event.title(), event.summary(), event.content) } @@ -263,7 +263,7 @@ object SearchFieldExtractor { tiers(event, event.title(), null, event.content) } - is CalendarEvent -> { + is CalendarCollectionEvent -> { tiers(event, event.title(), null, event.content) } @@ -352,7 +352,7 @@ object SearchFieldExtractor { // kind 9002 edits the very metadata kind 39000 publishes, so it // splits the same way -- it was the only half of the pair falling // through. Its hashtags() is `t`, carried once by the funnel. - is EditMetadataEvent -> { + is GroupEditMetadataEvent -> { tiers(event, event.name(), event.about(), null) } @@ -360,7 +360,7 @@ object SearchFieldExtractor { tiers(event, event.title(), event.description(), null) } - is FollowListEvent -> { + is StarterPackEvent -> { tiers(event, event.title(), event.description(), null) } @@ -448,7 +448,7 @@ object SearchFieldExtractor { // concatenates the topics INTO the body while the funnel added // them as hashtags. Whether that role is tokenized or kept as // keywords is the backend's call, per IndexableFields. - is ContactCardEvent -> { + is UserAssertionEvent -> { tiers(event, event.petName(), event.summary(), null) } @@ -456,11 +456,11 @@ object SearchFieldExtractor { tiers(event, event.title(), null, null) } - is LabeledBookmarkListEvent -> { + is BookmarkSetEvent -> { tiers(event, event.titleOrName(), event.description(), null) } - is PeopleListEvent -> { + is FollowSetEvent -> { tiers(event, event.titleOrName(), event.description(), null) } @@ -472,7 +472,7 @@ object SearchFieldExtractor { tiers(event, event.title(), null, null) } - is GoalEvent -> { + is ZapGoalEvent -> { tiers(event, null, event.summary(), event.content) } @@ -480,7 +480,7 @@ object SearchFieldExtractor { tiers(event, emptyList(), listOf(event.comment(), event.context()), event.content) } - is FileHeaderEvent -> { + is FileMetadataEvent -> { tiers(event, null, event.summary(), event.content) } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchableKinds.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchableKinds.kt index 7c7eb0e954..357eb0c7e2 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchableKinds.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchableKinds.kt @@ -71,7 +71,7 @@ object SearchableKinds { 54, // PodcastEpisodeEvent 818, // WikiMergeRequestEvent 1010, // TextNoteModificationEvent - 1063, // FileHeaderEvent + 1063, // FileMetadataEvent 1065, // FileStorageHeaderEvent 1068, // PollEvent 1111, // CommentEvent @@ -96,20 +96,20 @@ object SearchableKinds { 2004, // TorrentCommentEvent 2473, // BirdDetectionEvent 3302, // ConcordChatEditEvent - 5050, // NIP90TextGenerationRequestEvent - 5100, // NIP90ImageGenerationRequestEvent + 5050, // DvmTextGenerationRequestEvent + 5100, // DvmImageGenerationRequestEvent 5129, // NappletSnapshotEvent - 5250, // NIP90TextToSpeechRequestEvent - 5302, // NIP90ContentSearchRequestEvent - 5303, // NIP90PeopleSearchRequestEvent + 5250, // DvmTextToSpeechRequestEvent + 5302, // DvmContentSearchRequestEvent + 5303, // DvmPeopleSearchRequestEvent 6969, // ZapPollEvent 7516, // GeocacheFoundLogEvent 8333, // OnchainZapEvent - 9002, // EditMetadataEvent - 9041, // GoalEvent + 9002, // GroupEditMetadataEvent + 9041, // ZapGoalEvent 9321, // NutzapEvent - 9734, // LnZapRequestEvent - 9735, // LnZapEvent + 9734, // ZapRequestEvent + 9735, // ZapReceiptEvent 9736, // Bolt12ZapEvent 9737, // Bolt12ZapIntentEvent 9802, // HighlightEvent @@ -122,10 +122,10 @@ object SearchableKinds { 12473, // BirdexEvent 15128, // RootSiteEvent 15129, // RootNappletEvent - 30000, // PeopleListEvent + 30000, // FollowSetEvent 30001, // OldBookmarkListEvent 30002, // RelaySetEvent - 30003, // LabeledBookmarkListEvent + 30003, // BookmarkSetEvent 30004, // ArticleCurationSetEvent 30005, // VideoCurationSetEvent 30006, // PictureCurationSetEvent @@ -135,7 +135,7 @@ object SearchableKinds { 30018, // ProductEvent 30019, // MarketplaceEvent 30020, // AuctionEvent - 30023, // LongTextNoteEvent + 30023, // LongFormContentEvent 30030, // EmojiPackEvent 30040, // PublicationIndexEvent 30041, // PublicationContentEvent @@ -153,8 +153,8 @@ object SearchableKinds { 30311, // LiveActivitiesEvent 30312, // MeetingSpaceEvent 30313, // MeetingRoomEvent - 30315, // StatusEvent - 30382, // ContactCardEvent + 30315, // UserStatusEvent + 30382, // UserAssertionEvent 30392, // UserTrustedListEvent 30393, // EventTrustedListEvent 30394, // AddressableTrustedListEvent @@ -163,14 +163,14 @@ object SearchableKinds { 30617, // GitRepositoryEvent 30620, // WorkflowDefEvent 30817, // NipTextEvent - 30818, // WikiNoteEvent + 30818, // WikiArticleEvent 31337, // AudioTrackEvent 31871, // AttestationEvent 31872, // AttestationRequestEvent 31873, // AttestorRecommendationEvent 31922, // CalendarDateSlotEvent 31923, // CalendarTimeSlotEvent - 31924, // CalendarEvent + 31924, // CalendarCollectionEvent 31925, // CalendarRSVPEvent 31987, // RelayReviewEvent 31990, // AppDefinitionEvent @@ -179,8 +179,8 @@ object SearchableKinds { 33401, // ExerciseTemplateEvent 33863, // FundraiserEvent 34139, // MusicPlaylistEvent - 34235, // VideoHorizontalEvent - 34236, // VideoVerticalEvent + 34235, // AddressableNormalVideoEvent + 34236, // AddressableShortVideoEvent 34259, // EntityRatingEvent 34550, // CommunityDefinitionEvent 35128, // NamedSiteEvent @@ -192,7 +192,7 @@ object SearchableKinds { 38192, // Ps1SaveEvent 38383, // P2POrderEvent 39000, // GroupMetadataEvent - 39089, // FollowListEvent + 39089, // StarterPackEvent 39092, // MediaStarterPackEvent 39307, // TextTrackEvent 39701, // WebBookmarkEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/FollowListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/StarterPackEvent.kt similarity index 90% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/FollowListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/StarterPackEvent.kt index edcc791377..c38841df66 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/FollowListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/StarterPackEvent.kt @@ -42,7 +42,7 @@ import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @Immutable -class FollowListEvent( +class StarterPackEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -99,7 +99,7 @@ class FollowListEvent( signer: NostrSigner, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - ): FollowListEvent = + ): StarterPackEvent = create( name = name, people = listOf(person), @@ -109,11 +109,11 @@ class FollowListEvent( ) suspend fun addUsers( - earlierVersion: FollowListEvent, + earlierVersion: StarterPackEvent, people: List<UserTag>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): FollowListEvent = + ): StarterPackEvent = resign( content = earlierVersion.content, tags = earlierVersion.tags.plus(people.map { it.toTagArray() }), @@ -122,18 +122,18 @@ class FollowListEvent( ) suspend fun add( - earlierVersion: FollowListEvent, + earlierVersion: StarterPackEvent, person: UserTag, signer: NostrSigner, createdAt: Long = TimeUtils.now(), ) = addUsers(earlierVersion, listOf(person), signer, createdAt) suspend fun remove( - earlierVersion: FollowListEvent, + earlierVersion: StarterPackEvent, person: UserTag, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): FollowListEvent = + ): StarterPackEvent = resign( content = earlierVersion.content, tags = earlierVersion.tags.remove(person.toTagIdOnly()), @@ -146,7 +146,7 @@ class FollowListEvent( tags: Array<Array<String>>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): FollowListEvent { + ): StarterPackEvent { val newTags = tags return signer.sign(createdAt, KIND, newTags, content) @@ -159,7 +159,7 @@ class FollowListEvent( signer: NostrSigner, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - ): FollowListEvent { + ): StarterPackEvent { val template = build(name, people, dTag, createdAt) return signer.sign(template) } @@ -170,7 +170,7 @@ class FollowListEvent( people: List<UserTag> = emptyList(), dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<FollowListEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<StarterPackEvent>.() -> Unit = {}, ) = eventTemplate( kind = KIND, description = "", @@ -184,3 +184,9 @@ class FollowListEvent( } } } + +@Deprecated( + "Renamed to StarterPackEvent. Kind 39089 is a NIP-51 starter pack. The NIP-02 follow list is kind 3 (ContactListEvent).", + ReplaceWith("StarterPackEvent", "com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent"), +) +typealias FollowListEvent = StarterPackEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayBuilderExt.kt index 60eac2631c..6b5cf9bc13 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayBuilderExt.kt @@ -28,24 +28,24 @@ import com.vitorpamplona.quartz.nip51Lists.tags.DescriptionTag import com.vitorpamplona.quartz.nip51Lists.tags.ImageTag import com.vitorpamplona.quartz.nip51Lists.tags.TitleTag -fun TagArrayBuilder<FollowListEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) +fun TagArrayBuilder<StarterPackEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) -fun TagArrayBuilder<FollowListEvent>.description(desc: String) = addUnique(DescriptionTag.assemble(desc)) +fun TagArrayBuilder<StarterPackEvent>.description(desc: String) = addUnique(DescriptionTag.assemble(desc)) -fun TagArrayBuilder<FollowListEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) +fun TagArrayBuilder<StarterPackEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) -fun TagArrayBuilder<FollowListEvent>.people(peoples: List<UserTag>) = addAll(peoples.map { it.toTagArray() }) +fun TagArrayBuilder<StarterPackEvent>.people(peoples: List<UserTag>) = addAll(peoples.map { it.toTagArray() }) -fun TagArrayBuilder<FollowListEvent>.person(person: UserTag) = add(person.toTagArray()) +fun TagArrayBuilder<StarterPackEvent>.person(person: UserTag) = add(person.toTagArray()) -fun TagArrayBuilder<FollowListEvent>.person( +fun TagArrayBuilder<StarterPackEvent>.person( pubkey: HexKey, relayHint: NormalizedRelayUrl?, ) = add(UserTag.assemble(pubkey, relayHint)) -fun TagArrayBuilder<FollowListEvent>.personFirst( +fun TagArrayBuilder<StarterPackEvent>.personFirst( pubkey: HexKey, relayHint: NormalizedRelayUrl?, ) = addFirst(UserTag.assemble(pubkey, relayHint)) -fun TagArrayBuilder<FollowListEvent>.removePerson(pubkey: HexKey) = remove(UserTag.TAG_NAME, pubkey) +fun TagArrayBuilder<StarterPackEvent>.removePerson(pubkey: HexKey) = remove(UserTag.TAG_NAME, pubkey) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/HashtagListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/InterestListEvent.kt similarity index 90% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/HashtagListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/InterestListEvent.kt index 67af6cddc7..950fb6c7a9 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/HashtagListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/InterestListEvent.kt @@ -41,7 +41,7 @@ import com.vitorpamplona.quartz.nip51Lists.removeIgnoreCase import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class HashtagListEvent( +class InterestListEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -51,7 +51,7 @@ class HashtagListEvent( ) : PrivateTagArrayEvent(id, pubKey, createdAt, KIND, tags, content, sig), DiffableEvent<HashtagListDiff> { override fun diffFrom(older: Event): HashtagListDiff? { - if (older !is HashtagListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null + if (older !is InterestListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null return HashtagListDiff( ListDiff.of(older.publicHashtags(), publicHashtags(), { it.lowercase() }), privateItemsChangeFrom(older), @@ -83,7 +83,7 @@ class HashtagListEvent( isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): HashtagListEvent = + ): InterestListEvent = if (isPrivate) { create( publicHashtags = emptyList(), @@ -101,7 +101,7 @@ class HashtagListEvent( } suspend fun add( - earlierVersion: HashtagListEvent, + earlierVersion: InterestListEvent, hashtag: String, isPrivate: Boolean, signer: NostrSigner, @@ -115,12 +115,12 @@ class HashtagListEvent( ) suspend fun add( - earlierVersion: HashtagListEvent, + earlierVersion: InterestListEvent, hashtags: List<String>, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): HashtagListEvent { + ): InterestListEvent { val hashtags = hashtags.map { HashtagTag.assemble(it) } return if (isPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() @@ -141,11 +141,11 @@ class HashtagListEvent( } suspend fun remove( - earlierVersion: HashtagListEvent, + earlierVersion: InterestListEvent, hashtag: String, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): HashtagListEvent { + ): InterestListEvent { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() return resign( privateTags = privateTags.removeIgnoreCase(HashtagTag.assemble(hashtag)), @@ -172,7 +172,7 @@ class HashtagListEvent( tags: TagArray, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): HashtagListEvent { + ): InterestListEvent { val newTags = tags return signer.sign(createdAt, KIND, newTags, content) @@ -183,7 +183,7 @@ class HashtagListEvent( privateHashtags: List<String> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): HashtagListEvent { + ): InterestListEvent { val template = build(publicHashtags, privateHashtags, signer, createdAt) return signer.sign(template) } @@ -193,7 +193,7 @@ class HashtagListEvent( privateHashtags: List<String> = emptyList(), signer: NostrSignerSync, createdAt: Long = TimeUtils.now(), - ): HashtagListEvent { + ): InterestListEvent { val privateTagArray = publicHashtags.map { HashtagTag.assemble(it) }.toTypedArray() val publicTagArray = privateHashtags.map { HashtagTag.assemble(it) }.toTypedArray() return signer.signNip51List(createdAt, KIND, publicTagArray, privateTagArray) @@ -204,8 +204,8 @@ class HashtagListEvent( privateHashtags: List<String> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<HashtagListEvent>.() -> Unit = {}, - ) = eventTemplate<HashtagListEvent>( + initializer: TagArrayBuilder<InterestListEvent>.() -> Unit = {}, + ) = eventTemplate<InterestListEvent>( kind = KIND, description = PrivateTagsInContent.encryptNip44(privateHashtags.map { HashtagTag.assemble(it) }.toTypedArray(), signer), createdAt = createdAt, @@ -216,3 +216,9 @@ class HashtagListEvent( } } } + +@Deprecated( + "Renamed to InterestListEvent. NIP-51 names kind 10015 the interests list.", + ReplaceWith("InterestListEvent", "com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent"), +) +typealias HashtagListEvent = InterestListEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayBuilderExt.kt index 5d271de593..70977ca9b7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayBuilderExt.kt @@ -23,6 +23,6 @@ package com.vitorpamplona.quartz.nip51Lists.hashtagList import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip01Core.tags.hashtags.HashtagTag -fun TagArrayBuilder<HashtagListEvent>.followHashTag(hashtag: String) = add(HashtagTag.assemble(hashtag)) +fun TagArrayBuilder<InterestListEvent>.followHashTag(hashtag: String) = add(HashtagTag.assemble(hashtag)) -fun TagArrayBuilder<HashtagListEvent>.hashtags(hashtags: List<String>) = addAll(hashtags.map { HashtagTag.assemble(it) }) +fun TagArrayBuilder<InterestListEvent>.hashtags(hashtags: List<String>) = addAll(hashtags.map { HashtagTag.assemble(it) }) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/LabeledBookmarkListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/BookmarkSetEvent.kt similarity index 94% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/LabeledBookmarkListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/BookmarkSetEvent.kt index 2edbdca9e1..01494372a3 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/LabeledBookmarkListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/BookmarkSetEvent.kt @@ -49,7 +49,7 @@ import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @Immutable -class LabeledBookmarkListEvent( +class BookmarkSetEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -113,7 +113,7 @@ class LabeledBookmarkListEvent( optionalListDescription: String? = null, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent = + ): BookmarkSetEvent = if (isPrivate) { create( title = title, @@ -135,12 +135,12 @@ class LabeledBookmarkListEvent( } suspend fun addBookmark( - earlierVersion: LabeledBookmarkListEvent, + earlierVersion: BookmarkSetEvent, bookmarkIdTag: BookmarkIdTag, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent = + ): BookmarkSetEvent = if (isPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() resign( @@ -159,12 +159,12 @@ class LabeledBookmarkListEvent( } suspend fun moveBookmark( - earlierVersion: LabeledBookmarkListEvent, + earlierVersion: BookmarkSetEvent, bookmarkIdTag: BookmarkIdTag, isCurrentlyPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent = + ): BookmarkSetEvent = if (isCurrentlyPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() resign( @@ -184,12 +184,12 @@ class LabeledBookmarkListEvent( } suspend fun removeBookmark( - earlierVersion: LabeledBookmarkListEvent, + earlierVersion: BookmarkSetEvent, bookmarkIdTag: BookmarkIdTag, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent = + ): BookmarkSetEvent = if (isPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() resign( @@ -208,11 +208,11 @@ class LabeledBookmarkListEvent( } suspend fun modifyName( - earlierVersion: LabeledBookmarkListEvent, + earlierVersion: BookmarkSetEvent, newTitle: String, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent { + ): BookmarkSetEvent { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() val currentTitle = earlierVersion.tags.first { it[0] == NameTag.TAG_NAME || it[0] == TitleTag.TAG_NAME } val newTitleTag = @@ -231,11 +231,11 @@ class LabeledBookmarkListEvent( } suspend fun modifyDescription( - earlierVersion: LabeledBookmarkListEvent, + earlierVersion: BookmarkSetEvent, newDescription: String?, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent? { + ): BookmarkSetEvent? { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() val currentDescriptionTag = earlierVersion.tags.firstOrNull { it[0] == DescriptionTag.TAG_NAME } val currentDescription = currentDescriptionTag?.get(1) @@ -288,7 +288,7 @@ class LabeledBookmarkListEvent( tags: TagArray, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent { + ): BookmarkSetEvent { val newTags = tags return signer.sign(createdAt, KIND, newTags, content) @@ -304,7 +304,7 @@ class LabeledBookmarkListEvent( dTag: String = Uuid.random().toString(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): LabeledBookmarkListEvent { + ): BookmarkSetEvent { val template = build(title, publicBookmarks, privateBookmarks, signer, dTag, createdAt) { if (description != null) description(description) @@ -321,7 +321,7 @@ class LabeledBookmarkListEvent( signer: NostrSigner, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<LabeledBookmarkListEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<BookmarkSetEvent>.() -> Unit = {}, ) = eventTemplate( kind = KIND, description = PrivateTagsInContent.encryptNip44(privateBookmarks.map { it.toTagArray() }.toTypedArray(), signer), @@ -335,3 +335,9 @@ class LabeledBookmarkListEvent( } } } + +@Deprecated( + "Renamed to BookmarkSetEvent. NIP-51 names kind 30003 bookmark sets.", + ReplaceWith("BookmarkSetEvent", "com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent"), +) +typealias LabeledBookmarkListEvent = BookmarkSetEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/TagArrayBuilderExt.kt index 109d81a516..5754f4f9f2 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/TagArrayBuilderExt.kt @@ -28,12 +28,12 @@ import com.vitorpamplona.quartz.nip51Lists.tags.NameTag import com.vitorpamplona.quartz.nip51Lists.tags.TitleTag @Deprecated("NIP-51 has deprecated name. Use title instead", ReplaceWith("title()")) -fun TagArrayBuilder<LabeledBookmarkListEvent>.name(name: String) = addUnique(NameTag.assemble(name)) +fun TagArrayBuilder<BookmarkSetEvent>.name(name: String) = addUnique(NameTag.assemble(name)) -fun TagArrayBuilder<LabeledBookmarkListEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) +fun TagArrayBuilder<BookmarkSetEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) -fun TagArrayBuilder<LabeledBookmarkListEvent>.bookmarks(bookmarks: List<BookmarkIdTag>) = addAll(bookmarks.map { it.toTagArray() }) +fun TagArrayBuilder<BookmarkSetEvent>.bookmarks(bookmarks: List<BookmarkIdTag>) = addAll(bookmarks.map { it.toTagArray() }) -fun TagArrayBuilder<LabeledBookmarkListEvent>.description(listDescription: String) = addUnique(DescriptionTag.assemble(listDescription)) +fun TagArrayBuilder<BookmarkSetEvent>.description(listDescription: String) = addUnique(DescriptionTag.assemble(listDescription)) -fun TagArrayBuilder<LabeledBookmarkListEvent>.image(url: String) = addUnique(ImageTag.assemble(url)) +fun TagArrayBuilder<BookmarkSetEvent>.image(url: String) = addUnique(ImageTag.assemble(url)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/PeopleListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/FollowSetEvent.kt similarity index 93% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/PeopleListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/FollowSetEvent.kt index 906f06587e..d10d7de69b 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/PeopleListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/FollowSetEvent.kt @@ -48,7 +48,7 @@ import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @Immutable -class PeopleListEvent( +class FollowSetEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -121,7 +121,7 @@ class PeopleListEvent( signer: NostrSigner, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - ): PeopleListEvent = + ): FollowSetEvent = if (isPrivate) { create( title = title, @@ -143,12 +143,12 @@ class PeopleListEvent( } suspend fun add( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, person: UserTag, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent = + ): FollowSetEvent = if (isPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() resign( @@ -167,12 +167,12 @@ class PeopleListEvent( } suspend fun addFirst( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, person: UserTag, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent = + ): FollowSetEvent = if (isPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() resign( @@ -191,11 +191,11 @@ class PeopleListEvent( } suspend fun remove( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, person: MuteTag, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent { + ): FollowSetEvent { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() return resign( @@ -207,11 +207,11 @@ class PeopleListEvent( } suspend fun removeAll( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, persons: List<MuteTag>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent { + ): FollowSetEvent { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() val ids = persons.map { it.toTagIdOnly() } @@ -224,12 +224,12 @@ class PeopleListEvent( } suspend fun remove( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, person: UserTag, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent { + ): FollowSetEvent { if (isPrivate) { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() return resign( @@ -265,7 +265,7 @@ class PeopleListEvent( tags: Array<Array<String>>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent { + ): FollowSetEvent { val newTags = tags return signer.sign(createdAt, KIND, newTags, content) @@ -279,7 +279,7 @@ class PeopleListEvent( signer: NostrSigner, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - ): PeopleListEvent { + ): FollowSetEvent { val template = build(title, publicMembers, privateMembers, signer, dTag, createdAt) return signer.sign(template) } @@ -292,8 +292,8 @@ class PeopleListEvent( signer: NostrSigner, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<PeopleListEvent>.() -> Unit = {}, - ) = eventTemplate<PeopleListEvent>( + initializer: TagArrayBuilder<FollowSetEvent>.() -> Unit = {}, + ) = eventTemplate<FollowSetEvent>( kind = KIND, description = PrivateTagsInContent.encryptNip44(privateMembers.map { it.toTagArray() }.toTypedArray(), signer), createdAt = createdAt, @@ -313,7 +313,7 @@ class PeopleListEvent( privateMembers: List<UserTag> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent { + ): FollowSetEvent { val newListTemplate = build( title = title, @@ -336,7 +336,7 @@ class PeopleListEvent( privateMembers: List<UserTag> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent { + ): FollowSetEvent { val cloneTemplate = build( title = title, @@ -358,7 +358,7 @@ class PeopleListEvent( isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent = + ): FollowSetEvent = create( title = title, person = UserTag(pubKey = pubKeyHex), @@ -368,13 +368,13 @@ class PeopleListEvent( ) suspend fun addUser( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, pubKeyHex: String, relayHint: NormalizedRelayUrl?, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent = + ): FollowSetEvent = add( earlierVersion = earlierVersion, person = UserTag(pubKey = pubKeyHex, relayHint), @@ -384,13 +384,13 @@ class PeopleListEvent( ) suspend fun addUserFirst( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, pubKeyHex: String, relayHint: NormalizedRelayUrl?, isPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent = + ): FollowSetEvent = addFirst( earlierVersion = earlierVersion, person = UserTag(pubKey = pubKeyHex, relayHint), @@ -400,12 +400,12 @@ class PeopleListEvent( ) suspend fun removeUser( - earlierVersion: PeopleListEvent, + earlierVersion: FollowSetEvent, pubKeyHex: String, isUserPrivate: Boolean, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): PeopleListEvent = + ): FollowSetEvent = remove( earlierVersion = earlierVersion, person = UserTag(pubKey = pubKeyHex), @@ -415,3 +415,9 @@ class PeopleListEvent( ) } } + +@Deprecated( + "Renamed to FollowSetEvent. NIP-51 names kind 30000 follow sets.", + ReplaceWith("FollowSetEvent", "com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent"), +) +typealias PeopleListEvent = FollowSetEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayBuilderExt.kt index 5129023f76..9a07db2fec 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayBuilderExt.kt @@ -28,12 +28,12 @@ import com.vitorpamplona.quartz.nip51Lists.tags.NameTag import com.vitorpamplona.quartz.nip51Lists.tags.TitleTag @Deprecated("NIP-51 has deprecated name. Use title instead", ReplaceWith("title()")) -fun TagArrayBuilder<PeopleListEvent>.name(name: String) = addUnique(NameTag.assemble(name)) +fun TagArrayBuilder<FollowSetEvent>.name(name: String) = addUnique(NameTag.assemble(name)) -fun TagArrayBuilder<PeopleListEvent>.title(name: String) = addUnique(TitleTag.assemble(name)) +fun TagArrayBuilder<FollowSetEvent>.title(name: String) = addUnique(TitleTag.assemble(name)) -fun TagArrayBuilder<PeopleListEvent>.description(desc: String) = addUnique(DescriptionTag.assemble(desc)) +fun TagArrayBuilder<FollowSetEvent>.description(desc: String) = addUnique(DescriptionTag.assemble(desc)) -fun TagArrayBuilder<PeopleListEvent>.image(url: String) = addUnique(ImageTag.assemble(url)) +fun TagArrayBuilder<FollowSetEvent>.image(url: String) = addUnique(ImageTag.assemble(url)) -fun TagArrayBuilder<PeopleListEvent>.peoples(peoples: List<UserTag>) = addAll(peoples.map { it.toTagArray() }) +fun TagArrayBuilder<FollowSetEvent>.peoples(peoples: List<UserTag>) = addAll(peoples.map { it.toTagArray() }) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayFeedsListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/FavoriteRelayListEvent.kt similarity index 88% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayFeedsListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/FavoriteRelayListEvent.kt index a758db06d1..29179f5d54 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayFeedsListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/FavoriteRelayListEvent.kt @@ -44,7 +44,7 @@ import com.vitorpamplona.quartz.nip51Lists.splitRelayListUpdate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class RelayFeedsListEvent( +class FavoriteRelayListEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -54,7 +54,7 @@ class RelayFeedsListEvent( ) : PrivateTagArrayEvent(id, pubKey, createdAt, KIND, tags, content, sig), DiffableEvent<RelayListDiff> { override fun diffFrom(older: Event): RelayListDiff? { - if (older !is RelayFeedsListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null + if (older !is FavoriteRelayListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null return RelayListDiff(ListDiff.of(older.publicRelays(), publicRelays(), { it }), privateItemsChangeFrom(older)) } @@ -74,11 +74,11 @@ class RelayFeedsListEvent( fun createAddressTag(pubKey: HexKey): String = Address.Companion.assemble(KIND, pubKey, "") suspend fun updateRelayList( - earlierVersion: RelayFeedsListEvent, + earlierVersion: FavoriteRelayListEvent, relays: List<NormalizedRelayUrl>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): RelayFeedsListEvent { + ): FavoriteRelayListEvent { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() // Keeps public relays public and private relays private: rewriting them all as @@ -95,7 +95,7 @@ class RelayFeedsListEvent( relays: List<NormalizedRelayUrl>, signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): RelayFeedsListEvent { + ): FavoriteRelayListEvent { val privateTagArray = relays.map { RelayTag.assemble(it) }.toTypedArray() return signer.signNip51List(createdAt, KIND, emptyArray(), privateTagArray) } @@ -104,7 +104,7 @@ class RelayFeedsListEvent( relays: List<NormalizedRelayUrl>, signer: NostrSignerSync, createdAt: Long = TimeUtils.now(), - ): RelayFeedsListEvent { + ): FavoriteRelayListEvent { val privateTagArray = relays.map { RelayTag.assemble(it) }.toTypedArray() return signer.signNip51List(createdAt, KIND, emptyArray(), privateTagArray) } @@ -114,8 +114,8 @@ class RelayFeedsListEvent( privateRelays: List<NormalizedRelayUrl> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<RelayFeedsListEvent>.() -> Unit = {}, - ) = eventTemplate<RelayFeedsListEvent>( + initializer: TagArrayBuilder<FavoriteRelayListEvent>.() -> Unit = {}, + ) = eventTemplate<FavoriteRelayListEvent>( kind = KIND, description = PrivateTagsInContent.encryptNip44(privateRelays.map { RelayTag.assemble(it) }.toTypedArray(), signer), createdAt = createdAt, @@ -126,3 +126,9 @@ class RelayFeedsListEvent( } } } + +@Deprecated( + "Renamed to FavoriteRelayListEvent. NIP-51 names kind 10012 the favorite relays list.", + ReplaceWith("FavoriteRelayListEvent", "com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent"), +) +typealias RelayFeedsListEvent = FavoriteRelayListEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/tags/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/tags/TagArrayBuilderExt.kt index ecbc663eea..c2dfb98574 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/tags/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/tags/TagArrayBuilderExt.kt @@ -27,9 +27,9 @@ import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.tags.NameTag @@ -52,4 +52,4 @@ fun TagArrayBuilder<PrivateOutboxRelayListEvent>.privateRelays(relays: List<Norm fun TagArrayBuilder<RelaySetEvent>.relaySet(relays: List<NormalizedRelayUrl>) = addAll(relays.map { RelayTag.assemble(it) }) -fun TagArrayBuilder<RelayFeedsListEvent>.relayFeeds(relays: List<NormalizedRelayUrl>) = addAll(relays.map { RelayTag.assemble(it) }) +fun TagArrayBuilder<FavoriteRelayListEvent>.relayFeeds(relays: List<NormalizedRelayUrl>) = addAll(relays.map { RelayTag.assemble(it) }) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt index 99bb13f527..b3c2dee634 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt @@ -21,11 +21,18 @@ package com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet import androidx.compose.runtime.Immutable +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.SoftwareAssetEvent +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.appId +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.assets +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.channel +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.version import com.vitorpamplona.quartz.nip01Core.core.Address +import com.vitorpamplona.quartz.nip01Core.core.BaseAddressableEvent import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.TagArray import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip01Core.hints.AddressHintProvider +import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle import com.vitorpamplona.quartz.nip01Core.hints.EventHintProvider import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate @@ -42,6 +49,15 @@ import com.vitorpamplona.quartz.utils.TimeUtils import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid +/** + * Kind 30063: the artifacts of one software release. + * + * Two specs publish this kind and both are parsed here: + * - NIP-51 "release artifact set": a `title`, a `description` and `e`/`a` items. + * - NIP-82 "software release": `d = <app-id>@<version>`, `i` (app id), `version`, + * `c` (channel), `e` tags to its kind 3063 assets, and the release notes as content. + * Use `isNip82SoftwareRelease()` to tell them apart. + */ @Immutable class ReleaseArtifactSetEvent( id: HexKey, @@ -50,7 +66,7 @@ class ReleaseArtifactSetEvent( tags: Array<Array<String>>, content: String, sig: HexKey, -) : com.vitorpamplona.quartz.nip01Core.core.BaseAddressableEvent(id, pubKey, createdAt, KIND, tags, content, sig), +) : BaseAddressableEvent(id, pubKey, createdAt, KIND, tags, content, sig), EventHintProvider, AddressHintProvider, SearchableEvent { @@ -77,9 +93,48 @@ class ReleaseArtifactSetEvent( fun items(): List<BookmarkIdTag> = tags.mapNotNull(BookmarkIdTag::parse) + /** NIP-82: the application identifier (`i` tag). */ + fun appId() = tags.appId() + + /** NIP-82: the release version. */ + fun version() = tags.version() + + /** NIP-82: the release channel (`c` tag). */ + fun channel() = tags.channel() + + /** NIP-82: the kind 3063 assets of this release. */ + fun assets() = tags.assets() + + /** NIP-82: the release notes. */ + fun releaseNotes() = content + companion object { const val KIND = 30063 + /** NIP-82 requires `d = <app-id>@<version>`. */ + fun buildSoftwareReleaseDTag( + appId: String, + version: String, + ) = "$appId@$version" + + /** Builds a NIP-82 software release. */ + fun buildSoftwareRelease( + appId: String, + version: String, + channel: String, + assets: List<EventHintBundle<SoftwareAssetEvent>>, + releaseNotes: String = "", + createdAt: Long = TimeUtils.now(), + initializer: TagArrayBuilder<ReleaseArtifactSetEvent>.() -> Unit = {}, + ) = eventTemplate(KIND, releaseNotes, createdAt) { + dTag(buildSoftwareReleaseDTag(appId, version)) + appId(appId) + version(version) + channel(channel) + assets(assets) + initializer() + } + fun createAddress( pubKey: HexKey, dTag: String, diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/CalendarEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/CalendarCollectionEvent.kt similarity index 89% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/CalendarEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/CalendarCollectionEvent.kt index 5bbebfda64..f9347efae3 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/CalendarEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/CalendarCollectionEvent.kt @@ -37,7 +37,7 @@ import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @Immutable -class CalendarEvent( +class CalendarCollectionEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -76,7 +76,7 @@ class CalendarEvent( content: String = "", dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<CalendarEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<CalendarCollectionEvent>.() -> Unit = {}, ) = eventTemplate(KIND, content, createdAt) { dTag(dTag) title(title) @@ -84,3 +84,9 @@ class CalendarEvent( } } } + +@Deprecated( + "Renamed to CalendarCollectionEvent. NIP-52 kind 31924 is a calendar (a collection of calendar events), not a calendar event.", + ReplaceWith("CalendarCollectionEvent", "com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent"), +) +typealias CalendarEvent = CalendarCollectionEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/TagArrayBuilderExt.kt index 5e0a174929..2376bb6f97 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip52Calendar/calendar/TagArrayBuilderExt.kt @@ -23,6 +23,6 @@ package com.vitorpamplona.quartz.nip52Calendar.calendar import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip23LongContent.tags.TitleTag -// CalendarEvent builder extensions +// CalendarCollectionEvent builder extensions -fun TagArrayBuilder<CalendarEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) +fun TagArrayBuilder<CalendarCollectionEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/TagArrayBuilderExt.kt index fc7bcb353a..eb73b29190 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/TagArrayBuilderExt.kt @@ -26,10 +26,10 @@ import com.vitorpamplona.quartz.nip23LongContent.tags.PublishedAtTag import com.vitorpamplona.quartz.nip23LongContent.tags.SummaryTag import com.vitorpamplona.quartz.nip23LongContent.tags.TitleTag -fun TagArrayBuilder<WikiNoteEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) +fun TagArrayBuilder<WikiArticleEvent>.title(title: String) = addUnique(TitleTag.assemble(title)) -fun TagArrayBuilder<WikiNoteEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) +fun TagArrayBuilder<WikiArticleEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) -fun TagArrayBuilder<WikiNoteEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) +fun TagArrayBuilder<WikiArticleEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) -fun TagArrayBuilder<WikiNoteEvent>.publishedAt(publishedAt: Long) = addUnique(PublishedAtTag.assemble(publishedAt)) +fun TagArrayBuilder<WikiArticleEvent>.publishedAt(publishedAt: Long) = addUnique(PublishedAtTag.assemble(publishedAt)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiNoteEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiArticleEvent.kt similarity index 95% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiNoteEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiArticleEvent.kt index 42cae11b8a..ce75d16efb 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiNoteEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiArticleEvent.kt @@ -62,7 +62,7 @@ import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @Immutable -class WikiNoteEvent( +class WikiArticleEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -177,8 +177,8 @@ class WikiNoteEvent( publishedAt: Long? = null, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<WikiNoteEvent>.() -> Unit = {}, - ): EventTemplate<WikiNoteEvent> = + initializer: TagArrayBuilder<WikiArticleEvent>.() -> Unit = {}, + ): EventTemplate<WikiArticleEvent> = eventTemplate(KIND, description, createdAt) { dTag(dTag) @@ -191,3 +191,9 @@ class WikiNoteEvent( } } } + +@Deprecated( + "Renamed to WikiArticleEvent. NIP-54 names kind 30818 the wiki article.", + ReplaceWith("WikiArticleEvent", "com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent"), +) +typealias WikiNoteEvent = WikiArticleEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt index 2b717721b2..bae51c5c4f 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt @@ -25,7 +25,7 @@ package com.vitorpamplona.quartz.nip57Zaps * Used by Note.kt for checking private zap status. */ interface IPrivateZapsDecryptionCache { - fun cachedPrivateZap(event: LnZapRequestEvent): LnZapPrivateEvent? + fun cachedPrivateZap(event: ZapRequestEvent): LnZapPrivateEvent? - suspend fun decryptPrivateZap(event: LnZapRequestEvent): LnZapPrivateEvent? + suspend fun decryptPrivateZap(event: ZapRequestEvent): LnZapPrivateEvent? } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt index 129d64a346..57eb0a796c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt @@ -28,8 +28,8 @@ class PrivateZapCache( signer: NostrSigner, ) : IPrivateZapsDecryptionCache { private val decryptionCache = - object : LruCache<LnZapRequestEvent, PrivateZapDecryptCache>(1000) { - override fun create(key: LnZapRequestEvent): PrivateZapDecryptCache? { + object : LruCache<ZapRequestEvent, PrivateZapDecryptCache>(1000) { + override fun create(key: ZapRequestEvent): PrivateZapDecryptCache? { val zappedAuthor = key.zappedAuthor().firstOrNull() return if (key.isPrivateZap() && zappedAuthor != null) { PrivateZapDecryptCache(signer) @@ -39,20 +39,20 @@ class PrivateZapCache( } } - fun delete(event: LnZapRequestEvent) { + fun delete(event: ZapRequestEvent) { decryptionCache.remove(event) } - override fun cachedPrivateZap(event: LnZapRequestEvent): LnZapPrivateEvent? = decryptionCache[event]?.cached() + override fun cachedPrivateZap(event: ZapRequestEvent): LnZapPrivateEvent? = decryptionCache[event]?.cached() - override suspend fun decryptPrivateZap(event: LnZapRequestEvent) = decryptionCache[event]?.decrypt(event) + override suspend fun decryptPrivateZap(event: ZapRequestEvent) = decryptionCache[event]?.decrypt(event) } class PrivateZapDecryptCache( signer: NostrSigner, -) : DecryptCache<LnZapRequestEvent, LnZapPrivateEvent>(signer) { +) : DecryptCache<ZapRequestEvent, LnZapPrivateEvent>(signer) { override suspend fun decryptAndParse( - event: LnZapRequestEvent, + event: ZapRequestEvent, signer: NostrSigner, ): LnZapPrivateEvent = signer.decryptZapEvent(event) } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt index 2b91ea6934..595dc24600 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt @@ -73,7 +73,7 @@ class PrivateZapRequestBuilder { } fun decryptZapEvent( - event: LnZapRequestEvent, + event: ZapRequestEvent, signer: NostrSignerSync, ): LnZapPrivateEvent { if (signer.keyPair.privKey == null) throw SignerExceptions.ReadOnlyException() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapReceiptEvent.kt similarity index 87% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapReceiptEvent.kt index 5bbf5d889e..c8df2c63a9 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapReceiptEvent.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip50Search.SearchableEvent import com.vitorpamplona.quartz.utils.Log @Immutable -class LnZapEvent( +class ZapReceiptEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -44,7 +44,7 @@ class LnZapEvent( content: String, sig: HexKey, ) : Event(id, pubKey, createdAt, KIND, tags, content, sig), - LnZapEventInterface, + ZapReceiptEventInterface, EventHintProvider, AddressHintProvider, PubKeyHintProvider, @@ -75,23 +75,23 @@ class LnZapEvent( // This event is also kept in LocalCache (same object) @kotlinx.serialization.Transient @kotlin.jvm.Transient - val zapRequest: LnZapRequestEvent? + val zapRequest: ZapRequestEvent? // Keeps this as a field because it's a heavier function used everywhere. val amount by lazy { try { lnInvoice()?.let { LnInvoiceUtil.getAmountInSats(it) } } catch (e: Exception) { - Log.e("LnZapEvent", "Failed to Parse LnInvoice ${lnInvoice()}", e) + Log.e("ZapReceiptEvent", "Failed to Parse LnInvoice ${lnInvoice()}", e) null } } - override fun containedPost(): LnZapRequestEvent? = + override fun containedPost(): ZapRequestEvent? = try { - description()?.ifBlank { null }?.let { fromJson(it) } as? LnZapRequestEvent + description()?.ifBlank { null }?.let { fromJson(it) } as? ZapRequestEvent } catch (e: Exception) { - Log.w("LnZapEvent", "Failed to Parse Contained Post ${description()} in event $id", e) + Log.w("ZapReceiptEvent", "Failed to Parse Contained Post ${description()} in event $id", e) null } @@ -111,7 +111,7 @@ class LnZapEvent( ?.get(1) ?.toInt() } catch (e: Exception) { - Log.e("LnZapEvent", "ZappedPollOption failed to parse", e) + Log.e("ZapReceiptEvent", "ZappedPollOption failed to parse", e) null } @@ -135,3 +135,9 @@ class LnZapEvent( NONZAP, } } + +@Deprecated( + "Renamed to ZapReceiptEvent. NIP-57 names kind 9735 the zap receipt.", + ReplaceWith("ZapReceiptEvent", "com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent"), +) +typealias LnZapEvent = ZapReceiptEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapEventInterface.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapReceiptEventInterface.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapEventInterface.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapReceiptEventInterface.kt index d5fc8c0d96..5a188986a1 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapEventInterface.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapReceiptEventInterface.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.utils.BigDecimal @Immutable -interface LnZapEventInterface { +interface ZapReceiptEventInterface { fun zappedPost(): List<String> fun zappedPollOption(): Int? @@ -38,3 +38,9 @@ interface LnZapEventInterface { fun containedPost(): Event? } + +@Deprecated( + "Renamed to ZapReceiptEventInterface. Follows the LnZapEvent to ZapReceiptEvent rename (NIP-57 zap receipt).", + ReplaceWith("ZapReceiptEventInterface", "com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEventInterface"), +) +typealias LnZapEventInterface = ZapReceiptEventInterface diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestEvent.kt similarity index 91% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestEvent.kt index 7347f6bf62..7896537350 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestEvent.kt @@ -43,7 +43,7 @@ import com.vitorpamplona.quartz.nip50Search.SearchableEvent import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class LnZapRequestEvent( +class ZapRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -113,12 +113,12 @@ class LnZapRequestEvent( signer: NostrSigner, pollOption: Int?, message: String, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, toUserPubHex: String?, amountMillisats: Long? = null, lnurl: String? = null, createdAt: Long = TimeUtils.now(), - ): LnZapRequestEvent { + ): ZapRequestEvent { var tags = listOf( arrayOf("e", zappedEvent.id), @@ -146,21 +146,21 @@ class LnZapRequestEvent( } return when (zapType) { - LnZapEvent.ZapType.PUBLIC -> { + ZapReceiptEvent.ZapType.PUBLIC -> { signer.sign(createdAt, KIND, tags.toTypedArray(), message) } - LnZapEvent.ZapType.ANONYMOUS -> { + ZapReceiptEvent.ZapType.ANONYMOUS -> { tags = tags + listOf(arrayOf("anon")) NostrSignerInternal(KeyPair()).sign(createdAt, KIND, tags.toTypedArray(), message) } - LnZapEvent.ZapType.PRIVATE -> { + ZapReceiptEvent.ZapType.PRIVATE -> { tags = tags + listOf(arrayOf("anon", "")) signer.sign(createdAt, KIND, tags.toTypedArray(), message) } - LnZapEvent.ZapType.NONZAP -> { + ZapReceiptEvent.ZapType.NONZAP -> { throw IllegalArgumentException("Invalid zap type") } } @@ -171,11 +171,11 @@ class LnZapRequestEvent( relays: Set<NormalizedRelayUrl>, signer: NostrSigner, message: String, - zapType: LnZapEvent.ZapType, + zapType: ZapReceiptEvent.ZapType, amountMillisats: Long? = null, lnurl: String? = null, createdAt: Long = TimeUtils.now(), - ): LnZapRequestEvent { + ): ZapRequestEvent { var tags = arrayOf( arrayOf("p", userHex), @@ -189,11 +189,11 @@ class LnZapRequestEvent( } return when (zapType) { - LnZapEvent.ZapType.PUBLIC -> { + ZapReceiptEvent.ZapType.PUBLIC -> { signer.sign(createdAt, KIND, tags, message) } - LnZapEvent.ZapType.ANONYMOUS -> { + ZapReceiptEvent.ZapType.ANONYMOUS -> { // Valueless `anon` tag: a blank-valued one (`["anon", ""]`) is the // marker for an *unsigned private* zap and would make the throwaway // signer encrypt the message instead of keeping it public. @@ -201,15 +201,21 @@ class LnZapRequestEvent( NostrSignerInternal(KeyPair()).sign(createdAt, KIND, tags, message) } - LnZapEvent.ZapType.PRIVATE -> { + ZapReceiptEvent.ZapType.PRIVATE -> { tags += arrayOf(arrayOf("anon", "")) signer.sign(createdAt, KIND, tags, message) } - LnZapEvent.ZapType.NONZAP -> { + ZapReceiptEvent.ZapType.NONZAP -> { throw IllegalArgumentException("Invalid zap type") } } } } } + +@Deprecated( + "Renamed to ZapRequestEvent. NIP-57 names kind 9734 the zap request.", + ReplaceWith("ZapRequestEvent", "com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent"), +) +typealias LnZapRequestEvent = ZapRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidator.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidator.kt index c6206814f5..da42cdb131 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidator.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidator.kt @@ -22,8 +22,8 @@ package com.vitorpamplona.quartz.nip57Zaps.validate import com.vitorpamplona.quartz.lightning.LnInvoiceUtil import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.utils.BigDecimal /** @@ -84,7 +84,7 @@ object LnZapReceiptValidator { * When true, a missing `amount` tag is treated as a failure. */ fun validate( - receipt: LnZapEvent, + receipt: ZapReceiptEvent, expectedNostrPubkey: HexKey?, expectedLnurl: String?, strictAmount: Boolean = false, @@ -141,13 +141,13 @@ object LnZapReceiptValidator { return Result.Valid } - private fun LnZapRequestEvent.amountMillisats(): Long? = + private fun ZapRequestEvent.amountMillisats(): Long? = tags .firstOrNull { it.size > 1 && it[0] == "amount" } ?.get(1) ?.toLongOrNull() - private fun LnZapRequestEvent.lnurl(): String? = + private fun ZapRequestEvent.lnurl(): String? = tags .firstOrNull { it.size > 1 && it[0] == "lnurl" } ?.get(1) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/HasInnerEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/HasInnerEvent.kt index 45b0b0af55..1e948258c7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/HasInnerEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/HasInnerEvent.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey /** * Marker for NIP-59 wrappers that carry an inner-event id once decrypted — - * GiftWrapEvent (and its subclasses) and SealedRumorEvent. Lets callers walk + * GiftWrapEvent (and its subclasses) and SealEvent. Lets callers walk * to the wrapped event without branching on the concrete wrapper type. */ interface HasInnerEvent { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/rumors/Rumor.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/rumors/Rumor.kt index c1ca788297..6d3d79d0b8 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/rumors/Rumor.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/rumors/Rumor.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.core.OptimizedJsonMapper import com.vitorpamplona.quartz.nip01Core.core.OptimizedSerializable import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher import com.vitorpamplona.quartz.nip59Giftwrap.rumors.kotlinSerialization.RumorKSerializer -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.utils.EventFactory import kotlinx.serialization.Serializable @@ -41,7 +41,7 @@ class Rumor( val tags: Array<Array<String>>?, val content: String?, ) : OptimizedSerializable { - fun mergeWith(event: SealedRumorEvent): Event { + fun mergeWith(event: SealEvent): Event { val newPubKey = event.pubKey // forces to be the pubkey of the seal to make sure impersonators don't impersonate val newCreatedAt = if (createdAt != null && createdAt > 1000) createdAt else event.createdAt val newKind = kind ?: -1 diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealedRumorEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealEvent.kt similarity index 93% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealedRumorEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealEvent.kt index d37a771984..badc0cbc7d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealedRumorEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip59Giftwrap/seals/SealEvent.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils import kotlin.concurrent.Volatile @Immutable -class SealedRumorEvent( +class SealEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -48,9 +48,9 @@ class SealedRumorEvent( @Volatile override var innerEventId: HexKey? = null - fun copyNoContent(): SealedRumorEvent { + fun copyNoContent(): SealEvent { val copy = - SealedRumorEvent( + SealEvent( id, pubKey, createdAt, @@ -98,7 +98,7 @@ class SealedRumorEvent( signer: NostrSigner, expirationDelta: Long? = null, createdAt: Long = TimeUtils.now(), - ): SealedRumorEvent { + ): SealEvent { val rumor = Rumor.create(event) return create(rumor, encryptTo, signer, expirationDelta, createdAt) } @@ -109,7 +109,7 @@ class SealedRumorEvent( signer: NostrSigner, expirationDelta: Long? = null, createdAt: Long = TimeUtils.randomWithTwoDays(), - ): SealedRumorEvent { + ): SealEvent { val msg = Rumor.toJson(rumor) val tags = @@ -128,3 +128,9 @@ class SealedRumorEvent( } } } + +@Deprecated( + "Renamed to SealEvent. NIP-59 names kind 13 the seal.", + ReplaceWith("SealEvent", "com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent"), +) +typealias SealedRumorEvent = SealEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/CashuSpendingHistoryEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/CashuSpendingHistoryEvent.kt index adcd455875..66cf469bf6 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/CashuSpendingHistoryEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/CashuSpendingHistoryEvent.kt @@ -25,10 +25,15 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.TagArray import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder +import com.vitorpamplona.quartz.nip01Core.hints.EventHintProvider +import com.vitorpamplona.quartz.nip01Core.hints.PubKeyHintProvider import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate +import com.vitorpamplona.quartz.nip01Core.tags.events.ETag +import com.vitorpamplona.quartz.nip01Core.tags.people.PTag import com.vitorpamplona.quartz.nip51Lists.encryption.PrivateTagsInContent +import com.vitorpamplona.quartz.nip61Nutzaps.redemption.redeemedNutzaps import com.vitorpamplona.quartz.utils.TimeUtils /** @@ -43,6 +48,10 @@ import com.vitorpamplona.quartz.utils.TimeUtils * * The "e" tags with "redeemed" marker SHOULD be left unencrypted in the tags array. * All other "e" tags should be encrypted in the content. + * + * NIP-61 nutzap redemptions are this same kind: a history entry whose public tags + * carry the redeemed nutzap (`["e", <nutzap-id>, <relay>, "redeemed"]`) and the + * sender's `p` tag. See `buildNutzapRedemption` in `nip61Nutzaps.redemption`. */ @Immutable class CashuSpendingHistoryEvent( @@ -52,7 +61,22 @@ class CashuSpendingHistoryEvent( tags: Array<Array<String>>, content: String, sig: HexKey, -) : Event(id, pubKey, createdAt, KIND, tags, content, sig) { +) : Event(id, pubKey, createdAt, KIND, tags, content, sig), + EventHintProvider, + PubKeyHintProvider { + override fun eventHints() = tags.mapNotNull(ETag::parseAsHint) + + override fun linkedEventIds() = tags.mapNotNull(ETag::parseId) + + override fun pubKeyHints() = tags.mapNotNull(PTag::parseAsHint) + + override fun linkedPubKeys() = tags.mapNotNull(PTag::parseKey) + + /** + * NIP-61: the nutzaps this entry redeemed, from the public `e` tags marked `redeemed`. + */ + fun redeemedNutzaps() = tags.redeemedNutzaps() + /** * Decrypts the content to get the private spending history tags. */ diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt index 8cfc908eef..1382f57b12 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt @@ -20,52 +20,37 @@ */ package com.vitorpamplona.quartz.nip61Nutzaps.redemption -import androidx.compose.runtime.Immutable -import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle -import com.vitorpamplona.quartz.nip01Core.hints.EventHintProvider -import com.vitorpamplona.quartz.nip01Core.hints.PubKeyHintProvider import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate -import com.vitorpamplona.quartz.nip01Core.tags.events.ETag -import com.vitorpamplona.quartz.nip01Core.tags.people.PTag +import com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.utils.TimeUtils -@Immutable -class NutzapRedemptionEvent( - id: HexKey, - pubKey: HexKey, - createdAt: Long, - tags: Array<Array<String>>, - content: String, - sig: HexKey, -) : Event(id, pubKey, createdAt, KIND, tags, content, sig), - EventHintProvider, - PubKeyHintProvider { - override fun eventHints() = tags.mapNotNull(ETag::parseAsHint) - - override fun linkedEventIds() = tags.mapNotNull(ETag::parseId) - - override fun pubKeyHints() = tags.mapNotNull(PTag::parseAsHint) - - override fun linkedPubKeys() = tags.mapNotNull(PTag::parseKey) - - fun redeemedNutzaps() = tags.redeemedNutzaps() - - companion object { - const val KIND = 7376 - - fun build( - nutzap: EventHintBundle<NutzapEvent>, - encryptedContent: String, - createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NutzapRedemptionEvent>.() -> Unit = {}, - ) = eventTemplate(KIND, encryptedContent, createdAt) { - redeemedNutzap(nutzap) - notifySender(nutzap) - initializer() - } - } +/** + * Builds a NIP-61 nutzap redemption: a NIP-60 spending history event (kind 7376) + * that publicly marks [nutzap] as redeemed and notifies its sender. + * + * [encryptedContent] is the NIP-44 encrypted history payload (direction, amount, ...). + */ +fun CashuSpendingHistoryEvent.Companion.buildNutzapRedemption( + nutzap: EventHintBundle<NutzapEvent>, + encryptedContent: String, + createdAt: Long = TimeUtils.now(), + initializer: TagArrayBuilder<CashuSpendingHistoryEvent>.() -> Unit = {}, +) = eventTemplate(KIND, encryptedContent, createdAt) { + redeemedNutzap(nutzap) + notifySender(nutzap) + initializer() } + +/** + * NIP-61 redemptions are NIP-60 spending history events (kind 7376). This used to be a + * second class for the same kind, which `EventFactory` could never instantiate because + * [CashuSpendingHistoryEvent] matched first. + */ +@Deprecated( + "Kind 7376 is the NIP-60 spending history event. Use CashuSpendingHistoryEvent and CashuSpendingHistoryEvent.buildNutzapRedemption.", + ReplaceWith("CashuSpendingHistoryEvent", "com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent"), +) +typealias NutzapRedemptionEvent = CashuSpendingHistoryEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/TagArrayBuilderExt.kt index 26ffc67ab9..cfd334df4e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/TagArrayBuilderExt.kt @@ -23,10 +23,11 @@ package com.vitorpamplona.quartz.nip61Nutzaps.redemption import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle import com.vitorpamplona.quartz.nip01Core.tags.people.PTag +import com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent import com.vitorpamplona.quartz.utils.arrayOfNotNull -fun TagArrayBuilder<NutzapRedemptionEvent>.redeemedNutzap(nutzap: EventHintBundle<NutzapEvent>) = +fun TagArrayBuilder<CashuSpendingHistoryEvent>.redeemedNutzap(nutzap: EventHintBundle<NutzapEvent>) = add( arrayOfNotNull( "e", @@ -36,4 +37,4 @@ fun TagArrayBuilder<NutzapRedemptionEvent>.redeemedNutzap(nutzap: EventHintBundl ), ) -fun TagArrayBuilder<NutzapRedemptionEvent>.notifySender(nutzap: EventHintBundle<NutzapEvent>) = add(PTag.assemble(nutzap.event.pubKey, nutzap.authorHomeRelay)) +fun TagArrayBuilder<CashuSpendingHistoryEvent>.notifySender(nutzap: EventHintBundle<NutzapEvent>) = add(PTag.assemble(nutzap.event.pubKey, nutzap.authorHomeRelay)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt index 0970ccde4a..0e72608c50 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt @@ -20,31 +20,15 @@ */ package com.vitorpamplona.quartz.nip61Nutzaps.token -import androidx.compose.runtime.Immutable -import com.vitorpamplona.quartz.nip01Core.core.Event -import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder -import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate -import com.vitorpamplona.quartz.utils.TimeUtils +import com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent -@Immutable -class TokenEvent( - id: HexKey, - pubKey: HexKey, - createdAt: Long, - tags: Array<Array<String>>, - content: String, - sig: HexKey, -) : Event(id, pubKey, createdAt, KIND, tags, content, sig) { - companion object { - const val KIND = 7375 - - fun build( - encryptedContent: String, - createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<TokenEvent>.() -> Unit = {}, - ) = eventTemplate(KIND, encryptedContent, createdAt) { - initializer() - } - } -} +/** + * NIP-61 does not define its own kind 7375: redeemed nutzap proofs are stored as + * ordinary NIP-60 wallet token events. This used to be a second class for the same + * kind, which `EventFactory` could never instantiate because [CashuTokenEvent] matched first. + */ +@Deprecated( + "Kind 7375 is the NIP-60 Cashu wallet token event. Use CashuTokenEvent.", + ReplaceWith("CashuTokenEvent", "com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent"), +) +typealias TokenEvent = CashuTokenEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/VideoHorizontalEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableNormalVideoEvent.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/VideoHorizontalEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableNormalVideoEvent.kt index 67abb889ff..9f979d38f0 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/VideoHorizontalEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableNormalVideoEvent.kt @@ -32,7 +32,7 @@ import kotlin.uuid.Uuid @Immutable @OptIn(ExperimentalUuidApi::class) -class VideoHorizontalEvent( +class AddressableNormalVideoEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -49,7 +49,7 @@ class VideoHorizontalEvent( description: String, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<VideoHorizontalEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<AddressableNormalVideoEvent>.() -> Unit = {}, ) = build(description, dTag, createdAt) { videoIMeta(video) initializer() @@ -60,7 +60,7 @@ class VideoHorizontalEvent( description: String, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<VideoHorizontalEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<AddressableNormalVideoEvent>.() -> Unit = {}, ) = build(description, dTag, createdAt) { videoIMetas(video) initializer() @@ -70,10 +70,16 @@ class VideoHorizontalEvent( description: String, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<VideoHorizontalEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<AddressableNormalVideoEvent>.() -> Unit = {}, ) = eventTemplate(KIND, description, createdAt) { dTag(dTag) initializer() } } } + +@Deprecated( + "Renamed to AddressableNormalVideoEvent. NIP-71 names kind 34235 the addressable normal video.", + ReplaceWith("AddressableNormalVideoEvent", "com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent"), +) +typealias VideoHorizontalEvent = AddressableNormalVideoEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/VideoVerticalEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableShortVideoEvent.kt similarity index 83% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/VideoVerticalEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableShortVideoEvent.kt index 880c8bf885..0c0347707d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/VideoVerticalEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableShortVideoEvent.kt @@ -32,7 +32,7 @@ import kotlin.uuid.Uuid @Immutable @OptIn(ExperimentalUuidApi::class) -class VideoVerticalEvent( +class AddressableShortVideoEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -49,7 +49,7 @@ class VideoVerticalEvent( description: String, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<VideoVerticalEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<AddressableShortVideoEvent>.() -> Unit = {}, ) = build(description, dTag, createdAt) { videoIMeta(video) initializer() @@ -59,10 +59,16 @@ class VideoVerticalEvent( description: String, dTag: String = Uuid.random().toString(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<VideoVerticalEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<AddressableShortVideoEvent>.() -> Unit = {}, ) = eventTemplate(KIND, description, createdAt) { dTag(dTag) initializer() } } } + +@Deprecated( + "Renamed to AddressableShortVideoEvent. NIP-71 names kind 34236 the addressable short video.", + ReplaceWith("AddressableShortVideoEvent", "com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent"), +) +typealias VideoVerticalEvent = AddressableShortVideoEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/TagArrayBuilderExt.kt index 117e00a207..3bde9fbdd1 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/TagArrayBuilderExt.kt @@ -30,16 +30,16 @@ import com.vitorpamplona.quartz.nip75ZapGoals.tags.AmountTag import com.vitorpamplona.quartz.nip75ZapGoals.tags.ClosedAtTag import com.vitorpamplona.quartz.nip75ZapGoals.tags.RelayListTag -fun TagArrayBuilder<GoalEvent>.amount(amountInMillisats: Long) = addUnique(AmountTag.assemble(amountInMillisats)) +fun TagArrayBuilder<ZapGoalEvent>.amount(amountInMillisats: Long) = addUnique(AmountTag.assemble(amountInMillisats)) -fun TagArrayBuilder<GoalEvent>.relays(urls: List<NormalizedRelayUrl>) = add(RelayListTag.assemble(urls)) +fun TagArrayBuilder<ZapGoalEvent>.relays(urls: List<NormalizedRelayUrl>) = add(RelayListTag.assemble(urls)) -fun TagArrayBuilder<GoalEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) +fun TagArrayBuilder<ZapGoalEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) -fun TagArrayBuilder<GoalEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) +fun TagArrayBuilder<ZapGoalEvent>.image(imageUrl: String) = addUnique(ImageTag.assemble(imageUrl)) -fun TagArrayBuilder<GoalEvent>.closedAt(closedAt: Long) = addUnique(ClosedAtTag.assemble(closedAt)) +fun TagArrayBuilder<ZapGoalEvent>.closedAt(closedAt: Long) = addUnique(ClosedAtTag.assemble(closedAt)) -fun TagArrayBuilder<GoalEvent>.linked(tag: ETag) = addUnique(tag.toTagArray()) +fun TagArrayBuilder<ZapGoalEvent>.linked(tag: ETag) = addUnique(tag.toTagArray()) -fun TagArrayBuilder<GoalEvent>.linked(tag: ATag) = addUnique(tag.toATagArray()) +fun TagArrayBuilder<ZapGoalEvent>.linked(tag: ATag) = addUnique(tag.toATagArray()) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/GoalEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/ZapGoalEvent.kt similarity index 94% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/GoalEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/ZapGoalEvent.kt index da7b923c80..66f3007031 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/GoalEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip75ZapGoals/ZapGoalEvent.kt @@ -48,7 +48,7 @@ import com.vitorpamplona.quartz.nip75ZapGoals.tags.RelayListTag import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class GoalEvent( +class ZapGoalEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -106,7 +106,7 @@ class GoalEvent( websiteUrl: String? = null, linkedEvent: EventHintBundle<Event>? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<GoalEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<ZapGoalEvent>.() -> Unit = {}, ) = eventTemplate(KIND, description, createdAt) { amount(amount) relays(relays) @@ -124,3 +124,9 @@ class GoalEvent( } } } + +@Deprecated( + "Renamed to ZapGoalEvent. NIP-75 names kind 9041 the zap goal.", + ReplaceWith("ZapGoalEvent", "com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent"), +) +typealias GoalEvent = ZapGoalEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/TagArrayBuilderExt.kt index 161912e25d..1cdb5412b7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/TagArrayBuilderExt.kt @@ -42,42 +42,42 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.users.tags.ZapAvgAmountDa import com.vitorpamplona.quartz.nip85TrustedAssertions.users.tags.ZapCountReceivedTag import com.vitorpamplona.quartz.nip85TrustedAssertions.users.tags.ZapCountSentTag -fun TagArrayBuilder<ContactCardEvent>.rank(rank: Int) = addUnique(RankTag.assemble(rank)) +fun TagArrayBuilder<UserAssertionEvent>.rank(rank: Int) = addUnique(RankTag.assemble(rank)) -fun TagArrayBuilder<ContactCardEvent>.followers(count: Int) = addUnique(FollowerCountTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.followers(count: Int) = addUnique(FollowerCountTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.hops(hops: Int) = addUnique(HopsTag.assemble(hops)) +fun TagArrayBuilder<UserAssertionEvent>.hops(hops: Int) = addUnique(HopsTag.assemble(hops)) -fun TagArrayBuilder<ContactCardEvent>.firstCreatedAt(timestamp: Long) = addUnique(FirstCreatedAtTag.assemble(timestamp)) +fun TagArrayBuilder<UserAssertionEvent>.firstCreatedAt(timestamp: Long) = addUnique(FirstCreatedAtTag.assemble(timestamp)) -fun TagArrayBuilder<ContactCardEvent>.postCount(count: Int) = addUnique(PostCountTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.postCount(count: Int) = addUnique(PostCountTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.replyCount(count: Int) = addUnique(ReplyCountTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.replyCount(count: Int) = addUnique(ReplyCountTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.reactionsCount(count: Int) = addUnique(ReactionsCountTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.reactionsCount(count: Int) = addUnique(ReactionsCountTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.zapAmountReceived(sats: Long) = addUnique(ZapAmountReceivedTag.assemble(sats)) +fun TagArrayBuilder<UserAssertionEvent>.zapAmountReceived(sats: Long) = addUnique(ZapAmountReceivedTag.assemble(sats)) -fun TagArrayBuilder<ContactCardEvent>.zapAmountSent(sats: Long) = addUnique(ZapAmountSentTag.assemble(sats)) +fun TagArrayBuilder<UserAssertionEvent>.zapAmountSent(sats: Long) = addUnique(ZapAmountSentTag.assemble(sats)) -fun TagArrayBuilder<ContactCardEvent>.zapCountReceived(count: Int) = addUnique(ZapCountReceivedTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.zapCountReceived(count: Int) = addUnique(ZapCountReceivedTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.zapCountSent(count: Int) = addUnique(ZapCountSentTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.zapCountSent(count: Int) = addUnique(ZapCountSentTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.zapAvgAmountDayReceived(sats: Long) = addUnique(ZapAvgAmountDayReceivedTag.assemble(sats)) +fun TagArrayBuilder<UserAssertionEvent>.zapAvgAmountDayReceived(sats: Long) = addUnique(ZapAvgAmountDayReceivedTag.assemble(sats)) -fun TagArrayBuilder<ContactCardEvent>.zapAvgAmountDaySent(sats: Long) = addUnique(ZapAvgAmountDaySentTag.assemble(sats)) +fun TagArrayBuilder<UserAssertionEvent>.zapAvgAmountDaySent(sats: Long) = addUnique(ZapAvgAmountDaySentTag.assemble(sats)) -fun TagArrayBuilder<ContactCardEvent>.reportsCountReceived(count: Int) = addUnique(ReportsCountReceivedTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.reportsCountReceived(count: Int) = addUnique(ReportsCountReceivedTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.reportsCountSent(count: Int) = addUnique(ReportsCountSentTag.assemble(count)) +fun TagArrayBuilder<UserAssertionEvent>.reportsCountSent(count: Int) = addUnique(ReportsCountSentTag.assemble(count)) -fun TagArrayBuilder<ContactCardEvent>.topic(topic: String) = add(TopicTag.assemble(topic)) +fun TagArrayBuilder<UserAssertionEvent>.topic(topic: String) = add(TopicTag.assemble(topic)) -fun TagArrayBuilder<ContactCardEvent>.activeHoursStart(hour: Int) = addUnique(ActiveHoursStartTag.assemble(hour)) +fun TagArrayBuilder<UserAssertionEvent>.activeHoursStart(hour: Int) = addUnique(ActiveHoursStartTag.assemble(hour)) -fun TagArrayBuilder<ContactCardEvent>.activeHoursEnd(hour: Int) = addUnique(ActiveHoursEndTag.assemble(hour)) +fun TagArrayBuilder<UserAssertionEvent>.activeHoursEnd(hour: Int) = addUnique(ActiveHoursEndTag.assemble(hour)) -fun TagArrayBuilder<ContactCardEvent>.petName(name: String) = addUnique(PetNameTag.assemble(name)) +fun TagArrayBuilder<UserAssertionEvent>.petName(name: String) = addUnique(PetNameTag.assemble(name)) -fun TagArrayBuilder<ContactCardEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) +fun TagArrayBuilder<UserAssertionEvent>.summary(summary: String) = addUnique(SummaryTag.assemble(summary)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/ContactCardEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/UserAssertionEvent.kt similarity index 89% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/ContactCardEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/UserAssertionEvent.kt index 91e7d58355..055df00154 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/ContactCardEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip85TrustedAssertions/users/UserAssertionEvent.kt @@ -43,7 +43,7 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.users.tags.SummaryTag import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class ContactCardEvent( +class UserAssertionEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -127,9 +127,9 @@ class ContactCardEvent( emojis: List<EmojiUrlTag> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - publicInitializer: TagArrayBuilder<ContactCardEvent>.() -> Unit = {}, - privateInitializer: TagArrayBuilder<ContactCardEvent>.() -> Unit = {}, - ): ContactCardEvent = signer.sign(build(targetUser, petName, summary, emojis, signer, createdAt, publicInitializer, privateInitializer)) + publicInitializer: TagArrayBuilder<UserAssertionEvent>.() -> Unit = {}, + privateInitializer: TagArrayBuilder<UserAssertionEvent>.() -> Unit = {}, + ): UserAssertionEvent = signer.sign(build(targetUser, petName, summary, emojis, signer, createdAt, publicInitializer, privateInitializer)) /** * Unsigned template for a new card about [targetUser]. The petname, summary @@ -143,9 +143,9 @@ class ContactCardEvent( emojis: List<EmojiUrlTag> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - publicInitializer: TagArrayBuilder<ContactCardEvent>.() -> Unit = {}, - privateInitializer: TagArrayBuilder<ContactCardEvent>.() -> Unit = {}, - ): EventTemplate<ContactCardEvent> { + publicInitializer: TagArrayBuilder<UserAssertionEvent>.() -> Unit = {}, + privateInitializer: TagArrayBuilder<UserAssertionEvent>.() -> Unit = {}, + ): EventTemplate<UserAssertionEvent> { val privateTags = tagArray { petName?.let { petName(it) } @@ -174,13 +174,13 @@ class ContactCardEvent( * [signer] only decrypts/encrypts here; the caller signs the template. */ suspend fun updatePetNameAndSummary( - earlierVersion: ContactCardEvent, + earlierVersion: UserAssertionEvent, petName: String? = null, summary: String? = null, emojis: List<EmojiUrlTag> = emptyList(), signer: NostrSigner, createdAt: Long = TimeUtils.now(), - ): EventTemplate<ContactCardEvent> { + ): EventTemplate<UserAssertionEvent> { val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException() @@ -211,3 +211,9 @@ class ContactCardEvent( } } } + +@Deprecated( + "Renamed to UserAssertionEvent. NIP-85 names kind 30382 the user trusted assertion.", + ReplaceWith("UserAssertionEvent", "com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent"), +) +typealias ContactCardEvent = UserAssertionEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt index 7cd234f925..48c72d8de2 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent /** * A [NostrSigner] decorator that automatically appends a NIP-89 client tag @@ -94,7 +94,7 @@ class NostrSignerWithClientTag( fromPublicKey: HexKey, ): String = inner.nip44Decrypt(ciphertext, fromPublicKey) - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = inner.decryptZapEvent(event) + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = inner.decryptZapEvent(event) override suspend fun deriveKey(nonce: HexKey): HexKey = inner.deriveKey(nonce) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/NIP90ContentDiscoveryRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/DvmContentDiscoveryRequestEvent.kt similarity index 85% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/NIP90ContentDiscoveryRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/DvmContentDiscoveryRequestEvent.kt index d6df3c9589..d7b0825f50 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/NIP90ContentDiscoveryRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/DvmContentDiscoveryRequestEvent.kt @@ -34,7 +34,7 @@ import com.vitorpamplona.quartz.utils.TimeUtils @Stable @Immutable -class NIP90ContentDiscoveryRequestEvent( +class DvmContentDiscoveryRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -62,7 +62,7 @@ class NIP90ContentDiscoveryRequestEvent( forUser: HexKey, relays: Set<NormalizedRelayUrl>, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ContentDiscoveryRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmContentDiscoveryRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { dvmPubKey(dvmPublicKey) relays(relays) @@ -72,3 +72,9 @@ class NIP90ContentDiscoveryRequestEvent( } } } + +@Deprecated( + "Renamed to DvmContentDiscoveryRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmContentDiscoveryRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent"), +) +typealias NIP90ContentDiscoveryRequestEvent = DvmContentDiscoveryRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/TagArrayBuilderExt.kt index b9ca5e65de..0af5322d05 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryRequest/TagArrayBuilderExt.kt @@ -26,11 +26,11 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.tags.ParamTag import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.tags.RelaysTag -fun TagArrayBuilder<NIP90ContentDiscoveryRequestEvent>.dvmPubKey(pubKey: HexKey) = addUnique(arrayOf("p", pubKey)) +fun TagArrayBuilder<DvmContentDiscoveryRequestEvent>.dvmPubKey(pubKey: HexKey) = addUnique(arrayOf("p", pubKey)) -fun TagArrayBuilder<NIP90ContentDiscoveryRequestEvent>.relays(relays: Set<NormalizedRelayUrl>) = addUnique(RelaysTag.assemble(relays)) +fun TagArrayBuilder<DvmContentDiscoveryRequestEvent>.relays(relays: Set<NormalizedRelayUrl>) = addUnique(RelaysTag.assemble(relays)) -fun TagArrayBuilder<NIP90ContentDiscoveryRequestEvent>.param( +fun TagArrayBuilder<DvmContentDiscoveryRequestEvent>.param( key: String, value: String, ) = add(ParamTag.assemble(key, value)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryResponse/NIP90ContentDiscoveryResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryResponse/DvmContentDiscoveryResponseEvent.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryResponse/NIP90ContentDiscoveryResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryResponse/DvmContentDiscoveryResponseEvent.kt index 105a1d1fde..8b2cd681f7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryResponse/NIP90ContentDiscoveryResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentDiscoveryResponse/DvmContentDiscoveryResponseEvent.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90ContentDiscoveryResponseEvent( +class DvmContentDiscoveryResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -61,7 +61,7 @@ class NIP90ContentDiscoveryResponseEvent( } } } catch (e: Throwable) { - Log.w("NIP90ContentDiscoveryResponseEvent") { "Error parsing the JSON ${e.message}" } + Log.w("DvmContentDiscoveryResponseEvent") { "Error parsing the JSON ${e.message}" } } return events ?: listOf() @@ -72,9 +72,15 @@ class NIP90ContentDiscoveryResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ContentDiscoveryResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmContentDiscoveryResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmContentDiscoveryResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmContentDiscoveryResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent"), +) +typealias NIP90ContentDiscoveryResponseEvent = DvmContentDiscoveryResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/NIP90ContentSearchRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/DvmContentSearchRequestEvent.kt similarity index 89% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/NIP90ContentSearchRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/DvmContentSearchRequestEvent.kt index ca04176d38..910922bd11 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/NIP90ContentSearchRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/DvmContentSearchRequestEvent.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90ContentSearchRequestEvent( +class DvmContentSearchRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -76,7 +76,7 @@ class NIP90ContentSearchRequestEvent( until: Long? = null, maxResults: Int? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ContentSearchRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmContentSearchRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputText(searchQuery) users?.let { param("users", it) } @@ -87,3 +87,9 @@ class NIP90ContentSearchRequestEvent( } } } + +@Deprecated( + "Renamed to DvmContentSearchRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmContentSearchRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.contentSearch.DvmContentSearchRequestEvent"), +) +typealias NIP90ContentSearchRequestEvent = DvmContentSearchRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/NIP90ContentSearchResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/DvmContentSearchResponseEvent.kt similarity index 83% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/NIP90ContentSearchResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/DvmContentSearchResponseEvent.kt index 894a70dc90..013fa3abc7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/NIP90ContentSearchResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/contentSearch/DvmContentSearchResponseEvent.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90ContentSearchResponseEvent( +class DvmContentSearchResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -61,7 +61,7 @@ class NIP90ContentSearchResponseEvent( } } } catch (e: Throwable) { - Log.w("NIP90ContentSearchResponseEvent") { "Error parsing the JSON ${e.message}" } + Log.w("DvmContentSearchResponseEvent") { "Error parsing the JSON ${e.message}" } } return events ?: listOf() @@ -72,9 +72,15 @@ class NIP90ContentSearchResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ContentSearchResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmContentSearchResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmContentSearchResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmContentSearchResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.contentSearch.DvmContentSearchResponseEvent"), +) +typealias NIP90ContentSearchResponseEvent = DvmContentSearchResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/NIP90EventCountRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/DvmEventCountRequestEvent.kt similarity index 86% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/NIP90EventCountRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/DvmEventCountRequestEvent.kt index 504672ea10..408c2be134 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/NIP90EventCountRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/DvmEventCountRequestEvent.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventCountRequestEvent( +class DvmEventCountRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -58,7 +58,7 @@ class NIP90EventCountRequestEvent( groups: List<String> = emptyList(), filterJson: String = "", createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventCountRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventCountRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, filterJson, createdAt) { inputs.forEach { inputText(it) } relays.forEach { param("relay", it) } @@ -67,3 +67,9 @@ class NIP90EventCountRequestEvent( } } } + +@Deprecated( + "Renamed to DvmEventCountRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventCountRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.eventCount.DvmEventCountRequestEvent"), +) +typealias NIP90EventCountRequestEvent = DvmEventCountRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/NIP90EventCountResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/DvmEventCountResponseEvent.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/NIP90EventCountResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/DvmEventCountResponseEvent.kt index 84f0d173d6..10e0e62444 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/NIP90EventCountResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventCount/DvmEventCountResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventCountResponseEvent( +class DvmEventCountResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -43,9 +43,15 @@ class NIP90EventCountResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventCountResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventCountResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmEventCountResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventCountResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.eventCount.DvmEventCountResponseEvent"), +) +typealias NIP90EventCountResponseEvent = DvmEventCountResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/NIP90EventPowDelegationRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/DvmEventPowDelegationRequestEvent.kt similarity index 83% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/NIP90EventPowDelegationRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/DvmEventPowDelegationRequestEvent.kt index 1f0d7570ae..ee577cb305 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/NIP90EventPowDelegationRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/DvmEventPowDelegationRequestEvent.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventPowDelegationRequestEvent( +class DvmEventPowDelegationRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -54,7 +54,7 @@ class NIP90EventPowDelegationRequestEvent( eventJson: String, pow: Int, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventPowDelegationRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventPowDelegationRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputText(eventJson) param("pow", pow.toString()) @@ -62,3 +62,9 @@ class NIP90EventPowDelegationRequestEvent( } } } + +@Deprecated( + "Renamed to DvmEventPowDelegationRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventPowDelegationRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.DvmEventPowDelegationRequestEvent"), +) +typealias NIP90EventPowDelegationRequestEvent = DvmEventPowDelegationRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/NIP90EventPowDelegationResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/DvmEventPowDelegationResponseEvent.kt similarity index 79% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/NIP90EventPowDelegationResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/DvmEventPowDelegationResponseEvent.kt index ab46d67d28..0174d11e57 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/NIP90EventPowDelegationResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPowDelegation/DvmEventPowDelegationResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventPowDelegationResponseEvent( +class DvmEventPowDelegationResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90EventPowDelegationResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventPowDelegationResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventPowDelegationResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmEventPowDelegationResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventPowDelegationResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.DvmEventPowDelegationResponseEvent"), +) +typealias NIP90EventPowDelegationResponseEvent = DvmEventPowDelegationResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/NIP90EventPublishScheduleRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/DvmEventPublishScheduleRequestEvent.kt similarity index 84% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/NIP90EventPublishScheduleRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/DvmEventPublishScheduleRequestEvent.kt index a6eab69fa8..5160350b86 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/NIP90EventPublishScheduleRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/DvmEventPublishScheduleRequestEvent.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventPublishScheduleRequestEvent( +class DvmEventPublishScheduleRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -54,7 +54,7 @@ class NIP90EventPublishScheduleRequestEvent( eventJson: String, relays: List<String> = emptyList(), createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventPublishScheduleRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventPublishScheduleRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputText(eventJson) if (relays.isNotEmpty()) { @@ -64,3 +64,9 @@ class NIP90EventPublishScheduleRequestEvent( } } } + +@Deprecated( + "Renamed to DvmEventPublishScheduleRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventPublishScheduleRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.DvmEventPublishScheduleRequestEvent"), +) +typealias NIP90EventPublishScheduleRequestEvent = DvmEventPublishScheduleRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/NIP90EventPublishScheduleResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/DvmEventPublishScheduleResponseEvent.kt similarity index 79% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/NIP90EventPublishScheduleResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/DvmEventPublishScheduleResponseEvent.kt index 1dfa2e5980..8a5fde2e6e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/NIP90EventPublishScheduleResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventPublishSchedule/DvmEventPublishScheduleResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventPublishScheduleResponseEvent( +class DvmEventPublishScheduleResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -43,9 +43,15 @@ class NIP90EventPublishScheduleResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventPublishScheduleResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventPublishScheduleResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmEventPublishScheduleResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventPublishScheduleResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.DvmEventPublishScheduleResponseEvent"), +) +typealias NIP90EventPublishScheduleResponseEvent = DvmEventPublishScheduleResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/NIP90EventTimestampingRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/DvmEventTimestampingRequestEvent.kt similarity index 83% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/NIP90EventTimestampingRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/DvmEventTimestampingRequestEvent.kt index 4280ea87ca..454e3574a2 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/NIP90EventTimestampingRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/DvmEventTimestampingRequestEvent.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.inputs import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventTimestampingRequestEvent( +class DvmEventTimestampingRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -50,10 +50,16 @@ class NIP90EventTimestampingRequestEvent( fun build( eventId: HexKey, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventTimestampingRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventTimestampingRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputEvent(eventId) initializer() } } } + +@Deprecated( + "Renamed to DvmEventTimestampingRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventTimestampingRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.DvmEventTimestampingRequestEvent"), +) +typealias NIP90EventTimestampingRequestEvent = DvmEventTimestampingRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/NIP90EventTimestampingResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/DvmEventTimestampingResponseEvent.kt similarity index 80% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/NIP90EventTimestampingResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/DvmEventTimestampingResponseEvent.kt index 604079190e..d4a1125fea 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/NIP90EventTimestampingResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/eventTimestamping/DvmEventTimestampingResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90EventTimestampingResponseEvent( +class DvmEventTimestampingResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -43,9 +43,15 @@ class NIP90EventTimestampingResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90EventTimestampingResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmEventTimestampingResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmEventTimestampingResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmEventTimestampingResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.DvmEventTimestampingResponseEvent"), +) +typealias NIP90EventTimestampingResponseEvent = DvmEventTimestampingResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/NIP90ImageGenerationRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/DvmImageGenerationRequestEvent.kt similarity index 89% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/NIP90ImageGenerationRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/DvmImageGenerationRequestEvent.kt index 08dc291512..7ffb56dad8 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/NIP90ImageGenerationRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/DvmImageGenerationRequestEvent.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90ImageGenerationRequestEvent( +class DvmImageGenerationRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -85,7 +85,7 @@ class NIP90ImageGenerationRequestEvent( size: String? = null, negativePrompt: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ImageGenerationRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmImageGenerationRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { sourceImageUrl?.let { inputUrl(it) } inputText(prompt) @@ -98,3 +98,9 @@ class NIP90ImageGenerationRequestEvent( } } } + +@Deprecated( + "Renamed to DvmImageGenerationRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmImageGenerationRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.imageGeneration.DvmImageGenerationRequestEvent"), +) +typealias NIP90ImageGenerationRequestEvent = DvmImageGenerationRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/NIP90ImageGenerationResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/DvmImageGenerationResponseEvent.kt similarity index 80% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/NIP90ImageGenerationResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/DvmImageGenerationResponseEvent.kt index ef07dd5fee..7978dc4aab 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/NIP90ImageGenerationResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageGeneration/DvmImageGenerationResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90ImageGenerationResponseEvent( +class DvmImageGenerationResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90ImageGenerationResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ImageGenerationResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmImageGenerationResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmImageGenerationResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmImageGenerationResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.imageGeneration.DvmImageGenerationResponseEvent"), +) +typealias NIP90ImageGenerationResponseEvent = DvmImageGenerationResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/NIP90ImageToVideoRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/DvmImageToVideoRequestEvent.kt similarity index 84% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/NIP90ImageToVideoRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/DvmImageToVideoRequestEvent.kt index 98557b94d5..a4d875fbaa 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/NIP90ImageToVideoRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/DvmImageToVideoRequestEvent.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.inputs import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90ImageToVideoRequestEvent( +class DvmImageToVideoRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -50,10 +50,16 @@ class NIP90ImageToVideoRequestEvent( fun build( imageUrl: String, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ImageToVideoRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmImageToVideoRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputUrl(imageUrl) initializer() } } } + +@Deprecated( + "Renamed to DvmImageToVideoRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmImageToVideoRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.imageToVideo.DvmImageToVideoRequestEvent"), +) +typealias NIP90ImageToVideoRequestEvent = DvmImageToVideoRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/NIP90ImageToVideoResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/DvmImageToVideoResponseEvent.kt similarity index 81% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/NIP90ImageToVideoResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/DvmImageToVideoResponseEvent.kt index 9e3c21edfa..2fe0247505 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/NIP90ImageToVideoResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/imageToVideo/DvmImageToVideoResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90ImageToVideoResponseEvent( +class DvmImageToVideoResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90ImageToVideoResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90ImageToVideoResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmImageToVideoResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmImageToVideoResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmImageToVideoResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.imageToVideo.DvmImageToVideoResponseEvent"), +) +typealias NIP90ImageToVideoResponseEvent = DvmImageToVideoResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/NIP90MalwareScanRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/DvmMalwareScanRequestEvent.kt similarity index 84% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/NIP90MalwareScanRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/DvmMalwareScanRequestEvent.kt index af90743b08..9486fb274c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/NIP90MalwareScanRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/DvmMalwareScanRequestEvent.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.inputs import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90MalwareScanRequestEvent( +class DvmMalwareScanRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -50,10 +50,16 @@ class NIP90MalwareScanRequestEvent( fun build( fileUrl: String, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90MalwareScanRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmMalwareScanRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputUrl(fileUrl) initializer() } } } + +@Deprecated( + "Renamed to DvmMalwareScanRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmMalwareScanRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.malwareScanning.DvmMalwareScanRequestEvent"), +) +typealias NIP90MalwareScanRequestEvent = DvmMalwareScanRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/NIP90MalwareScanResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/DvmMalwareScanResponseEvent.kt similarity index 81% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/NIP90MalwareScanResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/DvmMalwareScanResponseEvent.kt index 37aae8e6df..d6cdace38d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/NIP90MalwareScanResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/malwareScanning/DvmMalwareScanResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90MalwareScanResponseEvent( +class DvmMalwareScanResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -43,9 +43,15 @@ class NIP90MalwareScanResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90MalwareScanResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmMalwareScanResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmMalwareScanResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmMalwareScanResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.malwareScanning.DvmMalwareScanResponseEvent"), +) +typealias NIP90MalwareScanResponseEvent = DvmMalwareScanResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/NIP90OpReturnRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/DvmOpReturnRequestEvent.kt similarity index 85% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/NIP90OpReturnRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/DvmOpReturnRequestEvent.kt index 2cf9def354..478ab68e93 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/NIP90OpReturnRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/DvmOpReturnRequestEvent.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.inputs import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90OpReturnRequestEvent( +class DvmOpReturnRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -51,10 +51,16 @@ class NIP90OpReturnRequestEvent( fun build( text: String, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90OpReturnRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmOpReturnRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputText(text) initializer() } } } + +@Deprecated( + "Renamed to DvmOpReturnRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmOpReturnRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.opReturn.DvmOpReturnRequestEvent"), +) +typealias NIP90OpReturnRequestEvent = DvmOpReturnRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/NIP90OpReturnResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/DvmOpReturnResponseEvent.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/NIP90OpReturnResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/DvmOpReturnResponseEvent.kt index 9e9b8e986c..32007e843e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/NIP90OpReturnResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/opReturn/DvmOpReturnResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90OpReturnResponseEvent( +class DvmOpReturnResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -43,9 +43,15 @@ class NIP90OpReturnResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90OpReturnResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmOpReturnResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmOpReturnResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmOpReturnResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.opReturn.DvmOpReturnResponseEvent"), +) +typealias NIP90OpReturnResponseEvent = DvmOpReturnResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/NIP90PeopleSearchRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/DvmPeopleSearchRequestEvent.kt similarity index 87% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/NIP90PeopleSearchRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/DvmPeopleSearchRequestEvent.kt index d542a5ccc9..a44279270c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/NIP90PeopleSearchRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/DvmPeopleSearchRequestEvent.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90PeopleSearchRequestEvent( +class DvmPeopleSearchRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -67,7 +67,7 @@ class NIP90PeopleSearchRequestEvent( searchQuery: String, maxResults: Int? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90PeopleSearchRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmPeopleSearchRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputText(searchQuery) maxResults?.let { param("max_results", it.toString()) } @@ -75,3 +75,9 @@ class NIP90PeopleSearchRequestEvent( } } } + +@Deprecated( + "Renamed to DvmPeopleSearchRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmPeopleSearchRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.peopleSearch.DvmPeopleSearchRequestEvent"), +) +typealias NIP90PeopleSearchRequestEvent = DvmPeopleSearchRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/NIP90PeopleSearchResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/DvmPeopleSearchResponseEvent.kt similarity index 83% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/NIP90PeopleSearchResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/DvmPeopleSearchResponseEvent.kt index 6156985d53..05c7c163ac 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/NIP90PeopleSearchResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/peopleSearch/DvmPeopleSearchResponseEvent.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90PeopleSearchResponseEvent( +class DvmPeopleSearchResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -61,7 +61,7 @@ class NIP90PeopleSearchResponseEvent( } } } catch (e: Throwable) { - Log.w("NIP90PeopleSearchResponseEvent") { "Error parsing the JSON ${e.message}" } + Log.w("DvmPeopleSearchResponseEvent") { "Error parsing the JSON ${e.message}" } } return people ?: listOf() @@ -72,9 +72,15 @@ class NIP90PeopleSearchResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90PeopleSearchResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmPeopleSearchResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmPeopleSearchResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmPeopleSearchResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.peopleSearch.DvmPeopleSearchResponseEvent"), +) +typealias NIP90PeopleSearchResponseEvent = DvmPeopleSearchResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/NIP90StatusEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/DvmStatusEvent.kt similarity index 85% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/NIP90StatusEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/DvmStatusEvent.kt index c01eb4cc38..e14e41468c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/NIP90StatusEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/DvmStatusEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90StatusEvent( +class DvmStatusEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -45,9 +45,15 @@ class NIP90StatusEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90StatusEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmStatusEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmStatusEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmStatusEvent", "com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent"), +) +typealias NIP90StatusEvent = DvmStatusEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/TagArrayBuilderExt.kt index ff12777c74..bc919bff57 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/status/TagArrayBuilderExt.kt @@ -24,14 +24,14 @@ import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip90Dvms.status.tags.AmountTag import com.vitorpamplona.quartz.nip90Dvms.status.tags.StatusTag -fun TagArrayBuilder<NIP90StatusEvent>.status( +fun TagArrayBuilder<DvmStatusEvent>.status( code: String, description: String, ) = addUnique(StatusTag.assemble(code, description)) -fun TagArrayBuilder<NIP90StatusEvent>.amount(amount: Long) = addUnique(AmountTag.assemble(amount)) +fun TagArrayBuilder<DvmStatusEvent>.amount(amount: Long) = addUnique(AmountTag.assemble(amount)) -fun TagArrayBuilder<NIP90StatusEvent>.amount( +fun TagArrayBuilder<DvmStatusEvent>.amount( amount: Long, lnInvoice: String, ) = addUnique(AmountTag.assemble(amount, lnInvoice)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/NIP90SummarizationRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/DvmSummarizationRequestEvent.kt similarity index 85% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/NIP90SummarizationRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/DvmSummarizationRequestEvent.kt index 3e7cf4a0db..aaf23220b0 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/NIP90SummarizationRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/DvmSummarizationRequestEvent.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90SummarizationRequestEvent( +class DvmSummarizationRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -57,7 +57,7 @@ class NIP90SummarizationRequestEvent( length: String? = null, outputMimeType: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90SummarizationRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmSummarizationRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { eventIds.forEach { inputEvent(it) } length?.let { param("length", it) } @@ -66,3 +66,9 @@ class NIP90SummarizationRequestEvent( } } } + +@Deprecated( + "Renamed to DvmSummarizationRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmSummarizationRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.summarization.DvmSummarizationRequestEvent"), +) +typealias NIP90SummarizationRequestEvent = DvmSummarizationRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/NIP90SummarizationResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/DvmSummarizationResponseEvent.kt similarity index 80% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/NIP90SummarizationResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/DvmSummarizationResponseEvent.kt index d4b97ca533..9b04b3ffa0 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/NIP90SummarizationResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/summarization/DvmSummarizationResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90SummarizationResponseEvent( +class DvmSummarizationResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90SummarizationResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90SummarizationResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmSummarizationResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmSummarizationResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmSummarizationResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.summarization.DvmSummarizationResponseEvent"), +) +typealias NIP90SummarizationResponseEvent = DvmSummarizationResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/NIP90TextExtractionRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/DvmTextExtractionRequestEvent.kt similarity index 87% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/NIP90TextExtractionRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/DvmTextExtractionRequestEvent.kt index c61c29b542..8ea2ad8cca 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/NIP90TextExtractionRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/DvmTextExtractionRequestEvent.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TextExtractionRequestEvent( +class DvmTextExtractionRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -64,7 +64,7 @@ class NIP90TextExtractionRequestEvent( rangeEnd: String? = null, alignment: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TextExtractionRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTextExtractionRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputUrl(inputUrl) outputMimeType?.let { output(it) } @@ -76,3 +76,9 @@ class NIP90TextExtractionRequestEvent( } } } + +@Deprecated( + "Renamed to DvmTextExtractionRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTextExtractionRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.textExtraction.DvmTextExtractionRequestEvent"), +) +typealias NIP90TextExtractionRequestEvent = DvmTextExtractionRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/NIP90TextExtractionResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/DvmTextExtractionResponseEvent.kt similarity index 80% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/NIP90TextExtractionResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/DvmTextExtractionResponseEvent.kt index ae808faa45..814f311d3e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/NIP90TextExtractionResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textExtraction/DvmTextExtractionResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TextExtractionResponseEvent( +class DvmTextExtractionResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90TextExtractionResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TextExtractionResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTextExtractionResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmTextExtractionResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTextExtractionResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.textExtraction.DvmTextExtractionResponseEvent"), +) +typealias NIP90TextExtractionResponseEvent = DvmTextExtractionResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/NIP90TextGenerationRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/DvmTextGenerationRequestEvent.kt similarity index 90% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/NIP90TextGenerationRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/DvmTextGenerationRequestEvent.kt index 6554dd73ab..2e0f57fdde 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/NIP90TextGenerationRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/DvmTextGenerationRequestEvent.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TextGenerationRequestEvent( +class DvmTextGenerationRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -88,7 +88,7 @@ class NIP90TextGenerationRequestEvent( frequencyPenalty: Double? = null, outputMimeType: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TextGenerationRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTextGenerationRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputPrompt(prompt) model?.let { param("model", it) } @@ -102,3 +102,9 @@ class NIP90TextGenerationRequestEvent( } } } + +@Deprecated( + "Renamed to DvmTextGenerationRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTextGenerationRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.textGeneration.DvmTextGenerationRequestEvent"), +) +typealias NIP90TextGenerationRequestEvent = DvmTextGenerationRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/NIP90TextGenerationResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/DvmTextGenerationResponseEvent.kt similarity index 80% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/NIP90TextGenerationResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/DvmTextGenerationResponseEvent.kt index ded0df9d9b..2619816759 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/NIP90TextGenerationResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textGeneration/DvmTextGenerationResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TextGenerationResponseEvent( +class DvmTextGenerationResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90TextGenerationResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TextGenerationResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTextGenerationResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmTextGenerationResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTextGenerationResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.textGeneration.DvmTextGenerationResponseEvent"), +) +typealias NIP90TextGenerationResponseEvent = DvmTextGenerationResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/NIP90TextToSpeechRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/DvmTextToSpeechRequestEvent.kt similarity index 87% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/NIP90TextToSpeechRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/DvmTextToSpeechRequestEvent.kt index 251fe7b510..41427dbb9e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/NIP90TextToSpeechRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/DvmTextToSpeechRequestEvent.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TextToSpeechRequestEvent( +class DvmTextToSpeechRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -67,7 +67,7 @@ class NIP90TextToSpeechRequestEvent( text: String, language: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TextToSpeechRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTextToSpeechRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputText(text) language?.let { param("language", it) } @@ -75,3 +75,9 @@ class NIP90TextToSpeechRequestEvent( } } } + +@Deprecated( + "Renamed to DvmTextToSpeechRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTextToSpeechRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.textToSpeech.DvmTextToSpeechRequestEvent"), +) +typealias NIP90TextToSpeechRequestEvent = DvmTextToSpeechRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/NIP90TextToSpeechResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/DvmTextToSpeechResponseEvent.kt similarity index 81% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/NIP90TextToSpeechResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/DvmTextToSpeechResponseEvent.kt index 01cbf1e0ca..2a76d0f54a 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/NIP90TextToSpeechResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/textToSpeech/DvmTextToSpeechResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TextToSpeechResponseEvent( +class DvmTextToSpeechResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90TextToSpeechResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TextToSpeechResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTextToSpeechResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmTextToSpeechResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTextToSpeechResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.textToSpeech.DvmTextToSpeechResponseEvent"), +) +typealias NIP90TextToSpeechResponseEvent = DvmTextToSpeechResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/NIP90TranslationRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/DvmTranslationRequestEvent.kt similarity index 85% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/NIP90TranslationRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/DvmTranslationRequestEvent.kt index aed285ea54..560842a3cd 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/NIP90TranslationRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/DvmTranslationRequestEvent.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TranslationRequestEvent( +class DvmTranslationRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -52,7 +52,7 @@ class NIP90TranslationRequestEvent( eventIds: List<HexKey>, language: String, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TranslationRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTranslationRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { eventIds.forEach { inputEvent(it) } param("language", language) @@ -60,3 +60,9 @@ class NIP90TranslationRequestEvent( } } } + +@Deprecated( + "Renamed to DvmTranslationRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTranslationRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.translation.DvmTranslationRequestEvent"), +) +typealias NIP90TranslationRequestEvent = DvmTranslationRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/NIP90TranslationResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/DvmTranslationResponseEvent.kt similarity index 81% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/NIP90TranslationResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/DvmTranslationResponseEvent.kt index b43ef64283..a051d8a242 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/NIP90TranslationResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/translation/DvmTranslationResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90TranslationResponseEvent( +class DvmTranslationResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90TranslationResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90TranslationResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmTranslationResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmTranslationResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmTranslationResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.translation.DvmTranslationResponseEvent"), +) +typealias NIP90TranslationResponseEvent = DvmTranslationResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryRequest/NIP90UserDiscoveryRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryRequest/DvmUserDiscoveryRequestEvent.kt similarity index 83% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryRequest/NIP90UserDiscoveryRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryRequest/DvmUserDiscoveryRequestEvent.kt index be937e06fe..a3482cd7e7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryRequest/NIP90UserDiscoveryRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryRequest/DvmUserDiscoveryRequestEvent.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.inputs import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90UserDiscoveryRequestEvent( +class DvmUserDiscoveryRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -50,9 +50,15 @@ class NIP90UserDiscoveryRequestEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90UserDiscoveryRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmUserDiscoveryRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmUserDiscoveryRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmUserDiscoveryRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.DvmUserDiscoveryRequestEvent"), +) +typealias NIP90UserDiscoveryRequestEvent = DvmUserDiscoveryRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryResponse/NIP90UserDiscoveryResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryResponse/DvmUserDiscoveryResponseEvent.kt similarity index 82% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryResponse/NIP90UserDiscoveryResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryResponse/DvmUserDiscoveryResponseEvent.kt index ba220f40bd..28d3d42e05 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryResponse/NIP90UserDiscoveryResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/userDiscoveryResponse/DvmUserDiscoveryResponseEvent.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90UserDiscoveryResponseEvent( +class DvmUserDiscoveryResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -61,7 +61,7 @@ class NIP90UserDiscoveryResponseEvent( } } } catch (e: Throwable) { - Log.w("NIP90UserDiscoveryResponseEvent") { "Error parsing the JSON ${e.message}" } + Log.w("DvmUserDiscoveryResponseEvent") { "Error parsing the JSON ${e.message}" } } return people ?: listOf() @@ -72,9 +72,15 @@ class NIP90UserDiscoveryResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90UserDiscoveryResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmUserDiscoveryResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmUserDiscoveryResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmUserDiscoveryResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.DvmUserDiscoveryResponseEvent"), +) +typealias NIP90UserDiscoveryResponseEvent = DvmUserDiscoveryResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/NIP90VideoConversionRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/DvmVideoConversionRequestEvent.kt similarity index 86% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/NIP90VideoConversionRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/DvmVideoConversionRequestEvent.kt index ffc3adc0c5..d438273af9 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/NIP90VideoConversionRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/DvmVideoConversionRequestEvent.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90VideoConversionRequestEvent( +class DvmVideoConversionRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -60,7 +60,7 @@ class NIP90VideoConversionRequestEvent( rangeStart: String? = null, rangeEnd: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90VideoConversionRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmVideoConversionRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputUrl(videoUrl) outputMimeType?.let { output(it) } @@ -71,3 +71,9 @@ class NIP90VideoConversionRequestEvent( } } } + +@Deprecated( + "Renamed to DvmVideoConversionRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmVideoConversionRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.videoConversion.DvmVideoConversionRequestEvent"), +) +typealias NIP90VideoConversionRequestEvent = DvmVideoConversionRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/NIP90VideoConversionResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/DvmVideoConversionResponseEvent.kt similarity index 80% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/NIP90VideoConversionResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/DvmVideoConversionResponseEvent.kt index ebd7a9031c..923217e476 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/NIP90VideoConversionResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoConversion/DvmVideoConversionResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90VideoConversionResponseEvent( +class DvmVideoConversionResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90VideoConversionResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90VideoConversionResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmVideoConversionResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmVideoConversionResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmVideoConversionResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.videoConversion.DvmVideoConversionResponseEvent"), +) +typealias NIP90VideoConversionResponseEvent = DvmVideoConversionResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/NIP90VideoTranslationRequestEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/DvmVideoTranslationRequestEvent.kt similarity index 87% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/NIP90VideoTranslationRequestEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/DvmVideoTranslationRequestEvent.kt index 859be0382c..7df77e7a7f 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/NIP90VideoTranslationRequestEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/DvmVideoTranslationRequestEvent.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip90Dvms.tags.param import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90VideoTranslationRequestEvent( +class DvmVideoTranslationRequestEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -67,7 +67,7 @@ class NIP90VideoTranslationRequestEvent( rangeEnd: String? = null, outputFormat: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90VideoTranslationRequestEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmVideoTranslationRequestEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { inputUrl(videoUrl) param("language", language) @@ -80,3 +80,9 @@ class NIP90VideoTranslationRequestEvent( } } } + +@Deprecated( + "Renamed to DvmVideoTranslationRequestEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmVideoTranslationRequestEvent", "com.vitorpamplona.quartz.nip90Dvms.videoTranslation.DvmVideoTranslationRequestEvent"), +) +typealias NIP90VideoTranslationRequestEvent = DvmVideoTranslationRequestEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/NIP90VideoTranslationResponseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/DvmVideoTranslationResponseEvent.kt similarity index 80% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/NIP90VideoTranslationResponseEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/DvmVideoTranslationResponseEvent.kt index cea768fdd5..a1ee14aa54 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/NIP90VideoTranslationResponseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip90Dvms/videoTranslation/DvmVideoTranslationResponseEvent.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class NIP90VideoTranslationResponseEvent( +class DvmVideoTranslationResponseEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -41,9 +41,15 @@ class NIP90VideoTranslationResponseEvent( fun build( createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<NIP90VideoTranslationResponseEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<DvmVideoTranslationResponseEvent>.() -> Unit = {}, ) = eventTemplate(KIND, "", createdAt) { initializer() } } } + +@Deprecated( + "Renamed to DvmVideoTranslationResponseEvent. NIP-90 Data Vending Machine events use the Dvm prefix.", + ReplaceWith("DvmVideoTranslationResponseEvent", "com.vitorpamplona.quartz.nip90Dvms.videoTranslation.DvmVideoTranslationResponseEvent"), +) +typealias NIP90VideoTranslationResponseEvent = DvmVideoTranslationResponseEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/FileHeaderEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/FileMetadataEvent.kt similarity index 93% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/FileHeaderEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/FileMetadataEvent.kt index 6ac3a389cf..d4e9cfd79d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/FileHeaderEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/FileMetadataEvent.kt @@ -46,7 +46,7 @@ import com.vitorpamplona.quartz.nip94FileMetadata.tags.UrlTag import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class FileHeaderEvent( +class FileMetadataEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -105,7 +105,7 @@ class FileHeaderEvent( url: String, caption: String?, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<FileHeaderEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<FileMetadataEvent>.() -> Unit = {}, ) = eventTemplate(KIND, caption ?: "", createdAt) { url(url) // NIP-94 accessibility description of the file (kept; the deprecated @@ -127,7 +127,7 @@ class FileHeaderEvent( magnetUri: String? = null, torrentInfoHash: String? = null, createdAt: Long = TimeUtils.now(), - initializer: TagArrayBuilder<FileHeaderEvent>.() -> Unit = {}, + initializer: TagArrayBuilder<FileMetadataEvent>.() -> Unit = {}, ) = eventTemplate(KIND, caption ?: "", createdAt) { url(url) // NIP-94 accessibility description of the file (kept; the deprecated @@ -148,3 +148,9 @@ class FileHeaderEvent( } } } + +@Deprecated( + "Renamed to FileMetadataEvent. NIP-94 names kind 1063 file metadata.", + ReplaceWith("FileMetadataEvent", "com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent"), +) +typealias FileHeaderEvent = FileMetadataEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/TagArrayBuilderExt.kt index e000583d6e..d89c862235 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip94FileMetadata/TagArrayBuilderExt.kt @@ -38,32 +38,32 @@ import com.vitorpamplona.quartz.nip94FileMetadata.tags.ThumbhashTag import com.vitorpamplona.quartz.nip94FileMetadata.tags.TorrentInfoHash import com.vitorpamplona.quartz.nip94FileMetadata.tags.UrlTag -fun TagArrayBuilder<FileHeaderEvent>.url(url: String) = add(UrlTag.assemble(url)) +fun TagArrayBuilder<FileMetadataEvent>.url(url: String) = add(UrlTag.assemble(url)) -fun TagArrayBuilder<FileHeaderEvent>.mimeType(mimeType: String) = add(MimeTypeTag.assemble(mimeType)) +fun TagArrayBuilder<FileMetadataEvent>.mimeType(mimeType: String) = add(MimeTypeTag.assemble(mimeType)) -fun TagArrayBuilder<FileHeaderEvent>.hash(hash: HexKey) = add(HashSha256Tag.assemble(hash)) +fun TagArrayBuilder<FileMetadataEvent>.hash(hash: HexKey) = add(HashSha256Tag.assemble(hash)) -fun TagArrayBuilder<FileHeaderEvent>.fileSize(size: Int) = add(SizeTag.assemble(size)) +fun TagArrayBuilder<FileMetadataEvent>.fileSize(size: Int) = add(SizeTag.assemble(size)) -fun TagArrayBuilder<FileHeaderEvent>.dimension(dim: DimensionTag) = add(DimensionTag.assemble(dim)) +fun TagArrayBuilder<FileMetadataEvent>.dimension(dim: DimensionTag) = add(DimensionTag.assemble(dim)) -fun TagArrayBuilder<FileHeaderEvent>.blurhash(blurhash: String) = add(BlurhashTag.assemble(blurhash)) +fun TagArrayBuilder<FileMetadataEvent>.blurhash(blurhash: String) = add(BlurhashTag.assemble(blurhash)) -fun TagArrayBuilder<FileHeaderEvent>.thumbhash(thumbhash: String) = add(ThumbhashTag.assemble(thumbhash)) +fun TagArrayBuilder<FileMetadataEvent>.thumbhash(thumbhash: String) = add(ThumbhashTag.assemble(thumbhash)) -fun TagArrayBuilder<FileHeaderEvent>.originalHash(hash: HexKey) = add(OriginalHashTag.assemble(hash)) +fun TagArrayBuilder<FileMetadataEvent>.originalHash(hash: HexKey) = add(OriginalHashTag.assemble(hash)) -fun TagArrayBuilder<FileHeaderEvent>.torrentInfohash(hash: String) = add(TorrentInfoHash.assemble(hash)) +fun TagArrayBuilder<FileMetadataEvent>.torrentInfohash(hash: String) = add(TorrentInfoHash.assemble(hash)) -fun TagArrayBuilder<FileHeaderEvent>.magnet(magnetUri: String) = add(MagnetTag.assemble(magnetUri)) +fun TagArrayBuilder<FileMetadataEvent>.magnet(magnetUri: String) = add(MagnetTag.assemble(magnetUri)) -fun TagArrayBuilder<FileHeaderEvent>.image(imageUrl: HexKey) = add(ImageTag.assemble(imageUrl)) +fun TagArrayBuilder<FileMetadataEvent>.image(imageUrl: HexKey) = add(ImageTag.assemble(imageUrl)) -fun TagArrayBuilder<FileHeaderEvent>.thumb(trumbUrl: HexKey) = add(ThumbTag.assemble(trumbUrl)) +fun TagArrayBuilder<FileMetadataEvent>.thumb(trumbUrl: HexKey) = add(ThumbTag.assemble(trumbUrl)) -fun TagArrayBuilder<FileHeaderEvent>.summary(summary: HexKey) = add(SummaryTag.assemble(summary)) +fun TagArrayBuilder<FileMetadataEvent>.summary(summary: HexKey) = add(SummaryTag.assemble(summary)) -fun TagArrayBuilder<FileHeaderEvent>.fallback(fallbackUrl: HexKey) = add(FallbackTag.assemble(fallbackUrl)) +fun TagArrayBuilder<FileMetadataEvent>.fallback(fallbackUrl: HexKey) = add(FallbackTag.assemble(fallbackUrl)) -fun TagArrayBuilder<FileHeaderEvent>.service(service: HexKey) = add(ServiceTag.assemble(service)) +fun TagArrayBuilder<FileMetadataEvent>.service(service: HexKey) = add(ServiceTag.assemble(service)) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt index 15d8d83388..d852130e87 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt @@ -181,8 +181,8 @@ import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip03Timestamp.OtsEvent -import com.vitorpamplona.quartz.nip04Dm.messages.PrivateDmEvent -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip15Marketplace.auction.AuctionEvent import com.vitorpamplona.quartz.nip15Marketplace.bid.BidEvent @@ -192,38 +192,38 @@ import com.vitorpamplona.quartz.nip15Marketplace.product.ProductEvent import com.vitorpamplona.quartz.nip15Marketplace.stall.StallEvent import com.vitorpamplona.quartz.nip17Dm.files.ChatMessageEncryptedFileHeaderEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent -import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent +import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip25Reactions.ExternalReactionEvent import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelHideMessageEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMuteUserEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupParticipantsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateInviteEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteEventEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.PutUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.RemoveUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.UpdatePinListEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.JoinRequestEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.LeaveRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupCreateInviteEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupDeleteEventEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupPutUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupRemoveUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupUpdatePinListEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent import com.vitorpamplona.quartz.nip29RelayGroups.tags.GroupIdTag import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent -import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiPackSelectionEvent +import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent import com.vitorpamplona.quartz.nip32Labeling.LabelEvent import com.vitorpamplona.quartz.nip34Git.grasp.UserGraspListEvent import com.vitorpamplona.quartz.nip34Git.issue.GitIssueEvent @@ -241,7 +241,7 @@ import com.vitorpamplona.quartz.nip35Torrents.TorrentCommentEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent -import com.vitorpamplona.quartz.nip38UserStatus.StatusEvent +import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip39ExtIdentities.ExternalIdentitiesEvent import com.vitorpamplona.quartz.nip42RelayAuth.RelayAuthEvent import com.vitorpamplona.quartz.nip43RelayMembers.addMember.RelayAddMemberEvent @@ -251,10 +251,10 @@ import com.vitorpamplona.quartz.nip43RelayMembers.leaveRequest.RelayLeaveRequest import com.vitorpamplona.quartz.nip43RelayMembers.list.RelayMembershipListEvent import com.vitorpamplona.quartz.nip43RelayMembers.removeMember.RelayRemoveMemberEvent import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcInfoEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcNotificationEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.appCurationSet.AppCurationSetEvent @@ -262,26 +262,26 @@ import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSet import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent import com.vitorpamplona.quartz.nip51Lists.gitAuthorList.GitAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.gitRepositoryList.GitRepositoryListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiAuthorList.GoodWikiAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiRelayList.GoodWikiRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent +import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.kindMuteSet.KindMuteSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.LabeledBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaFollowList.MediaFollowListEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent +import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent +import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent @@ -289,7 +289,7 @@ import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent @@ -299,19 +299,19 @@ import com.vitorpamplona.quartz.nip53LiveActivities.nestsServers.NestsServersEve import com.vitorpamplona.quartz.nip53LiveActivities.presence.MeetingRoomPresenceEvent import com.vitorpamplona.quartz.nip53LiveActivities.raid.LiveActivitiesRaidEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent +import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeAcceptanceEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeRequestEvent -import com.vitorpamplona.quartz.nip54Wiki.WikiNoteEvent import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent import com.vitorpamplona.quartz.nip58Badges.profile.ProfileBadgesEvent -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.EphemeralGiftWrapEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent @@ -325,8 +325,6 @@ import com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.NutzapInfoEvent import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent -import com.vitorpamplona.quartz.nip61Nutzaps.redemption.NutzapRedemptionEvent -import com.vitorpamplona.quartz.nip61Nutzaps.token.TokenEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent import com.vitorpamplona.quartz.nip64Chess.challenge.accept.LiveChessGameAcceptEvent import com.vitorpamplona.quartz.nip64Chess.challenge.offer.LiveChessGameChallengeEvent @@ -340,16 +338,16 @@ import com.vitorpamplona.quartz.nip66RelayMonitor.discovery.RelayDiscoveryEvent import com.vitorpamplona.quartz.nip66RelayMonitor.monitor.RelayMonitorEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip69P2pOrderEvents.P2POrderEvent -import com.vitorpamplona.quartz.nip71Video.VideoHorizontalEvent +import com.vitorpamplona.quartz.nip71Video.AddressableNormalVideoEvent +import com.vitorpamplona.quartz.nip71Video.AddressableShortVideoEvent import com.vitorpamplona.quartz.nip71Video.VideoNormalEvent import com.vitorpamplona.quartz.nip71Video.VideoShortEvent -import com.vitorpamplona.quartz.nip71Video.VideoVerticalEvent import com.vitorpamplona.quartz.nip71Video.textTrack.TextTrackEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent import com.vitorpamplona.quartz.nip72ModCommunities.rules.CommunityRulesEvent -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import com.vitorpamplona.quartz.nip78AppData.AppDataEvent import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent @@ -358,7 +356,7 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.addressables.AddressableA import com.vitorpamplona.quartz.nip85TrustedAssertions.events.EventAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.externalIds.ExternalIdAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip87Ecash.cashu.CashuMintEvent import com.vitorpamplona.quartz.nip87Ecash.fedimint.FedimintEvent import com.vitorpamplona.quartz.nip87Ecash.recommendation.MintRecommendationEvent @@ -366,47 +364,47 @@ import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip88Polls.response.PollResponseEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.NIP90ContentDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.NIP90ContentDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.contentSearch.NIP90ContentSearchRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.contentSearch.NIP90ContentSearchResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryRequest.DvmContentDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.contentSearch.DvmContentSearchRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.contentSearch.DvmContentSearchResponseEvent import com.vitorpamplona.quartz.nip90Dvms.dvmHeartbeat.DvmHeartbeatEvent -import com.vitorpamplona.quartz.nip90Dvms.eventCount.NIP90EventCountRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventCount.NIP90EventCountResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.NIP90EventPowDelegationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.NIP90EventPowDelegationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.NIP90EventPublishScheduleRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.NIP90EventPublishScheduleResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.NIP90EventTimestampingRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.NIP90EventTimestampingResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.NIP90ImageGenerationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.NIP90ImageGenerationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.NIP90ImageToVideoRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.NIP90ImageToVideoResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.NIP90MalwareScanRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.NIP90MalwareScanResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.opReturn.NIP90OpReturnRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.opReturn.NIP90OpReturnResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.NIP90PeopleSearchRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.NIP90PeopleSearchResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.status.NIP90StatusEvent -import com.vitorpamplona.quartz.nip90Dvms.summarization.NIP90SummarizationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.summarization.NIP90SummarizationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.textExtraction.NIP90TextExtractionRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.textExtraction.NIP90TextExtractionResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.textGeneration.NIP90TextGenerationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.textGeneration.NIP90TextGenerationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.NIP90TextToSpeechRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.NIP90TextToSpeechResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.translation.NIP90TranslationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.translation.NIP90TranslationResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.NIP90UserDiscoveryRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.NIP90UserDiscoveryResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.videoConversion.NIP90VideoConversionRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.videoConversion.NIP90VideoConversionResponseEvent -import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.NIP90VideoTranslationRequestEvent -import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.NIP90VideoTranslationResponseEvent -import com.vitorpamplona.quartz.nip94FileMetadata.FileHeaderEvent +import com.vitorpamplona.quartz.nip90Dvms.eventCount.DvmEventCountRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventCount.DvmEventCountResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.DvmEventPowDelegationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPowDelegation.DvmEventPowDelegationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.DvmEventPublishScheduleRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventPublishSchedule.DvmEventPublishScheduleResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.DvmEventTimestampingRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.eventTimestamping.DvmEventTimestampingResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.DvmImageGenerationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.imageGeneration.DvmImageGenerationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.DvmImageToVideoRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.imageToVideo.DvmImageToVideoResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.DvmMalwareScanRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.malwareScanning.DvmMalwareScanResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.opReturn.DvmOpReturnRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.opReturn.DvmOpReturnResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.DvmPeopleSearchRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.peopleSearch.DvmPeopleSearchResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent +import com.vitorpamplona.quartz.nip90Dvms.summarization.DvmSummarizationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.summarization.DvmSummarizationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.textExtraction.DvmTextExtractionRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.textExtraction.DvmTextExtractionResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.textGeneration.DvmTextGenerationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.textGeneration.DvmTextGenerationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.DvmTextToSpeechRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.textToSpeech.DvmTextToSpeechResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.translation.DvmTranslationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.translation.DvmTranslationResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryRequest.DvmUserDiscoveryRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.userDiscoveryResponse.DvmUserDiscoveryResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.videoConversion.DvmVideoConversionRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.videoConversion.DvmVideoConversionResponseEvent +import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.DvmVideoTranslationRequestEvent +import com.vitorpamplona.quartz.nip90Dvms.videoTranslation.DvmVideoTranslationResponseEvent +import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent import com.vitorpamplona.quartz.nip96FileStorage.config.FileServersEvent import com.vitorpamplona.quartz.nip98HttpAuth.HTTPAuthorizationEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent @@ -570,7 +568,7 @@ class EventFactory { BookmarkListEvent.KIND -> BookmarkListEvent(id, pubKey, createdAt, tags, content, sig) OldBookmarkListEvent.KIND -> OldBookmarkListEvent(id, pubKey, createdAt, tags, content, sig) CalendarDateSlotEvent.KIND -> CalendarDateSlotEvent(id, pubKey, createdAt, tags, content, sig) - CalendarEvent.KIND -> CalendarEvent(id, pubKey, createdAt, tags, content, sig) + CalendarCollectionEvent.KIND -> CalendarCollectionEvent(id, pubKey, createdAt, tags, content, sig) CalendarTimeSlotEvent.KIND -> CalendarTimeSlotEvent(id, pubKey, createdAt, tags, content, sig) CalendarRSVPEvent.KIND -> CalendarRSVPEvent(id, pubKey, createdAt, tags, content, sig) CallAnswerEvent.KIND -> CallAnswerEvent(id, pubKey, createdAt, tags, content, sig) @@ -585,19 +583,19 @@ class EventFactory { CashuSpendingHistoryEvent.KIND -> CashuSpendingHistoryEvent(id, pubKey, createdAt, tags, content, sig) CashuWalletEvent.KIND -> CashuWalletEvent(id, pubKey, createdAt, tags, content, sig) ChatEvent.KIND -> ChatEvent(id, pubKey, createdAt, tags, content, sig) - PutUserEvent.KIND -> PutUserEvent(id, pubKey, createdAt, tags, content, sig) - RemoveUserEvent.KIND -> RemoveUserEvent(id, pubKey, createdAt, tags, content, sig) - EditMetadataEvent.KIND -> EditMetadataEvent(id, pubKey, createdAt, tags, content, sig) - DeleteEventEvent.KIND -> DeleteEventEvent(id, pubKey, createdAt, tags, content, sig) + GroupPutUserEvent.KIND -> GroupPutUserEvent(id, pubKey, createdAt, tags, content, sig) + GroupRemoveUserEvent.KIND -> GroupRemoveUserEvent(id, pubKey, createdAt, tags, content, sig) + GroupEditMetadataEvent.KIND -> GroupEditMetadataEvent(id, pubKey, createdAt, tags, content, sig) + GroupDeleteEventEvent.KIND -> GroupDeleteEventEvent(id, pubKey, createdAt, tags, content, sig) CreateGroupEvent.KIND -> CreateGroupEvent(id, pubKey, createdAt, tags, content, sig) DeleteGroupEvent.KIND -> DeleteGroupEvent(id, pubKey, createdAt, tags, content, sig) - CreateInviteEvent.KIND -> CreateInviteEvent(id, pubKey, createdAt, tags, content, sig) - JoinRequestEvent.KIND -> JoinRequestEvent(id, pubKey, createdAt, tags, content, sig) - LeaveRequestEvent.KIND -> LeaveRequestEvent(id, pubKey, createdAt, tags, content, sig) + GroupCreateInviteEvent.KIND -> GroupCreateInviteEvent(id, pubKey, createdAt, tags, content, sig) + GroupJoinRequestEvent.KIND -> GroupJoinRequestEvent(id, pubKey, createdAt, tags, content, sig) + GroupLeaveRequestEvent.KIND -> GroupLeaveRequestEvent(id, pubKey, createdAt, tags, content, sig) GroupMetadataEvent.KIND -> GroupMetadataEvent(id, pubKey, createdAt, tags, content, sig) GroupAdminsEvent.KIND -> GroupAdminsEvent(id, pubKey, createdAt, tags, content, sig) GroupMembersEvent.KIND -> GroupMembersEvent(id, pubKey, createdAt, tags, content, sig) - SupportedRolesEvent.KIND -> SupportedRolesEvent(id, pubKey, createdAt, tags, content, sig) + GroupRolesEvent.KIND -> GroupRolesEvent(id, pubKey, createdAt, tags, content, sig) GroupParticipantsEvent.KIND -> GroupParticipantsEvent(id, pubKey, createdAt, tags, content, sig) // kind:39005 is shared by two relay-signed, addressable events that never coexist on // one relay: NIP-29's group pin list (relay29 family) and Buzz's NIP-CW thread @@ -618,10 +616,10 @@ class EventFactory { } else { GroupPinnedEvent(id, pubKey, createdAt, tags, content, sig) } - UpdatePinListEvent.KIND -> UpdatePinListEvent(id, pubKey, createdAt, tags, content, sig) + GroupUpdatePinListEvent.KIND -> GroupUpdatePinListEvent(id, pubKey, createdAt, tags, content, sig) ChessGameEvent.KIND -> ChessGameEvent(id, pubKey, createdAt, tags, content, sig) CodeSnippetEvent.KIND -> CodeSnippetEvent(id, pubKey, createdAt, tags, content, sig) - RelayFeedsListEvent.KIND -> RelayFeedsListEvent(id, pubKey, createdAt, tags, content, sig) + FavoriteRelayListEvent.KIND -> FavoriteRelayListEvent(id, pubKey, createdAt, tags, content, sig) JesterEvent.KIND -> JesterEvent(id, pubKey, createdAt, tags, content, sig) LiveChessGameChallengeEvent.KIND -> LiveChessGameChallengeEvent(id, pubKey, createdAt, tags, content, sig) LiveChessGameAcceptEvent.KIND -> LiveChessGameAcceptEvent(id, pubKey, createdAt, tags, content, sig) @@ -630,13 +628,13 @@ class EventFactory { LiveChessDrawOfferEvent.KIND -> LiveChessDrawOfferEvent(id, pubKey, createdAt, tags, content, sig) ChannelCreateEvent.KIND -> ChannelCreateEvent(id, pubKey, createdAt, tags, content, sig) ChannelHideMessageEvent.KIND -> ChannelHideMessageEvent(id, pubKey, createdAt, tags, content, sig) - ChannelListEvent.KIND -> ChannelListEvent(id, pubKey, createdAt, tags, content, sig) + PublicChatListEvent.KIND -> PublicChatListEvent(id, pubKey, createdAt, tags, content, sig) ChannelMessageEvent.KIND -> ChannelMessageEvent(id, pubKey, createdAt, tags, content, sig) ChannelMetadataEvent.KIND -> ChannelMetadataEvent(id, pubKey, createdAt, tags, content, sig) ChannelMuteUserEvent.KIND -> ChannelMuteUserEvent(id, pubKey, createdAt, tags, content, sig) ChatMessageEncryptedFileHeaderEvent.KIND -> ChatMessageEncryptedFileHeaderEvent(id.ifBlank { EventHasher.hashId(pubKey, createdAt, kind, tags, content) }, pubKey, createdAt, tags, content, sig) ChatMessageEvent.KIND -> ChatMessageEvent(id.ifBlank { EventHasher.hashId(pubKey, createdAt, kind, tags, content) }, pubKey, createdAt, tags, content, sig) - ChatMessageRelayListEvent.KIND -> ChatMessageRelayListEvent(id, pubKey, createdAt, tags, content, sig) + DmRelayListEvent.KIND -> DmRelayListEvent(id, pubKey, createdAt, tags, content, sig) ClassifiedsEvent.KIND -> ClassifiedsEvent(id, pubKey, createdAt, tags, content, sig) CommentEvent.KIND -> CommentEvent(id, pubKey, createdAt, tags, content, sig) CommunityDefinitionEvent.KIND -> CommunityDefinitionEvent(id, pubKey, createdAt, tags, content, sig) @@ -644,21 +642,21 @@ class EventFactory { CommunityPostApprovalEvent.KIND -> CommunityPostApprovalEvent(id, pubKey, createdAt, tags, content, sig) CommunityRulesEvent.KIND -> CommunityRulesEvent(id, pubKey, createdAt, tags, content, sig) ContactListEvent.KIND -> ContactListEvent(id, pubKey, createdAt, tags, content, sig) - DeletionEvent.KIND -> DeletionEvent(id, pubKey, createdAt, tags, content, sig) + DeletionRequestEvent.KIND -> DeletionRequestEvent(id, pubKey, createdAt, tags, content, sig) DraftWrapEvent.KIND -> DraftWrapEvent(id, pubKey, createdAt, tags, content, sig) EmojiPackEvent.KIND -> EmojiPackEvent(id, pubKey, createdAt, tags, content, sig) - EmojiPackSelectionEvent.KIND -> EmojiPackSelectionEvent(id, pubKey, createdAt, tags, content, sig) + EmojiListEvent.KIND -> EmojiListEvent(id, pubKey, createdAt, tags, content, sig) EphemeralChatEvent.KIND -> EphemeralChatEvent(id, pubKey, createdAt, tags, content, sig) EphemeralChatListEvent.KIND -> EphemeralChatListEvent(id, pubKey, createdAt, tags, content, sig) ExternalIdentitiesEvent.KIND -> ExternalIdentitiesEvent(id, pubKey, createdAt, tags, content, sig) FedimintEvent.KIND -> FedimintEvent(id, pubKey, createdAt, tags, content, sig) - FileHeaderEvent.KIND -> FileHeaderEvent(id, pubKey, createdAt, tags, content, sig) + FileMetadataEvent.KIND -> FileMetadataEvent(id, pubKey, createdAt, tags, content, sig) ProfileGalleryEntryEvent.KIND -> ProfileGalleryEntryEvent(id, pubKey, createdAt, tags, content, sig) FileServersEvent.KIND -> FileServersEvent(id, pubKey, createdAt, tags, content, sig) FileStorageEvent.KIND -> FileStorageEvent(id, pubKey, createdAt, tags, content, sig) FileStorageHeaderEvent.KIND -> FileStorageHeaderEvent(id, pubKey, createdAt, tags, content, sig) FhirResourceEvent.KIND -> FhirResourceEvent(id, pubKey, createdAt, tags, content, sig) - FollowListEvent.KIND -> FollowListEvent(id, pubKey, createdAt, tags, content, sig) + StarterPackEvent.KIND -> StarterPackEvent(id, pubKey, createdAt, tags, content, sig) FundraiserEvent.KIND -> FundraiserEvent(id, pubKey, createdAt, tags, content, sig) GenericRepostEvent.KIND -> GenericRepostEvent(id, pubKey, createdAt, tags, content, sig) CyberspaceBagEvent.KIND -> CyberspaceBagEvent(id, pubKey, createdAt, tags, content, sig) @@ -701,9 +699,9 @@ class EventFactory { UserGraspListEvent.KIND -> UserGraspListEvent(id, pubKey, createdAt, tags, content, sig) GoodWikiAuthorListEvent.KIND -> GoodWikiAuthorListEvent(id, pubKey, createdAt, tags, content, sig) GoodWikiRelayListEvent.KIND -> GoodWikiRelayListEvent(id, pubKey, createdAt, tags, content, sig) - GoalEvent.KIND -> GoalEvent(id, pubKey, createdAt, tags, content, sig) + ZapGoalEvent.KIND -> ZapGoalEvent(id, pubKey, createdAt, tags, content, sig) FavoriteAlgoFeedsListEvent.KIND -> FavoriteAlgoFeedsListEvent(id, pubKey, createdAt, tags, content, sig) - HashtagListEvent.KIND -> HashtagListEvent(id, pubKey, createdAt, tags, content, sig) + InterestListEvent.KIND -> InterestListEvent(id, pubKey, createdAt, tags, content, sig) HighlightEvent.KIND -> HighlightEvent(id, pubKey, createdAt, tags, content, sig) HTTPAuthorizationEvent.KIND -> HTTPAuthorizationEvent(id, pubKey, createdAt, tags, content, sig) IndexerRelayListEvent.KIND -> IndexerRelayListEvent(id, pubKey, createdAt, tags, content, sig) @@ -713,14 +711,14 @@ class EventFactory { InteractiveStoryReadingStateEvent.KIND -> InteractiveStoryReadingStateEvent(id, pubKey, createdAt, tags, content, sig) LabelEvent.KIND -> LabelEvent(id, pubKey, createdAt, tags, content, sig) KindMuteSetEvent.KIND -> KindMuteSetEvent(id, pubKey, createdAt, tags, content, sig) - LabeledBookmarkListEvent.KIND -> LabeledBookmarkListEvent(id, pubKey, createdAt, tags, content, sig) + BookmarkSetEvent.KIND -> BookmarkSetEvent(id, pubKey, createdAt, tags, content, sig) LiveActivitiesChatMessageEvent.KIND -> LiveActivitiesChatMessageEvent(id, pubKey, createdAt, tags, content, sig) LiveActivitiesClipEvent.KIND -> LiveActivitiesClipEvent(id, pubKey, createdAt, tags, content, sig) LiveActivitiesEvent.KIND -> LiveActivitiesEvent(id, pubKey, createdAt, tags, content, sig) LiveActivitiesRaidEvent.KIND -> LiveActivitiesRaidEvent(id, pubKey, createdAt, tags, content, sig) - LnZapEvent.KIND -> LnZapEvent(id, pubKey, createdAt, tags, content, sig) - LnZapPaymentRequestEvent.KIND -> LnZapPaymentRequestEvent(id, pubKey, createdAt, tags, content, sig) - LnZapPaymentResponseEvent.KIND -> LnZapPaymentResponseEvent(id, pubKey, createdAt, tags, content, sig) + ZapReceiptEvent.KIND -> ZapReceiptEvent(id, pubKey, createdAt, tags, content, sig) + NwcRequestEvent.KIND -> NwcRequestEvent(id, pubKey, createdAt, tags, content, sig) + NwcResponseEvent.KIND -> NwcResponseEvent(id, pubKey, createdAt, tags, content, sig) OfferEvent.KIND -> OfferEvent(id, pubKey, createdAt, tags, content, sig) DebitEvent.KIND -> DebitEvent(id, pubKey, createdAt, tags, content, sig) ManageEvent.KIND -> ManageEvent(id, pubKey, createdAt, tags, content, sig) @@ -728,8 +726,8 @@ class EventFactory { NwcNotificationEvent.KIND -> NwcNotificationEvent(id, pubKey, createdAt, tags, content, sig) NwcNotificationEvent.LEGACY_KIND -> NwcNotificationEvent(id, pubKey, createdAt, tags, content, sig) LnZapPrivateEvent.KIND -> LnZapPrivateEvent(id, pubKey, createdAt, tags, content, sig) - LnZapRequestEvent.KIND -> LnZapRequestEvent(id, pubKey, createdAt, tags, content, sig) - LongTextNoteEvent.KIND -> LongTextNoteEvent(id, pubKey, createdAt, tags, content, sig) + ZapRequestEvent.KIND -> ZapRequestEvent(id, pubKey, createdAt, tags, content, sig) + LongFormContentEvent.KIND -> LongFormContentEvent(id, pubKey, createdAt, tags, content, sig) MarketplaceEvent.KIND -> MarketplaceEvent(id, pubKey, createdAt, tags, content, sig) MeetingRoomEvent.KIND -> MeetingRoomEvent(id, pubKey, createdAt, tags, content, sig) MeetingRoomPresenceEvent.KIND -> MeetingRoomPresenceEvent(id, pubKey, createdAt, tags, content, sig) @@ -758,55 +756,54 @@ class EventFactory { NipTextEvent.KIND -> NipTextEvent(id, pubKey, createdAt, tags, content, sig) NutzapEvent.KIND -> NutzapEvent(id, pubKey, createdAt, tags, content, sig) NutzapInfoEvent.KIND -> NutzapInfoEvent(id, pubKey, createdAt, tags, content, sig) - NutzapRedemptionEvent.KIND -> NutzapRedemptionEvent(id, pubKey, createdAt, tags, content, sig) NostrConnectEvent.KIND -> NostrConnectEvent(id, pubKey, createdAt, tags, content, sig) - NIP90StatusEvent.KIND -> NIP90StatusEvent(id, pubKey, createdAt, tags, content, sig) + DvmStatusEvent.KIND -> DvmStatusEvent(id, pubKey, createdAt, tags, content, sig) DvmHeartbeatEvent.KIND -> DvmHeartbeatEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TextExtractionRequestEvent.KIND -> NIP90TextExtractionRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TextExtractionResponseEvent.KIND -> NIP90TextExtractionResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90SummarizationRequestEvent.KIND -> NIP90SummarizationRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90SummarizationResponseEvent.KIND -> NIP90SummarizationResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TranslationRequestEvent.KIND -> NIP90TranslationRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TranslationResponseEvent.KIND -> NIP90TranslationResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TextGenerationRequestEvent.KIND -> NIP90TextGenerationRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TextGenerationResponseEvent.KIND -> NIP90TextGenerationResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ImageGenerationRequestEvent.KIND -> NIP90ImageGenerationRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ImageGenerationResponseEvent.KIND -> NIP90ImageGenerationResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90VideoConversionRequestEvent.KIND -> NIP90VideoConversionRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90VideoConversionResponseEvent.KIND -> NIP90VideoConversionResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90VideoTranslationRequestEvent.KIND -> NIP90VideoTranslationRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90VideoTranslationResponseEvent.KIND -> NIP90VideoTranslationResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ImageToVideoRequestEvent.KIND -> NIP90ImageToVideoRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ImageToVideoResponseEvent.KIND -> NIP90ImageToVideoResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TextToSpeechRequestEvent.KIND -> NIP90TextToSpeechRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90TextToSpeechResponseEvent.KIND -> NIP90TextToSpeechResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ContentDiscoveryRequestEvent.KIND -> NIP90ContentDiscoveryRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ContentDiscoveryResponseEvent.KIND -> NIP90ContentDiscoveryResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90UserDiscoveryRequestEvent.KIND -> NIP90UserDiscoveryRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90UserDiscoveryResponseEvent.KIND -> NIP90UserDiscoveryResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ContentSearchRequestEvent.KIND -> NIP90ContentSearchRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90ContentSearchResponseEvent.KIND -> NIP90ContentSearchResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90PeopleSearchRequestEvent.KIND -> NIP90PeopleSearchRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90PeopleSearchResponseEvent.KIND -> NIP90PeopleSearchResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventCountRequestEvent.KIND -> NIP90EventCountRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventCountResponseEvent.KIND -> NIP90EventCountResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90MalwareScanRequestEvent.KIND -> NIP90MalwareScanRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90MalwareScanResponseEvent.KIND -> NIP90MalwareScanResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventTimestampingRequestEvent.KIND -> NIP90EventTimestampingRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventTimestampingResponseEvent.KIND -> NIP90EventTimestampingResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90OpReturnRequestEvent.KIND -> NIP90OpReturnRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90OpReturnResponseEvent.KIND -> NIP90OpReturnResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventPublishScheduleRequestEvent.KIND -> NIP90EventPublishScheduleRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventPublishScheduleResponseEvent.KIND -> NIP90EventPublishScheduleResponseEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventPowDelegationRequestEvent.KIND -> NIP90EventPowDelegationRequestEvent(id, pubKey, createdAt, tags, content, sig) - NIP90EventPowDelegationResponseEvent.KIND -> NIP90EventPowDelegationResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmTextExtractionRequestEvent.KIND -> DvmTextExtractionRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmTextExtractionResponseEvent.KIND -> DvmTextExtractionResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmSummarizationRequestEvent.KIND -> DvmSummarizationRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmSummarizationResponseEvent.KIND -> DvmSummarizationResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmTranslationRequestEvent.KIND -> DvmTranslationRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmTranslationResponseEvent.KIND -> DvmTranslationResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmTextGenerationRequestEvent.KIND -> DvmTextGenerationRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmTextGenerationResponseEvent.KIND -> DvmTextGenerationResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmImageGenerationRequestEvent.KIND -> DvmImageGenerationRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmImageGenerationResponseEvent.KIND -> DvmImageGenerationResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmVideoConversionRequestEvent.KIND -> DvmVideoConversionRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmVideoConversionResponseEvent.KIND -> DvmVideoConversionResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmVideoTranslationRequestEvent.KIND -> DvmVideoTranslationRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmVideoTranslationResponseEvent.KIND -> DvmVideoTranslationResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmImageToVideoRequestEvent.KIND -> DvmImageToVideoRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmImageToVideoResponseEvent.KIND -> DvmImageToVideoResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmTextToSpeechRequestEvent.KIND -> DvmTextToSpeechRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmTextToSpeechResponseEvent.KIND -> DvmTextToSpeechResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmContentDiscoveryRequestEvent.KIND -> DvmContentDiscoveryRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmContentDiscoveryResponseEvent.KIND -> DvmContentDiscoveryResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmUserDiscoveryRequestEvent.KIND -> DvmUserDiscoveryRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmUserDiscoveryResponseEvent.KIND -> DvmUserDiscoveryResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmContentSearchRequestEvent.KIND -> DvmContentSearchRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmContentSearchResponseEvent.KIND -> DvmContentSearchResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmPeopleSearchRequestEvent.KIND -> DvmPeopleSearchRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmPeopleSearchResponseEvent.KIND -> DvmPeopleSearchResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventCountRequestEvent.KIND -> DvmEventCountRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventCountResponseEvent.KIND -> DvmEventCountResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmMalwareScanRequestEvent.KIND -> DvmMalwareScanRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmMalwareScanResponseEvent.KIND -> DvmMalwareScanResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventTimestampingRequestEvent.KIND -> DvmEventTimestampingRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventTimestampingResponseEvent.KIND -> DvmEventTimestampingResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmOpReturnRequestEvent.KIND -> DvmOpReturnRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmOpReturnResponseEvent.KIND -> DvmOpReturnResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventPublishScheduleRequestEvent.KIND -> DvmEventPublishScheduleRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventPublishScheduleResponseEvent.KIND -> DvmEventPublishScheduleResponseEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventPowDelegationRequestEvent.KIND -> DvmEventPowDelegationRequestEvent(id, pubKey, createdAt, tags, content, sig) + DvmEventPowDelegationResponseEvent.KIND -> DvmEventPowDelegationResponseEvent(id, pubKey, createdAt, tags, content, sig) OnchainZapEvent.KIND -> OnchainZapEvent(id, pubKey, createdAt, tags, content, sig) Bolt12ZapEvent.KIND -> Bolt12ZapEvent(id, pubKey, createdAt, tags, content, sig) Bolt12ZapIntentEvent.KIND -> Bolt12ZapIntentEvent(id, pubKey, createdAt, tags, content, sig) Bolt12OfferListEvent.KIND -> Bolt12OfferListEvent(id, pubKey, createdAt, tags, content, sig) OtsEvent.KIND -> OtsEvent(id, pubKey, createdAt, tags, content, sig) PaymentTargetsEvent.KIND -> PaymentTargetsEvent(id, pubKey, createdAt, tags, content, sig) - PeopleListEvent.KIND -> PeopleListEvent(id, pubKey, createdAt, tags, content, sig) + FollowSetEvent.KIND -> FollowSetEvent(id, pubKey, createdAt, tags, content, sig) PictureCurationSetEvent.KIND -> PictureCurationSetEvent(id, pubKey, createdAt, tags, content, sig) P2POrderEvent.KIND -> P2POrderEvent(id, pubKey, createdAt, tags, content, sig) PictureEvent.KIND -> PictureEvent(id, pubKey, createdAt, tags, content, sig) @@ -823,7 +820,7 @@ class EventFactory { Podcasting20EpisodeEvent.KIND -> Podcasting20EpisodeEvent(id, pubKey, createdAt, tags, content, sig) Podcasting20TrailerEvent.KIND -> Podcasting20TrailerEvent(id, pubKey, createdAt, tags, content, sig) ProductEvent.KIND -> ProductEvent(id, pubKey, createdAt, tags, content, sig) - PrivateDmEvent.KIND -> PrivateDmEvent(id, pubKey, createdAt, tags, content, sig) + EncryptedDmEvent.KIND -> EncryptedDmEvent(id, pubKey, createdAt, tags, content, sig) PrivateOutboxRelayListEvent.KIND -> PrivateOutboxRelayListEvent(id, pubKey, createdAt, tags, content, sig) ProxyRelayListEvent.KIND -> ProxyRelayListEvent(id, pubKey, createdAt, tags, content, sig) PublicMessageEvent.KIND -> PublicMessageEvent(id, pubKey, createdAt, tags, content, sig) @@ -842,7 +839,7 @@ class EventFactory { PublicationIndexEvent.KIND -> PublicationIndexEvent(id, pubKey, createdAt, tags, content, sig) PublicationContentEvent.KIND -> PublicationContentEvent(id, pubKey, createdAt, tags, content, sig) RelayReviewEvent.KIND -> RelayReviewEvent(id, pubKey, createdAt, tags, content, sig) - ContactCardEvent.KIND -> ContactCardEvent(id, pubKey, createdAt, tags, content, sig) + UserAssertionEvent.KIND -> UserAssertionEvent(id, pubKey, createdAt, tags, content, sig) EventAssertionEvent.KIND -> EventAssertionEvent(id, pubKey, createdAt, tags, content, sig) AddressableAssertionEvent.KIND -> AddressableAssertionEvent(id, pubKey, createdAt, tags, content, sig) ExternalIdAssertionEvent.KIND -> ExternalIdAssertionEvent(id, pubKey, createdAt, tags, content, sig) @@ -875,24 +872,23 @@ class EventFactory { ControlEditionEvent.KIND -> ControlEditionEvent(id, pubKey, createdAt, tags, content, sig) ConcordInviteListEvent.KIND -> ConcordInviteListEvent(id, pubKey, createdAt, tags, content, sig) ConcordInviteBundleEvent.KIND -> ConcordInviteBundleEvent(id, pubKey, createdAt, tags, content, sig) - SealedRumorEvent.KIND -> SealedRumorEvent(id, pubKey, createdAt, tags, content, sig) + SealEvent.KIND -> SealEvent(id, pubKey, createdAt, tags, content, sig) SearchRelayListEvent.KIND -> SearchRelayListEvent(id, pubKey, createdAt, tags, content, sig) SimpleGroupListEvent.KIND -> SimpleGroupListEvent(id, pubKey, createdAt, tags, content, sig) SoftwareApplicationEvent.KIND -> SoftwareApplicationEvent(id, pubKey, createdAt, tags, content, sig) SoftwareAssetEvent.KIND -> SoftwareAssetEvent(id, pubKey, createdAt, tags, content, sig) StallEvent.KIND -> StallEvent(id, pubKey, createdAt, tags, content, sig) - StatusEvent.KIND -> StatusEvent(id, pubKey, createdAt, tags, content, sig) + UserStatusEvent.KIND -> UserStatusEvent(id, pubKey, createdAt, tags, content, sig) TextNoteEvent.KIND -> TextNoteEvent(id, pubKey, createdAt, tags, content, sig) ThreadEvent.KIND -> ThreadEvent(id, pubKey, createdAt, tags, content, sig) TextNoteModificationEvent.KIND -> TextNoteModificationEvent(id, pubKey, createdAt, tags, content, sig) - TokenEvent.KIND -> TokenEvent(id, pubKey, createdAt, tags, content, sig) TorrentEvent.KIND -> TorrentEvent(id, pubKey, createdAt, tags, content, sig) TorrentCommentEvent.KIND -> TorrentCommentEvent(id, pubKey, createdAt, tags, content, sig) TrustedRelayListEvent.KIND -> TrustedRelayListEvent(id, pubKey, createdAt, tags, content, sig) TrustProviderListEvent.KIND -> TrustProviderListEvent(id, pubKey, createdAt, tags, content, sig) VideoCurationSetEvent.KIND -> VideoCurationSetEvent(id, pubKey, createdAt, tags, content, sig) - VideoHorizontalEvent.KIND -> VideoHorizontalEvent(id, pubKey, createdAt, tags, content, sig) - VideoVerticalEvent.KIND -> VideoVerticalEvent(id, pubKey, createdAt, tags, content, sig) + AddressableNormalVideoEvent.KIND -> AddressableNormalVideoEvent(id, pubKey, createdAt, tags, content, sig) + AddressableShortVideoEvent.KIND -> AddressableShortVideoEvent(id, pubKey, createdAt, tags, content, sig) TextTrackEvent.KIND -> TextTrackEvent(id, pubKey, createdAt, tags, content, sig) VideoCollaborationEvent.KIND -> VideoCollaborationEvent(id, pubKey, createdAt, tags, content, sig) VideoNormalEvent.KIND -> VideoNormalEvent(id, pubKey, createdAt, tags, content, sig) @@ -901,7 +897,7 @@ class EventFactory { VoiceReplyEvent.KIND -> VoiceReplyEvent(id, pubKey, createdAt, tags, content, sig) WakeUpEvent.KIND -> WakeUpEvent(id, pubKey, createdAt, tags, content, sig) WebBookmarkEvent.KIND -> WebBookmarkEvent(id, pubKey, createdAt, tags, content, sig) - WikiNoteEvent.KIND -> WikiNoteEvent(id, pubKey, createdAt, tags, content, sig) + WikiArticleEvent.KIND -> WikiArticleEvent(id, pubKey, createdAt, tags, content, sig) WorkoutRecordEvent.KIND -> WorkoutRecordEvent(id, pubKey, createdAt, tags, content, sig) ExerciseTemplateEvent.KIND -> ExerciseTemplateEvent(id, pubKey, createdAt, tags, content, sig) else -> factories[kind]?.build(id, pubKey, createdAt, tags, content, sig) ?: Event(id, pubKey, createdAt, kind, tags, content, sig) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEventTest.kt index 0f53a118c3..ec1a31dea2 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/buzz/moderation/ModerationUnbanEventTest.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.quartz.buzz.moderation -import com.vitorpamplona.quartz.nip75ZapGoals.GoalEvent +import com.vitorpamplona.quartz.nip75ZapGoals.ZapGoalEvent import kotlin.test.Test import kotlin.test.assertEquals @@ -40,7 +40,7 @@ class ModerationUnbanEventTest { @Test fun kindCollidesWithNip75GoalEvent() { // Documents the collision: this kind must NOT be registered in EventFactory, - // where 9041 already belongs to the NIP-75 GoalEvent. - assertEquals(GoalEvent.KIND, ModerationUnbanEvent.KIND) + // where 9041 already belongs to the NIP-75 ZapGoalEvent. + assertEquals(ZapGoalEvent.KIND, ModerationUnbanEvent.KIND) } } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisherTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisherTest.kt index a5ef8d76eb..241e13ed53 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisherTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/graperank/GrapeRankPublisherTest.kt @@ -27,8 +27,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip01Core.store.IEventStore import com.vitorpamplona.quartz.nip01Core.store.sqlite.EventStore -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import kotlinx.coroutines.runBlocking import kotlin.test.Test import kotlin.test.assertEquals @@ -48,8 +48,8 @@ class GrapeRankPublisherTest { provider: String, ): Map<String, Int?> = store - .query<Event>(Filter(kinds = listOf(ContactCardEvent.KIND), authors = listOf(provider))) - .filterIsInstance<ContactCardEvent>() + .query<Event>(Filter(kinds = listOf(UserAssertionEvent.KIND), authors = listOf(provider))) + .filterIsInstance<UserAssertionEvent>() .associate { it.aboutUser() to it.rank() } @Test @@ -72,7 +72,7 @@ class GrapeRankPublisherTest { assertEquals(mapOf(a to 50, b to 10), cardsByTarget(store, provider)) val firstIds = store - .query<Event>(Filter(kinds = listOf(ContactCardEvent.KIND), authors = listOf(provider))) + .query<Event>(Filter(kinds = listOf(UserAssertionEvent.KIND), authors = listOf(provider))) .map { it.id } .toSet() @@ -83,7 +83,7 @@ class GrapeRankPublisherTest { assertEquals(0, r2.retracted) val secondIds = store - .query<Event>(Filter(kinds = listOf(ContactCardEvent.KIND), authors = listOf(provider))) + .query<Event>(Filter(kinds = listOf(UserAssertionEvent.KIND), authors = listOf(provider))) .map { it.id } .toSet() assertEquals(firstIds, secondIds) @@ -98,7 +98,7 @@ class GrapeRankPublisherTest { assertEquals(mapOf(a to 60, c to 5), cardsByTarget(store, provider)) // …but its kind:5 tombstone remains, ready to sync to relays. - val deletions = store.query<Event>(Filter(kinds = listOf(DeletionEvent.KIND), authors = listOf(provider))) + val deletions = store.query<Event>(Filter(kinds = listOf(DeletionRequestEvent.KIND), authors = listOf(provider))) assertEquals(1, deletions.size) store.close() @@ -137,10 +137,10 @@ class GrapeRankPublisherTest { val a = hexKey(0xA) - suspend fun cardFor(target: String): ContactCardEvent = + suspend fun cardFor(target: String): UserAssertionEvent = store - .query<Event>(Filter(kinds = listOf(ContactCardEvent.KIND), authors = listOf(provider))) - .filterIsInstance<ContactCardEvent>() + .query<Event>(Filter(kinds = listOf(UserAssertionEvent.KIND), authors = listOf(provider))) + .filterIsInstance<UserAssertionEvent>() .first { it.aboutUser() == target } // A card carrying rank + followers + hops persists all three tags. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt index c92f07fb5a..25990b13ff 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt @@ -32,15 +32,17 @@ import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.SoftwareAss import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.apkCertificateHash import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.platform import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.versionCode -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.SoftwareReleaseEvent import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.asSoftwareRelease import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.isNip82SoftwareRelease import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.shared.Platform import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtag +import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent +import com.vitorpamplona.quartz.utils.EventFactory import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse +import kotlin.test.assertIs import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -107,7 +109,7 @@ class SoftwareApplicationEventTest { id = "0".repeat(64), pubKey = "1".repeat(64), createdAt = 0, - kind = SoftwareReleaseEvent.KIND, + kind = ReleaseArtifactSetEvent.KIND, tags = arrayOf( arrayOf("d", "com.example.app@1.0.0"), @@ -126,7 +128,7 @@ class SoftwareApplicationEventTest { id = "0".repeat(64), pubKey = "1".repeat(64), createdAt = 0, - kind = SoftwareReleaseEvent.KIND, + kind = ReleaseArtifactSetEvent.KIND, tags = arrayOf(arrayOf("d", "some-uuid"), arrayOf("title", "My Release")), content = "", sig = "", @@ -141,7 +143,7 @@ class SoftwareApplicationEventTest { id = "0".repeat(64), pubKey = "1".repeat(64), createdAt = 0, - kind = SoftwareReleaseEvent.KIND, + kind = ReleaseArtifactSetEvent.KIND, tags = arrayOf( arrayOf("d", "com.example.app@1.0.0"), @@ -158,6 +160,53 @@ class SoftwareApplicationEventTest { assertEquals("main", release.channel()) } + @Test + fun eventFactory_parsesNip82ReleaseAsReleaseArtifactSet() { + val event = + EventFactory.create<Event>( + id = "0".repeat(64), + pubKey = "1".repeat(64), + createdAt = 0, + kind = ReleaseArtifactSetEvent.KIND, + tags = + arrayOf( + arrayOf("d", "com.example.app@1.0.0"), + arrayOf("i", "com.example.app"), + arrayOf("version", "1.0.0"), + arrayOf("c", "main"), + arrayOf("e", "2".repeat(64)), + ), + content = "Initial release", + sig = "", + ) + val release = assertIs<ReleaseArtifactSetEvent>(event) + assertTrue(release.isNip82SoftwareRelease()) + assertEquals("com.example.app", release.appId()) + assertEquals("1.0.0", release.version()) + assertEquals("main", release.channel()) + assertEquals(1, release.assets().size) + assertEquals("Initial release", release.releaseNotes()) + } + + @Test + fun buildSoftwareRelease_roundTripsNip82Fields() { + val template = + ReleaseArtifactSetEvent.buildSoftwareRelease( + appId = "com.example.app", + version = "2.0.0", + channel = "beta", + assets = emptyList(), + releaseNotes = "notes", + ) + assertEquals(ReleaseArtifactSetEvent.KIND, template.kind) + val tagsByName = template.tags.associate { it[0] to it.getOrNull(1) } + assertEquals("com.example.app@2.0.0", tagsByName["d"]) + assertEquals("com.example.app", tagsByName["i"]) + assertEquals("2.0.0", tagsByName["version"]) + assertEquals("beta", tagsByName["c"]) + assertEquals("notes", template.content) + } + @Test fun parses_realWorldAmethystEvent() { // Real NIP-82 event published for Amethyst — used as a regression fixture so renderer diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/AssertionEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/AssertionEventTest.kt index 7eccdaf3dd..bc225b0cb9 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/AssertionEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/AssertionEventTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.experimental.nip85TrustedAssertions import com.vitorpamplona.quartz.nip85TrustedAssertions.addressables.AddressableAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.events.EventAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.externalIds.ExternalIdAssertionEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull @@ -36,7 +36,7 @@ class AssertionEventTest { fun parseUserAssertionWithAllTags() { val targetUser = "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411" val event = - ContactCardEvent( + UserAssertionEvent( id = "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234", pubKey = servicePubKey, createdAt = 1700000000, @@ -89,7 +89,7 @@ class AssertionEventTest { @Test fun parseUserAssertionMinimalTags() { val event = - ContactCardEvent( + UserAssertionEvent( id = "abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234", pubKey = servicePubKey, createdAt = 1700000000, @@ -228,7 +228,7 @@ class AssertionEventTest { @Test fun eventKindsAreCorrect() { - assertEquals(30382, ContactCardEvent.KIND) + assertEquals(30382, UserAssertionEvent.KIND) assertEquals(30383, EventAssertionEvent.KIND) assertEquals(30384, AddressableAssertionEvent.KIND) assertEquals(30385, ExternalIdAssertionEvent.KIND) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/ContactCardPetNameTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/ContactCardPetNameTest.kt index 17d1f2d14b..1f58771e64 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/ContactCardPetNameTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/ContactCardPetNameTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.experimental.nip85TrustedAssertions import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip85TrustedAssertions.users.tags.PetNameTag import com.vitorpamplona.quartz.nip85TrustedAssertions.users.tags.SummaryTag import kotlinx.coroutines.test.runTest @@ -36,15 +36,15 @@ class ContactCardPetNameTest { val signer = NostrSignerInternal(KeyPair()) val targetUser = "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411" - private suspend fun ContactCardEvent.privatePetName() = privateTags(signer)?.firstNotNullOfOrNull(PetNameTag::parse) + private suspend fun UserAssertionEvent.privatePetName() = privateTags(signer)?.firstNotNullOfOrNull(PetNameTag::parse) - private suspend fun ContactCardEvent.privateSummary() = privateTags(signer)?.firstNotNullOfOrNull(SummaryTag::parse) + private suspend fun UserAssertionEvent.privateSummary() = privateTags(signer)?.firstNotNullOfOrNull(SummaryTag::parse) @Test fun createKeepsPetNameAndSummaryEncrypted() = runTest { val card = - ContactCardEvent.create( + UserAssertionEvent.create( targetUser = targetUser, petName = "Bob from work", summary = "Met at the conference", @@ -66,7 +66,7 @@ class ContactCardPetNameTest { fun updateReplacesPetNameAndKeepsOtherPrivateTags() = runTest { val card = - ContactCardEvent.create( + UserAssertionEvent.create( targetUser = targetUser, petName = "Bob", summary = "old summary", @@ -77,7 +77,7 @@ class ContactCardPetNameTest { val updated = signer.sign( - ContactCardEvent.updatePetNameAndSummary( + UserAssertionEvent.updatePetNameAndSummary( earlierVersion = card, petName = "Bobby", summary = "new summary", @@ -102,7 +102,7 @@ class ContactCardPetNameTest { fun updateWithNullsClearsBothFields() = runTest { val card = - ContactCardEvent.create( + UserAssertionEvent.create( targetUser = targetUser, petName = "Bob", summary = "summary", @@ -111,7 +111,7 @@ class ContactCardPetNameTest { val cleared = signer.sign( - ContactCardEvent.updatePetNameAndSummary( + UserAssertionEvent.updatePetNameAndSummary( earlierVersion = card, petName = null, summary = null, @@ -130,7 +130,7 @@ class ContactCardPetNameTest { val newEmoji = EmojiUrlTag("soapbox", "https://new.example/soapbox.png") val card = - ContactCardEvent.create( + UserAssertionEvent.create( targetUser = targetUser, petName = "Bob :wave:", emojis = listOf(oldEmoji), @@ -140,7 +140,7 @@ class ContactCardPetNameTest { val updated = signer.sign( - ContactCardEvent.updatePetNameAndSummary( + UserAssertionEvent.updatePetNameAndSummary( earlierVersion = card, petName = "Bob :soapbox:", emojis = listOf(newEmoji), @@ -159,7 +159,7 @@ class ContactCardPetNameTest { runTest { // a card that (incorrectly) carries public petname/summary tags val card = - ContactCardEvent.create( + UserAssertionEvent.create( targetUser = targetUser, signer = signer, publicInitializer = { @@ -171,7 +171,7 @@ class ContactCardPetNameTest { val updated = signer.sign( - ContactCardEvent.updatePetNameAndSummary( + UserAssertionEvent.updatePetNameAndSummary( earlierVersion = card, petName = "private bob", signer = signer, diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjectionTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjectionTest.kt index d16e03b68f..be617307b3 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjectionTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/cache/projection/EventStoreProjectionTest.kt @@ -29,9 +29,9 @@ import com.vitorpamplona.quartz.nip01Core.store.ObservableEventStore import com.vitorpamplona.quartz.nip01Core.store.ObservableEventStore.StoreChange import com.vitorpamplona.quartz.nip01Core.store.sqlite.EventStore import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtag -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip40Expiration.expiration import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent import com.vitorpamplona.quartz.utils.TimeUtils @@ -186,13 +186,13 @@ class EventStoreProjectionTest { fun addressableUpdateMutatesSlotInPlace() = runBlocking { val time = TimeUtils.now() - val v1 = signer.sign(LongTextNoteEvent.build("blog v1", "title", dTag = "blog", createdAt = time)) + val v1 = signer.sign(LongFormContentEvent.build("blog v1", "title", dTag = "blog", createdAt = time)) observable.insert(v1) val projection = - projectionOf<LongTextNoteEvent>( + projectionOf<LongFormContentEvent>( Filter( - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), authors = listOf(v1.pubKey), tags = mapOf("d" to listOf("blog")), ), @@ -201,7 +201,7 @@ class EventStoreProjectionTest { val seedList = projection.items val slot = seedList[0] - val v2 = signer.sign(LongTextNoteEvent.build("blog v2", "title", dTag = "blog", createdAt = time + 1)) + val v2 = signer.sign(LongFormContentEvent.build("blog v2", "title", dTag = "blog", createdAt = time + 1)) observable.insert(v2) awaitFlow(slot) { it.id == v2.id } @@ -220,7 +220,7 @@ class EventStoreProjectionTest { // v1 carries tag "nostr"; v2 changes the tag to "bitcoin". val v1 = signer.sign( - LongTextNoteEvent.build("blog v1", "title", dTag = "blog", createdAt = time) { + LongFormContentEvent.build("blog v1", "title", dTag = "blog", createdAt = time) { hashtag("nostr") }, ) @@ -228,9 +228,9 @@ class EventStoreProjectionTest { // Filter narrows to events that ALSO carry hashtag "nostr". val projection = - projectionOf<LongTextNoteEvent>( + projectionOf<LongFormContentEvent>( Filter( - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), authors = listOf(v1.pubKey), tags = mapOf("t" to listOf("nostr")), ), @@ -240,7 +240,7 @@ class EventStoreProjectionTest { val v2 = signer.sign( - LongTextNoteEvent.build("blog v2", "title", dTag = "blog", createdAt = time + 1) { + LongFormContentEvent.build("blog v2", "title", dTag = "blog", createdAt = time + 1) { hashtag("bitcoin") }, ) @@ -300,7 +300,7 @@ class EventStoreProjectionTest { projection.awaitLoaded() assertEquals(2, projection.items.size) - val deletion = signer.sign(DeletionEvent.build(listOf(a))) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(a))) observable.insert(deletion) val after = projection.awaitItems { it.size == 1 } @@ -322,7 +322,7 @@ class EventStoreProjectionTest { val seed = projection.items assertEquals(1, seed.size) - val foreignDeletion = otherSigner.sign(DeletionEvent.build(listOf(a))) + val foreignDeletion = otherSigner.sign(DeletionRequestEvent.build(listOf(a))) observable.insert(foreignDeletion) // Give the projection time to process the event. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AddressableTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AddressableTest.kt index 759d1b223b..8c26a66714 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AddressableTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AddressableTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.nip01Core.store.sqlite import androidx.sqlite.SQLiteException import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlin.test.Test import kotlin.test.assertEquals @@ -36,9 +36,9 @@ class AddressableTest : BaseDBTest() { fun testReplacingAddressables() = forEachDB { db -> val time = TimeUtils.now() - val version1 = signer.sign(LongTextNoteEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) - val version2 = signer.sign(LongTextNoteEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) - val version3 = signer.sign(LongTextNoteEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) + val version1 = signer.sign(LongFormContentEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) + val version2 = signer.sign(LongFormContentEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) + val version3 = signer.sign(LongFormContentEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) val addressableQuery = Filter(kinds = listOf(version1.kind), authors = listOf(version1.pubKey), tags = mapOf("d" to listOf(version1.dTag()))) @@ -65,9 +65,9 @@ class AddressableTest : BaseDBTest() { fun testBlockingOldAddressables() = forEachDB { db -> val time = TimeUtils.now() - val version1 = signer.sign(LongTextNoteEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) - val version2 = signer.sign(LongTextNoteEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) - val version3 = signer.sign(LongTextNoteEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) + val version1 = signer.sign(LongFormContentEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) + val version2 = signer.sign(LongFormContentEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) + val version3 = signer.sign(LongFormContentEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) val addressableQuery = Filter(kinds = listOf(version1.kind), authors = listOf(version1.pubKey), tags = mapOf("d" to listOf(version1.dTag()))) @@ -97,7 +97,7 @@ class AddressableTest : BaseDBTest() { // different content -> different ids. NIP-01 says the lower-id wins. val a = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "version A", "title", dTag = "tie", @@ -106,7 +106,7 @@ class AddressableTest : BaseDBTest() { ) val b = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "version B", "title", dTag = "tie", @@ -129,7 +129,7 @@ class AddressableTest : BaseDBTest() { val time = TimeUtils.now() val a = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "version A", "title", dTag = "tie", @@ -138,7 +138,7 @@ class AddressableTest : BaseDBTest() { ) val b = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "version B", "title", dTag = "tie", diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AuthorsMissingOutboxTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AuthorsMissingOutboxTest.kt index 103eb82d3c..d70bdd6952 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AuthorsMissingOutboxTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/AuthorsMissingOutboxTest.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.quartz.nip01Core.store.sqlite import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -83,7 +83,7 @@ class AuthorsMissingOutboxTest : BaseDBTest() { // NIP-09: the author deletes their own relay list. No 10002 row // remains, so the anti-join reports them as missing again. - db.insert(signer.sign(DeletionEvent.build(listOf(relayList)))) + db.insert(signer.sign(DeletionRequestEvent.build(listOf(relayList)))) assertEquals(setOf(signer.pubKey), db.authorsMissingOutbox().toSet()) } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/BasicTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/BasicTest.kt index 6c695ff744..bff21ff649 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/BasicTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/BasicTest.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtag import com.vitorpamplona.quartz.nip01Core.tags.hashtags.isTaggedHash -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import kotlin.test.Test @@ -261,7 +261,7 @@ class BasicTest : BaseDBTest() { forEachDB { db -> // Pre-load a target event and a deletion that blocks re-insertion. val deletedTarget = signer.sign(TextNoteEvent.build("target", createdAt = 1)) - val deletion = signer.sign(DeletionEvent.build(listOf(deletedTarget), createdAt = 100)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(deletedTarget), createdAt = 100)) db.insert(deletion) db.assertQuery(deletion, Filter(ids = listOf(deletion.id))) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionTest.kt index 811e9b5323..62ab2e4183 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/DeletionTest.kt @@ -24,9 +24,9 @@ import androidx.sqlite.SQLiteException import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlin.test.Test @@ -51,7 +51,7 @@ class DeletionTest : BaseDBTest() { db.assertQuery(note2, Filter(ids = listOf(note2.id))) db.assertQuery(note3, Filter(ids = listOf(note3.id))) - val deletion = signer.sign(DeletionEvent.build(listOf(note1))) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(note1))) db.insert(deletion) @@ -74,9 +74,9 @@ class DeletionTest : BaseDBTest() { fun testInsertDeleteEventOfAddressable() = forEachDB { db -> val time = TimeUtils.now() - val note1 = signer.sign(LongTextNoteEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) - val note2 = signer.sign(LongTextNoteEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) - val note3 = signer.sign(LongTextNoteEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) + val note1 = signer.sign(LongFormContentEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) + val note2 = signer.sign(LongFormContentEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) + val note3 = signer.sign(LongFormContentEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) db.insert(note1) @@ -95,7 +95,7 @@ class DeletionTest : BaseDBTest() { // Deletion must be timestamped >= note3.createdAt for it to // remove the latest addressable per NIP-09. - val deletion = signer.sign(DeletionEvent.build(listOf(note1), createdAt = time + 100)) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(note1), createdAt = time + 100)) db.insert(deletion) @@ -118,9 +118,9 @@ class DeletionTest : BaseDBTest() { fun testInsertDeleteEventOfAddressable2() = forEachDB { db -> val time = TimeUtils.now() - val note1 = signer.sign(LongTextNoteEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) - val note2 = signer.sign(LongTextNoteEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) - val note3 = signer.sign(LongTextNoteEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) + val note1 = signer.sign(LongFormContentEvent.build("my cool blog, version 1", "title", dTag = "my-cool-blog", createdAt = time)) + val note2 = signer.sign(LongFormContentEvent.build("my cool blog, version 2", "title", dTag = "my-cool-blog", createdAt = time + 1)) + val note3 = signer.sign(LongFormContentEvent.build("my cool blog, version 3", "title", dTag = "my-cool-blog", createdAt = time + 2)) db.insert(note1) db.insert(note2) @@ -130,7 +130,7 @@ class DeletionTest : BaseDBTest() { db.assertQuery(null, Filter(ids = listOf(note2.id))) db.assertQuery(note3, Filter(ids = listOf(note3.id))) - val deletion = signer.sign(DeletionEvent.buildAddressOnly(listOf(note1), createdAt = time + 100)) + val deletion = signer.sign(DeletionRequestEvent.buildAddressOnly(listOf(note1), createdAt = time + 100)) db.insert(deletion) @@ -165,7 +165,7 @@ class DeletionTest : BaseDBTest() { db.assertQuery(wrap1, Filter(ids = listOf(wrap1.id))) db.assertQuery(wrap2, Filter(ids = listOf(wrap2.id))) - val randomDeletionToWrap = signer.sign(DeletionEvent.build(listOf(wrap1))) + val randomDeletionToWrap = signer.sign(DeletionRequestEvent.build(listOf(wrap1))) db.insert(randomDeletionToWrap) @@ -173,7 +173,7 @@ class DeletionTest : BaseDBTest() { db.assertQuery(wrap1, Filter(ids = listOf(wrap1.id))) db.assertQuery(wrap2, Filter(ids = listOf(wrap2.id))) - val deletion = me.sign(DeletionEvent.build(listOf(wrap1))) + val deletion = me.sign(DeletionRequestEvent.build(listOf(wrap1))) db.insert(deletion) @@ -427,14 +427,14 @@ class DeletionTest : BaseDBTest() { // A deletion event from a *different* author must not remove the // target — only the original author can delete via NIP-09. - val strangerDeletion = stranger.sign(DeletionEvent.build(listOf(target))) + val strangerDeletion = stranger.sign(DeletionRequestEvent.build(listOf(target))) db.insert(strangerDeletion) db.assertQuery(target, Filter(ids = listOf(target.id))) db.assertQuery(strangerDeletion, Filter(ids = listOf(strangerDeletion.id))) // The owner's deletion still works after a failed third-party attempt. - val ownerDeletion = owner.sign(DeletionEvent.build(listOf(target))) + val ownerDeletion = owner.sign(DeletionRequestEvent.build(listOf(target))) db.insert(ownerDeletion) db.assertQuery(null, Filter(ids = listOf(target.id))) } @@ -447,7 +447,7 @@ class DeletionTest : BaseDBTest() { // a second deletion that removes the first. Cross-author // deletion of a kind-5 must NOT work. val target = signer.sign(TextNoteEvent.build("target")) - val firstDeletion = signer.sign(DeletionEvent.build(listOf(target), createdAt = 100)) + val firstDeletion = signer.sign(DeletionRequestEvent.build(listOf(target), createdAt = 100)) db.insert(target) db.insert(firstDeletion) @@ -457,13 +457,13 @@ class DeletionTest : BaseDBTest() { // Stranger cannot delete the kind-5. val stranger = NostrSignerSync() val strangerDeletion = - stranger.sign(DeletionEvent.build(listOf(firstDeletion), createdAt = 200)) + stranger.sign(DeletionRequestEvent.build(listOf(firstDeletion), createdAt = 200)) db.insert(strangerDeletion) db.assertQuery(firstDeletion, Filter(ids = listOf(firstDeletion.id))) // Same author can delete their previous kind-5. val secondDeletion = - signer.sign(DeletionEvent.build(listOf(firstDeletion), createdAt = 300)) + signer.sign(DeletionRequestEvent.build(listOf(firstDeletion), createdAt = 300)) db.insert(secondDeletion) db.assertQuery(null, Filter(ids = listOf(firstDeletion.id))) db.assertQuery(secondDeletion, Filter(ids = listOf(secondDeletion.id))) @@ -493,17 +493,17 @@ class DeletionTest : BaseDBTest() { // Inner author (the "sender") cannot delete a wrap addressed to // someone else — sender pubkey != wrap's pubkey_owner_hash. - val senderDeletion = sender.sign(DeletionEvent.build(listOf(wrap))) + val senderDeletion = sender.sign(DeletionRequestEvent.build(listOf(wrap))) db.insert(senderDeletion) db.assertQuery(wrap, Filter(ids = listOf(wrap.id))) // An unrelated third party can't delete it either. - val unrelatedDeletion = unrelated.sign(DeletionEvent.build(listOf(wrap))) + val unrelatedDeletion = unrelated.sign(DeletionRequestEvent.build(listOf(wrap))) db.insert(unrelatedDeletion) db.assertQuery(wrap, Filter(ids = listOf(wrap.id))) // The recipient (whose pubkey matches pubkey_owner_hash) can. - val recipientDeletion = recipient.sign(DeletionEvent.build(listOf(wrap))) + val recipientDeletion = recipient.sign(DeletionRequestEvent.build(listOf(wrap))) db.insert(recipientDeletion) db.assertQuery(null, Filter(ids = listOf(wrap.id))) } @@ -514,7 +514,7 @@ class DeletionTest : BaseDBTest() { // Old addressable (will be deleted by deletion request) val old = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "version 1", "title", dTag = "blog-1", @@ -528,7 +528,7 @@ class DeletionTest : BaseDBTest() { // Deletion targeting the address with created_at = 1500 val deletion = signer.sign( - DeletionEvent.buildAddressOnly( + DeletionRequestEvent.buildAddressOnly( listOf(old), createdAt = 1500, ), @@ -542,7 +542,7 @@ class DeletionTest : BaseDBTest() { // created_at AFTER the deletion. NIP-09 says it must be kept. val newer = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "version 2", "title", dTag = "blog-1", diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/InsertOutcomeClassificationTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/InsertOutcomeClassificationTest.kt index 6507de40f4..2bdcba4dc0 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/InsertOutcomeClassificationTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/InsertOutcomeClassificationTest.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync import com.vitorpamplona.quartz.nip01Core.store.IEventStore import com.vitorpamplona.quartz.nip01Core.store.RejectionReason import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlin.test.Test import kotlin.test.assertEquals @@ -111,8 +111,8 @@ class InsertOutcomeClassificationTest : BaseDBTest() { fun olderAddressableIsRejectedAsSuperseded() = forEachDB { db -> val time = TimeUtils.now() - val older = signer.sign(LongTextNoteEvent.build("v1", "title", dTag = "blog", createdAt = time)) - val newer = signer.sign(LongTextNoteEvent.build("v2", "title", dTag = "blog", createdAt = time + 1)) + val older = signer.sign(LongFormContentEvent.build("v1", "title", dTag = "blog", createdAt = time)) + val newer = signer.sign(LongFormContentEvent.build("v2", "title", dTag = "blog", createdAt = time + 1)) assertEquals(IEventStore.InsertOutcome.Accepted, db.batchInsert(listOf<Event>(newer))[0]) assertRejected(RejectionReason.SUPERSEDED, db.batchInsert(listOf<Event>(older))[0]) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt index ac034e6af3..496def0887 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import kotlin.test.Test import kotlin.test.assertEquals @@ -984,7 +984,7 @@ class QueryAssemblerTest : BaseDBTest() { forEachDB { db -> val filter = Filter( - kinds = listOf(ContactCardEvent.KIND), + kinds = listOf(UserAssertionEvent.KIND), authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"), tags = mapOf( diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SearchTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SearchTest.kt index 7f238e30e6..23024b8be5 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SearchTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SearchTest.kt @@ -29,10 +29,10 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.utils.TimeUtils import kotlin.test.Test @@ -134,7 +134,7 @@ class SearchTest : BaseDBTest() { val time = TimeUtils.now() val v1 = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "first version uniqalpha", title = "blog title", dTag = "fts-rotation", @@ -143,7 +143,7 @@ class SearchTest : BaseDBTest() { ) val v2 = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "second version uniqbeta", title = "blog title", dTag = "fts-rotation", @@ -163,10 +163,10 @@ class SearchTest : BaseDBTest() { @Test fun testNewlySearchableKinds() = forEachDB { db -> - // CalendarEvent indexes the title tag plus the free-text content. + // CalendarCollectionEvent indexes the title tag plus the free-text content. val cal = signer.sign( - CalendarEvent.build( + CalendarCollectionEvent.build( title = "uniqtitle Meetup", content = "annual uniqbody gathering", ), @@ -254,7 +254,7 @@ class SearchTest : BaseDBTest() { // events that were stored before their kind became searchable. val cal = signer.sign( - CalendarEvent.build( + CalendarCollectionEvent.build( title = "uniqtitle Meetup", content = "annual uniqbody gathering", ), diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/ChannelSettingsTagTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/ChannelSettingsTagTest.kt index 080e477790..6f0f7e4b28 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/ChannelSettingsTagTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/ChannelSettingsTagTest.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.quartz.nip29RelayGroups import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent import com.vitorpamplona.quartz.utils.EventFactory import kotlin.test.Test import kotlin.test.assertEquals @@ -48,22 +48,22 @@ class ChannelSettingsTagTest { @Test fun editEmitsVisibilityTagOnlyWhenSet() { - val priv = EditMetadataEvent.build(gid, visibility = "private") + val priv = GroupEditMetadataEvent.build(gid, visibility = "private") assertEquals("private", tagValue(priv.tags, "visibility")) - val open = EditMetadataEvent.build(gid, visibility = "open") + val open = GroupEditMetadataEvent.build(gid, visibility = "open") assertEquals("open", tagValue(open.tags, "visibility")) // Absent by default so an ordinary metadata edit doesn't reclassify visibility. - assertNull(tagValue(EditMetadataEvent.build(gid, name = "x").tags, "visibility")) + assertNull(tagValue(GroupEditMetadataEvent.build(gid, name = "x").tags, "visibility")) } @Test fun editEmitsArchivedTagAsTrueFalse() { - assertEquals("true", tagValue(EditMetadataEvent.build(gid, archived = true).tags, "archived")) - assertEquals("false", tagValue(EditMetadataEvent.build(gid, archived = false).tags, "archived")) + assertEquals("true", tagValue(GroupEditMetadataEvent.build(gid, archived = true).tags, "archived")) + assertEquals("false", tagValue(GroupEditMetadataEvent.build(gid, archived = false).tags, "archived")) // Null archived means "don't touch it" — no tag emitted. - assertNull(tagValue(EditMetadataEvent.build(gid, name = "x").tags, "archived")) + assertNull(tagValue(GroupEditMetadataEvent.build(gid, name = "x").tags, "archived")) } @Test diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/Nip29ArmadaInteropTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/Nip29ArmadaInteropTest.kt index dae29d1b8c..6d7949047d 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/Nip29ArmadaInteropTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/Nip29ArmadaInteropTest.kt @@ -32,16 +32,16 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupParticipantsEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateInviteEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteEventEvent import com.vitorpamplona.quartz.nip29RelayGroups.moderation.DeleteGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.PutUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.RemoveUserEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.JoinRequestEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.LeaveRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupCreateInviteEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupDeleteEventEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupPutUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupRemoveUserEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.GroupTag import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent @@ -169,12 +169,12 @@ class Nip29ArmadaInteropTest { fun parsesGroupRoles() { val e = parse( - SupportedRolesEvent.KIND, + GroupRolesEvent.KIND, arrayOf( arrayOf("role", "admin", "Full control"), arrayOf("role", "moderator"), ), - ) as SupportedRolesEvent + ) as GroupRolesEvent val roles = e.roles() assertEquals("admin", roles[0].name) assertEquals("Full control", roles[0].description) @@ -202,37 +202,37 @@ class Nip29ArmadaInteropTest { assertTrue(parse(CreateGroupEvent.KIND, arrayOf(arrayOf("h", gid)), pubKey = alice) is CreateGroupEvent) assertTrue(parse(DeleteGroupEvent.KIND, arrayOf(arrayOf("h", gid)), pubKey = alice) is DeleteGroupEvent) - val put = parse(PutUserEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("p", bob, "moderator")), pubKey = alice) as PutUserEvent + val put = parse(GroupPutUserEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("p", bob, "moderator")), pubKey = alice) as GroupPutUserEvent assertEquals(gid, put.groupId()) assertEquals(listOf(bob), put.userPubKeys()) - val remove = parse(RemoveUserEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("p", bob)), content = "spam", pubKey = alice) as RemoveUserEvent + val remove = parse(GroupRemoveUserEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("p", bob)), content = "spam", pubKey = alice) as GroupRemoveUserEvent assertEquals(listOf(bob), remove.userPubKeys()) assertEquals("spam", remove.content) - val del = parse(DeleteEventEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("e", "de".repeat(32))), pubKey = alice) as DeleteEventEvent + val del = parse(GroupDeleteEventEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("e", "de".repeat(32))), pubKey = alice) as GroupDeleteEventEvent assertEquals(listOf("de".repeat(32)), del.deletedEventIds()) - val invite = parse(CreateInviteEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("code", "abc123")), pubKey = alice) as CreateInviteEvent + val invite = parse(GroupCreateInviteEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("code", "abc123")), pubKey = alice) as GroupCreateInviteEvent assertEquals("abc123", invite.code()) - val edit = parse(EditMetadataEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("name", "N"), arrayOf("public"), arrayOf("open")), pubKey = alice) as EditMetadataEvent + val edit = parse(GroupEditMetadataEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("name", "N"), arrayOf("public"), arrayOf("open")), pubKey = alice) as GroupEditMetadataEvent assertEquals("N", edit.name()) assertEquals(gid, edit.groupId()) } @Test fun parsesJoinAndLeaveRequests() { - val join = parse(JoinRequestEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("code", "inv1")), content = "let me in", pubKey = alice) as JoinRequestEvent + val join = parse(GroupJoinRequestEvent.KIND, arrayOf(arrayOf("h", gid), arrayOf("code", "inv1")), content = "let me in", pubKey = alice) as GroupJoinRequestEvent assertEquals(gid, join.groupId()) assertEquals("inv1", join.inviteCode()) assertEquals("let me in", join.content) // Armada also sends a join with no code. - val joinNoCode = parse(JoinRequestEvent.KIND, arrayOf(arrayOf("h", gid)), pubKey = alice) as JoinRequestEvent + val joinNoCode = parse(GroupJoinRequestEvent.KIND, arrayOf(arrayOf("h", gid)), pubKey = alice) as GroupJoinRequestEvent assertNull(joinNoCode.inviteCode()) - val leave = parse(LeaveRequestEvent.KIND, arrayOf(arrayOf("h", gid)), pubKey = alice) as LeaveRequestEvent + val leave = parse(GroupLeaveRequestEvent.KIND, arrayOf(arrayOf("h", gid)), pubKey = alice) as GroupLeaveRequestEvent assertEquals(gid, leave.groupId()) } @@ -399,7 +399,7 @@ class Nip29ArmadaInteropTest { @Test fun buildsEditMetadataWithTopicsAndGeohashes() { val edit = - EditMetadataEvent.build( + GroupEditMetadataEvent.build( groupId = gid, name = "Bitcoin Devs", hashtags = listOf("bitcoin"), @@ -412,12 +412,12 @@ class Nip29ArmadaInteropTest { @Test fun buildsCreateAndModerationEvents() { assertTrue(CreateGroupEvent.build(gid).tags.any { it[0] == "h" && it[1] == gid }) - assertTrue(CreateInviteEvent.build(gid, "code42").tags.any { it[0] == "code" && it[1] == "code42" }) + assertTrue(GroupCreateInviteEvent.build(gid, "code42").tags.any { it[0] == "code" && it[1] == "code42" }) - val put = PutUserEvent.build(gid, listOf(bob to listOf("moderator"))).tags + val put = GroupPutUserEvent.build(gid, listOf(bob to listOf("moderator"))).tags assertTrue(put.any { it[0] == "p" && it[1] == bob && it.contains("moderator") }) - val remove = RemoveUserEvent.build(gid, listOf(bob)).tags + val remove = GroupRemoveUserEvent.build(gid, listOf(bob)).tags assertTrue(remove.any { it[0] == "p" && it[1] == bob }) // relay29 forks are avoided by NOT emitting `previous` when none provided. @@ -466,12 +466,12 @@ class Nip29ArmadaInteropTest { @Test fun buildsJoinLeaveAndGroupScopedChat() { - val join = JoinRequestEvent.build(gid, reason = "hi", inviteCode = "inv9") + val join = GroupJoinRequestEvent.build(gid, reason = "hi", inviteCode = "inv9") assertEquals("hi", join.content) assertTrue(join.tags.any { it[0] == "h" && it[1] == gid }) assertTrue(join.tags.any { it[0] == "code" && it[1] == "inv9" }) - assertTrue(LeaveRequestEvent.build(gid).tags.any { it[0] == "h" && it[1] == gid }) + assertTrue(GroupLeaveRequestEvent.build(gid).tags.any { it[0] == "h" && it[1] == gid }) // Group-scope a plain kind-9 chat message via the shared `hTag` helper. val chat = ChatEvent.build("gm") { hTag(gid) } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/PinEventsTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/PinEventsTest.kt index b5ee8e80f3..27dea39abd 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/PinEventsTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/PinEventsTest.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.buzz.cwChannelWindow.ThreadSummaryContent import com.vitorpamplona.quartz.buzz.cwChannelWindow.ThreadSummaryEvent import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.UpdatePinListEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupUpdatePinListEvent import com.vitorpamplona.quartz.nip29RelayGroups.tags.GroupIdTag import com.vitorpamplona.quartz.utils.EventFactory import kotlin.test.Test @@ -90,19 +90,19 @@ class PinEventsTest { @Test fun updatePinListEventParsesGroupAndIds() { val tags = arrayOf(arrayOf("h", gid), arrayOf("e", id1), arrayOf("e", id2)) - val event: Event = EventFactory.create("00".repeat(32), relaySelf, 100, UpdatePinListEvent.KIND, tags, "", "22".repeat(64)) + val event: Event = EventFactory.create("00".repeat(32), relaySelf, 100, GroupUpdatePinListEvent.KIND, tags, "", "22".repeat(64)) - assertEquals(true, event is UpdatePinListEvent) - event as UpdatePinListEvent + assertEquals(true, event is GroupUpdatePinListEvent) + event as GroupUpdatePinListEvent assertEquals(gid, event.groupId()) assertEquals(listOf(id1, id2), event.pinnedEventIds()) } @Test fun updatePinListBuildCarriesHTagAndFullList() { - val template = UpdatePinListEvent.build(gid, listOf(id1, id2)) + val template = GroupUpdatePinListEvent.build(gid, listOf(id1, id2)) - assertEquals(UpdatePinListEvent.KIND, template.kind) + assertEquals(GroupUpdatePinListEvent.KIND, template.kind) assertEquals(gid, template.tags.firstOrNull { it[0] == GroupIdTag.TAG_NAME }?.getOrNull(1)) assertEquals(listOf(id1, id2), template.tags.filter { it[0] == "e" }.map { it[1] }) } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/SubgroupTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/SubgroupTest.kt index cc4360e828..58d16706f6 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/SubgroupTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/SubgroupTest.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.quartz.nip29RelayGroups import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent import com.vitorpamplona.quartz.utils.EventFactory import kotlin.test.Test import kotlin.test.assertEquals @@ -66,8 +66,8 @@ class SubgroupTest { @Test fun editMetadataRoundTripsParentAndChildren() { - val template = EditMetadataEvent.build("nostr", name = "Nostr", parent = "social", children = listOf("nip29")) - val event = EventFactory.create(id, relaySelf, template.createdAt, EditMetadataEvent.KIND, template.tags, "", sig) as EditMetadataEvent + val template = GroupEditMetadataEvent.build("nostr", name = "Nostr", parent = "social", children = listOf("nip29")) + val event = EventFactory.create(id, relaySelf, template.createdAt, GroupEditMetadataEvent.KIND, template.tags, "", sig) as GroupEditMetadataEvent assertEquals("nostr", event.groupId()) assertEquals("social", event.parent()) @@ -76,8 +76,8 @@ class SubgroupTest { @Test fun editMetadataWithoutParentRoots() { - val template = EditMetadataEvent.build("nostr", name = "Nostr") - val event = EventFactory.create(id, relaySelf, template.createdAt, EditMetadataEvent.KIND, template.tags, "", sig) as EditMetadataEvent + val template = GroupEditMetadataEvent.build("nostr", name = "Nostr") + val event = EventFactory.create(id, relaySelf, template.createdAt, GroupEditMetadataEvent.KIND, template.tags, "", sig) as GroupEditMetadataEvent assertNull(event.parent()) } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt index 7ee9fdc303..5226a302ce 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestSign import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponse import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponseEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest @@ -101,7 +101,7 @@ class BunkerRequestProcessorConcurrencyTest { fromPublicKey: HexKey, ) = "" - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt index 3533bb2959..bc5598a518 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt @@ -41,7 +41,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponseGetRelays import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponsePong import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponsePublicKey import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals @@ -116,7 +116,7 @@ class BunkerRequestProcessorTest { return "nip44dec:$ciphertext" } - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() @@ -371,7 +371,7 @@ class BunkerRequestProcessorTest { fromPublicKey: HexKey, ) = "" - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt index 3dcf86afd1..0e631bc3e1 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponseEvent import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponsePublicKey import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapRequestEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.utils.RandomInstance import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -112,7 +112,7 @@ class NostrConnectSignerServiceTest { fromPublicKey: HexKey, ) = ciphertext - override suspend fun decryptZapEvent(event: LnZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt index 4e9a209c09..edc3143ba5 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetInfoMethod import kotlinx.coroutines.test.runTest @@ -44,7 +44,7 @@ class LnZapPaymentRequestNip44EventTest { val request = GetBalanceMethod.Companion.create() val event = - LnZapPaymentRequestEvent.Companion.createRequest( + NwcRequestEvent.Companion.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, @@ -68,7 +68,7 @@ class LnZapPaymentRequestNip44EventTest { val request = GetInfoMethod.Companion.create() val event = - LnZapPaymentRequestEvent.Companion.createRequest( + NwcRequestEvent.Companion.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcOutgoingMetadataTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcOutgoingMetadataTest.kt index 8bddfc1446..c7020dc022 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcOutgoingMetadataTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcOutgoingMetadataTest.kt @@ -84,7 +84,7 @@ class NwcOutgoingMetadataTest { /** * THE INTEROP PROPERTY. NIP-57 sets a zap invoice's `description_hash` to the * sha256 of the raw JSON the LNURL callback received in `nostr=` — which is - * `LnZapRequestEvent.toJson()` (see LightningAddressResolver). A wallet that + * `ZapRequestEvent.toJson()` (see LightningAddressResolver). A wallet that * binds a stored zap request to the invoice it labels hashes the bytes of the * `nostr` member, so anything short of byte-identity reads as a forged event * and the row is silently stored unlabelled. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRefusalRoundTripTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRefusalRoundTripTest.kt index e90ea7e6a2..9c69def4ca 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRefusalRoundTripTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRefusalRoundTripTest.kt @@ -23,8 +23,8 @@ package com.vitorpamplona.quartz.nip47WalletConnect import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip47WalletConnect.cache.NostrWalletConnectResponseCache -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentResponseEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.IErrorResponseLike import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayInvoiceMethod import kotlinx.coroutines.test.runTest @@ -50,14 +50,14 @@ class NwcRefusalRoundTripTest { for (useNip44 in listOf(false, true)) { val request = - LnZapPaymentRequestEvent.createRequest( + NwcRequestEvent.createRequest( PayInvoiceMethod.create("lnbc50n1pjtest"), walletSigner.pubKey, clientSigner, useNip44 = useNip44, ) - // Encrypted by hand rather than through LnZapPaymentResponseEvent.createResponse, + // Encrypted by hand rather than through NwcResponseEvent.createResponse, // which re-serializes a Response: the point is the wallet's bytes, verbatim. val encrypted = if (useNip44) { @@ -66,9 +66,9 @@ class NwcRefusalRoundTripTest { walletSigner.nip04Encrypt(walletJson, clientSigner.pubKey) } val reply = - walletSigner.sign<LnZapPaymentResponseEvent>( + walletSigner.sign<NwcResponseEvent>( request.createdAt, - LnZapPaymentResponseEvent.KIND, + NwcResponseEvent.KIND, arrayOf(arrayOf("p", clientSigner.pubKey), arrayOf("e", request.id)), encrypted, ) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestEventTest.kt similarity index 93% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestEventTest.kt index 07fa5ac130..2b3f56f594 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestEventTest.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip47WalletConnect.events.LnZapPaymentRequestEvent +import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent import com.vitorpamplona.quartz.nip47WalletConnect.rpc.GetBalanceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.MakeInvoiceMethod import com.vitorpamplona.quartz.nip47WalletConnect.rpc.PayInvoiceMethod @@ -36,10 +36,10 @@ import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue -class LnZapPaymentRequestEventTest { +class NwcRequestEventTest { @Test fun testEventKind() { - assertEquals(23194, LnZapPaymentRequestEvent.KIND) + assertEquals(23194, NwcRequestEvent.KIND) } @Test @@ -52,7 +52,7 @@ class LnZapPaymentRequestEventTest { walletKeyPair.pubKey.toHexKey() val event = - LnZapPaymentRequestEvent.create( + NwcRequestEvent.create( lnInvoice = "lnbc50n1...", walletServicePubkey = walletServicePubkey, signer = clientSigner, @@ -77,7 +77,7 @@ class LnZapPaymentRequestEventTest { val request = GetBalanceMethod.create() val event = - LnZapPaymentRequestEvent.createRequest( + NwcRequestEvent.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, @@ -101,7 +101,7 @@ class LnZapPaymentRequestEventTest { walletKeyPair.pubKey.toHexKey() val event = - LnZapPaymentRequestEvent.create( + NwcRequestEvent.create( lnInvoice = "lnbc50n1...", walletServicePubkey = walletServicePubkey, signer = clientSigner, @@ -125,7 +125,7 @@ class LnZapPaymentRequestEventTest { val request = MakeInvoiceMethod.create(5000L, "test payment") val event = - LnZapPaymentRequestEvent.createRequest( + NwcRequestEvent.createRequest( request = request, walletServicePubkey = walletServicePubkey, signer = clientSigner, @@ -150,7 +150,7 @@ class LnZapPaymentRequestEventTest { walletKeyPair.pubKey.toHexKey() val event = - LnZapPaymentRequestEvent.create( + NwcRequestEvent.create( lnInvoice = "lnbc50n1...", walletServicePubkey = walletServicePubkey, signer = clientSigner, diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt index 3075095a39..5d044ecb52 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt @@ -33,15 +33,15 @@ import com.vitorpamplona.quartz.nip15Marketplace.product.ProductEvent import com.vitorpamplona.quartz.nip15Marketplace.stall.StallEvent import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent -import com.vitorpamplona.quartz.nip29RelayGroups.moderation.EditMetadataEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent +import com.vitorpamplona.quartz.nip29RelayGroups.moderation.GroupEditMetadataEvent import com.vitorpamplona.quartz.nip32Labeling.LabelEvent import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent import com.vitorpamplona.quartz.nip35Torrents.TorrentEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip5aStaticWebsites.NamedSiteEvent import com.vitorpamplona.quartz.nip69P2pOrderEvents.P2POrderEvent -import com.vitorpamplona.quartz.nip85TrustedAssertions.users.ContactCardEvent +import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nipB0WebBookmarks.WebBookmarkEvent @@ -72,7 +72,7 @@ class SearchFieldExtractorTest { @Test fun longFormDecomposesIntoTitleSummaryHashtagsContent() { val tags = arrayOf(arrayOf("d", "post"), arrayOf("title", "My Post"), arrayOf("summary", "tl;dr"), arrayOf("t", "nostr"), arrayOf("t", "search")) - val fields = SearchFieldExtractor.extract(LongTextNoteEvent("2".repeat(64), alice, 1L, tags, "the whole article", "")) + val fields = SearchFieldExtractor.extract(LongFormContentEvent("2".repeat(64), alice, 1L, tags, "the whole article", "")) assertEquals(IndexableFields.Tiered(primary = listOf("My Post"), secondary = listOf("tl;dr"), text = "the whole article", hashtags = listOf("nostr", "search")), fields) } @@ -165,7 +165,7 @@ class SearchFieldExtractorTest { arrayOf("t", "bitcoin"), arrayOf("rank", "87"), ) - val fields = SearchFieldExtractor.extract(ContactCardEvent("f".repeat(64), alice, 1L, tags, "", "")) + val fields = SearchFieldExtractor.extract(UserAssertionEvent("f".repeat(64), alice, 1L, tags, "", "")) assertEquals( IndexableFields.Tiered( primary = listOf("Verified Human"), @@ -184,7 +184,7 @@ class SearchFieldExtractorTest { // role, once -- and a hashtags-only extraction must not normalize to // None (Tiered.isEmpty() compares against a fully-empty Tiered). val tags = arrayOf(arrayOf("d", alice), arrayOf("t", "bitcoin"), arrayOf("t", "nostr"), arrayOf("rank", "87")) - val fields = SearchFieldExtractor.extract(ContactCardEvent("2a".repeat(32), alice, 1L, tags, "encrypted", "")) + val fields = SearchFieldExtractor.extract(UserAssertionEvent("2a".repeat(32), alice, 1L, tags, "encrypted", "")) assertEquals(IndexableFields.Tiered(hashtags = listOf("bitcoin", "nostr")), fields) } @@ -194,7 +194,7 @@ class SearchFieldExtractorTest { // encrypted content, which is never indexed -- so a card carrying only // scores has nothing to search. val tags = arrayOf(arrayOf("d", alice), arrayOf("rank", "87"), arrayOf("followers", "1200")) - assertEquals(IndexableFields.None, SearchFieldExtractor.extract(ContactCardEvent("1a".repeat(32), alice, 1L, tags, "encrypted", ""))) + assertEquals(IndexableFields.None, SearchFieldExtractor.extract(UserAssertionEvent("1a".repeat(32), alice, 1L, tags, "encrypted", ""))) } @Test @@ -270,7 +270,7 @@ class SearchFieldExtractorTest { // kind 9002 edits what kind 39000 publishes; it was the only half of // the pair without a branch. Its hashtags() is `t`: carried once. val tags = arrayOf(arrayOf("h", "grp"), arrayOf("name", "Nostr Devs"), arrayOf("about", "we build"), arrayOf("t", "nostr")) - val fields = SearchFieldExtractor.extract(EditMetadataEvent("23".repeat(32), alice, 1L, tags, "", "")) + val fields = SearchFieldExtractor.extract(GroupEditMetadataEvent("23".repeat(32), alice, 1L, tags, "", "")) assertEquals( IndexableFields.Tiered(primary = listOf("Nostr Devs"), secondary = listOf("we build"), hashtags = listOf("nostr")), fields, diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayFeedsListEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/FavoriteRelayListEventTest.kt similarity index 87% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayFeedsListEventTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/FavoriteRelayListEventTest.kt index 40af5a2166..62e54bdc8f 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayFeedsListEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/FavoriteRelayListEventTest.kt @@ -28,7 +28,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -class RelayFeedsListEventTest { +class FavoriteRelayListEventTest { private val signer = NostrSignerInternal("nsec10g0wheggqn9dawlc0yuv6adnat6n09anr7eyykevw2dm8xa5fffs0wsdsr".nsecToKeyPair()) private val damus = RelayUrlNormalizer.normalize("wss://relay.damus.io") @@ -37,7 +37,7 @@ class RelayFeedsListEventTest { @Test fun kindMatchesSpec() { - assertEquals(10012, RelayFeedsListEvent.KIND) + assertEquals(10012, FavoriteRelayListEvent.KIND) } /** @@ -49,8 +49,8 @@ class RelayFeedsListEventTest { fun removingOneRelayKeepsTheOtherPublicEntriesPublic() = runTest { val fromAnotherClient = - signer.sign<RelayFeedsListEvent>( - RelayFeedsListEvent.build( + signer.sign<FavoriteRelayListEvent>( + FavoriteRelayListEvent.build( publicRelays = listOf(damus, nosLol), signer = signer, createdAt = 1740669816, @@ -60,7 +60,7 @@ class RelayFeedsListEventTest { assertEquals(listOf(damus, nosLol), fromAnotherClient.publicRelays()) val afterRemoval = - RelayFeedsListEvent.updateRelayList( + FavoriteRelayListEvent.updateRelayList( earlierVersion = fromAnotherClient, relays = listOf(damus), signer = signer, @@ -79,8 +79,8 @@ class RelayFeedsListEventTest { fun privateRelaysStayPrivate() = runTest { val mixed = - signer.sign<RelayFeedsListEvent>( - RelayFeedsListEvent.build( + signer.sign<FavoriteRelayListEvent>( + FavoriteRelayListEvent.build( publicRelays = listOf(damus), privateRelays = listOf(nosLol, primal), signer = signer, @@ -89,7 +89,7 @@ class RelayFeedsListEventTest { ) val afterRemoval = - RelayFeedsListEvent.updateRelayList( + FavoriteRelayListEvent.updateRelayList( earlierVersion = mixed, relays = listOf(damus, nosLol), signer = signer, @@ -104,8 +104,8 @@ class RelayFeedsListEventTest { fun newRelaysFollowTheConventionOfTheList() = runTest { val publicOnly = - signer.sign<RelayFeedsListEvent>( - RelayFeedsListEvent.build( + signer.sign<FavoriteRelayListEvent>( + FavoriteRelayListEvent.build( publicRelays = listOf(damus), signer = signer, createdAt = 1740669816, @@ -113,7 +113,7 @@ class RelayFeedsListEventTest { ) val afterAdd = - RelayFeedsListEvent.updateRelayList( + FavoriteRelayListEvent.updateRelayList( earlierVersion = publicOnly, relays = listOf(damus, nosLol), signer = signer, @@ -127,8 +127,8 @@ class RelayFeedsListEventTest { ) val privateOnly = - signer.sign<RelayFeedsListEvent>( - RelayFeedsListEvent.build( + signer.sign<FavoriteRelayListEvent>( + FavoriteRelayListEvent.build( privateRelays = listOf(damus), signer = signer, createdAt = 1740669816, @@ -136,7 +136,7 @@ class RelayFeedsListEventTest { ) val afterPrivateAdd = - RelayFeedsListEvent.updateRelayList( + FavoriteRelayListEvent.updateRelayList( earlierVersion = privateOnly, relays = listOf(damus, nosLol), signer = signer, @@ -151,8 +151,8 @@ class RelayFeedsListEventTest { fun keepsUnrelatedTags() = runTest { val withTitle = - signer.sign<RelayFeedsListEvent>( - RelayFeedsListEvent.build( + signer.sign<FavoriteRelayListEvent>( + FavoriteRelayListEvent.build( publicRelays = listOf(damus, nosLol), signer = signer, createdAt = 1740669816, @@ -162,7 +162,7 @@ class RelayFeedsListEventTest { ) val afterRemoval = - RelayFeedsListEvent.updateRelayList( + FavoriteRelayListEvent.updateRelayList( earlierVersion = withTitle, relays = listOf(nosLol), signer = signer, diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt index a4eb27a872..5111ca4c15 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt @@ -62,8 +62,8 @@ class RelayListPublicEntriesTest { @Test fun relayFeedsListKeepsTheSurvivorPublic() = runTest { - val before = publicListFromAnotherClient<RelayFeedsListEvent>(RelayFeedsListEvent.KIND) - val after = RelayFeedsListEvent.updateRelayList(before, listOf(damus), signer, 1740669817) + val before = publicListFromAnotherClient<FavoriteRelayListEvent>(FavoriteRelayListEvent.KIND) + val after = FavoriteRelayListEvent.updateRelayList(before, listOf(damus), signer, 1740669817) assertEquals(listOf(damus), after.tags.relays()) } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip52Calendar/CalendarHintProviderTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip52Calendar/CalendarHintProviderTest.kt index dba5cf91cd..42fc62755e 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip52Calendar/CalendarHintProviderTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip52Calendar/CalendarHintProviderTest.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.hints.PubKeyHintProvider import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent -import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarEvent +import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent import com.vitorpamplona.quartz.nip52Calendar.rsvp.CalendarRSVPEvent import kotlin.test.Test import kotlin.test.assertEquals @@ -66,7 +66,7 @@ class CalendarHintProviderTest { ) private fun calendar(vararg tags: Array<String>) = - CalendarEvent( + CalendarCollectionEvent( id = "33".repeat(32), pubKey = host, createdAt = 1700000000, diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiCollaborationTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiCollaborationTest.kt index 6a81dd3b56..1d015a2d68 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiCollaborationTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip54Wiki/WikiCollaborationTest.kt @@ -36,7 +36,7 @@ class WikiCollaborationTest { private fun mergeRequest(vararg tags: Array<String>) = WikiMergeRequestEvent("id", "pk", 0L, arrayOf(*tags), "why", "sig") - private fun coordinate() = "${WikiNoteEvent.KIND}:$destination:hot-ice-creams" + private fun coordinate() = "${WikiArticleEvent.KIND}:$destination:hot-ice-creams" // ---- kind 818 -------------------------------------------------------------------------- @@ -115,7 +115,7 @@ class WikiCollaborationTest { fun buildsWithTheSpecMarker() { val template = WikiMergeRequestEvent.build( - targetArticle = Address(WikiNoteEvent.KIND, destination, "hot-ice-creams"), + targetArticle = Address(WikiArticleEvent.KIND, destination, "hot-ice-creams"), destinationAuthor = destination, mergeSourceId = fork, explanation = "I added a section", @@ -180,7 +180,7 @@ class WikiCollaborationTest { 0L, arrayOf( arrayOf("d", "shell-structure"), - arrayOf("a", "${WikiNoteEvent.KIND}:$destination:thin-shell-structure"), + arrayOf("a", "${WikiArticleEvent.KIND}:$destination:thin-shell-structure"), ), "", "sig", @@ -232,11 +232,11 @@ class WikiCollaborationTest { @Test fun buildsARedirectWithANormalizedSlug() { val template = - WikiRedirectEvent.build("Shell Structure", Address(WikiNoteEvent.KIND, destination, "thin-shell-structure")) + WikiRedirectEvent.build("Shell Structure", Address(WikiArticleEvent.KIND, destination, "thin-shell-structure")) val tags = template.tags.associate { it[0] to it[1] } assertEquals("shell-structure", tags["d"]) - assertEquals("${WikiNoteEvent.KIND}:$destination:thin-shell-structure", tags["a"]) + assertEquals("${WikiArticleEvent.KIND}:$destination:thin-shell-structure", tags["a"]) assertEquals("", template.content) } } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestAnonTagTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestAnonTagTest.kt index e22a2030d5..9592029d3c 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestAnonTagTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestAnonTagTest.kt @@ -57,8 +57,8 @@ class LnZapRequestAnonTagTest { sig = "b".repeat(128), ) - private suspend fun request(zapType: LnZapEvent.ZapType) = - LnZapRequestEvent.create( + private suspend fun request(zapType: ZapReceiptEvent.ZapType) = + ZapRequestEvent.create( zappedEvent = zappedEvent, relays = relays, signer = signer, @@ -71,7 +71,7 @@ class LnZapRequestAnonTagTest { @Test fun `public zap request has no anon tag and is signed by the sender`() = runTest { - val zapRequest = request(LnZapEvent.ZapType.PUBLIC) + val zapRequest = request(ZapReceiptEvent.ZapType.PUBLIC) assertFalse(zapRequest.hasAnonTag()) assertFalse(zapRequest.isPrivateZap()) @@ -81,7 +81,7 @@ class LnZapRequestAnonTagTest { @Test fun `anonymous zap request has anon tag but is not private`() = runTest { - val zapRequest = request(LnZapEvent.ZapType.ANONYMOUS) + val zapRequest = request(ZapReceiptEvent.ZapType.ANONYMOUS) assertTrue(zapRequest.hasAnonTag()) assertFalse(zapRequest.isPrivateZap()) @@ -98,12 +98,12 @@ class LnZapRequestAnonTagTest { fun `anonymous profile zap request keeps the message public`() = runTest { val zapRequest = - LnZapRequestEvent.create( + ZapRequestEvent.create( userHex = receiverPubKey, relays = relays, signer = signer, message = "great work", - zapType = LnZapEvent.ZapType.ANONYMOUS, + zapType = ZapReceiptEvent.ZapType.ANONYMOUS, ) assertTrue(zapRequest.hasAnonTag()) @@ -115,7 +115,7 @@ class LnZapRequestAnonTagTest { @Test fun `private zap request has anon tag and is private and hides the sender key`() = runTest { - val zapRequest = request(LnZapEvent.ZapType.PRIVATE) + val zapRequest = request(ZapReceiptEvent.ZapType.PRIVATE) assertTrue(zapRequest.hasAnonTag()) assertTrue(zapRequest.isPrivateZap()) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestGroupTagTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestGroupTagTest.kt index 2553b9e31d..07451237b4 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestGroupTagTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestGroupTagTest.kt @@ -63,13 +63,13 @@ class LnZapRequestGroupTagTest { ) private suspend fun zapRequestFor(zapped: Event) = - LnZapRequestEvent.create( + ZapRequestEvent.create( zappedEvent = zapped, relays = relays, signer = nostrSigner, pollOption = null, message = "", - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, toUserPubHex = null, ) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestKindTagTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestKindTagTest.kt index 0ba8202418..1ba8c3c279 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestKindTagTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestKindTagTest.kt @@ -52,13 +52,13 @@ class LnZapRequestKindTagTest { val relays = setOf(NormalizedRelayUrl("wss://relay.example.com/")) val zapRequest = - LnZapRequestEvent.create( + ZapRequestEvent.create( zappedEvent = publicMsg, relays = relays, signer = nostrSigner, pollOption = null, message = "", - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, toUserPubHex = null, ) @@ -84,13 +84,13 @@ class LnZapRequestKindTagTest { val relays = setOf(NormalizedRelayUrl("wss://relay.example.com/")) val zapRequest = - LnZapRequestEvent.create( + ZapRequestEvent.create( zappedEvent = kind1Event, relays = relays, signer = nostrSigner, pollOption = null, message = "", - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, toUserPubHex = null, ) @@ -105,12 +105,12 @@ class LnZapRequestKindTagTest { val relays = setOf(NormalizedRelayUrl("wss://relay.example.com/")) val zapRequest = - LnZapRequestEvent.create( + ZapRequestEvent.create( userHex = receiverPubKey, relays = relays, signer = nostrSigner, message = "", - zapType = LnZapEvent.ZapType.PUBLIC, + zapType = ZapReceiptEvent.ZapType.PUBLIC, ) val kTag = zapRequest.tags.firstOrNull { it[0] == "k" } diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidatorTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidatorTest.kt index a3ce50b8d2..ef3344b0b0 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidatorTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidatorTest.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.quartz.nip57Zaps.validate -import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertIs @@ -62,13 +62,13 @@ class LnZapReceiptValidatorTest { signerPubkey: String = providerPubkey, bolt11: String? = invoice100kSats, description: String? = zapRequestJson(), - ): LnZapEvent { + ): ZapReceiptEvent { val tags = mutableListOf<Array<String>>() tags.add(arrayOf("p", recipientPubkey)) if (bolt11 != null) tags.add(arrayOf("bolt11", bolt11)) if (description != null) tags.add(arrayOf("description", description)) - return LnZapEvent( + return ZapReceiptEvent( id = "f".repeat(64), pubKey = signerPubkey, createdAt = 1700000001, diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapInfoEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapInfoEventTest.kt index 4b9c4dd50e..06eb717482 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapInfoEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapInfoEventTest.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip61Nutzaps import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.NutzapInfoEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.tags.NutzapMintTag import com.vitorpamplona.quartz.utils.nsecToKeyPair @@ -75,7 +75,7 @@ class NutzapInfoEventTest { fun deletionTargetsTheReplaceableAddress() = runTest { val empty = signer.sign(NutzapInfoEvent.buildEmpty()) - val deletion = signer.sign(DeletionEvent.build(listOf(empty))) + val deletion = signer.sign(DeletionRequestEvent.build(listOf(empty))) // NIP-09 deletion of a replaceable event needs the `a` address // coordinate so compliant relays drop all versions, plus the `e` diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapRedemptionTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapRedemptionTest.kt new file mode 100644 index 0000000000..28500b137b --- /dev/null +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/NutzapRedemptionTest.kt @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.quartz.nip61Nutzaps + +import com.vitorpamplona.quartz.nip01Core.core.Event +import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle +import com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent +import com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent +import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent +import com.vitorpamplona.quartz.nip61Nutzaps.redemption.buildNutzapRedemption +import com.vitorpamplona.quartz.utils.EventFactory +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertIs + +/** + * NIP-61 reuses the NIP-60 wallet kinds: redeemed tokens are kind 7375 wallet token + * events and redemptions are kind 7376 spending history events. Each kind has a + * single class, so what EventFactory builds must expose the NIP-61 fields. + */ +class NutzapRedemptionTest { + private val sender = "1".repeat(64) + private val nutzap = NutzapEvent("a".repeat(64), sender, 1, emptyArray(), "", "b".repeat(128)) + + @Test + fun redemptionIsParsedAsSpendingHistory() { + val template = CashuSpendingHistoryEvent.buildNutzapRedemption(EventHintBundle(nutzap), "encrypted") + assertEquals(CashuSpendingHistoryEvent.KIND, template.kind) + + val event = EventFactory.create<Event>("c".repeat(64), "2".repeat(64), 2, template.kind, template.tags, template.content, "d".repeat(128)) + val history = assertIs<CashuSpendingHistoryEvent>(event) + + assertEquals(listOf(nutzap.id), history.redeemedNutzaps().map { it.eventId }) + assertEquals(listOf(nutzap.id), history.redeemedReferences().map { it.eventId }) + assertEquals(listOf(sender), history.linkedPubKeys()) + } + + @Test + fun walletTokenKindHasOneClass() { + val event = EventFactory.create<Event>("c".repeat(64), "2".repeat(64), 2, CashuTokenEvent.KIND, emptyArray(), "", "d".repeat(128)) + assertIs<CashuTokenEvent>(event) + } +} diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableVideoEventAddressTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableVideoEventAddressTest.kt index e31e88f745..283756ee98 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableVideoEventAddressTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip71Video/AddressableVideoEventAddressTest.kt @@ -53,7 +53,7 @@ class AddressableVideoEventAddressTest { @Test fun verticalVideoAddressUsesDTag() { val event = - VideoVerticalEvent( + AddressableShortVideoEvent( id = "bfe2f2244fefc7cebc7b2eae825495f99dabb4649ee3f90ab1fa33bcd1e9bb9f", pubKey = pubkey, createdAt = 1780894816, @@ -62,13 +62,13 @@ class AddressableVideoEventAddressTest { sig = "", ) - assertAddressUsesDTag(VideoVerticalEvent.KIND, event) + assertAddressUsesDTag(AddressableShortVideoEvent.KIND, event) } @Test fun horizontalVideoAddressUsesDTag() { val event = - VideoHorizontalEvent( + AddressableNormalVideoEvent( id = "bfe2f2244fefc7cebc7b2eae825495f99dabb4649ee3f90ab1fa33bcd1e9bb9f", pubKey = pubkey, createdAt = 1780894816, @@ -77,13 +77,13 @@ class AddressableVideoEventAddressTest { sig = "", ) - assertAddressUsesDTag(VideoHorizontalEvent.KIND, event) + assertAddressUsesDTag(AddressableNormalVideoEvent.KIND, event) } @Test fun videoWithoutDTagFallsBackToEmptyAddress() { val event = - VideoVerticalEvent( + AddressableShortVideoEvent( id = "bfe2f2244fefc7cebc7b2eae825495f99dabb4649ee3f90ab1fa33bcd1e9bb9f", pubKey = pubkey, createdAt = 1780894816, @@ -93,7 +93,7 @@ class AddressableVideoEventAddressTest { ) assertEquals("", event.dTag()) - assertEquals(Address(VideoVerticalEvent.KIND, pubkey, ""), event.address()) - assertEquals("${VideoVerticalEvent.KIND}:$pubkey:", event.addressTag()) + assertEquals(Address(AddressableShortVideoEvent.KIND, pubkey, ""), event.address()) + assertEquals("${AddressableShortVideoEvent.KIND}:$pubkey:", event.addressTag()) } } diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/MarmotMipBehaviorTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/MarmotMipBehaviorTest.kt index 711852c67e..32d09a3046 100644 --- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/MarmotMipBehaviorTest.kt +++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/marmot/MarmotMipBehaviorTest.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent +import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import kotlinx.coroutines.runBlocking import kotlin.test.Test @@ -350,8 +350,8 @@ class MarmotMipBehaviorTest { // Bob unwraps: kind:1059 → kind:13 (Seal) → kind:444 (Rumor). val sealed = delivery.giftWrapEvent.unwrapThrowing(bobSigner) - assertEquals(SealedRumorEvent.KIND, sealed.kind, "Middle layer MUST be NIP-59 Seal kind:13") - assertIs<SealedRumorEvent>(sealed) + assertEquals(SealEvent.KIND, sealed.kind, "Middle layer MUST be NIP-59 Seal kind:13") + assertIs<SealEvent>(sealed) val rumor = sealed.unsealThrowing(bobSigner) assertEquals(WelcomeEvent.KIND, rumor.kind, "Innermost rumor MUST be kind:444") diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt index fb949ca47d..76022f4303 100644 --- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt +++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.nip01Core.jackson import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor import kotlin.test.Test import kotlin.test.assertContentEquals @@ -46,7 +46,7 @@ class JacksonMapperTest { ) val followCard = - FollowListEvent( + StarterPackEvent( id = "eca31634fce7c9068b56fa8db9f387da70bdcceb3986a77ca1a9844f3128eb5f", pubKey = "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da", createdAt = 1761736286, diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt index 40e7aa5884..a3ee938277 100644 --- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt +++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequest import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponse -import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent +import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor import kotlin.test.Test import kotlin.test.assertContentEquals @@ -65,7 +65,7 @@ class KotlinSerializationMapperTest { ) val followCard = - FollowListEvent( + StarterPackEvent( id = "eca31634fce7c9068b56fa8db9f387da70bdcceb3986a77ca1a9844f3128eb5f", pubKey = "3c39a7b53dec9ac85acf08b267637a9841e6df7b7b0f5e2ac56a8cf107de37da", createdAt = 1761736286, @@ -194,7 +194,7 @@ class KotlinSerializationMapperTest { fun deserializeEventWithSpecialCharactersInContent() { val content = "Hello \"world\" \n\ttab\\backslash" val event = - FollowListEvent( + StarterPackEvent( id = "abc", pubKey = "def", createdAt = 1000, @@ -769,7 +769,7 @@ class KotlinSerializationMapperTest { @Test fun emptyContentEvent() { val event = - FollowListEvent( + StarterPackEvent( id = "a".repeat(64), pubKey = "b".repeat(64), createdAt = 0, @@ -796,7 +796,7 @@ class KotlinSerializationMapperTest { fun eventWithUnicodeContent() { val content = "Hello \uD83D\uDE00 world \u00E9\u00E8\u00EA" val event = - FollowListEvent( + StarterPackEvent( id = "a".repeat(64), pubKey = "b".repeat(64), createdAt = 1000, diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/RelayGroupFilterServingRelayTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/RelayGroupFilterServingRelayTest.kt index 1bf3edf89c..bd1395c3df 100644 --- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/RelayGroupFilterServingRelayTest.kt +++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip29RelayGroups/RelayGroupFilterServingRelayTest.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupAdminsEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMembersEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupMetadataEvent import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupPinnedEvent -import com.vitorpamplona.quartz.nip29RelayGroups.metadata.SupportedRolesEvent +import com.vitorpamplona.quartz.nip29RelayGroups.metadata.GroupRolesEvent import com.vitorpamplona.quartz.nip29RelayGroups.tags.GroupIdTag import com.vitorpamplona.quartz.nip7DThreads.ThreadEvent import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent @@ -72,7 +72,7 @@ class RelayGroupFilterServingRelayTest : RelayClientTest() { GroupMetadataEvent.KIND -> GroupMetadataEvent(id, relayKey, 100L, tags, "", sig) GroupAdminsEvent.KIND -> GroupAdminsEvent(id, relayKey, 100L, tags, "", sig) GroupMembersEvent.KIND -> GroupMembersEvent(id, relayKey, 100L, tags, "", sig) - SupportedRolesEvent.KIND -> SupportedRolesEvent(id, relayKey, 100L, tags, "", sig) + GroupRolesEvent.KIND -> GroupRolesEvent(id, relayKey, 100L, tags, "", sig) GroupPinnedEvent.KIND -> GroupPinnedEvent(id, relayKey, 100L, tags, "", sig) else -> error("unexpected state kind $kind") } @@ -105,7 +105,7 @@ class RelayGroupFilterServingRelayTest : RelayClientTest() { state(1, GroupMetadataEvent.KIND), state(2, GroupAdminsEvent.KIND), state(3, GroupMembersEvent.KIND), - state(4, SupportedRolesEvent.KIND), + state(4, GroupRolesEvent.KIND), state(5, GroupPinnedEvent.KIND), ), ) @@ -119,7 +119,7 @@ class RelayGroupFilterServingRelayTest : RelayClientTest() { GroupMetadataEvent.KIND, GroupAdminsEvent.KIND, GroupMembersEvent.KIND, - SupportedRolesEvent.KIND, + GroupRolesEvent.KIND, GroupPinnedEvent.KIND, ), tags = mapOf("d" to listOf("g1")), @@ -268,7 +268,7 @@ class RelayGroupFilterServingRelayTest : RelayClientTest() { GroupMetadataEvent.KIND, GroupAdminsEvent.KIND, GroupMembersEvent.KIND, - SupportedRolesEvent.KIND, + GroupRolesEvent.KIND, ), limit = 500, ), diff --git a/quartz/src/jvmMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsEventStore.kt b/quartz/src/jvmMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsEventStore.kt index 38cc465830..62616dd7ef 100644 --- a/quartz/src/jvmMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsEventStore.kt +++ b/quartz/src/jvmMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsEventStore.kt @@ -33,7 +33,7 @@ import com.vitorpamplona.quartz.nip01Core.store.IEventStore import com.vitorpamplona.quartz.nip01Core.store.sqlite.DefaultIndexingStrategy import com.vitorpamplona.quartz.nip01Core.store.sqlite.IndexingStrategy import com.vitorpamplona.quartz.nip01Core.store.sqlite.TagNameValueHasher -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip40Expiration.expiration import com.vitorpamplona.quartz.nip50Search.SearchableEvent import com.vitorpamplona.quartz.nip50Search.strippingSearchExtensions @@ -136,7 +136,7 @@ open class FsEventStore( if (slot != null && existingSlot?.id != event.id) { slots.install(slot, canonical, event, existingSlot) } - if (event is DeletionEvent) processDeletion(event, canonical) + if (event is DeletionRequestEvent) processDeletion(event, canonical) if (event is RequestToVanishEvent) processVanish(event, canonical) return } @@ -158,7 +158,7 @@ open class FsEventStore( if (slot != null) { slots.install(slot, canonical, event, existingSlot) } - if (event is DeletionEvent) processDeletion(event, canonical) + if (event is DeletionRequestEvent) processDeletion(event, canonical) if (event is RequestToVanishEvent) processVanish(event, canonical) } catch (t: Throwable) { Files.deleteIfExists(tmp) @@ -223,7 +223,7 @@ open class FsEventStore( * future re-inserts are blocked. */ private fun processDeletion( - deletion: DeletionEvent, + deletion: DeletionRequestEvent, deletionCanonical: java.nio.file.Path, ) { val ownerHashOfDeletion = hasher.hash(deletion.pubKey) diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/buzz/interop/BuzzRelayLiveInteropTest.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/buzz/interop/BuzzRelayLiveInteropTest.kt index 429936584d..fd513e3b49 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/buzz/interop/BuzzRelayLiveInteropTest.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/buzz/interop/BuzzRelayLiveInteropTest.kt @@ -29,8 +29,8 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip29RelayGroups.moderation.CreateGroupEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.JoinRequestEvent -import com.vitorpamplona.quartz.nip29RelayGroups.request.LeaveRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupJoinRequestEvent +import com.vitorpamplona.quartz.nip29RelayGroups.request.GroupLeaveRequestEvent import com.vitorpamplona.quartz.nip42RelayAuth.RelayAuthEvent import kotlinx.coroutines.runBlocking import okhttp3.OkHttpClient @@ -238,7 +238,7 @@ class BuzzRelayLiveInteropTest { val (ws2, frames2) = authedSocket(joiner) val join = joiner.sign( - JoinRequestEvent.build(channelId), + GroupJoinRequestEvent.build(channelId), ) ws2.send("""["EVENT",${join.toJson()}]""") val joinOk = frames2.nextOf("OK") @@ -250,7 +250,7 @@ class BuzzRelayLiveInteropTest { assertTrue("true" in frames2.nextOf("OK"), "post after join should be accepted") // LEAVE: kind 9022, the NIP-29 leave request. - val leave = joiner.sign(LeaveRequestEvent.build(channelId)) + val leave = joiner.sign(GroupLeaveRequestEvent.build(channelId)) ws2.send("""["EVENT",${leave.toJson()}]""") assertTrue("true" in frames2.nextOf("OK"), "leave (9022) should be accepted") diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsAuthorsMissingOutboxTest.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsAuthorsMissingOutboxTest.kt index 09238d03b2..1d57a7d042 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsAuthorsMissingOutboxTest.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsAuthorsMissingOutboxTest.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.quartz.nip01Core.store.fs import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent @@ -95,7 +95,7 @@ class FsAuthorsMissingOutboxTest { store.insert(relayList) assertEquals(emptySet(), store.authorsMissingOutbox().toSet()) - store.insert(signer.sign(DeletionEvent.build(listOf(relayList)))) + store.insert(signer.sign(DeletionRequestEvent.build(listOf(relayList)))) assertEquals(setOf(signer.pubKey), store.authorsMissingOutbox().toSet()) } } diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsDeletionTest.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsDeletionTest.kt index 88cc2d05b5..cbb23808b2 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsDeletionTest.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsDeletionTest.kt @@ -22,9 +22,9 @@ package com.vitorpamplona.quartz.nip01Core.store.fs import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.coroutines.runBlocking import java.nio.file.Files import java.nio.file.Path @@ -67,9 +67,9 @@ class FsDeletionTest { body: String, ts: Long, signer: NostrSignerSync = this.signer, - ) = signer.sign<LongTextNoteEvent>( + ) = signer.sign<LongFormContentEvent>( createdAt = ts, - kind = LongTextNoteEvent.KIND, + kind = LongFormContentEvent.KIND, tags = arrayOf(arrayOf("d", slug)), content = body, ) @@ -92,12 +92,12 @@ class FsDeletionTest { store.insert(n1) store.insert(n2) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(n1), createdAt = 30)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(n1), createdAt = 30)) store.insert(del) assertEquals(emptyList(), store.query<TextNoteEvent>(Filter(ids = listOf(n1.id))).map { it.id }) assertEquals(listOf(n2.id), store.query<TextNoteEvent>(Filter(ids = listOf(n2.id))).map { it.id }) - assertEquals(listOf(del.id), store.query<DeletionEvent>(Filter(ids = listOf(del.id))).map { it.id }) + assertEquals(listOf(del.id), store.query<DeletionRequestEvent>(Filter(ids = listOf(del.id))).map { it.id }) } @Test @@ -106,7 +106,7 @@ class FsDeletionTest { val n1 = note("one", 10) store.insert(n1) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(n1), createdAt = 30)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(n1), createdAt = 30)) store.insert(del) store.insert(n1) // should be blocked @@ -121,7 +121,7 @@ class FsDeletionTest { store.insert(theirs) // Our signer attempts to delete it. - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(theirs), createdAt = 30)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(theirs), createdAt = 30)) store.insert(del) // Cascade did NOT run — not our author. @@ -150,14 +150,14 @@ class FsDeletionTest { store.insert(v1) store.insert(v2) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v2), createdAt = 30)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v2), createdAt = 30)) store.insert(del) // Slot cleared, canonical removed, indexes gone. val dHash = FsLayout.sha256Hex("intro") - val slot = root.resolve("addressable/${LongTextNoteEvent.KIND}/${signer.pubKey}/$dHash.json") + val slot = root.resolve("addressable/${LongFormContentEvent.KIND}/${signer.pubKey}/$dHash.json") assertFalse(slot.exists(), "addressable slot should be cleared") - assertEquals(emptyList(), store.query<LongTextNoteEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND))).map { it.id }) + assertEquals(emptyList(), store.query<LongFormContentEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND))).map { it.id }) } @Test @@ -166,14 +166,14 @@ class FsDeletionTest { val v1 = article("intro", "draft 1", 10) store.insert(v1) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v1), createdAt = 20)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v1), createdAt = 20)) store.insert(del) // A newer addressable at the same address should still be accepted. val v3 = article("intro", "draft 3", 30) store.insert(v3) - val got = store.query<LongTextNoteEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND))) + val got = store.query<LongFormContentEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND))) assertEquals(listOf(v3.id), got.map { it.id }) } @@ -183,13 +183,13 @@ class FsDeletionTest { val v1 = article("intro", "draft 1", 10) store.insert(v1) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v1), createdAt = 20)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v1), createdAt = 20)) store.insert(del) // Attempting to re-insert an event authored earlier than the deletion should fail. val older = article("intro", "even-older", 5) store.insert(older) - assertEquals(emptyList(), store.query<LongTextNoteEvent>(Filter(ids = listOf(older.id))).map { it.id }) + assertEquals(emptyList(), store.query<LongFormContentEvent>(Filter(ids = listOf(older.id))).map { it.id }) } @Test @@ -198,12 +198,12 @@ class FsDeletionTest { val v = article("intro", "v", 10) store.insert(v) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v), createdAt = 15)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v), createdAt = 15)) store.insert(del) val equal = article("intro", "equal", 15) store.insert(equal) - assertEquals(emptyList(), store.query<LongTextNoteEvent>(Filter(ids = listOf(equal.id))).map { it.id }) + assertEquals(emptyList(), store.query<LongFormContentEvent>(Filter(ids = listOf(equal.id))).map { it.id }) } // ------------------------------------------------------------------ @@ -216,18 +216,18 @@ class FsDeletionTest { val v = article("intro", "v", 10) store.insert(v) - val del1 = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v), createdAt = 20)) + val del1 = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v), createdAt = 20)) store.insert(del1) val del2Target = article("intro", "v2", 30) // inserted only to give del2 a target store.insert(del2Target) - val del2 = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(del2Target), createdAt = 40)) + val del2 = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(del2Target), createdAt = 40)) store.insert(del2) // Cutoff should now be 40, so an event at createdAt=35 is blocked. val mid = article("intro", "mid", 35) store.insert(mid) - assertEquals(emptyList(), store.query<LongTextNoteEvent>(Filter(ids = listOf(mid.id))).map { it.id }) + assertEquals(emptyList(), store.query<LongFormContentEvent>(Filter(ids = listOf(mid.id))).map { it.id }) } @Test @@ -238,23 +238,23 @@ class FsDeletionTest { store.insert(v1) store.insert(v2) - val strongDel = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v2), createdAt = 100)) + val strongDel = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v2), createdAt = 100)) store.insert(strongDel) // Now insert a weaker (earlier) deletion for the same address. val weakTarget = article("slug", "target-for-weak", 30) store.insert(weakTarget) // this passes? No: cutoff=100, target@30 is blocked. Actually we want to - // construct a DeletionEvent that targets the slug address directly. The simplest way: + // construct a DeletionRequestEvent that targets the slug address directly. The simplest way: val weakDel = - signer.sign<DeletionEvent>( - DeletionEvent.buildAddressOnly(listOf(v1), createdAt = 50), + signer.sign<DeletionRequestEvent>( + DeletionRequestEvent.buildAddressOnly(listOf(v1), createdAt = 50), ) store.insert(weakDel) // Cutoff should still be 100 — an event at 60 must still be blocked. val blocked = article("slug", "should-be-blocked", 60) store.insert(blocked) - assertEquals(emptyList(), store.query<LongTextNoteEvent>(Filter(ids = listOf(blocked.id))).map { it.id }) + assertEquals(emptyList(), store.query<LongFormContentEvent>(Filter(ids = listOf(blocked.id))).map { it.id }) } // ------------------------------------------------------------------ @@ -266,10 +266,10 @@ class FsDeletionTest { runBlocking { val n = note("x", 10) store.insert(n) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(n), createdAt = 20)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(n), createdAt = 20)) store.insert(del) - val byKind = store.query<DeletionEvent>(Filter(kinds = listOf(DeletionEvent.KIND))) + val byKind = store.query<DeletionRequestEvent>(Filter(kinds = listOf(DeletionRequestEvent.KIND))) assertEquals(listOf(del.id), byKind.map { it.id }) } @@ -289,10 +289,10 @@ class FsDeletionTest { // `event_tags.pubkey_hash = NEW.pubkey_owner_hash` guard. val v1 = otherArticle("shared", "v1", 10) store.insert(v1) - assertEquals(listOf(v1.id), store.query<LongTextNoteEvent>(Filter(ids = listOf(v1.id))).map { it.id }) + assertEquals(listOf(v1.id), store.query<LongFormContentEvent>(Filter(ids = listOf(v1.id))).map { it.id }) val strangerDel = - signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v1), createdAt = 20)) + signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v1), createdAt = 20)) store.insert(strangerDel) // Bob can still publish a newer version at the same address. Since @@ -300,7 +300,7 @@ class FsDeletionTest { // exists to block. val v2 = otherArticle("shared", "v2", 30) store.insert(v2) - assertEquals(listOf(v2.id), store.query<LongTextNoteEvent>(Filter(ids = listOf(v2.id))).map { it.id }) + assertEquals(listOf(v2.id), store.query<LongFormContentEvent>(Filter(ids = listOf(v2.id))).map { it.id }) } @Test @@ -308,7 +308,7 @@ class FsDeletionTest { runBlocking { val n = note("x", 10) store.insert(n) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(n), createdAt = 20)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(n), createdAt = 20)) store.insert(del) val tomb = root.resolve("tombstones/id/${n.id}.json") diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsParityTest.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsParityTest.kt index a9603f8996..0a79e052d5 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsParityTest.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsParityTest.kt @@ -25,9 +25,9 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync import com.vitorpamplona.quartz.nip01Core.store.sqlite.EventStore -import com.vitorpamplona.quartz.nip09Deletions.DeletionEvent +import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.coroutines.runBlocking import java.nio.file.Files import java.nio.file.Path @@ -121,10 +121,10 @@ class FsParityTest { slug: String, body: String, ts: Long, - ): LongTextNoteEvent = + ): LongFormContentEvent = signer.sign( createdAt = ts, - kind = LongTextNoteEvent.KIND, + kind = LongFormContentEvent.KIND, tags = arrayOf(arrayOf("d", slug)), content = body, ) @@ -234,7 +234,7 @@ class FsParityTest { insertBoth(v2) insertBoth(v3) - assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND))) + assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND))) } @Test @@ -284,7 +284,7 @@ class FsParityTest { assertParity( Filter( authors = listOf(signer.pubKey), - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), tags = mapOf("d" to listOf("tie")), ), ) @@ -303,12 +303,12 @@ class FsParityTest { insertBoth(a) insertBoth(b) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(a), createdAt = 30)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(a), createdAt = 30)) insertBoth(del) assertParity(Filter(ids = listOf(a.id))) assertParity(Filter(ids = listOf(b.id))) - assertParity(Filter(kinds = listOf(DeletionEvent.KIND))) + assertParity(Filter(kinds = listOf(DeletionRequestEvent.KIND))) // Re-insert blocked. insertBoth(a) @@ -321,16 +321,16 @@ class FsParityTest { val v = article("intro", "v1", 10) insertBoth(v) - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(v), createdAt = 20)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(v), createdAt = 20)) insertBoth(del) - assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND))) + assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND))) // Older event at this address must be blocked, newer must pass. insertBoth(article("intro", "older", 5)) insertBoth(article("intro", "newer", 100)) - assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND))) + assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND))) } // ------------------------------------------------------------------ @@ -429,7 +429,7 @@ class FsParityTest { val artB = article("b", "B v1", 30) val artBv2 = article("b", "B v2", 50) // Deletion of n1 - val del = signer.sign<DeletionEvent>(DeletionEvent.build(listOf(n1), createdAt = 40)) + val del = signer.sign<DeletionRequestEvent>(DeletionRequestEvent.build(listOf(n1), createdAt = 40)) listOf(n1, n2, meta1, meta2, artA, artB, artBv2, del).forEach { insertBoth(it) } @@ -437,8 +437,8 @@ class FsParityTest { assertParity(Filter(ids = listOf(n1.id)), "n1 deleted") assertParity(Filter(ids = listOf(n2.id)), "n2 alive") assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(0)), "metadata winner") - assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND)), "articles set") - assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(DeletionEvent.KIND)), "deletion present") + assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND)), "articles set") + assertParity(Filter(authors = listOf(signer.pubKey), kinds = listOf(DeletionRequestEvent.KIND)), "deletion present") } // ------------------------------------------------------------------ diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSearchTest.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSearchTest.kt index ccd9400ae9..ddfdadacb0 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSearchTest.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSearchTest.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.coroutines.runBlocking import java.nio.file.Files import java.nio.file.Path @@ -166,7 +166,7 @@ class FsSearchTest { val n = note("uniqnote bitcoin", ts = 100) val long = signer.sign( - LongTextNoteEvent.build( + LongFormContentEvent.build( "uniqlong body", title = "title", dTag = "d1", diff --git a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSlotsTest.kt b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSlotsTest.kt index 26ac6f6463..4ebda49500 100644 --- a/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSlotsTest.kt +++ b/quartz/src/jvmTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/fs/FsSlotsTest.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync -import com.vitorpamplona.quartz.nip23LongContent.LongTextNoteEvent +import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import kotlinx.coroutines.runBlocking import java.nio.file.Files import java.nio.file.Path @@ -224,10 +224,10 @@ class FsSlotsTest { } val got = - store.query<LongTextNoteEvent>( + store.query<LongFormContentEvent>( Filter( authors = listOf(signer.pubKey), - kinds = listOf(LongTextNoteEvent.KIND), + kinds = listOf(LongFormContentEvent.KIND), tags = mapOf("d" to listOf("intro")), ), ) @@ -255,10 +255,10 @@ class FsSlotsTest { slug: String, body: String, createdAt: Long, - ): LongTextNoteEvent = + ): LongFormContentEvent = signer.sign( createdAt = createdAt, - kind = LongTextNoteEvent.KIND, + kind = LongFormContentEvent.KIND, tags = arrayOf(arrayOf("d", slug)), content = body, ) @@ -271,7 +271,7 @@ class FsSlotsTest { store.insert(v1) store.insert(v2) - val got = store.query<LongTextNoteEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND))) + val got = store.query<LongFormContentEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND))) assertEquals(listOf(v2.id), got.map { it.id }) assertFalse(store.hasCanonical(v1.id), "older draft canonical should be removed") } @@ -284,7 +284,7 @@ class FsSlotsTest { store.insert(intro) store.insert(about) - val got = store.query<LongTextNoteEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongTextNoteEvent.KIND))) + val got = store.query<LongFormContentEvent>(Filter(authors = listOf(signer.pubKey), kinds = listOf(LongFormContentEvent.KIND))) assertEquals(setOf(intro.id, about.id), got.map { it.id }.toSet()) } @@ -296,7 +296,7 @@ class FsSlotsTest { store.insert(newer) store.insert(older) - val got = store.query<LongTextNoteEvent>(Filter(authors = listOf(signer.pubKey))) + val got = store.query<LongFormContentEvent>(Filter(authors = listOf(signer.pubKey))) assertEquals(listOf(newer.id), got.map { it.id }) } @@ -307,7 +307,7 @@ class FsSlotsTest { store.insert(v) val dHash = FsLayout.sha256Hex("intro") - val slot = root.resolve("addressable/${LongTextNoteEvent.KIND}/${signer.pubKey}/$dHash.json") + val slot = root.resolve("addressable/${LongFormContentEvent.KIND}/${signer.pubKey}/$dHash.json") assertTrue(slot.exists()) val parsed = Event.fromJson(slot.readText()) assertEquals(v.id, parsed.id) @@ -320,7 +320,7 @@ class FsSlotsTest { store.insert(v) val dHash = FsLayout.sha256Hex("") - val slot = root.resolve("addressable/${LongTextNoteEvent.KIND}/${signer.pubKey}/$dHash.json") + val slot = root.resolve("addressable/${LongFormContentEvent.KIND}/${signer.pubKey}/$dHash.json") assertTrue(slot.exists()) } @@ -330,7 +330,7 @@ class FsSlotsTest { val v = article("intro", "hello", 10) store.insert(v) val dHash = FsLayout.sha256Hex("intro") - val slot = root.resolve("addressable/${LongTextNoteEvent.KIND}/${signer.pubKey}/$dHash.json") + val slot = root.resolve("addressable/${LongFormContentEvent.KIND}/${signer.pubKey}/$dHash.json") assertTrue(slot.exists()) store.delete(v.id) From 5e029cd9c05784c950d66999ce709542bd92698d Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 20:40:23 +0000 Subject: [PATCH 48/57] fix(quartz): conform the tagging d to the revised Tapestry rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Tapestry draft fixed this defect on its own `feat/tags` branch, dated "Superseded 2026-09-10", before it was reported. Same diagnosis that `1770ef27` reached — the old rule used only the coordinate's author segment, which is constant across everything that author writes — but a different wire format, so this branch has to follow rather than diverge. `event-taggings.md` § "The assertion d-tag (normative)" now reads, for an `a` target: d = event-tag-<slug>-<author8>-<d16>-<hash8>-<asserter8> `hash8` is the first 8 lowercase hex of SHA-256 over the UTF-8 bytes of the full coordinate `<kind>:<author>:<d>`, and is the only segment that carries uniqueness; `author8` and `d16` are readable decoration. `d16` is the first 16 UTF-16 code units of the target's own `d`, verbatim, which is what String.take counts. `1770ef27` collapsed the whole thing to just the hash, so it was correct but non-conformant. The `e` branch is untouched: an event id already covers the whole event, and the draft leaves it as the first 8 hex of the id. Nothing parses the `d` back into these fields, and the draft now forbids it outright, since `d16` is user-influenced text that can itself contain hyphens. The target is read from the `a`/`e` tag. Two cases the draft spells out are pinned alongside the three collision cases: an empty `d` leaves the double hyphen `<author8>--<hash8>`, and a `d` longer than 16 units is truncated in the decoration while `hash8` still separates. All hashes are SHA-256 prefixes computed outside this codebase. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../taggings/EventTagging.kt | 46 +++++++++++++++---- .../decentralizedLists/AuditRegressionTest.kt | 37 +++++++++++---- .../TapestryExtensionsTest.kt | 7 +-- 3 files changed, 70 insertions(+), 20 deletions(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt index 782ad80571..8a45a5ef82 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt @@ -42,9 +42,10 @@ import com.vitorpamplona.quartz.utils.sha256.sha256 @Immutable sealed interface TaggingTarget { /** - * The 8 hex characters that stand for this target in the assertion `d`. Two distinct targets - * must not produce the same one: kind 39999 is addressable, so taggings that share a `d` do - * not sit side by side — the later one replaces the earlier. + * What stands for this target in the assertion `d`: `<id8>` for a plain event, + * `<author8>-<d16>-<hash8>` for an addressable one. Two distinct targets must never produce + * the same one — kind 39999 is addressable, so taggings sharing a `d` do not sit side by + * side: the later one replaces the earlier. */ val prefix: String @@ -52,17 +53,39 @@ sealed interface TaggingTarget { data class ByAddress( val address: Address, ) : TaggingTarget { - // Hashed over the WHOLE coordinate, because no single segment identifies the target: the - // author repeats across everything they write, and the kind across everything of a type. - // A plain event can use its own id (below) since that already covers the whole event. - override val prefix get() = sha256(address.toValue().encodeToByteArray()).toHexKey().take(8) + /** + * `<author8>-<d16>-<hash8>`. Only `hash8` carries uniqueness — it is taken over the WHOLE + * coordinate, because no single segment identifies the target: the author repeats across + * everything they write, and the kind across everything of a type. The other two are + * decoration the draft asks for so a `d` stays readable. + * + * An empty `dTag` yields an empty `d16`, i.e. `<author8>--<hash8>`, which the draft spells + * out. A plain event uses its own id (below): that already covers the whole event. + */ + override val prefix get() = "${address.pubKeyHex.take(AUTHOR_CHARS)}-${address.dTag.take(D_TAG_CHARS)}-${hash8()}" + + // Lowercase hex of the UTF-8 coordinate exactly as the `a` tag carries it: no trimming, + // no normalization, no reordering. Hex.encode already emits lower case. + private fun hash8() = sha256(address.toValue().encodeToByteArray()).toHexKey().take(HASH_CHARS) } @Immutable data class ByEventId( val eventId: HexKey, ) : TaggingTarget { - override val prefix get() = eventId.take(8) + override val prefix get() = eventId.take(EVENT_ID_CHARS) + } + + companion object { + const val EVENT_ID_CHARS = 8 + const val AUTHOR_CHARS = 8 + const val HASH_CHARS = 8 + + /** + * UTF-16 code units, which is what the draft pins ("as JavaScript `String.prototype.slice` + * counts them") and what [String.take] counts. + */ + const val D_TAG_CHARS = 16 } } @@ -113,7 +136,8 @@ object TaggingHeader { * [TaggingHeader]: * * ``` - * ["d", "event-tag-<tagSlug>-<target8>-<asserter8>"] + * ["d", "event-tag-<tagSlug>-<target8>-<asserter8>"] // <target8> = <id8>, or + * // <author8>-<d16>-<hash8> for an `a` * ["a", <target coordinate>] or ["e", <target id>] * ["z", <nostr-event-tag concept>] * ["z", <tagging header coordinate>] @@ -121,6 +145,10 @@ object TaggingHeader { * ``` * * An `a`/`e` reference without such a `z` is not a tagging and must not be read as one. + * + * The `d` is a replaceability key, never a source of truth: the draft forbids parsing it back into + * its fields, because `d16` is user-influenced text that may itself contain hyphens. [parse] reads + * the target from the `a`/`e` tag, which is authoritative. */ @Immutable data class EventTagging( diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt index e1f2f2c56a..fbf7384959 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt @@ -143,27 +143,48 @@ class AuditRegressionTest { } // ...while the `d` stays deterministic, which is what lets a re-tag replace its own assertion - // instead of piling up a second one. Pinned against SHA-256 prefixes of the coordinates - // computed outside this codebase, so the test cross-checks the derivation rather than - // restating it: a change of hash input would silently orphan every assertion already signed. + // instead of piling up a second one. `event-taggings.md` § "The assertion d-tag (normative)": + // `<author8>-<d16>-<hash8>`, only hash8 unique. The hashes are SHA-256 prefixes of the full + // coordinate computed outside this codebase, so the test cross-checks the derivation rather + // than restating it: a change of hash input would silently orphan every assertion signed. @Test - fun theAddressablePrefixIsTheHashOfTheWholeCoordinate() { + fun theAddressablePrefixIsAuthorThenDTagThenTheHashOfTheWholeCoordinate() { assertEquals( - "event-tag-awesome-tag-6a5e1c40-aaaaaaaa", + "event-tag-awesome-tag-bbbbbbbb-good-tag-6a5e1c40-aaaaaaaa", EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, "good-tag")), alice), ) assertEquals( - "event-tag-awesome-tag-e89b797c-aaaaaaaa", + "event-tag-awesome-tag-bbbbbbbb-other-tag-e89b797c-aaaaaaaa", EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, "other-tag")), alice), ) + // same author8 AND same d16 as the first; only the kind differs, so only hash8 separates them assertEquals( - "event-tag-awesome-tag-96856fd8-aaaaaaaa", + "event-tag-awesome-tag-bbbbbbbb-good-tag-96856fd8-aaaaaaaa", EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(30023, bob, "good-tag")), alice), ) } + // The draft spells this case out: an empty `d` yields an empty `d16`, hence the double hyphen. + @Test + fun anEmptyDTagSegmentLeavesADoubleHyphen() { + assertEquals( + "event-tag-awesome-tag-bbbbbbbb--76600e1a-aaaaaaaa", + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, "")), alice), + ) + } + + // d16 is the first 16 UTF-16 code units, verbatim and truncated — decoration, not identity. + @Test + fun aLongDTagIsTruncatedToSixteenCharactersInTheDecoration() { + val d = "a-very-long-d-tag-that-exceeds-sixteen" + assertEquals( + "event-tag-awesome-tag-bbbbbbbb-a-very-long-d-ta-58899d62-aaaaaaaa", + EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, d)), alice), + ) + } + // A plain event is still named by its own id: it already covers the whole event, and hashing - // it would only cost a round of SHA-256 per assertion built. + // it would only cost a round of SHA-256 per assertion built. The `e` branch is unchanged. @Test fun plainEventTargetsStillUseTheirOwnId() { assertEquals( diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt index c212e8deb2..f244c1da1d 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/TapestryExtensionsTest.kt @@ -247,9 +247,10 @@ class TapestryExtensionsTest { assertEquals( listOf( - // 4d7a80b1 is sha256("39999:${"c".repeat(64)}:good-tag").take(8) — the whole - // coordinate, so two of the assistant's tags cannot share this `d`. - listOf("d", "event-tag-awesome-tag-4d7a80b1-aaaaaaaa"), + // <author8>-<d16>-<hash8>: cccccccc is the assistant, good-tag the target's own + // `d`, and 4d7a80b1 = sha256("39999:${"c".repeat(64)}:good-tag").take(8), the one + // segment that makes two of the assistant's tags land on different addresses. + listOf("d", "event-tag-awesome-tag-cccccccc-good-tag-4d7a80b1-aaaaaaaa"), listOf("z", "39998:$ta:nostr-event-tag"), listOf("z", "39999:$bob:tagging:awesome-tag-tagging"), listOf("a", "39999:$assistant:good-tag"), From f72388a55937c573cab998931f10eb90b37253f2 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 20:56:07 +0000 Subject: [PATCH 49/57] refactor: rename packages, helpers and app code after the NIP event renames Follow-up to the event class renames: the names around those classes now match too. Quartz (published API, every old name kept as a @Deprecated alias/forwarder): - nip51Lists packages moved: followList -> starterPack, hashtagList -> interestList, peopleList -> followSet, labeledBookmarkList -> bookmarkSet. The old packages keep a Deprecated.kt with typealiases and forwarding extension functions (ReplaceWith points at the new package). - LnZapPrivateEvent -> PrivateZapEvent, LnZapReceiptValidator -> ZapReceiptValidator, ChannelListDiff -> PublicChatListDiff, HashtagListDiff -> InterestListDiff. - Kind 30063 now indexes NIP-82 release notes for search (never NIP-51 content, which can hold encrypted private items). searchable-events docs updated. App code (amethyst, commons, desktopApp, cli; no aliases needed): - model packages nip51Lists.{hashtagLists,peopleList,labeledBookmarkLists,relayFeeds} -> {interestLists,followSets,bookmarkSets,favoriteRelays}. - State/cache/UI names derived from the old event names: HashtagListState -> InterestListState, PeopleListsState -> FollowSetsState, FollowListsState -> StarterPacksState, LabeledBookmarkList -> BookmarkSet, RelayFeedListState -> FavoriteRelayListState, ContactCardsState -> UserAssertionsState, NIP90* view models/renderers -> Dvm*, LnZap* handlers -> Zap*, SealedRumor* -> Seal*, and Account.peopleLists/followLists/hashtagList -> followSets/starterPacks/interestList. - String literals were left untouched, so preference keys and @SerialName values stored on disk are unchanged. - The generic PeopleList UI model (shared by follow sets and starter packs) and the EmojiPackSelection route (which shows a kind 30030 pack) keep their names. Docs: plans, brainstorms, changelogs, skills and READMEs use the new names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015VvJ8XpeYqBe8bYT3bJ7UD --- .claude/skills/account-state/SKILL.md | 4 +- .../references/account-state-flow.md | 10 +-- .../skills/nip85-trusted-assertions/SKILL.md | 8 +- .claude/skills/searchable-events/SKILL.md | 7 +- .../references/searchable-kinds.md | 18 ++-- ...2026-07-01-auth-permission-architecture.md | 4 +- .../plans/2026-07-07-nip29-armada-study.md | 12 +-- .../2026-07-13-chat-scroll-performance.md | 2 +- .../2026-07-15-bitchat-geohash-interop.md | 2 +- .../2026-07-23-push-notification-redesign.md | 6 +- amethyst/plans/2026-07-24-nwc-bolt12-pay.md | 2 +- ...2026-07-31-shortpost-notify-list-picker.md | 6 +- .../2026-09-10-dvm-heartbeat-liveness-plan.md | 4 +- .../2026-09-10-dvm-heartbeat-liveness.md | 2 +- .../plans/2026-09-17-nip-cc-geocaching.md | 2 +- .../plans/archive/2026-05-14-onchain-zaps.md | 6 +- .../2026-06-22-napplet-nsite-security.md | 2 +- .../amethyst/LocalPreferences.kt | 32 +++---- .../vitorpamplona/amethyst/model/Account.kt | 82 ++++++++--------- .../amethyst/model/AccountSettings.kt | 40 ++++----- .../amethyst/model/EventBroadcaster.kt | 2 +- .../BookmarkSetsState.kt} | 84 ++++++++--------- .../FavoriteRelayListState.kt} | 50 +++++------ .../FollowSetsState.kt} | 18 ++-- .../StarterPacksState.kt} | 36 ++++---- .../InterestListState.kt} | 34 +++---- .../preferences/AccountPreferenceStores.kt | 4 +- .../serverList/MergedFollowListsState.kt | 30 +++---- .../notifications/NotificationDispatcher.kt | 6 +- .../notifications/PushWrapDecryptor.kt | 2 +- .../FilterAccountInfoAndListsFromKey.kt | 6 +- .../reqCommand/user/UserObservers.kt | 38 ++++---- .../resourceusage/MeteringNostrSigner.kt | 4 +- .../amethyst/ui/dal/FilterByListParams.kt | 2 +- .../amethyst/ui/feeds/PrefetchFeedMedia.kt | 4 +- .../ui/navigation/drawer/DrawerContent.kt | 4 +- .../ui/navigation/routes/RouteMaker.kt | 2 +- .../amethyst/ui/note/MultiSetCompose.kt | 4 +- .../amethyst/ui/note/NoteCompose.kt | 40 ++++----- .../amethyst/ui/note/NoteQuickActionMenu.kt | 4 +- .../ui/note/UpdateReactionTypeDialog.kt | 2 +- .../amethyst/ui/note/UserProfilePicture.kt | 4 +- .../ui/note/creators/notify/AudienceSheet.kt | 6 +- .../amethyst/ui/note/elements/DropDownMenu.kt | 4 +- .../ui/note/types/ActivityCardPreviews.kt | 10 +-- .../amethyst/ui/note/types/Emoji.kt | 2 +- .../amethyst/ui/note/types/FileHeader.kt | 8 +- .../types/NIP90ContentDiscoveryResponse.kt | 2 +- .../amethyst/ui/note/types/NIP90Status.kt | 2 +- .../amethyst/ui/note/types/PeopleList.kt | 2 +- .../amethyst/ui/note/types/ProfileCard.kt | 4 +- .../amethyst/ui/note/types/RelayList.kt | 6 +- .../types/{FollowList.kt => StarterPack.kt} | 4 +- .../amethyst/ui/note/types/Wiki.kt | 4 +- .../amethyst/ui/note/types/ZapEvent.kt | 6 +- .../ui/note/types/lists/BookmarkLists.kt | 4 +- .../amethyst/ui/note/types/lists/TagLists.kt | 4 +- .../ui/screen/AccountSessionManager.kt | 8 +- .../amethyst/ui/screen/TopNavFilterState.kt | 20 ++--- .../ui/screen/loggedIn/AccountViewModel.kt | 6 +- .../loggedIn/DecryptAndIndexProcessor.kt | 22 ++--- .../loggedIn/backups/BackupConflictCards.kt | 14 +-- .../backups/BackupConflictListViews.kt | 12 +-- .../backups/BackupConflictPresentation.kt | 12 +-- .../backups/BackupConflictReviewScreen.kt | 8 +- .../display/BookmarkGroupScreen.kt | 2 +- .../display/BookmarkGroupViewModel.kt | 14 +-- .../list/ListOfBookmarkGroupsScreen.kt | 18 ++-- .../BookmarkGroupMetadataViewModel.kt | 10 +-- .../ArticleBookmarkListManagementScreen.kt | 10 +-- .../PostBookmarkListManagementScreen.kt | 10 +-- .../relayGroup/RelayGroupDiscoveryScreen.kt | 4 +- .../relayGroup/RelayGroupMembersScreen.kt | 2 +- .../RelayGroupsDiscoverySubAssembler.kt | 4 +- .../loggedIn/discover/ChannelCardCompose.kt | 2 +- .../loggedIn/discover/DiscoverScreen.kt | 2 +- .../DiscoverFollowSetsFeedFilter.kt | 2 +- .../discover/nip51FollowSets/FollowSetCard.kt | 2 +- .../dvms/DvmContentDiscoveryScreen.kt | 12 +-- ...kt => DvmContentDiscoveryFeedViewModel.kt} | 6 +- ...t => DvmContentDiscoveryResponseFilter.kt} | 2 +- .../emojipacks/list/ListOfEmojiPacksScreen.kt | 2 +- .../EmojiPackSelectionScreen.kt | 2 +- .../membershipManagement/MyEmojiListScreen.kt | 2 +- .../followPacks/feed/FollowPackFeedScreen.kt | 2 +- .../FollowPackFeedConversationsFeedFilter.kt | 2 +- .../dal/FollowPackFeedNewThreadFeedFilter.kt | 2 +- .../feed/dal/FollowPackMembersFeedFilter.kt | 2 +- .../FollowPackFeedFilterSubAssembler.kt | 2 +- .../followPacks/list/FollowPacksFeedLoaded.kt | 2 +- .../followPacks/list/FollowPacksTopBar.kt | 2 +- .../display/lists/PeopleListViewModel.kt | 12 +-- .../display/packs/FollowPackViewModel.kt | 12 +-- .../lists/list/FollowPackViewModel.kt | 8 +- .../lists/list/PeopleListViewModel.kt | 8 +- .../metadata/FollowPackMetadataViewModel.kt | 8 +- .../metadata/PeopleListMetadataViewModel.kt | 8 +- .../FollowListAndPackAndUserView.kt | 12 +-- .../profile/followers/FollowersTabHeader.kt | 4 +- .../profile/header/UserNicknameCard.kt | 4 +- .../profile/header/UserProfileDropDownMenu.kt | 4 +- .../loggedIn/relays/AllRelayListScreen.kt | 6 +- .../screen/loggedIn/relays/KindDisplayName.kt | 12 +-- ...Model.kt => FavoriteRelayListViewModel.kt} | 6 +- .../relays/feeds/RelayFeedsListView.kt | 6 +- .../loggedIn/threadview/ThreadFeedView.kt | 20 ++--- ...dCompose.kt => FileMetadataCardCompose.kt} | 16 ++-- .../ui/screen/loggedIn/video/VideoScreen.kt | 2 +- .../resourceusage/ResourceUsageLedgerTest.kt | 4 +- cli/plans/archive/2026-04-23-nip17-dm.md | 6 +- commons/plans/2026-05-04-custom-feeds-plan.md | 6 +- .../2026-08-30-commons-migration-sweep.md | 4 +- .../commons/account/AccountBootstrapEvents.kt | 12 +-- .../backups/ReplaceableBackupConflict.kt | 2 +- .../commons/model/cache/EventCache.kt | 28 +++--- .../nip28PublicChats/PublicChatListState.kt | 28 +++--- .../nip29RelayGroups/RelayGroupChannel.kt | 14 +-- .../model/nip30CustomEmojis/EmojiPackState.kt | 18 ++-- .../blockPeopleList/BlockPeopleListState.kt | 6 +- .../BookmarkSet.kt} | 4 +- .../FavoriteRelayListDecryptionCache.kt} | 4 +- .../FollowSetDecryptionCache.kt} | 6 +- .../{peopleList => followSets}/PeopleList.kt | 2 +- .../InterestListDecryptionCache.kt} | 8 +- ...che.kt => UserAssertionDecryptionCache.kt} | 2 +- ...ctCardsState.kt => UserAssertionsState.kt} | 4 +- .../model/topNavFeeds/FeedDecryptionCaches.kt | 8 +- .../topNavFeeds/noteBased/NoteFeedFlow.kt | 6 +- .../notifications/NotificationKinds.kt | 2 +- .../FilterBasicAccountInfoFromKeys.kt | 2 +- .../FilterBookmarksAndReportsFromKey.kt | 2 +- .../metadata/FilterFollowsAndMutesFromKey.kt | 4 +- .../assemblers/ContactCardFilters.kt | 10 +-- .../FilterFollowSetsByAllCommunities.kt | 2 +- .../FilterFollowSetsByAuthors.kt | 2 +- .../FilterFollowSetsByCommunity.kt | 2 +- .../FilterFollowSetsByGeohash.kt | 2 +- .../FilterFollowSetsByHashtag.kt | 2 +- .../nip51FollowSets/FilterFollowSetsGlobal.kt | 2 +- .../profile/FilterUserProfileLists.kt | 6 +- .../user/watchers/UserCardsSubAssembler.kt | 6 +- .../amethyst/commons/search/KindRegistry.kt | 2 +- .../commons/search/RenderableKinds.kt | 4 +- .../model/privateChats/ChatPreviewTest.kt | 14 +-- .../notifications/NotificationKindsTest.kt | 10 +-- .../commons/napplet/NappletBrokerTest.kt | 4 +- .../commons/onchain/OnchainZapSenderTest.kt | 4 +- .../commons/viewmodels/NestViewModelTest.kt | 4 +- .../nip51Lists/ui/BookmarkGroupItem.kt | 4 +- .../ui/ListOfBookmarkGroupsFeedView.kt | 14 +-- .../commons/nip51Lists/ui/PeopleListItem.kt | 2 +- .../ui/EditNicknameDialog.kt | 12 +-- ...sktop-wallet-zapping-test-coverage-plan.md | 16 ++-- ...-23-feat-desktop-moderation-safety-plan.md | 10 +-- ...07-27-feat-desktop-profile-actions-plan.md | 34 +++---- ...-07-27-feat-desktop-profile-parity-plan.md | 24 ++--- ...26-07-27-feat-desktop-profile-tabs-plan.md | 2 +- ...ta-loading-upstream-reconciliation-plan.md | 2 +- .../2026-05-09-embedded-local-relay-plan.md | 2 +- .../2026-05-11-wallet-zapping-brainstorm.md | 2 +- .../desktop/cache/DesktopLocalCache.kt | 14 +-- .../desktop/followpacks/BulkFollowAction.kt | 2 +- .../desktop/followpacks/FollowPackEditor.kt | 2 +- .../desktop/followpacks/FollowPacksState.kt | 2 +- .../desktop/followpacks/ui/DiscoverScreen.kt | 2 +- .../followpacks/ui/FollowAllConfirmDialog.kt | 2 +- .../ui/FollowPackBrowseAllScreen.kt | 2 +- .../followpacks/ui/FollowPackComponents.kt | 2 +- .../followpacks/ui/FollowPackDetailScreen.kt | 2 +- .../followpacks/ui/RenderFollowPackCard.kt | 2 +- .../desktop/model/DesktopHiddenUsersState.kt | 8 +- .../amethyst/desktop/ui/UserProfileScreen.kt | 2 +- .../desktop/ui/note/DesktopRichText.kt | 2 +- docs/TODO.md | 2 +- .../2026-03-16-desktop-media-brainstorm.md | 2 +- ...26-03-19-dm-encryption-badge-brainstorm.md | 2 +- docs/changelog/v0.31.04.md | 2 +- docs/changelog/v0.76.01.md | 2 +- docs/changelog/v1.03.00.md | 2 +- docs/changelog/v1.12.00.md | 2 +- docs/changelog/v1.12.02.md | 2 +- ...-06-10-feat-desktop-dm-reliability-plan.md | 4 +- ...sktop-cache-navigation-persistence-plan.md | 6 +- ...clean-cache-single-source-of-truth-plan.md | 10 +-- ...3-24-feat-article-highlights-notes-plan.md | 6 +- ...026-04-21-feat-relay-config-parity-plan.md | 8 +- ...-21-feat-relay-subscription-wiring-plan.md | 2 +- ...-22-feat-relay-subscription-wiring-plan.md | 4 +- ...feat-desktop-multi-account-support-plan.md | 2 +- ...fix-bunker-timeouts-and-decryption-plan.md | 4 +- ...22-feat-desktop-note-action-bar-ux-plan.md | 2 +- ...2-fix-desktop-feed-review-findings-plan.md | 6 +- .../2026-06-12-giftwrap-deletion-requests.md | 2 +- .../plans/2026-07-11-concord-event-classes.md | 4 +- quartz/plans/archive/2026-06-09-clink.md | 4 +- ...entTest.kt => NwcRequestNip44EventTest.kt} | 2 +- .../nip55AndroidSigner/api/SignerResult.kt | 4 +- .../api/background/queries/DecryptZapQuery.kt | 4 +- .../intents/responses/DecryptZapResponse.kt | 6 +- .../client/NostrSignerExternal.kt | 4 +- .../vitorpamplona/quartz/kinds/KindNames.kt | 12 +-- .../quartz/marmot/MarmotInboundProcessor.kt | 2 +- .../marmot/mip02Welcome/WelcomeGiftWrap.kt | 4 +- .../quartz/nip01Core/signers/NostrSigner.kt | 4 +- .../nip01Core/signers/NostrSignerInternal.kt | 4 +- .../nip01Core/signers/NostrSignerSync.kt | 4 +- .../quartz/nip13Pow/signer/PoWNostrSigner.kt | 4 +- ...annelListDiff.kt => PublicChatListDiff.kt} | 8 +- .../list/PublicChatListEvent.kt | 6 +- .../signer/NostrSignerRemote.kt | 4 +- .../nip50Search/SearchFieldExtractor.kt | 8 +- .../BookmarkSetEvent.kt | 8 +- .../TagArrayBuilderExt.kt | 2 +- .../nip51Lists/followList/Deprecated.kt | 90 +++++++++++++++++++ .../FollowSetEvent.kt | 8 +- .../TagArrayBuilderExt.kt | 2 +- .../{peopleList => followSet}/TagArrayExt.kt | 2 +- .../nip51Lists/hashtagList/Deprecated.kt | 61 +++++++++++++ .../InterestListDiff.kt} | 4 +- .../InterestListEvent.kt | 14 +-- .../TagArrayBuilderExt.kt | 2 +- .../TagArrayExt.kt | 2 +- .../labeledBookmarkList/Deprecated.kt | 58 ++++++++++++ .../mediaStarterPack/MediaStarterPackEvent.kt | 6 +- .../nip51Lists/peopleList/Deprecated.kt | 83 +++++++++++++++++ .../ReleaseArtifactSetEvent.kt | 10 ++- .../StarterPackEvent.kt | 8 +- .../TagArrayBuilderExt.kt | 2 +- .../TagArrayExt.kt | 2 +- .../nip57Zaps/IPrivateZapsDecryptionCache.kt | 4 +- .../quartz/nip57Zaps/PrivateZapCache.kt | 6 +- ...nZapPrivateEvent.kt => PrivateZapEvent.kt} | 12 ++- .../nip57Zaps/PrivateZapRequestBuilder.kt | 8 +- .../validate/LnurlEndpointResolver.kt | 2 +- ...iptValidator.kt => ZapReceiptValidator.kt} | 8 +- .../clientTag/NostrSignerWithClientTag.kt | 4 +- .../quartz/utils/EventFactory.kt | 12 +-- .../SoftwareApplicationEventTest.kt | 26 ++++++ ...ameTest.kt => UserAssertionPetNameTest.kt} | 2 +- .../store/sqlite/QueryAssemblerTest.kt | 2 +- .../BunkerRequestProcessorConcurrencyTest.kt | 4 +- .../server/BunkerRequestProcessorTest.kt | 6 +- .../server/NostrConnectSignerServiceTest.kt | 4 +- ...entTest.kt => NwcRequestNip44EventTest.kt} | 2 +- .../nip50Search/SearchFieldExtractorTest.kt | 6 +- .../relayLists/RelayListPublicEntriesTest.kt | 2 +- ...nonTagTest.kt => ZapRequestAnonTagTest.kt} | 2 +- ...upTagTest.kt => ZapRequestGroupTagTest.kt} | 2 +- ...indTagTest.kt => ZapRequestKindTagTest.kt} | 2 +- ...atorTest.kt => ZapReceiptValidatorTest.kt} | 66 +++++++------- .../nip01Core/jackson/JacksonMapperTest.kt | 2 +- .../KotlinSerializationMapperTest.kt | 2 +- 252 files changed, 1262 insertions(+), 945 deletions(-) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/{labeledBookmarkLists/LabeledBookmarkListsState.kt => bookmarkSets/BookmarkSetsState.kt} (80%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/{relayFeeds/RelayFeedListState.kt => favoriteRelays/FavoriteRelayListState.kt} (65%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/{peopleList/PeopleListsState.kt => followSets/FollowSetsState.kt} (95%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/{peopleList/FollowListsState.kt => followSets/StarterPacksState.kt} (91%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/{hashtagLists/HashtagListState.kt => interestLists/InterestListState.kt} (80%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/{FollowList.kt => StarterPack.kt} (99%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/{NIP90ContentDiscoveryFeedViewModel.kt => DvmContentDiscoveryFeedViewModel.kt} (89%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/{NIP90ContentDiscoveryResponseFilter.kt => DvmContentDiscoveryResponseFilter.kt} (98%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/{RelayFeedsListViewModel.kt => FavoriteRelayListViewModel.kt} (90%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/{FileHeaderCardCompose.kt => FileMetadataCardCompose.kt} (93%) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/{labeledBookmarkLists/LabeledBookmarkList.kt => bookmarkSets/BookmarkSet.kt} (94%) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/{relayFeeds/RelayFeedsListDecryptionCache.kt => favoriteRelays/FavoriteRelayListDecryptionCache.kt} (92%) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/{peopleList/PeopleListDecryptionCache.kt => followSets/FollowSetDecryptionCache.kt} (94%) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/{peopleList => followSets}/PeopleList.kt (96%) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/{hashtagLists/HashtagListDecryptionCache.kt => interestLists/InterestListDecryptionCache.kt} (86%) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/{ContactCardDecryptionCache.kt => UserAssertionDecryptionCache.kt} (98%) rename commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/{ContactCardsState.kt => UserAssertionsState.kt} (98%) rename quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/{LnZapPaymentRequestNip44EventTest.kt => NwcRequestNip44EventTest.kt} (98%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/{ChannelListDiff.kt => PublicChatListDiff.kt} (84%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{labeledBookmarkList => bookmarkSet}/BookmarkSetEvent.kt (97%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{labeledBookmarkList => bookmarkSet}/TagArrayBuilderExt.kt (97%) create mode 100644 quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/Deprecated.kt rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{peopleList => followSet}/FollowSetEvent.kt (98%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{peopleList => followSet}/TagArrayBuilderExt.kt (97%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{peopleList => followSet}/TagArrayExt.kt (96%) create mode 100644 quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/Deprecated.kt rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{hashtagList/HashtagListDiff.kt => interestList/InterestListDiff.kt} (95%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{hashtagList => interestList}/InterestListEvent.kt (95%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{hashtagList => interestList}/TagArrayBuilderExt.kt (96%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{hashtagList => interestList}/TagArrayExt.kt (96%) create mode 100644 quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/Deprecated.kt create mode 100644 quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/Deprecated.kt rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{followList => starterPack}/StarterPackEvent.kt (95%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{followList => starterPack}/TagArrayBuilderExt.kt (97%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/{followList => starterPack}/TagArrayExt.kt (96%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/{LnZapPrivateEvent.kt => PrivateZapEvent.kt} (87%) rename quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/{LnZapReceiptValidator.kt => ZapReceiptValidator.kt} (95%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/{ContactCardPetNameTest.kt => UserAssertionPetNameTest.kt} (99%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/{LnZapPaymentRequestNip44EventTest.kt => NwcRequestNip44EventTest.kt} (98%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/{LnZapRequestAnonTagTest.kt => ZapRequestAnonTagTest.kt} (99%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/{LnZapRequestGroupTagTest.kt => ZapRequestGroupTagTest.kt} (99%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/{LnZapRequestKindTagTest.kt => ZapRequestKindTagTest.kt} (99%) rename quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/{LnZapReceiptValidatorTest.kt => ZapReceiptValidatorTest.kt} (70%) diff --git a/.claude/skills/account-state/SKILL.md b/.claude/skills/account-state/SKILL.md index 528a2dd273..6abc975cb4 100644 --- a/.claude/skills/account-state/SKILL.md +++ b/.claude/skills/account-state/SKILL.md @@ -43,10 +43,10 @@ Relay frame ──► LocalCache.insertOrUpdateNote() ──► LocalCacheFlow e - `kind3FollowList = Kind3FollowListState(...)` ← NIP-02 ContactList (kind 3) - `nip65RelayList = Nip65RelayListState(...)` ← NIP-65 RelayList (kind 10002), plus siblings `dmRelayList`, `searchRelayList`, `blockedRelayList`, `trustedRelayList`, `proxyRelayList`, `broadcastRelayList`, `indexerRelayList`, … - `muteList = MuteListState(...)` ← NIP-51 MuteList (kind 10000) - - `bookmarkState = BookmarkListState(...)` ← NIP-51 Bookmarks (kind 10003), plus `labeledBookmarkLists`, `pinState`, `interestSets`, `peopleLists`, `followLists`, `hashtagList`, `geohashList`, `communityList`, `emoji`, `blossomServers`, … + - `bookmarkState = BookmarkListState(...)` ← NIP-51 Bookmarks (kind 10003), plus `bookmarkSets`, `pinState`, `interestSets`, `peopleLists`, `followLists`, `hashtagList`, `geohashList`, `communityList`, `emoji`, `blossomServers`, … - Derived/merged views: `hiddenUsers`, `allFollows`, `homeRelays`, `outboxRelays`, `dmRelays`, `notificationRelays`, `trustedRelays`, and the `live*FollowListsPerRelay` outbox loaders. - **The pattern:** each `XState` class pins its addressable note via `cache.getOrCreateAddressableNote(address)` (a long-term reference so GC/eviction can't drop it), exposes `val flow: StateFlow<…>` derived from the note's metadata flow (decrypted through a per-feature `DecryptionCache`, with backup fallback from `AccountSettings`, `stateIn(scope, Eagerly, …)`), and offers suspend mutation helpers (e.g. `MuteListState.hideUser(pubkey)`) that build the updated signed event. Consumers read `account.muteList.flow`, never a raw `MutableStateFlow` on `Account`. -- Encrypted lists pair the state object with a `DecryptionCache` sibling (`muteListDecryptionCache`, `peopleListDecryptionCache`, …) so NIP-44 decryption results are cached per event. +- Encrypted lists pair the state object with a `DecryptionCache` sibling (`muteListDecryptionCache`, `followSetDecryptionCache`, …) so NIP-44 decryption results are cached per event. - UI reads via `collectAsStateWithLifecycle` on Android and `collectAsState` on Desktop. - Sibling files per feature live alongside: `AccountSettings.kt`, `AccountSyncedSettings.kt`, plus per-NIP state classes under `model/nip02FollowLists/`, `model/nip51Lists/`, `model/nip65RelayList/`, etc. diff --git a/.claude/skills/account-state/references/account-state-flow.md b/.claude/skills/account-state/references/account-state-flow.md index d7e37c5524..73a56cca1b 100644 --- a/.claude/skills/account-state/references/account-state-flow.md +++ b/.claude/skills/account-state/references/account-state-flow.md @@ -16,8 +16,8 @@ been renamed, grep `Account.kt` for the class name.) | `userMetadata` | `UserMetadataState` | 0 | `amethyst/.../model/nip01UserMetadata/` | | `kind3FollowList` | `Kind3FollowListState` | 3 | `model/nip02FollowLists/` | | `muteList` (+ `muteListDecryptionCache`) | `MuteListState` | 10000 | `model/nip51Lists/muteList/` | -| `blockPeopleList`, `peopleLists` | `BlockPeopleListState`, `PeopleListsState` | NIP-51 people sets | `model/nip51Lists/peopleList/` | -| `followLists` | `FollowListsState` | NIP-51 follow sets | `model/nip51Lists/peopleList/` | +| `blockPeopleList`, `peopleLists` | `BlockPeopleListState`, `FollowSetsState` | NIP-51 people sets | `model/nip51Lists/followSets/` | +| `followLists` | `StarterPacksState` | NIP-51 follow sets | `model/nip51Lists/followSets/` | | `hiddenUsers` | `HiddenUsersState` — derived from `muteList.flow` + `blockPeopleList.flow` | — | `model/nip51Lists/` | | `allFollows` | `MergedFollowListsState` — merges kind3 + people/follow/hashtag/geohash/community lists | — | `model/serverList/` | @@ -31,7 +31,7 @@ been renamed, grep `Account.kt` for the class name.) | `blockedRelayList` | `BlockedRelayListState` | 10006 | `model/nip51Lists/blockedRelays/` | | `localRelayList` | `LocalRelayListState` | local | `model/localRelays/` | | `privateStorageRelayList` | `PrivateStorageRelayListState` | private storage | `model/edits/` | -| `keyPackageRelayList`, `trustedRelayList`, `proxyRelayList`, `broadcastRelayList`, `indexerRelayList`, `relayFeedsList` | per-feature `…RelayListState` classes, each with a `DecryptionCache` sibling | custom relay sets | `model/nip51Lists/…` | +| `keyPackageRelayList`, `trustedRelayList`, `proxyRelayList`, `broadcastRelayList`, `indexerRelayList`, `favoriteRelayList` | per-feature `…RelayListState` classes, each with a `DecryptionCache` sibling | custom relay sets | `model/nip51Lists/…` | Derived relay views (merge several of the above): `homeRelays` (`AccountHomeRelayState`), `outboxRelays`, `dmRelays`, `notificationRelays`, @@ -43,10 +43,10 @@ Derived relay views (merge several of the above): `homeRelays` | Account property | State class | Kind | Package | |------------------|-------------|------|---------| | `bookmarkState` (and legacy `oldBookmarkState`) | `BookmarkListState` | 10003 | `model/nip51Lists/` | -| `labeledBookmarkLists` | `LabeledBookmarkListsState` | NIP-51 bookmark sets | `model/nip51Lists/labeledBookmarkLists/` | +| `bookmarkSets` | `BookmarkSetsState` | NIP-51 bookmark sets | `model/nip51Lists/bookmarkSets/` | | `pinState` | `PinListState` | NIP-51 | `model/nip51Lists/` | | `interestSets` | `InterestSetsState` | NIP-51 interest sets | `model/nip51Lists/interestSets/` | -| `hashtagList` / `geohashList` | `HashtagListState` / `GeohashListState` | NIP-51 | `model/nip51Lists/hashtagLists/`, `…/geohashLists/` | +| `hashtagList` / `geohashList` | `InterestListState` / `GeohashListState` | NIP-51 | `model/nip51Lists/interestLists/`, `…/geohashLists/` | | `communityList` | `CommunityListState` | NIP-72 communities | `model/nip72Communities/` | | `favoriteAlgoFeedsList` | `FavoriteAlgoFeedsListState` | NIP-51 | `model/nip51Lists/` | | `emoji`, `ownedEmojiPacks` | `EmojiPackState`, `OwnedEmojiPacksState` | 10030 | `commons/.../commons/model/nip30CustomEmojis/` | diff --git a/.claude/skills/nip85-trusted-assertions/SKILL.md b/.claude/skills/nip85-trusted-assertions/SKILL.md index d75415e4df..935ea8e3d4 100644 --- a/.claude/skills/nip85-trusted-assertions/SKILL.md +++ b/.claude/skills/nip85-trusted-assertions/SKILL.md @@ -92,8 +92,8 @@ The same kind serves two roles, distinguished **by author**: 2. **The account's own contact cards (nicknames, NIP-81-style)** — signed by the account, one per target user. The petname, summary, and their NIP-30 emoji mappings **always live in the NIP-44 encrypted content, never in public tags** (`UserAssertionEvent.build`/ - `updatePetNameAndSummary` strip stray public copies; asserted by `ContactCardPetNameTest`). - `commons/.../ContactCardsState.kt` keys everything on `author == account` and ignores + `updatePetNameAndSummary` strip stray public copies; asserted by `UserAssertionPetNameTest`). + `commons/.../UserAssertionsState.kt` keys everything on `author == account` and ignores provider cards. ## Tag vocabulary and value semantics @@ -225,8 +225,8 @@ card's `a`-tag (`30382:<provider>:<target>`). - **Publisher**: `quartz/.../experimental/graperank/GrapeRankPublisher.kt` (canonical 30382 writer), `cli/.../graperank/` (`amy graperank register|unregister|providers|publish`). -- **Client model**: `commons/.../model/nip85TrustedAssertions/` (`ContactCardsState`, - `UserCardsCache`, `ContactCardDecryptionCache`, `TrustProviderListDecryptionCache`), +- **Client model**: `commons/.../model/nip85TrustedAssertions/` (`UserAssertionsState`, + `UserCardsCache`, `UserAssertionDecryptionCache`, `TrustProviderListDecryptionCache`), `amethyst/.../model/trustedAssertions/TrustProviderListState.kt`. - **Relay plumbing**: `commons/.../relayClient/assemblers/ContactCardFilters.kt`, `amethyst/.../reqCommand/user/watchers/UserCardsSubAssembler.kt`. diff --git a/.claude/skills/searchable-events/SKILL.md b/.claude/skills/searchable-events/SKILL.md index aad4744f68..f27492bf5f 100644 --- a/.claude/skills/searchable-events/SKILL.md +++ b/.claude/skills/searchable-events/SKILL.md @@ -45,10 +45,9 @@ Notables that surprise people: (`zapRequest?.content.orEmpty()`) — receipts are searchable by the zapper's comment. - **Kind 0 / 31990** index many profile fields space-joined (name, about, nip05, lud16, website, picture URL, …). -- **Kind 30063 is claimed twice** (`ReleaseArtifactSetEvent` in nip51Lists and the experimental - `SoftwareReleaseEvent`); `EventFactory` resolves 30063 to `ReleaseArtifactSetEvent`, so - `title()\ndescription()` is what actually gets indexed — `SoftwareReleaseEvent.indexableContent()` - is dead on the store path. +- **Kind 30063** (`ReleaseArtifactSetEvent`) serves both NIP-51 release artifact sets and NIP-82 + software releases: it indexes `title()\ndescription()`, plus the release notes in `content` only + for NIP-82 releases (NIP-51 `content` can be encrypted private items). - Poll kinds (1068, 6969) append each option label on its own line. ## MANDATORY maintenance when you touch this surface diff --git a/.claude/skills/searchable-events/references/searchable-kinds.md b/.claude/skills/searchable-events/references/searchable-kinds.md index 92688128ec..d9942a6530 100644 --- a/.claude/skills/searchable-events/references/searchable-kinds.md +++ b/.claude/skills/searchable-events/references/searchable-kinds.md @@ -5,7 +5,7 @@ expression. **Update this file in the same PR as any change to the searchable se `indexableContent()` body** (see SKILL.md). Verified against the code 2026-09-17. Counts: 137 concrete classes covering 140 kind values (`GitStatusEvent` spans 4 kinds; -kind 30063 has a collision — see the footnote). File paths are under +kind 30063 is shared by two NIPs — see the footnote). File paths are under `quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/`. Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. @@ -74,10 +74,10 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 12473 | BirdexEvent | experimental/birdstar | `(listOfNotNull(summary()) + speciesNames())` NL | | 15128 | RootSiteEvent | nip5aStaticWebsites | `listOfNotNull(title(), description())` NL | | 15129 | RootNappletEvent | nip5dNapplets | `listOfNotNull(title(), description())` NL | -| 30000 | FollowSetEvent | nip51Lists/peopleList | `listOfNotNull(titleOrName(), description())` NL | +| 30000 | FollowSetEvent | nip51Lists/followSet | `listOfNotNull(titleOrName(), description())` NL | | 30001 | OldBookmarkListEvent | nip51Lists/bookmarkList | `listOfNotNull(title())` NL | | 30002 | RelaySetEvent | nip51Lists/relaySets | `listOfNotNull(title(), description())` NL | -| 30003 | BookmarkSetEvent | nip51Lists/labeledBookmarkList | `listOfNotNull(titleOrName(), description())` NL | +| 30003 | BookmarkSetEvent | nip51Lists/bookmarkSet | `listOfNotNull(titleOrName(), description())` NL | | 30004 | ArticleCurationSetEvent | nip51Lists/articleCurationSet | `listOfNotNull(title(), description())` NL | | 30005 | VideoCurationSetEvent | nip51Lists/videoCurationSet | `listOfNotNull(title(), description())` NL | | 30006 | PictureCurationSetEvent | nip51Lists/pictureCurationSet | `listOfNotNull(title(), description())` NL | @@ -91,7 +91,7 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 30030 | EmojiPackEvent | nip30CustomEmoji/pack | `listOfNotNull(titleOrName(), description(), content)` NL | | 30054 | Podcasting20EpisodeEvent | nipXXPodcasting20/episode | `(listOfNotNull(title(), description(), content) + topics())` NL | | 30055 | Podcasting20TrailerEvent | nipXXPodcasting20/trailer | `listOfNotNull(title(), content)` NL | -| 30063 | ReleaseArtifactSetEvent † | nip51Lists/releaseArtifactSet | `listOfNotNull(title(), description())` NL | +| 30063 | ReleaseArtifactSetEvent † | nip51Lists/releaseArtifactSet | `listOfNotNull(title(), description(), content if NIP-82)` NL | | 30175 | PersonaEvent | buzz/apPersonas | `personaOrNull()?.let { listOfNotNull(it.displayName, it.systemPrompt).joinToString("\n") } ?: ""` | | 30176 | TeamEvent | buzz/teams | `teamOrNull()?.let { listOfNotNull(it.name, it.description, it.instructions).joinToString("\n") } ?: ""` | | 30177 | ManagedAgentEvent | buzz/managedAgents | `agentOrNull()?.let { listOfNotNull(it.name, it.systemPrompt).joinToString("\n") } ?: ""` | @@ -138,7 +138,7 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 38192 | Ps1SaveEvent | experimental/ps1saves | `listOfNotNull(summary(), saveTitle(), region(), filename())` NL | | 38383 | P2POrderEvent | nip69P2pOrderEvents | `(listOfNotNull(makerName(), currency()) + paymentMethods().orEmpty()).joinToString(" ")` (SP) | | 39000 | GroupMetadataEvent | nip29RelayGroups/metadata | `listOfNotNull(name(), about())` NL | -| 39089 | StarterPackEvent | nip51Lists/followList | `listOfNotNull(title(), description())` NL | +| 39089 | StarterPackEvent | nip51Lists/starterPack | `listOfNotNull(title(), description())` NL | | 39092 | MediaStarterPackEvent | nip51Lists/mediaStarterPack | `listOfNotNull(title(), description())` NL | | 39307 | TextTrackEvent | nip71Video/textTrack | `content` (the WebVTT cue text) | | 39701 | WebBookmarkEvent | nipB0WebBookmarks | `listOfNotNull(title(), description())` NL | @@ -150,10 +150,10 @@ Separator legend: **NL** = `joinToString("\n")`, **SP** = `joinToString(" ")`. | 45003 | ForumCommentEvent | buzz/forum | `content` | | 48106 | HuddleGuidelinesEvent | buzz/huddles | `content` | -† **Kind 30063 collision:** `experimental/nip82SoftwareApps/release/SoftwareReleaseEvent` also -declares `KIND = 30063` and implements `SearchableEvent` (`content`), but `EventFactory` maps -30063 to `ReleaseArtifactSetEvent`, so on every store path kind 30063 indexes -`title()\ndescription()`. If the factory mapping ever changes, this table changes with it. +† **Kind 30063 is shared** by NIP-51 release artifact sets and NIP-82 software releases, and +`ReleaseArtifactSetEvent` parses both. It indexes `title()` and `description()`, plus `content` +(the release notes) only when the event carries the NIP-82 `i` + `version` tags — a NIP-51 set +may hold encrypted private items in `content`, which must never be indexed. ## Abstract bases (no kind of their own) diff --git a/amethyst/plans/2026-07-01-auth-permission-architecture.md b/amethyst/plans/2026-07-01-auth-permission-architecture.md index f3d431047a..17dce367c7 100644 --- a/amethyst/plans/2026-07-01-auth-permission-architecture.md +++ b/amethyst/plans/2026-07-01-auth-permission-architecture.md @@ -68,7 +68,7 @@ The NIP-42 plumbing and a first-cut permission gate are already in place: | Settings screen (global policy + per-relay list) | `amethyst/.../ui/screen/loggedIn/relayauth/RelayAuthSettingsScreen.kt` | | Global policy setting, persisted local-only | `AccountSettings.defaultRelayAuthPolicy`, `LocalPreferences` key `DEFAULT_RELAY_AUTH_POLICY` | | Blocked-relay list (kind 10006) | `amethyst/.../model/nip51Lists/blockedRelays/BlockedRelayListState.kt` (`.flow`) | -| Follow checks | `Account.isFollowing(...)`, `Account.allFollows.flow.value.authors`, `FollowListsState.isUserInFollowSets(...)` | +| Follow checks | `Account.isFollowing(...)`, `Account.allFollows.flow.value.authors`, `StarterPacksState.isUserInFollowSets(...)` | | DM / NIP-65 relay lookups | `DmRelayListState`, `Nip65RelayListState` (+ per-user via `LocalCache`) | ## The gap @@ -180,7 +180,7 @@ class RelayAuthContext(val relayUrl: String, val purposes: List<AuthPurpose>) - `IF_IN_MY_LIST` → `ALLOW` if relay ∈ my relay lists, else fall through - `TRUSTED_FOLLOWS` *(new — see idea A below)* → `ALLOW` if relay ∈ my lists **or** any counterparty in `ctx.purposes` is followed (`Account.allFollows` - / `FollowListsState.isUserInFollowSets`) and the purpose permits it; else + / `StarterPacksState.isUserInFollowSets`) and the purpose permits it; else fall through. 4. **Fall-through**: `ASK` if the purpose is attributable (we can show a reason); otherwise `DENY` silently (don't prompt for anonymous stranger challenges). diff --git a/amethyst/plans/2026-07-07-nip29-armada-study.md b/amethyst/plans/2026-07-07-nip29-armada-study.md index 4d8e0aa3cf..7c430631de 100644 --- a/amethyst/plans/2026-07-07-nip29-armada-study.md +++ b/amethyst/plans/2026-07-07-nip29-armada-study.md @@ -392,11 +392,11 @@ can be a group event if it carries `h` and the relay accepts the kind." has: - `metadata/` — `GroupMetadataEvent` (kind **39000**), `GroupAdminsEvent` - (39001), `GroupMembersEvent` (39002), `SupportedRolesEvent` (39003). -- `moderation/` — `CreateGroupEvent` (9007), `EditMetadataEvent` (9002), - `PutUserEvent` (9000), `RemoveUserEvent` (9001), `DeleteEventEvent` (9005), - `DeleteGroupEvent` (9008), `CreateInviteEvent` (9009), plus tag helpers. -- `request/` — `JoinRequestEvent` (9021), `LeaveRequestEvent` (9022). + (39001), `GroupMembersEvent` (39002), `GroupRolesEvent` (39003). +- `moderation/` — `CreateGroupEvent` (9007), `GroupEditMetadataEvent` (9002), + `GroupPutUserEvent` (9000), `GroupRemoveUserEvent` (9001), `GroupDeleteEventEvent` (9005), + `DeleteGroupEvent` (9008), `GroupCreateInviteEvent` (9009), plus tag helpers. +- `request/` — `GroupJoinRequestEvent` (9021), `GroupLeaveRequestEvent` (9022). - `tags/` — `GroupIdTag` (the `h` tag), `CodeTag`, `GroupAdminTag`, `RoleTag`, and even a `PreviousTag`. @@ -427,7 +427,7 @@ NIP-04/17 DMs, NIP-28 public channels, and NIP-C7 ephemeral chats — all under ### 5.2 The main protocol gap There is **no kind-9 group chat message event** in `nip29RelayGroups/` -(`CreateInviteEvent` at 9009 is the highest kind present; nothing for kind 9). +(`GroupCreateInviteEvent` at 9009 is the highest kind present; nothing for kind 9). The 9xxx moderation, 39xxx metadata, and 9021/9022 request events exist, but the actual message carrier does not. This is the first thing to build: diff --git a/amethyst/plans/2026-07-13-chat-scroll-performance.md b/amethyst/plans/2026-07-13-chat-scroll-performance.md index 4b066c6858..dd7de42179 100644 --- a/amethyst/plans/2026-07-13-chat-scroll-performance.md +++ b/amethyst/plans/2026-07-13-chat-scroll-performance.md @@ -71,7 +71,7 @@ Feed-level: marker update (only the newest visible timestamp matters; the marker is monotonic). One coroutine per scroll session instead of one per row. 6. **Jumbo without a coroutine (#4)**: only launch the decrypt effect for - encrypted kinds (`PrivateDmEvent`, sealed rumors not yet in the decrypt + encrypted kinds (`EncryptedDmEvent`, sealed rumors not yet in the decrypt cache). Plaintext kinds (public chats, NIP-17 rumors already unwrapped — the vast majority) take the synchronous path only. 7. **Retire settled delivery ticks (#6)**: once a message is fully accepted (or diff --git a/amethyst/plans/2026-07-15-bitchat-geohash-interop.md b/amethyst/plans/2026-07-15-bitchat-geohash-interop.md index 2722de432e..09af8f3a48 100644 --- a/amethyst/plans/2026-07-15-bitchat-geohash-interop.md +++ b/amethyst/plans/2026-07-15-bitchat-geohash-interop.md @@ -55,7 +55,7 @@ Bitchat's Nostr side has two chat features. Amethyst is a pure-Nostr client 1. **Encrypted DMs (Phase 2).** Port the `bitchat1:` binary packet (`BitchatPacket` TLV + `NoisePayloadType`) into quartz, wrap/unwrap it in the - existing NIP-17 stack (`GiftWrapEvent`/`SealedRumorEvent`/`ChatMessageEvent`), + existing NIP-17 stack (`GiftWrapEvent`/`SealEvent`/`ChatMessageEvent`), handle geohash DMs (to a per-geohash pubkey) and delivery/read receipts. Add `amy geochat dm` for interop testing. 2. **Desktop UI.** The shared pieces (quartz events, `GeoRelayDirectory`) are diff --git a/amethyst/plans/2026-07-23-push-notification-redesign.md b/amethyst/plans/2026-07-23-push-notification-redesign.md index 2e0acac758..a2f8d535ee 100644 --- a/amethyst/plans/2026-07-23-push-notification-redesign.md +++ b/amethyst/plans/2026-07-23-push-notification-redesign.md @@ -178,10 +178,10 @@ This keeps the *policy* (who gets notified) exactly where it is and isolates the | Kind(s) | Category | Style | Accent / icon | Title → Body | Actions | | --- | --- | --- | --- | --- | --- | -| NIP-17 `ChatMessageEvent` (14), file (15), NIP-04 `PrivateDmEvent` (4), Marmot group | DIRECT_MESSAGE | `MessagingStyle` + Conversation shortcut + Bubble | blue-green / `chat` | sender → message | Reply, Mark-read | +| NIP-17 `ChatMessageEvent` (14), file (15), NIP-04 `EncryptedDmEvent` (4), Marmot group | DIRECT_MESSAGE | `MessagingStyle` + Conversation shortcut + Bubble | blue-green / `chat` | sender → message | Reply, Mark-read | | `TextNoteEvent`(1)/`CommentEvent`(1111)/`ChannelMessageEvent`(42) **reply to me** | REPLY | `MessagingStyle` (parent as prior message) | purple / `reply` | "X replied" → excerpt (+ quoted parent) | Reply, View thread, Mute thread | | Same kinds, **mention/quote only** | MENTION | plain (BigText) | purple / `alternate_email` | "X mentioned you" → excerpt | View, Mute thread | -| `LnZapEvent`(9735) | ZAP | **colorized** amount card (BigText) | gold / `bolt` | "⚡ 2,100 sats from X" → zap comment + zapped-note excerpt | Zap back, View | +| `ZapReceiptEvent`(9735) | ZAP | **colorized** amount card (BigText) | gold / `bolt` | "⚡ 2,100 sats from X" → zap comment + zapped-note excerpt | Zap back, View | | `NutzapEvent`(9321) *(new)* | ZAP | colorized amount card | gold / `bolt` (cashu tint) | "🥜 X nutzapped you 2,100 sats" → … | Zap back, View | | `OnchainZapEvent`(8333) *(new)* | ZAP | colorized amount card | gold / `bolt` | "⛓ X sent an onchain zap" → … | View | | `ReactionEvent`(7) | REACTION | aggregated `InboxStyle` | heart-red / `favorite` | "🤙 X & N others liked your post" → note excerpt | Like back, View | @@ -189,7 +189,7 @@ This keeps the *policy* (who gets notified) exactly where it is and isolates the | `PictureEvent`(20)/`VideoNormal`/`Short`/`Vertical`/`Horizontal` | MEDIA | `BigPictureStyle` | purple / `image` | "X shared a photo/video" → caption, image inline | View | | `PollEvent`/`ZapPollEvent` | MENTION | plain | purple / `ballot` | "X asked a question" → poll title | Vote, View | | `HighlightEvent`(9802) | ARTICLE | plain | purple / `format_quote` | "X highlighted your article" → highlighted text | View | -| `LongTextNoteEvent`(30023)/`WikiNoteEvent`(30818) | ARTICLE | plain | purple / `article` | "X mentioned you in an article" → title | View | +| `LongFormContentEvent`(30023)/`WikiArticleEvent`(30818) | ARTICLE | plain | purple / `article` | "X mentioned you in an article" → title | View | | `GitIssueEvent`/`GitPatchEvent`/`GitPullRequestEvent`/`…Update` | CODE | plain | slate / `merge` | "X opened an issue/PR" → subject | View | | `BadgeAwardEvent`(8) *(new)* | BADGE | `BigPictureStyle` (badge art) | gold / `award_star` | "You earned a badge" → badge name, image | View | | `LiveChessGameAcceptEvent`/`LiveChessMoveEvent` | CHESS | plain | brown / `chess` | "X accepted your challenge" / "your turn" | Open board | diff --git a/amethyst/plans/2026-07-24-nwc-bolt12-pay.md b/amethyst/plans/2026-07-24-nwc-bolt12-pay.md index e42b00a729..4f4e0ba89a 100644 --- a/amethyst/plans/2026-07-24-nwc-bolt12-pay.md +++ b/amethyst/plans/2026-07-24-nwc-bolt12-pay.md @@ -59,7 +59,7 @@ and dispatches the decrypted `Response`, so a new method needs no changes there: decrypt-on-arrival. - `NwcPaymentTracker` (`commons/…/service/nwc/`) — request↔response match with the author-spoof gate. -- `LocalCache.consume(LnZapPaymentResponseEvent)` — routes 23195 back to the callback. +- `LocalCache.consume(NwcResponseEvent)` — routes 23195 back to the callback. - Wallet storage: `AccountSettings.nwcWallets` + `defaultPaymentSourceId`; `PaymentSourceResolver`. - Pay rail entry: `ZapPaymentHandler.zap()` → `payViaNWC()` (the `PaymentSource.Nwc` diff --git a/amethyst/plans/2026-07-31-shortpost-notify-list-picker.md b/amethyst/plans/2026-07-31-shortpost-notify-list-picker.md index e7a382b5d3..0e8cfe0552 100644 --- a/amethyst/plans/2026-07-31-shortpost-notify-list-picker.md +++ b/amethyst/plans/2026-07-31-shortpost-notify-list-picker.md @@ -41,9 +41,9 @@ storm. |---|---| | The chip row + "Add" chip | `ui/note/creators/notify/Notifying.kt` (`Notifying`, `NotifyUserChip`, `AddUserChip`) | | Audience state | `ShortNotePostViewModel.pTags: List<User>?`, `mutedNotifies: Set<HexKey>`, `activeNotifies()`, `addToReplyList(user)` | -| My NIP-51 people lists (kind 30000, public **and** decrypted private members) | `account.peopleLists.uiListFlow: StateFlow<List<PeopleList>>` (`model/nip51Lists/peopleList/PeopleListsState.kt`) | -| My follow packs (kind 39089, public members) | `account.followLists.uiListFlow` (`model/nip51Lists/peopleList/FollowListsState.kt`) | -| `PeopleList` UI model (`title`, `image`, `publicMembers`, `privateMembers` as `Set<User>`) | `model/nip51Lists/peopleList/PeopleList.kt` | +| My NIP-51 people lists (kind 30000, public **and** decrypted private members) | `account.peopleLists.uiListFlow: StateFlow<List<PeopleList>>` (`model/nip51Lists/followSets/FollowSetsState.kt`) | +| My follow packs (kind 39089, public members) | `account.followLists.uiListFlow` (`model/nip51Lists/followSets/StarterPacksState.kt`) | +| `PeopleList` UI model (`title`, `image`, `publicMembers`, `privateMembers` as `Set<User>`) | `model/nip51Lists/followSets/PeopleList.kt` | | Two-column list catalog rendering | `ui/screen/loggedIn/lists/memberEdit/FollowListAndPackAndUserView.kt` — same "Follow sets" + "Discover follows" sectioning | | Multi-select member review (count header, select-all checkbox, per-user row, confirm button) | `ui/screen/loggedIn/newUser/ImportFollowListPickFollowsScreen.kt` (`PreviewList` / `FollowEntryRow`) | | Bottom-sheet picker shell w/ search field | `ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupParentPicker.kt` | diff --git a/amethyst/plans/2026-09-10-dvm-heartbeat-liveness-plan.md b/amethyst/plans/2026-09-10-dvm-heartbeat-liveness-plan.md index dfe5996c2d..d56b7fd2e5 100644 --- a/amethyst/plans/2026-09-10-dvm-heartbeat-liveness-plan.md +++ b/amethyst/plans/2026-09-10-dvm-heartbeat-liveness-plan.md @@ -281,7 +281,7 @@ In `quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt` ```kotlin import com.vitorpamplona.quartz.nip90Dvms.dvmHeartbeat.DvmHeartbeatEvent ``` -2. Add a dispatch branch inside the `when (kind)` near the other NIP-90 kinds (next to line 736 `NIP90StatusEvent.KIND -> ...`): +2. Add a dispatch branch inside the `when (kind)` near the other NIP-90 kinds (next to line 736 `DvmStatusEvent.KIND -> ...`): ```kotlin DvmHeartbeatEvent.KIND -> DvmHeartbeatEvent(id, pubKey, createdAt, tags, content, sig) ``` @@ -304,7 +304,7 @@ private val knownDTagReaders = - [ ] **Step 6: Update the design doc §2** -In `amethyst/plans/2026-09-10-dvm-heartbeat-liveness.md`, replace the §2 bullet that says the class "extends `BaseReplaceableEvent`" / "Overrides `dTag()`" with the as-built wording: extends `BaseAddressableEvent` (the codebase convention for 10xxx events with real `d` tags, e.g. `FollowListEvent`), so `dTag()`/`address()`/`addressTag()` come from the base; note `MAX_AGE_SECONDS`, `isFreshAt`, and the `knownDTagReaders` entry live in quartz too (commons imports them). +In `amethyst/plans/2026-09-10-dvm-heartbeat-liveness.md`, replace the §2 bullet that says the class "extends `BaseReplaceableEvent`" / "Overrides `dTag()`" with the as-built wording: extends `BaseAddressableEvent` (the codebase convention for 10xxx events with real `d` tags, e.g. `StarterPackEvent`), so `dTag()`/`address()`/`addressTag()` come from the base; note `MAX_AGE_SECONDS`, `isFreshAt`, and the `knownDTagReaders` entry live in quartz too (commons imports them). - [ ] **Step 7: Run the tests to verify they pass** diff --git a/amethyst/plans/2026-09-10-dvm-heartbeat-liveness.md b/amethyst/plans/2026-09-10-dvm-heartbeat-liveness.md index b67a5cd4bc..3e76ed1eb6 100644 --- a/amethyst/plans/2026-09-10-dvm-heartbeat-liveness.md +++ b/amethyst/plans/2026-09-10-dvm-heartbeat-liveness.md @@ -45,7 +45,7 @@ feeds and the detail surface show an offline state instead. New `quartz/.../nip90Dvms/dvmHeartbeat/DvmHeartbeatEvent.kt`: - `class DvmHeartbeatEvent(...) : BaseAddressableEvent(...)`, `KIND = 11998` — the codebase - convention for 10xxx events with real `d` tags (e.g. `FollowListEvent`), so `dTag()` / + convention for 10xxx events with real `d` tags (e.g. `StarterPackEvent`), so `dTag()` / `address()` / `addressTag()` come from the base. The cache address is `Address(11998, dvmPubkey, dTag)`, the exact mirror of the announcement's `Address(31990, dvmPubkey, dTag)`. diff --git a/amethyst/plans/2026-09-17-nip-cc-geocaching.md b/amethyst/plans/2026-09-17-nip-cc-geocaching.md index 837d0de01c..ea2a24df5a 100644 --- a/amethyst/plans/2026-09-17-nip-cc-geocaching.md +++ b/amethyst/plans/2026-09-17-nip-cc-geocaching.md @@ -83,7 +83,7 @@ The listing event is mostly existing tags wearing a new kind number: | `r` | `nip51Lists/tags/RelayTag` (`"r"`) | | `a` | `nip01Core/tags/aTag/ATag` (curation list + found log) | | `title`, `description` (37517) | `nip51Lists/tags/TitleTag`, `.../DescriptionTag` | -| embedded 7517 | `Event.fromJson(...)` (same trick `LnZapEvent.zapRequest()` uses) | +| embedded 7517 | `Event.fromJson(...)` (same trick `ZapReceiptEvent.zapRequest()` uses) | | signature check | `Event.verifySignature()` in `nip01Core/crypto/EventExt.kt` | | kind 1111 logs | `nip22Comments/CommentEvent` **as-is** — it already models `A/K/P` + `a/k/p` addressable root+parent (`rootAddress()`, `replyAddress()`, `hasRootAddress()`). Only the `t` log-type vocabulary is new. | | required-tag gate | `containsAllTagNamesWithValues(REQUIRED_FIELDS)`, as `ClassifiedsEvent.isWellFormed()` does | diff --git a/amethyst/plans/archive/2026-05-14-onchain-zaps.md b/amethyst/plans/archive/2026-05-14-onchain-zaps.md index 4e06e084b3..9a449c7120 100644 --- a/amethyst/plans/archive/2026-05-14-onchain-zaps.md +++ b/amethyst/plans/archive/2026-05-14-onchain-zaps.md @@ -94,7 +94,7 @@ Section labels: "Bitcoin" and "Lightning". ## Subscription edits — extend existing kind lists No new assemblers. Add `OnchainZapEvent.KIND` (8333) to the existing -`LnZapEvent.KIND` (9735) sites: +`ZapReceiptEvent.KIND` (9735) sites: | File | Edit | |---|---| @@ -109,7 +109,7 @@ No new assemblers. Add `OnchainZapEvent.KIND` (8333) to the existing ## Display path — fold into `Note.zapsAmount` -Today: `LocalCache.consume(LnZapEvent)` → `Note.addZap()` → `Note.updateZapTotal()` +Today: `LocalCache.consume(ZapReceiptEvent)` → `Note.addZap()` → `Note.updateZapTotal()` sums lightning amounts into `Note.zapsAmount`, which `ReactionsRow` / `ObserveZapAmountText` / `SlidingAnimationAmount` render. We add onchain zap sats to the same `Note.zapsAmount` — no UI changes required. @@ -118,7 +118,7 @@ sats to the same `Note.zapsAmount` — no UI changes required. - Add `var onchainZaps = mapOf<...>()` (separate map from `zaps`). - Extend `updateZapTotal()` to add **verified** onchain sats. Unverified or pending tx amounts are NOT counted. -- `amethyst/.../model/LocalCache.kt` (after the `consume(LnZapEvent)` block ~line 1667) +- `amethyst/.../model/LocalCache.kt` (after the `consume(ZapReceiptEvent)` block ~line 1667) - New `consume(event: OnchainZapEvent)` handler. - Reject self-zap. - Enqueue verification against the configured `OnchainBackend`. diff --git a/amethyst/plans/archive/2026-06-22-napplet-nsite-security.md b/amethyst/plans/archive/2026-06-22-napplet-nsite-security.md index d9a14ff27d..d6236690cf 100644 --- a/amethyst/plans/archive/2026-06-22-napplet-nsite-security.md +++ b/amethyst/plans/archive/2026-06-22-napplet-nsite-security.md @@ -34,7 +34,7 @@ and what remains as future work. 2. **Private mute/block leak via `identity.getMutes`/`getBlocked`.** These read `muteList.flow` / `blockPeopleList.flow`, which contain **decrypted private** entries. Now they read the events' **public** tags only (`MuteListEvent.publicMutes()`, - `PeopleListEvent.publicUsersIdSet()`). + `FollowSetEvent.publicUsersIdSet()`). 3. **Silent "allow-always" actions + UI-redress.** Added persistent **trusted chrome** (a sandbox bar the applet can't draw over: shield + name + tap-to-see "what it can diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt index 7f1b0da472..7a55e9b22c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/LocalPreferences.kt @@ -62,7 +62,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent @@ -599,7 +599,7 @@ object LocalPreferences { putOrRemove(PrefKeys.LATEST_NIP65_RELAY_LIST, settings.backupNIP65RelayList) putOrRemove(PrefKeys.LATEST_SEARCH_RELAY_LIST, settings.backupSearchRelayList) putOrRemove(PrefKeys.LATEST_INDEX_RELAY_LIST, settings.backupIndexRelayList) - putOrRemove(PrefKeys.LATEST_RELAY_FEEDS_LIST, settings.backupRelayFeedsList) + putOrRemove(PrefKeys.LATEST_RELAY_FEEDS_LIST, settings.backupFavoriteRelayList) putOrRemove(PrefKeys.LATEST_BLOCKED_RELAY_LIST, settings.backupBlockedRelayList) putOrRemove(PrefKeys.LATEST_TRUSTED_RELAY_LIST, settings.backupTrustedRelayList) @@ -613,9 +613,9 @@ object LocalPreferences { putOrRemove(PrefKeys.LATEST_PRIVATE_HOME_RELAY_LIST, settings.backupPrivateHomeRelayList) putOrRemove(PrefKeys.LATEST_APP_SPECIFIC_DATA, settings.backupAppSpecificData) - putOrRemove(PrefKeys.LATEST_CHANNEL_LIST, settings.backupChannelList) + putOrRemove(PrefKeys.LATEST_CHANNEL_LIST, settings.backupPublicChatList) putOrRemove(PrefKeys.LATEST_COMMUNITY_LIST, settings.backupCommunityList) - putOrRemove(PrefKeys.LATEST_HASHTAG_LIST, settings.backupHashtagList) + putOrRemove(PrefKeys.LATEST_HASHTAG_LIST, settings.backupInterestList) putOrRemove(PrefKeys.LATEST_GEOHASH_LIST, settings.backupGeohashList) putOrRemove(PrefKeys.LATEST_EPHEMERAL_LIST, settings.backupEphemeralChatList) putOrRemove(PrefKeys.LATEST_RELAY_GROUP_LIST, settings.backupRelayGroupList) @@ -827,15 +827,15 @@ object LocalPreferences { val latestNip65RelayListStr = getString(PrefKeys.LATEST_NIP65_RELAY_LIST, null) val latestSearchRelayListStr = getString(PrefKeys.LATEST_SEARCH_RELAY_LIST, null) val latestIndexRelayListStr = getString(PrefKeys.LATEST_INDEX_RELAY_LIST, null) - val latestRelayFeedsListStr = getString(PrefKeys.LATEST_RELAY_FEEDS_LIST, null) + val latestFavoriteRelayListStr = getString(PrefKeys.LATEST_RELAY_FEEDS_LIST, null) val latestBlockedRelayListStr = getString(PrefKeys.LATEST_BLOCKED_RELAY_LIST, null) val latestTrustedRelayListStr = getString(PrefKeys.LATEST_TRUSTED_RELAY_LIST, null) val latestMuteListStr = getString(PrefKeys.LATEST_MUTE_LIST, null) val latestPrivateHomeRelayListStr = getString(PrefKeys.LATEST_PRIVATE_HOME_RELAY_LIST, null) val latestAppSpecificDataStr = getString(PrefKeys.LATEST_APP_SPECIFIC_DATA, null) - val latestChannelListStr = getString(PrefKeys.LATEST_CHANNEL_LIST, null) + val latestPublicChatListStr = getString(PrefKeys.LATEST_CHANNEL_LIST, null) val latestCommunityListStr = getString(PrefKeys.LATEST_COMMUNITY_LIST, null) - val latestHashtagListStr = getString(PrefKeys.LATEST_HASHTAG_LIST, null) + val latestInterestListStr = getString(PrefKeys.LATEST_HASHTAG_LIST, null) val latestGeohashListStr = getString(PrefKeys.LATEST_GEOHASH_LIST, null) val latestEphemeralListStr = getString(PrefKeys.LATEST_EPHEMERAL_LIST, null) val latestRelayGroupListStr = getString(PrefKeys.LATEST_RELAY_GROUP_LIST, null) @@ -891,15 +891,15 @@ object LocalPreferences { val latestNip65RelayList = async { parseEventOrNull<AdvertisedRelayListEvent>(latestNip65RelayListStr) } val latestSearchRelayList = async { parseEventOrNull<SearchRelayListEvent>(latestSearchRelayListStr) } val latestIndexRelayList = async { parseEventOrNull<IndexerRelayListEvent>(latestIndexRelayListStr) } - val latestRelayFeedsList = async { parseEventOrNull<FavoriteRelayListEvent>(latestRelayFeedsListStr) } + val latestFavoriteRelayList = async { parseEventOrNull<FavoriteRelayListEvent>(latestFavoriteRelayListStr) } val latestBlockedRelayList = async { parseEventOrNull<BlockedRelayListEvent>(latestBlockedRelayListStr) } val latestTrustedRelayList = async { parseEventOrNull<TrustedRelayListEvent>(latestTrustedRelayListStr) } val latestMuteList = async { parseEventOrNull<MuteListEvent>(latestMuteListStr) } val latestPrivateHomeRelayList = async { parseEventOrNull<PrivateOutboxRelayListEvent>(latestPrivateHomeRelayListStr) } val latestAppSpecificData = async { parseEventOrNull<AppSpecificDataEvent>(latestAppSpecificDataStr) } - val latestChannelList = async { parseEventOrNull<PublicChatListEvent>(latestChannelListStr) } + val latestPublicChatList = async { parseEventOrNull<PublicChatListEvent>(latestPublicChatListStr) } val latestCommunityList = async { parseEventOrNull<CommunityListEvent>(latestCommunityListStr) } - val latestHashtagList = async { parseEventOrNull<InterestListEvent>(latestHashtagListStr) } + val latestInterestList = async { parseEventOrNull<InterestListEvent>(latestInterestListStr) } val latestGeohashList = async { parseEventOrNull<GeohashListEvent>(latestGeohashListStr) } val latestEphemeralList = async { parseEventOrNull<EphemeralChatListEvent>(latestEphemeralListStr) } val latestRelayGroupList = async { parseEventOrNull<SimpleGroupListEvent>(latestRelayGroupListStr) } @@ -947,15 +947,15 @@ object LocalPreferences { val latestNip65RelayListResolved = latestNip65RelayList.await() val latestSearchRelayListResolved = latestSearchRelayList.await() val latestIndexRelayListResolved = latestIndexRelayList.await() - val latestRelayFeedsListResolved = latestRelayFeedsList.await() + val latestFavoriteRelayListResolved = latestFavoriteRelayList.await() val latestBlockedRelayListResolved = latestBlockedRelayList.await() val latestTrustedRelayListResolved = latestTrustedRelayList.await() val latestMuteListResolved = latestMuteList.await() val latestPrivateHomeRelayListResolved = latestPrivateHomeRelayList.await() val latestAppSpecificDataResolved = latestAppSpecificData.await() - val latestChannelListResolved = latestChannelList.await() + val latestPublicChatListResolved = latestPublicChatList.await() val latestCommunityListResolved = latestCommunityList.await() - val latestHashtagListResolved = latestHashtagList.await() + val latestInterestListResolved = latestInterestList.await() val latestGeohashListResolved = latestGeohashList.await() val latestEphemeralListResolved = latestEphemeralList.await() val latestRelayGroupListResolved = latestRelayGroupList.await() @@ -1049,15 +1049,15 @@ object LocalPreferences { backupDMRelayList = latestDmRelayListResolved, backupSearchRelayList = latestSearchRelayListResolved, backupIndexRelayList = latestIndexRelayListResolved, - backupRelayFeedsList = latestRelayFeedsListResolved, + backupFavoriteRelayList = latestFavoriteRelayListResolved, backupBlockedRelayList = latestBlockedRelayListResolved, backupTrustedRelayList = latestTrustedRelayListResolved, backupPrivateHomeRelayList = latestPrivateHomeRelayListResolved, backupMuteList = latestMuteListResolved, backupAppSpecificData = latestAppSpecificDataResolved, - backupChannelList = latestChannelListResolved, + backupPublicChatList = latestPublicChatListResolved, backupCommunityList = latestCommunityListResolved, - backupHashtagList = latestHashtagListResolved, + backupInterestList = latestInterestListResolved, backupGeohashList = latestGeohashListResolved, backupEphemeralChatList = latestEphemeralListResolved, backupRelayGroupList = latestRelayGroupListResolved, 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 438be42d4f..b69ea5f2b1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -75,21 +75,21 @@ import com.vitorpamplona.amethyst.commons.model.nip51Lists.blockPeopleList.Block import com.vitorpamplona.amethyst.commons.model.nip51Lists.blockedRelays.BlockedRelayListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.broadcastRelays.BroadcastRelayListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.favoriteAlgoFeedsLists.FavoriteAlgoFeedsListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.favoriteRelays.FavoriteRelayListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.FollowSetDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.geohashLists.GeohashListDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.hashtagLists.HashtagListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.indexerRelays.IndexerRelayListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.interestLists.InterestListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.muteList.MuteListDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.proxyRelays.ProxyRelayListDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.relayFeeds.RelayFeedsListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.searchRelays.SearchRelayListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.trustedRelays.TrustedRelayListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip56Reports.ReportAction import com.vitorpamplona.amethyst.commons.model.nip62Vanish.VanishRequestsState import com.vitorpamplona.amethyst.commons.model.nip72Communities.CommunityListDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip85TrustedAssertions.ContactCardDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip85TrustedAssertions.ContactCardsState import com.vitorpamplona.amethyst.commons.model.nip85TrustedAssertions.TrustProviderListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip85TrustedAssertions.UserAssertionDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip85TrustedAssertions.UserAssertionsState import com.vitorpamplona.amethyst.commons.model.nipBCOnchainZaps.OnchainWalletState import com.vitorpamplona.amethyst.commons.model.privateChatLastReadRoute import com.vitorpamplona.amethyst.commons.model.privateChats.hasEncryptedContent @@ -145,18 +145,18 @@ import com.vitorpamplona.amethyst.model.nip46Signer.Nip46SignerState import com.vitorpamplona.amethyst.model.nip47WalletConnect.NwcSignerState import com.vitorpamplona.amethyst.model.nip51Lists.HiddenUsersState import com.vitorpamplona.amethyst.model.nip51Lists.blockedRelays.BlockedRelayListState +import com.vitorpamplona.amethyst.model.nip51Lists.bookmarkSets.BookmarkSetsState import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListState import com.vitorpamplona.amethyst.model.nip51Lists.favoriteAlgoFeedsLists.FavoriteAlgoFeedsListState +import com.vitorpamplona.amethyst.model.nip51Lists.favoriteRelays.FavoriteRelayListState +import com.vitorpamplona.amethyst.model.nip51Lists.followSets.FollowSetsState +import com.vitorpamplona.amethyst.model.nip51Lists.followSets.StarterPacksState import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState -import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListState import com.vitorpamplona.amethyst.model.nip51Lists.indexerRelays.IndexerRelayListState +import com.vitorpamplona.amethyst.model.nip51Lists.interestLists.InterestListState import com.vitorpamplona.amethyst.model.nip51Lists.interestSets.InterestSetsState -import com.vitorpamplona.amethyst.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkListsState import com.vitorpamplona.amethyst.model.nip51Lists.muteList.MuteListState -import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.FollowListsState -import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.PeopleListsState import com.vitorpamplona.amethyst.model.nip51Lists.proxyRelays.ProxyRelayListState -import com.vitorpamplona.amethyst.model.nip51Lists.relayFeeds.RelayFeedListState import com.vitorpamplona.amethyst.model.nip51Lists.searchRelays.SearchRelayListState import com.vitorpamplona.amethyst.model.nip51Lists.trustedRelays.TrustedRelayListState import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState @@ -281,8 +281,8 @@ import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip56Reports.ReportType -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent import com.vitorpamplona.quartz.nip57Zaps.PrivateZapCache +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup @@ -639,8 +639,8 @@ class Account( val indexerRelayListDecryptionCache = IndexerRelayListDecryptionCache(signer) val indexerRelayList = IndexerRelayListState(signer, cache, indexerRelayListDecryptionCache, scope, settings) - val relayFeedsListDecryptionCache = RelayFeedsListDecryptionCache(signer) - val relayFeedsList = RelayFeedListState(signer, cache, relayFeedsListDecryptionCache, scope, settings) + val favoriteRelayListDecryptionCache = FavoriteRelayListDecryptionCache(signer) + val favoriteRelayList = FavoriteRelayListState(signer, cache, favoriteRelayListDecryptionCache, scope, settings) val blockedRelayListDecryptionCache = BlockedRelayListDecryptionCache(signer) val blockedRelayList = BlockedRelayListState(signer, cache, blockedRelayListDecryptionCache, scope, settings) @@ -758,8 +758,8 @@ class Account( val communityListDecryptionCache = CommunityListDecryptionCache(signer) val communityList = CommunityListState(signer, cache, communityListDecryptionCache, scope, settings) - val hashtagListDecryptionCache = HashtagListDecryptionCache(signer) - val hashtagList = HashtagListState(signer, cache, hashtagListDecryptionCache, scope, settings) + val interestListDecryptionCache = InterestListDecryptionCache(signer) + val interestList = InterestListState(signer, cache, interestListDecryptionCache, scope, settings) val favoriteAlgoFeedsListDecryptionCache = FavoriteAlgoFeedsListDecryptionCache(signer) val favoriteAlgoFeedsList = FavoriteAlgoFeedsListState(signer, cache, favoriteAlgoFeedsListDecryptionCache, scope, settings) @@ -777,14 +777,14 @@ class Account( val trustProviderListDecryptionCache = TrustProviderListDecryptionCache(signer) val trustProviderList = TrustProviderListState(signer, cache, trustProviderListDecryptionCache, scope, settings) - val peopleListDecryptionCache = PeopleListDecryptionCache(signer) - val blockPeopleList = BlockPeopleListState(signer, cache, peopleListDecryptionCache, scope) - val peopleLists = PeopleListsState(signer, cache, peopleListDecryptionCache, scope) - val followLists = FollowListsState(signer, cache, scope) + val followSetDecryptionCache = FollowSetDecryptionCache(signer) + val blockPeopleList = BlockPeopleListState(signer, cache, followSetDecryptionCache, scope) + val followSets = FollowSetsState(signer, cache, followSetDecryptionCache, scope) + val starterPacks = StarterPacksState(signer, cache, scope) val hiddenUsers = HiddenUsersState(muteList.flow, blockPeopleList.flow, scope, settings) - val labeledBookmarkLists = LabeledBookmarkListsState(signer, cache, scope) + val bookmarkSets = BookmarkSetsState(signer, cache, scope) val interestSets = InterestSetsState(signer, cache, scope) val appRecommendations = AppRecommendationsState(signer, cache, scope) val oldBookmarkState = OldBookmarkListState(signer, cache, scope) @@ -795,8 +795,8 @@ class Account( val ownedEmojiPacks = OwnedEmojiPacksState(signer, cache, scope) // needs `emoji` above: nickname edits resolve :shortcodes: against the account's packs - val contactCardDecryptionCache = ContactCardDecryptionCache(signer) - val contactCards = ContactCardsState(signer, cache, contactCardDecryptionCache, emoji) + val userAssertionDecryptionCache = UserAssertionDecryptionCache(signer) + val userAssertions = UserAssertionsState(signer, cache, userAssertionDecryptionCache, emoji) val vanish = VanishRequestsState(signer, cache, client, scope) @@ -893,7 +893,7 @@ class Account( val followsPerRelay = FollowsPerOutboxRelay(kind3FollowList, blockedRelayList, proxyRelayList, cache, scope).flow // Merges all follow lists to create a single All Follows feed. - val allFollows = MergedFollowListsState(kind3FollowList, peopleLists, followLists, hashtagList, geohashList, communityList, scope) + val allFollows = MergedFollowListsState(kind3FollowList, followSets, starterPacks, interestList, geohashList, communityList, scope) val privateDMDecryptionCache = PrivateDMCache(signer) override val privateZapsDecryptionCache = PrivateZapCache(signer) @@ -1030,10 +1030,10 @@ class Account( val feedDecryptionCaches = FeedDecryptionCaches( - peopleListCache = peopleListDecryptionCache, + peopleListCache = followSetDecryptionCache, muteListCache = muteListDecryptionCache, communityListCache = communityListDecryptionCache, - hashtagCache = hashtagListDecryptionCache, + hashtagCache = interestListDecryptionCache, geohashCache = geohashListDecryptionCache, ) @@ -1047,7 +1047,7 @@ class Account( blockedRelays = blockedRelayList.flow, proxyRelays = proxyRelayList.flow, mineRelays = mineRelays.flow, - relayFeeds = relayFeedsList.flow, + relayFeeds = favoriteRelayList.flow, caches = feedDecryptionCaches, signer = signer, scope = scope, @@ -2126,9 +2126,9 @@ class Account( suspend fun unfollow(community: AddressableNote) = sendMyPublicAndPrivateOutbox(communityList.unfollow(community)) - suspend fun followHashtag(tag: String) = sendMyPublicAndPrivateOutbox(hashtagList.follow(tag)) + suspend fun followHashtag(tag: String) = sendMyPublicAndPrivateOutbox(interestList.follow(tag)) - suspend fun unfollowHashtag(tag: String) = sendMyPublicAndPrivateOutbox(hashtagList.unfollow(tag)) + suspend fun unfollowHashtag(tag: String) = sendMyPublicAndPrivateOutbox(interestList.unfollow(tag)) suspend fun followFavoriteAlgoFeed(dvm: AddressBookmark) = sendMyPublicAndPrivateOutbox(favoriteAlgoFeedsList.follow(dvm)) @@ -3440,11 +3440,11 @@ class Account( * encrypted in the content. `null` clears a field. Goes out through the * account's extended outbox relays. */ - suspend fun updateContactCardPetName( + suspend fun updateUserAssertionPetName( pubkeyHex: HexKey, petName: String?, summary: String?, - ) = sendMyPublicAndPrivateOutbox(contactCards.updatePetNameAndSummary(pubkeyHex, petName, summary)) + ) = sendMyPublicAndPrivateOutbox(userAssertions.updatePetNameAndSummary(pubkeyHex, petName, summary)) suspend fun showUser(pubkeyHex: HexKey) { sendMyPublicAndPrivateOutbox(blockPeopleList.showUser(pubkeyHex)) @@ -3550,7 +3550,7 @@ class Account( } } - suspend fun decryptZapOrNull(event: ZapRequestEvent): LnZapPrivateEvent? = if (event.isPrivateZap() && isWriteable()) privateZapsDecryptionCache.decryptPrivateZap(event) else null + suspend fun decryptZapOrNull(event: ZapRequestEvent): PrivateZapEvent? = if (event.isPrivateZap() && isWriteable()) privateZapsDecryptionCache.decryptPrivateZap(event) else null fun isAllHidden(users: Set<HexKey>): Boolean = users.all { isHidden(it) } @@ -3747,11 +3747,11 @@ class Account( suspend fun saveTrustedRelayList(trustedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(trustedRelayList.saveRelayList(trustedRelays)) - suspend fun saveRelayFeedsList(trustedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(relayFeedsList.saveRelayList(trustedRelays)) + suspend fun saveFavoriteRelayList(trustedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(favoriteRelayList.saveRelayList(trustedRelays)) - suspend fun followRelayFeed(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(relayFeedsList.addRelay(url)) + suspend fun followRelayFeed(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(favoriteRelayList.addRelay(url)) - suspend fun unfollowRelayFeed(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(relayFeedsList.removeRelay(url)) + suspend fun unfollowRelayFeed(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(favoriteRelayList.removeRelay(url)) suspend fun saveBlockedRelayList(blockedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(blockedRelayList.saveRelayList(blockedRelays)) @@ -3783,7 +3783,7 @@ class Account( proxyRelayList.getProxyRelayList(), broadcastRelayList.getBroadcastRelayList(), indexerRelayList.getIndexerRelayList(), - relayFeedsList.getRelayFeedsList(), + favoriteRelayList.getFavoriteRelayList(), blockedRelayList.getBlockedRelayList(), muteList.getMuteList(), bookmarkState.getBookmarkList(), @@ -4056,9 +4056,9 @@ class Account( logTime("Account ${userProfile().toBestDisplayName()} newEventBundle Update with ${newNotes.size} new notes") { upgradeAttestations() newNotesPreProcessor.runNew(newNotes) - peopleLists.newNotes(newNotes) - followLists.newNotes(newNotes) - labeledBookmarkLists.newNotes(newNotes) + followSets.newNotes(newNotes) + starterPacks.newNotes(newNotes) + bookmarkSets.newNotes(newNotes) interestSets.newNotes(newNotes) ownedEmojiPacks.newNotes(newNotes) } @@ -4069,9 +4069,9 @@ class Account( cache.live.deletedEventBundles.collect { deletedNotes -> logTime("Account ${userProfile().toBestDisplayName()} deletedEventBundle Update with ${deletedNotes.size} new notes") { newNotesPreProcessor.runDeleted(deletedNotes) - peopleLists.deletedNotes(deletedNotes) - followLists.deletedNotes(deletedNotes) - labeledBookmarkLists.deletedNotes(deletedNotes) + followSets.deletedNotes(deletedNotes) + starterPacks.deletedNotes(deletedNotes) + bookmarkSets.deletedNotes(deletedNotes) interestSets.deletedNotes(deletedNotes) ownedEmojiPacks.deletedNotes(deletedNotes) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt index b70197390c..b6e63d83e4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt @@ -68,7 +68,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.Nip47WalletConnect import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent @@ -208,15 +208,15 @@ class AccountSettings( var backupNIP65RelayList: AdvertisedRelayListEvent? = null, var backupSearchRelayList: SearchRelayListEvent? = null, var backupIndexRelayList: IndexerRelayListEvent? = null, - var backupRelayFeedsList: FavoriteRelayListEvent? = null, + var backupFavoriteRelayList: FavoriteRelayListEvent? = null, var backupBlockedRelayList: BlockedRelayListEvent? = null, var backupTrustedRelayList: TrustedRelayListEvent? = null, var backupMuteList: MuteListEvent? = null, var backupPrivateHomeRelayList: PrivateOutboxRelayListEvent? = null, var backupAppSpecificData: AppSpecificDataEvent? = null, - var backupChannelList: PublicChatListEvent? = null, + var backupPublicChatList: PublicChatListEvent? = null, var backupCommunityList: CommunityListEvent? = null, - var backupHashtagList: InterestListEvent? = null, + var backupInterestList: InterestListEvent? = null, var backupFavoriteAlgoFeedsList: FavoriteAlgoFeedsListEvent? = null, var backupGeohashList: GeohashListEvent? = null, var backupEphemeralChatList: EphemeralChatListEvent? = null, @@ -1084,13 +1084,13 @@ class AccountSettings( is Bolt12OfferListEvent -> updateBolt12Offers(incoming) is SearchRelayListEvent -> updateSearchRelayList(incoming) is IndexerRelayListEvent -> updateIndexRelayList(incoming) - is FavoriteRelayListEvent -> updateRelayFeedList(incoming) + is FavoriteRelayListEvent -> updateFavoriteRelayList(incoming) is BlockedRelayListEvent -> updateBlockedRelayList(incoming) is TrustedRelayListEvent -> updateTrustedRelayList(incoming) is PrivateOutboxRelayListEvent -> updatePrivateHomeRelayList(incoming) - is PublicChatListEvent -> updateChannelListTo(incoming) + is PublicChatListEvent -> updatePublicChatListTo(incoming) is GeohashListEvent -> updateGeohashListTo(incoming) - is InterestListEvent -> updateHashtagListTo(incoming) + is InterestListEvent -> updateInterestListTo(incoming) is FavoriteAlgoFeedsListEvent -> updateFavoriteAlgoFeedsListTo(incoming) is CommunityListEvent -> updateCommunityListTo(incoming) is EphemeralChatListEvent -> updateEphemeralChatListTo(incoming) @@ -1284,11 +1284,11 @@ class AccountSettings( } } - fun updateRelayFeedList(newRelayFeedList: FavoriteRelayListEvent?) { - if (newRelayFeedList == null) return + fun updateFavoriteRelayList(newFavoriteRelayList: FavoriteRelayListEvent?) { + if (newFavoriteRelayList == null) return - if (backupGuard.accept(backupRelayFeedsList, newRelayFeedList, isEmpty = newRelayFeedList.tags.isEmpty()) { updateRelayFeedList(newRelayFeedList) }) { - backupRelayFeedsList = newRelayFeedList + if (backupGuard.accept(backupFavoriteRelayList, newFavoriteRelayList, isEmpty = newFavoriteRelayList.tags.isEmpty()) { updateFavoriteRelayList(newFavoriteRelayList) }) { + backupFavoriteRelayList = newFavoriteRelayList saveAccountSettings() } } @@ -1320,13 +1320,13 @@ class AccountSettings( } } - override fun channelList() = backupChannelList + override fun publicChatList() = backupPublicChatList - override fun updateChannelListTo(newChannelList: PublicChatListEvent?) { - if (newChannelList == null) return + override fun updatePublicChatListTo(newPublicChatList: PublicChatListEvent?) { + if (newPublicChatList == null) return - if (backupGuard.accept(backupChannelList, newChannelList, isEmpty = newChannelList.tags.isEmpty()) { updateChannelListTo(newChannelList) }) { - backupChannelList = newChannelList + if (backupGuard.accept(backupPublicChatList, newPublicChatList, isEmpty = newPublicChatList.tags.isEmpty()) { updatePublicChatListTo(newPublicChatList) }) { + backupPublicChatList = newPublicChatList saveAccountSettings() } } @@ -1340,11 +1340,11 @@ class AccountSettings( } } - fun updateHashtagListTo(newHashtagList: InterestListEvent?) { - if (newHashtagList == null) return + fun updateInterestListTo(newInterestList: InterestListEvent?) { + if (newInterestList == null) return - if (backupGuard.accept(backupHashtagList, newHashtagList, isEmpty = newHashtagList.tags.isEmpty()) { updateHashtagListTo(newHashtagList) }) { - backupHashtagList = newHashtagList + if (backupGuard.accept(backupInterestList, newInterestList, isEmpty = newInterestList.tags.isEmpty()) { updateInterestListTo(newInterestList) }) { + backupInterestList = newInterestList saveAccountSettings() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt index 9765753489..c5a8d6737c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/EventBroadcaster.kt @@ -45,7 +45,7 @@ import com.vitorpamplona.quartz.nip29RelayGroups.isGroupScoped import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/bookmarkSets/BookmarkSetsState.kt similarity index 80% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkListsState.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/bookmarkSets/BookmarkSetsState.kt index 49a1c8b3d4..305f9c26e0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/bookmarkSets/BookmarkSetsState.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip51Lists.labeledBookmarkLists +package com.vitorpamplona.amethyst.model.nip51Lists.bookmarkSets import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.cache.filter import com.vitorpamplona.amethyst.commons.model.eventIdSet import com.vitorpamplona.amethyst.commons.model.events -import com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets.BookmarkSet import com.vitorpamplona.amethyst.commons.model.updateFlow import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.Address @@ -37,10 +37,10 @@ import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.BookmarkIdTag import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.EventBookmark -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.description -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.image -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.title +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.description +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.image +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.title import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -55,41 +55,41 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.transformLatest import kotlinx.coroutines.flow.update -class LabeledBookmarkListsState( +class BookmarkSetsState( val signer: NostrSigner, val cache: LocalCache, val scope: CoroutineScope, ) { val user = cache.getOrCreateUser(signer.pubKey) - fun existingLabeledBookmarkNotes() = cache.addressables.filter(BookmarkSetEvent.KIND, user.pubkeyHex) + fun existingBookmarkSetNotes() = cache.addressables.filter(BookmarkSetEvent.KIND, user.pubkeyHex) - val labeledBookmarkListVersions = MutableStateFlow(0) + val bookmarkSetVersions = MutableStateFlow(0) - val labeledBookmarkListNotes = - labeledBookmarkListVersions - .map { existingLabeledBookmarkNotes() } - .onStart { emit(existingLabeledBookmarkNotes()) } + val bookmarkSetNotes = + bookmarkSetVersions + .map { existingBookmarkSetNotes() } + .onStart { emit(existingBookmarkSetNotes()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) - val labeledBookmarkListEventIds = - labeledBookmarkListNotes + val bookmarkSetEventIds = + bookmarkSetNotes .map { it.eventIdSet() } - .onStart { emit(labeledBookmarkListNotes.value.eventIdSet()) } + .onStart { emit(bookmarkSetNotes.value.eventIdSet()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptySet()) @OptIn(ExperimentalCoroutinesApi::class) val latestBookmarkLists: StateFlow<List<BookmarkSetEvent>> = - labeledBookmarkListNotes + bookmarkSetNotes .transformLatest { emitAll(it.updateFlow<BookmarkSetEvent>()) } - .onStart { emit(labeledBookmarkListNotes.value.events()) } + .onStart { emit(bookmarkSetNotes.value.events()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) - suspend fun BookmarkSetEvent.toLabeledBookmarkList() = - LabeledBookmarkList( + suspend fun BookmarkSetEvent.toBookmarkSet() = + BookmarkSet( identifier = dTag(), title = titleOrName() ?: dTag(), description = description(), @@ -98,23 +98,23 @@ class LabeledBookmarkListsState( publicBookmarks = publicBookmarks().toSet(), ) - suspend fun List<BookmarkSetEvent>.toLabeledBookmarkListsFeed() = map { it.toLabeledBookmarkList() }.sortedBy { it.title } + suspend fun List<BookmarkSetEvent>.toBookmarkSetsFeed() = map { it.toBookmarkSet() }.sortedBy { it.title } val listFeedFlow = latestBookmarkLists - .map { it.toLabeledBookmarkListsFeed() } - .onStart { emit(latestBookmarkLists.value.toLabeledBookmarkListsFeed()) } + .map { it.toBookmarkSetsFeed() } + .onStart { emit(latestBookmarkLists.value.toBookmarkSetsFeed()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) - fun List<LabeledBookmarkList>.getList(bookmarkListId: String) = + fun List<BookmarkSet>.getList(bookmarkListId: String) = this.firstOrNull { it.identifier == bookmarkListId } fun getBookmarkList(dTag: String) = listFeedFlow.value.getList(bookmarkListId = dTag) - fun DeletionRequestEvent.hasAnyDeletedBookmarkLists() = deleteAddressesWithKind(BookmarkSetEvent.KIND) || deletesAnyEventIn(labeledBookmarkListEventIds.value) + fun DeletionRequestEvent.hasAnyDeletedBookmarkLists() = deleteAddressesWithKind(BookmarkSetEvent.KIND) || deletesAnyEventIn(bookmarkSetEventIds.value) fun hasItemInNoteList(notes: Set<Note>): Boolean = notes.anyNotNullEvent { event -> @@ -138,14 +138,14 @@ class LabeledBookmarkListsState( } fun forceRefresh() { - labeledBookmarkListVersions.update { it + 1 } + bookmarkSetVersions.update { it + 1 } } - fun getLabeledBookmarkListNote(bookmarkIdentifier: String): AddressableNote? = existingLabeledBookmarkNotes().find { it.dTag() == bookmarkIdentifier } + fun getBookmarkSetNote(bookmarkIdentifier: String): AddressableNote? = existingBookmarkSetNotes().find { it.dTag() == bookmarkIdentifier } - fun getLabeledBookmarkListEvent(bookmarkIdentifier: String): BookmarkSetEvent = getLabeledBookmarkListNote(bookmarkIdentifier)?.event as BookmarkSetEvent + fun getBookmarkSetEvent(bookmarkIdentifier: String): BookmarkSetEvent = getBookmarkSetNote(bookmarkIdentifier)?.event as BookmarkSetEvent - fun getLabeledBookmarkListFlow(bookmarkIdentifier: String) = + fun getBookmarkSetFlow(bookmarkIdentifier: String) = listFeedFlow .map { it.getList(bookmarkIdentifier) } .onStart { @@ -154,7 +154,7 @@ class LabeledBookmarkListsState( ) }.flowOn(Dispatchers.IO) - suspend fun addLabeledBookmarkList( + suspend fun addBookmarkSet( listName: String, listDescription: String? = null, listImage: String? = null, @@ -178,10 +178,10 @@ class LabeledBookmarkListsState( listName: String?, listDescription: String?, listImage: String?, - bookmarkList: LabeledBookmarkList, + bookmarkList: BookmarkSet, account: Account, ) { - val listEvent = getLabeledBookmarkListEvent(bookmarkList.identifier) + val listEvent = getBookmarkSetEvent(bookmarkList.identifier) val template = listEvent.update { @@ -197,10 +197,10 @@ class LabeledBookmarkListsState( suspend fun renameBookmarkList( newName: String, - bookmarkList: LabeledBookmarkList, + bookmarkList: BookmarkSet, account: Account, ) { - val listEvent = getLabeledBookmarkListEvent(bookmarkList.identifier) + val listEvent = getBookmarkSetEvent(bookmarkList.identifier) val renamedList = BookmarkSetEvent.modifyName( earlierVersion = listEvent, @@ -212,10 +212,10 @@ class LabeledBookmarkListsState( suspend fun modifyListDescription( newDescription: String?, - bookmarkList: LabeledBookmarkList, + bookmarkList: BookmarkSet, account: Account, ) { - val listEvent = getLabeledBookmarkListEvent(bookmarkList.identifier) + val listEvent = getBookmarkSetEvent(bookmarkList.identifier) val modifiedList = BookmarkSetEvent.modifyDescription( earlierVersion = listEvent, @@ -226,7 +226,7 @@ class LabeledBookmarkListsState( } suspend fun cloneBookmarkList( - currentBookmarkList: LabeledBookmarkList, + currentBookmarkList: BookmarkSet, customCloneName: String?, customCloneDescription: String?, account: Account, @@ -246,7 +246,7 @@ class LabeledBookmarkListsState( bookmarkListIdentifier: String, account: Account, ) { - val listEvent = getLabeledBookmarkListEvent(bookmarkListIdentifier) + val listEvent = getBookmarkSetEvent(bookmarkListIdentifier) val deletionEventTemplate = DeletionRequestEvent.build(listOf(listEvent)) val deletionEvent = account.signer.sign(deletionEventTemplate) account.sendMyPublicAndPrivateOutbox(deletionEvent) @@ -258,7 +258,7 @@ class LabeledBookmarkListsState( isBookmarkPrivate: Boolean, account: Account, ) { - val currentBookmarkList = getLabeledBookmarkListEvent(bookmarkListIdentifier) + val currentBookmarkList = getBookmarkSetEvent(bookmarkListIdentifier) val updatedList = BookmarkSetEvent.addBookmark( earlierVersion = currentBookmarkList, @@ -275,7 +275,7 @@ class LabeledBookmarkListsState( isBookmarkCurrentlyPrivate: Boolean, account: Account, ) { - val bookmarkList = getLabeledBookmarkListEvent(bookmarkListIdentifier) + val bookmarkList = getBookmarkSetEvent(bookmarkListIdentifier) val updatedList = BookmarkSetEvent.moveBookmark( earlierVersion = bookmarkList, @@ -292,7 +292,7 @@ class LabeledBookmarkListsState( isBookmarkPrivate: Boolean, account: Account, ) { - val currentBookmarkList = getLabeledBookmarkListEvent(bookmarkListIdentifier) + val currentBookmarkList = getBookmarkSetEvent(bookmarkListIdentifier) val updatedList = BookmarkSetEvent.removeBookmark( earlierVersion = currentBookmarkList, @@ -311,7 +311,7 @@ class LabeledBookmarkListsState( ) { if (deletedEventIds.isEmpty() && deletedAddresses.isEmpty()) return - val currentList = getLabeledBookmarkListNote(bookmarkListIdentifier)?.event as? BookmarkSetEvent ?: return + val currentList = getBookmarkSetNote(bookmarkListIdentifier)?.event as? BookmarkSetEvent ?: return val newPublicTags = currentList.tags diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayFeeds/RelayFeedListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteRelays/FavoriteRelayListState.kt similarity index 65% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayFeeds/RelayFeedListState.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteRelays/FavoriteRelayListState.kt index 685e8411a9..2f0fa88e44 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/relayFeeds/RelayFeedListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/favoriteRelays/FavoriteRelayListState.kt @@ -18,12 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip51Lists.relayFeeds +package com.vitorpamplona.amethyst.model.nip51Lists.favoriteRelays import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.cache.LocalCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.relayFeeds.RelayFeedsListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.favoriteRelays.FavoriteRelayListDecryptionCache import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner @@ -40,32 +40,32 @@ import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch -class RelayFeedListState( +class FavoriteRelayListState( val signer: NostrSigner, val cache: LocalCache, - val decryptionCache: RelayFeedsListDecryptionCache, + val decryptionCache: FavoriteRelayListDecryptionCache, val scope: CoroutineScope, val settings: AccountSettings, ) { // Creates a long-term reference for this note so that the GC doesn't collect the note it self - val relayFeedListNote = cache.getOrCreateAddressableNote(getRelayFeedsListAddress()) + val favoriteRelayListNote = cache.getOrCreateAddressableNote(getFavoriteRelayListAddress()) - fun getRelayFeedsListAddress() = FavoriteRelayListEvent.createAddress(signer.pubKey) + fun getFavoriteRelayListAddress() = FavoriteRelayListEvent.createAddress(signer.pubKey) - fun getRelayFeedsListFlow(): StateFlow<NoteState> = relayFeedListNote.flow().metadata.stateFlow + fun getFavoriteRelayListFlow(): StateFlow<NoteState> = favoriteRelayListNote.flow().metadata.stateFlow - fun getRelayFeedsList(): FavoriteRelayListEvent? = relayFeedListNote.event as? FavoriteRelayListEvent + fun getFavoriteRelayList(): FavoriteRelayListEvent? = favoriteRelayListNote.event as? FavoriteRelayListEvent - fun relayFeedsListEvent(note: Note) = note.event as? FavoriteRelayListEvent ?: settings.backupRelayFeedsList + fun favoriteRelayListEvent(note: Note) = note.event as? FavoriteRelayListEvent ?: settings.backupFavoriteRelayList - suspend fun normalizeRelayFeedsListWithBackup(note: Note): Set<NormalizedRelayUrl> = relayFeedsListEvent(note)?.let { decryptionCache.relays(it) }?.ifEmpty { null } ?: emptySet() + suspend fun normalizeFavoriteRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> = favoriteRelayListEvent(note)?.let { decryptionCache.relays(it) }?.ifEmpty { null } ?: emptySet() - suspend fun normalizeRelayFeedsListWithBackupNoDefaults(note: Note): Set<NormalizedRelayUrl> = relayFeedsListEvent(note)?.let { decryptionCache.relays(it) } ?: emptySet() + suspend fun normalizeFavoriteRelayListWithBackupNoDefaults(note: Note): Set<NormalizedRelayUrl> = favoriteRelayListEvent(note)?.let { decryptionCache.relays(it) } ?: emptySet() val flow = - getRelayFeedsListFlow() - .map { normalizeRelayFeedsListWithBackup(it.note) } - .onStart { emit(normalizeRelayFeedsListWithBackup(relayFeedListNote)) } + getFavoriteRelayListFlow() + .map { normalizeFavoriteRelayListWithBackup(it.note) } + .onStart { emit(normalizeFavoriteRelayListWithBackup(favoriteRelayListNote)) } .flowOn(Dispatchers.IO) .stateIn( scope, @@ -74,9 +74,9 @@ class RelayFeedListState( ) val flowNoDefaults = - getRelayFeedsListFlow() - .map { normalizeRelayFeedsListWithBackupNoDefaults(it.note) } - .onStart { emit(normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote)) } + getFavoriteRelayListFlow() + .map { normalizeFavoriteRelayListWithBackupNoDefaults(it.note) } + .onStart { emit(normalizeFavoriteRelayListWithBackupNoDefaults(favoriteRelayListNote)) } .flowOn(Dispatchers.IO) .stateIn( scope, @@ -85,24 +85,24 @@ class RelayFeedListState( ) suspend fun addRelay(relay: NormalizedRelayUrl): FavoriteRelayListEvent { - val current = normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote).toMutableList() + val current = normalizeFavoriteRelayListWithBackupNoDefaults(favoriteRelayListNote).toMutableList() if (relay !in current) current.add(relay) return saveRelayList(current) } suspend fun removeRelay(relay: NormalizedRelayUrl): FavoriteRelayListEvent? { - val current = normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote).toMutableList() + val current = normalizeFavoriteRelayListWithBackupNoDefaults(favoriteRelayListNote).toMutableList() if (relay !in current) return null current.remove(relay) return saveRelayList(current) } suspend fun saveRelayList(relayFeeds: List<NormalizedRelayUrl>): FavoriteRelayListEvent { - val relayFeedsList = getRelayFeedsList() + val favoriteRelayList = getFavoriteRelayList() - return if (relayFeedsList != null && relayFeedsList.tags.isNotEmpty()) { + return if (favoriteRelayList != null && favoriteRelayList.tags.isNotEmpty()) { FavoriteRelayListEvent.updateRelayList( - earlierVersion = relayFeedsList, + earlierVersion = favoriteRelayList, relays = relayFeeds, signer = signer, ) @@ -115,7 +115,7 @@ class RelayFeedListState( } init { - settings.backupRelayFeedsList?.let { + settings.backupFavoriteRelayList?.let { Log.d("AccountRegisterObservers") { "Loading saved relay feeds list ${it.toJson()}" } @OptIn(DelicateCoroutinesApi::class) scope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) } @@ -123,10 +123,10 @@ class RelayFeedListState( scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Relay feeds list Collector Start") - getRelayFeedsListFlow().collect { + getFavoriteRelayListFlow().collect { Log.d("AccountRegisterObservers") { "Updating Relay feeds list for ${signer.pubKey}" } (it.note.event as? FavoriteRelayListEvent)?.let { - settings.updateRelayFeedList(it) + settings.updateFavoriteRelayList(it) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSetsState.kt similarity index 95% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSetsState.kt index bdd1731ab8..4b002aec38 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/PeopleListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/FollowSetsState.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip51Lists.peopleList +package com.vitorpamplona.amethyst.model.nip51Lists.followSets import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note @@ -28,19 +28,19 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.cache.filter import com.vitorpamplona.amethyst.commons.model.eventIdSet import com.vitorpamplona.amethyst.commons.model.events -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.FollowSetDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.commons.model.updateFlow import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.update import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.description +import com.vitorpamplona.quartz.nip51Lists.followSet.image +import com.vitorpamplona.quartz.nip51Lists.followSet.title import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.description -import com.vitorpamplona.quartz.nip51Lists.peopleList.image -import com.vitorpamplona.quartz.nip51Lists.peopleList.title import com.vitorpamplona.quartz.utils.flattenToSet import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -62,10 +62,10 @@ import java.util.UUID * * This class must receive updates from Large Cache as it receives new events. */ -class PeopleListsState( +class FollowSetsState( val signer: NostrSigner, val cache: LocalCache, - val decryptionCache: PeopleListDecryptionCache, + val decryptionCache: FollowSetDecryptionCache, val scope: CoroutineScope, ) { val user = cache.getOrCreateUser(signer.pubKey) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/FollowListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/StarterPacksState.kt similarity index 91% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/FollowListsState.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/StarterPacksState.kt index fbcdfe4e46..881b97a43d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/peopleList/FollowListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/followSets/StarterPacksState.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip51Lists.peopleList +package com.vitorpamplona.amethyst.model.nip51Lists.followSets import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.cache.filter import com.vitorpamplona.amethyst.commons.model.eventIdSet import com.vitorpamplona.amethyst.commons.model.events -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.commons.model.updateFlow import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.quartz.nip01Core.core.HexKey @@ -36,14 +36,14 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.update import com.vitorpamplona.quartz.nip01Core.tags.dTag.dTag import com.vitorpamplona.quartz.nip09Deletions.DeletionRequestEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent -import com.vitorpamplona.quartz.nip51Lists.followList.description -import com.vitorpamplona.quartz.nip51Lists.followList.image -import com.vitorpamplona.quartz.nip51Lists.followList.person -import com.vitorpamplona.quartz.nip51Lists.followList.personFirst -import com.vitorpamplona.quartz.nip51Lists.followList.removePerson -import com.vitorpamplona.quartz.nip51Lists.followList.title import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.description +import com.vitorpamplona.quartz.nip51Lists.starterPack.image +import com.vitorpamplona.quartz.nip51Lists.starterPack.person +import com.vitorpamplona.quartz.nip51Lists.starterPack.personFirst +import com.vitorpamplona.quartz.nip51Lists.starterPack.removePerson +import com.vitorpamplona.quartz.nip51Lists.starterPack.title import com.vitorpamplona.quartz.utils.flattenToSet import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -65,7 +65,7 @@ import java.util.UUID * * This class must receive updates from Large Cache as it receives new events. */ -class FollowListsState( +class StarterPacksState( val signer: NostrSigner, val cache: LocalCache, val scope: CoroutineScope, @@ -84,25 +84,25 @@ class FollowListsState( val followListVersions = MutableStateFlow(0) - val followListNotes = + val starterPackNotes = followListVersions .map { existingPeopleListNotes() } .onStart { emit(existingPeopleListNotes()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) - val followListsEventIds = - followListNotes + val starterPacksEventIds = + starterPackNotes .map { it.eventIdSet() } - .onStart { emit(followListNotes.value.eventIdSet()) } + .onStart { emit(starterPackNotes.value.eventIdSet()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptySet()) @OptIn(ExperimentalCoroutinesApi::class) val latestLists: StateFlow<List<StarterPackEvent>> = - followListNotes + starterPackNotes .transformLatest { emitAll(it.updateFlow<StarterPackEvent>()) } - .onStart { emit(followListNotes.value.events()) } + .onStart { emit(starterPackNotes.value.events()) } .flowOn(Dispatchers.IO) .stateIn(scope, SharingStarted.Eagerly, emptyList()) @@ -148,12 +148,12 @@ class FollowListsState( fun isUserInFollowSets(user: User): Boolean = allPeopleListProfiles.value.contains(user.pubkeyHex) - fun DeletionRequestEvent.hasDeletedAnyFollowList() = deleteAddressesWithKind(StarterPackEvent.KIND) || deletesAnyEventIn(followListsEventIds.value) + fun DeletionRequestEvent.hasDeletedAnyStarterPack() = deleteAddressesWithKind(StarterPackEvent.KIND) || deletesAnyEventIn(starterPacksEventIds.value) fun hasItemInNoteList(notes: Set<Note>): Boolean = notes.anyNotNullEvent { event -> if (event.pubKey == signer.pubKey) { - event is StarterPackEvent || (event is DeletionRequestEvent && event.hasDeletedAnyFollowList()) + event is StarterPackEvent || (event is DeletionRequestEvent && event.hasDeletedAnyStarterPack()) } else { false } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/interestLists/InterestListState.kt similarity index 80% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/interestLists/InterestListState.kt index 8ef88a5e24..25dcf8712b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/hashtagLists/HashtagListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/interestLists/InterestListState.kt @@ -18,15 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists +package com.vitorpamplona.amethyst.model.nip51Lists.interestLists import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.cache.LocalCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.hashtagLists.HashtagListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.interestLists.InterestListDecryptionCache import com.vitorpamplona.amethyst.model.AccountSettings import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi @@ -40,30 +40,30 @@ import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.transformLatest import kotlinx.coroutines.launch -class HashtagListState( +class InterestListState( val signer: NostrSigner, val cache: LocalCache, - val decryptionCache: HashtagListDecryptionCache, + val decryptionCache: InterestListDecryptionCache, val scope: CoroutineScope, val settings: AccountSettings, ) { // Creates a long-term reference for this note so that the GC doesn't collect the note it self - val hashtagListNote = cache.getOrCreateAddressableNote(getHashtagListAddress()) + val hashtagListNote = cache.getOrCreateAddressableNote(getInterestListAddress()) - fun getHashtagListAddress() = InterestListEvent.createAddress(signer.pubKey) + fun getInterestListAddress() = InterestListEvent.createAddress(signer.pubKey) - fun getHashtagListFlow(): StateFlow<NoteState> = hashtagListNote.flow().metadata.stateFlow + fun getInterestListFlow(): StateFlow<NoteState> = hashtagListNote.flow().metadata.stateFlow - fun getHashtagList(): InterestListEvent? = hashtagListNote.event as? InterestListEvent + fun getInterestList(): InterestListEvent? = hashtagListNote.event as? InterestListEvent suspend fun hashtagListWithBackup(note: Note): Set<String> { - val event = note.event as? InterestListEvent ?: settings.backupHashtagList + val event = note.event as? InterestListEvent ?: settings.backupInterestList return event?.let { decryptionCache.hashtags(it).mapTo(mutableSetOf()) { it.lowercase() } } ?: emptySet() } @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow<Set<String>> = - getHashtagListFlow() + getInterestListFlow() .transformLatest { noteState -> emit(hashtagListWithBackup(noteState.note)) }.onStart { @@ -76,7 +76,7 @@ class HashtagListState( ) suspend fun follow(hashtags: List<String>): InterestListEvent { - val hashtagList = getHashtagList() + val hashtagList = getInterestList() return if (hashtagList == null) { InterestListEvent.create(hashtags, true, signer) @@ -86,7 +86,7 @@ class HashtagListState( } suspend fun follow(hashtag: String): InterestListEvent { - val hashtagList = getHashtagList() + val hashtagList = getInterestList() return if (hashtagList == null) { InterestListEvent.create(hashtag.lowercase(), true, signer) @@ -96,7 +96,7 @@ class HashtagListState( } suspend fun unfollow(hashtag: String): InterestListEvent? { - val hashtagList = getHashtagList() + val hashtagList = getInterestList() return if (hashtagList != null) { InterestListEvent.remove(hashtagList, hashtag, signer) @@ -106,7 +106,7 @@ class HashtagListState( } init { - settings.backupHashtagList?.let { event -> + settings.backupInterestList?.let { event -> Log.d("AccountRegisterObservers") { "Loading saved Hashtag list ${event.toJson()}" } @OptIn(DelicateCoroutinesApi::class) scope.launch(Dispatchers.IO) { @@ -116,10 +116,10 @@ class HashtagListState( scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Hashtag List Collector Start") - getHashtagListFlow().collect { + getInterestListFlow().collect { Log.d("AccountRegisterObservers") { "Hashtag List for ${signer.pubKey}" } (it.note.event as? InterestListEvent)?.let { - settings.updateHashtagListTo(it) + settings.updateInterestListTo(it) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt index c7fdad1616..ec7248a3b1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/preferences/AccountPreferenceStores.kt @@ -49,9 +49,9 @@ class AccountPreferenceStores( val latestMuteList = stringPreferencesKey("latestMuteList") val latestPrivateHomeRelayList = stringPreferencesKey("latestPrivateHomeRelayList") val latestAppSpecificData = stringPreferencesKey("latestAppSpecificData") - val latestChannelList = stringPreferencesKey("latestChannelList") + val latestPublicChatList = stringPreferencesKey("latestChannelList") val latestCommunityList = stringPreferencesKey("latestCommunityList") - val latestHashtagList = stringPreferencesKey("latestHashtagList") + val latestInterestList = stringPreferencesKey("latestHashtagList") val latestGeohashList = stringPreferencesKey("latestGeohashList") val latestEphemeralChatList = stringPreferencesKey("latestEphemeralChatList") diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt index 85a875363d..29ad3470c2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt @@ -22,10 +22,10 @@ package com.vitorpamplona.amethyst.model.serverList import androidx.compose.runtime.Immutable import com.vitorpamplona.amethyst.model.nip02FollowLists.Kind3FollowListState +import com.vitorpamplona.amethyst.model.nip51Lists.followSets.FollowSetsState +import com.vitorpamplona.amethyst.model.nip51Lists.followSets.StarterPacksState import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState -import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListState -import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.FollowListsState -import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.PeopleListsState +import com.vitorpamplona.amethyst.model.nip51Lists.interestLists.InterestListState import com.vitorpamplona.amethyst.model.nip72Communities.CommunityListState import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip72ModCommunities.follow.tags.CommunityTag @@ -44,9 +44,9 @@ import kotlinx.coroutines.flow.stateIn @Suppress("UNCHECKED_CAST") class MergedFollowListsState( val kind3List: Kind3FollowListState, - val peopleList: PeopleListsState, - val followList: FollowListsState, - val hashtagList: HashtagListState, + val followSets: FollowSetsState, + val starterPacks: StarterPacksState, + val interestList: InterestListState, val geohashList: GeohashListState, val communityList: CommunityListState, val scope: CoroutineScope, @@ -85,9 +85,9 @@ class MergedFollowListsState( combine( listOf( kind3List.flow, - peopleList.allGoodPeopleListProfiles, - followList.allPeopleListProfiles, - hashtagList.flow, + followSets.allGoodPeopleListProfiles, + starterPacks.allPeopleListProfiles, + interestList.flow, geohashList.flow, communityList.flow, ), @@ -104,9 +104,9 @@ class MergedFollowListsState( emit( mergeLists( kind3List.flow.value, - peopleList.allGoodPeopleListProfiles.value, - followList.allPeopleListProfiles.value, - hashtagList.flow.value, + followSets.allGoodPeopleListProfiles.value, + starterPacks.allPeopleListProfiles.value, + interestList.flow.value, geohashList.flow.value, communityList.flow.value, ), @@ -118,9 +118,9 @@ class MergedFollowListsState( SharingStarted.Eagerly, mergeLists( kind3List.flow.value, - peopleList.allGoodPeopleListProfiles.value, - followList.allPeopleListProfiles.value, - hashtagList.flow.value, + followSets.allGoodPeopleListProfiles.value, + starterPacks.allPeopleListProfiles.value, + interestList.flow.value, geohashList.flow.value, communityList.flow.value, ), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt index e9bca8f358..b7f3b0908b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/NotificationDispatcher.kt @@ -101,7 +101,7 @@ class NotificationDispatcher( private const val TAG = "NotificationDispatcher" // The dispatcher observes the *final* notification payload kinds. - // GiftWrap/EphemeralGiftWrap (1059/21059) and SealedRumor (13) are NOT + // GiftWrap/EphemeralGiftWrap (1059/21059) and Seal (13) are NOT // listed here — by the time we care, Account.newNotesPreProcessor has // already unwrapped them and inserted the inner payload into LocalCache, // which fires the observer a second time on the inner event. @@ -235,8 +235,8 @@ class NotificationDispatcher( if (event is WakeUpEvent) return@predicate true // getNoteIfExists(event) — not (event.id) — so - // AddressableEvent kinds (LongTextNote, WikiNote, - // LiveChess*, VideoHorizontal/Vertical) resolve to + // AddressableEvent kinds (LongFormContent, WikiArticle, + // LiveChess*, AddressableNormalVideo/AddressableShortVideo) resolve to // their address-keyed replaceable note. The id-keyed // version note has its replyTo moved away during // insertion (LocalCache.consumeBaseReplaceable), so diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PushWrapDecryptor.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PushWrapDecryptor.kt index 17964dbecd..356051c867 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PushWrapDecryptor.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/notifications/PushWrapDecryptor.kt @@ -36,7 +36,7 @@ import kotlinx.coroutines.CancellationException * * Once decrypted, the inner event is fed into [LocalCache]. From there the * normal `Account.newNotesPreProcessor` → `GiftWrapEventHandler` → - * `SealedRumorEventHandler` chain unwraps any remaining layers, and + * `SealEventHandler` chain unwraps any remaining layers, and * [NotificationDispatcher] picks up the final payload and notifies. */ object PushWrapDecryptor { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt index 75a9090d82..a4403f5659 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/metadata/FilterAccountInfoAndListsFromKey.kt @@ -20,7 +20,7 @@ */ package com.vitorpamplona.amethyst.service.relayClient.reqCommand.account.metadata -import com.vitorpamplona.amethyst.commons.relayClient.assemblers.filterContactCardsByAuthorInTheRelay +import com.vitorpamplona.amethyst.commons.relayClient.assemblers.filterUserAssertionsByAuthorInTheRelay import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFilter import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.model.nip78AppSpecific.AppSpecificState.Companion.APP_SPECIFIC_DATA_D_TAG @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayList import com.vitorpamplona.quartz.nip38UserStatus.UserStatusEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent @@ -141,7 +141,7 @@ fun filterAccountInfoAndListsFromKey( ), // The account's own kind:30382 contact cards (nicknames, NIP-44 encrypted). // Addressable — one card per target user — hence its own larger-limit filter. - filterContactCardsByAuthorInTheRelay( + filterUserAssertionsByAuthorInTheRelay( relay = relay, authors = pubkeys, since = since, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt index bd26b5ad5a..ba253f5585 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/UserObservers.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -64,11 +64,11 @@ fun observeUserName( // Subscribe in the relay for changes in the metadata of this user. UserFinderFilterAssemblerSubscription(user, accountViewModel) - val contactCards = accountViewModel.account.contactCards - val flow = remember(user) { contactCards.displayNameFlow(user) } + val userAssertions = accountViewModel.account.userAssertions + val flow = remember(user) { userAssertions.displayNameFlow(user) } // Subscribe in the LocalCache for changes that arrive in the device - return flow.collectAsStateWithLifecycle(remember(user) { contactCards.cachedDisplayName(user) }) + return flow.collectAsStateWithLifecycle(remember(user) { userAssertions.cachedDisplayName(user) }) } /** @@ -83,10 +83,10 @@ fun observeUserNickname( user: User, accountViewModel: AccountViewModel, ): State<Nickname?> { - val contactCards = accountViewModel.account.contactCards - val flow = remember(user) { contactCards.nicknameFlow(user) } + val userAssertions = accountViewModel.account.userAssertions + val flow = remember(user) { userAssertions.nicknameFlow(user) } - return flow.collectAsStateWithLifecycle(remember(user) { contactCards.cachedNickname(user) }) + return flow.collectAsStateWithLifecycle(remember(user) { userAssertions.cachedNickname(user) }) } @Composable @@ -132,9 +132,9 @@ fun observeUserTagFollowCount( .metadata.stateFlow .sample(1000) .mapLatest { noteState -> - (noteState.note.event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.size ?: 0 + (noteState.note.event as? InterestListEvent)?.let { accountViewModel.account.interestListDecryptionCache.hashtags(it) }?.size ?: 0 }.onStart { - emit((accountViewModel.hashtagFollows(user).event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.size ?: 0) + emit((accountViewModel.hashtagFollows(user).event as? InterestListEvent)?.let { accountViewModel.account.interestListDecryptionCache.hashtags(it) }?.size ?: 0) }.distinctUntilChanged() .flowOn(Dispatchers.IO) } @@ -160,9 +160,9 @@ fun observeUserTagFollows( .metadata.stateFlow .sample(200) .mapLatest { noteState -> - (noteState.note.event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList() + (noteState.note.event as? InterestListEvent)?.let { accountViewModel.account.interestListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList() }.onStart { - emit((accountViewModel.hashtagFollows(user).event as? InterestListEvent)?.let { accountViewModel.account.hashtagListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList()) + emit((accountViewModel.hashtagFollows(user).event as? InterestListEvent)?.let { accountViewModel.account.interestListDecryptionCache.hashtags(it) }?.sorted() ?: emptyList()) }.distinctUntilChanged() .flowOn(Dispatchers.IO) } @@ -304,16 +304,16 @@ fun observeUserIsFollowingHashtag( // Subscribe in the LocalCache for changes that arrive in the device val flow = remember(accountViewModel) { - accountViewModel.account.hashtagList.flow + accountViewModel.account.interestList.flow .mapLatest { hashtags -> hashtag in hashtags }.onStart { - emit(hashtag in accountViewModel.account.hashtagList.flow.value) + emit(hashtag in accountViewModel.account.interestList.flow.value) }.distinctUntilChanged() .flowOn(Dispatchers.IO) } - return flow.collectAsStateWithLifecycle(hashtag in accountViewModel.account.hashtagList.flow.value) + return flow.collectAsStateWithLifecycle(hashtag in accountViewModel.account.interestList.flow.value) } @SuppressLint("StateFlowValueCalledInComposition") @@ -373,16 +373,16 @@ fun observeUserIsFollowingRelay( ): State<Boolean> { val flow = remember(accountViewModel) { - accountViewModel.account.relayFeedsList.flowNoDefaults + accountViewModel.account.favoriteRelayList.flowNoDefaults .mapLatest { relays -> relayUrl in relays }.onStart { - emit(relayUrl in accountViewModel.account.relayFeedsList.flowNoDefaults.value) + emit(relayUrl in accountViewModel.account.favoriteRelayList.flowNoDefaults.value) }.distinctUntilChanged() .flowOn(Dispatchers.IO) } - return flow.collectAsStateWithLifecycle(relayUrl in accountViewModel.account.relayFeedsList.flowNoDefaults.value) + return flow.collectAsStateWithLifecycle(relayUrl in accountViewModel.account.favoriteRelayList.flowNoDefaults.value) } @OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class) @@ -439,7 +439,7 @@ fun observeUserIsFollowingChannel( @OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class) @Composable -fun observeUserContactCardsScore( +fun observeUserAssertionsScore( user: User, accountViewModel: AccountViewModel, subscribe: Boolean = true, @@ -459,7 +459,7 @@ fun observeUserContactCardsScore( @OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class) @Composable -fun observeUserContactCardsFollowerCount( +fun observeUserAssertionsFollowerCount( user: User, accountViewModel: AccountViewModel, ): State<String> { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt index 1b5355efef..8bfe2fe129 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/resourceusage/MeteringNostrSigner.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal import com.vitorpamplona.quartz.nip46RemoteSigner.signer.NostrSignerRemote import com.vitorpamplona.quartz.nip55AndroidSigner.client.NostrSignerExternal -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip89AppHandlers.clientTag.NostrSignerWithClientTag @@ -89,7 +89,7 @@ class MeteringNostrSigner( fromPublicKey: HexKey, ): String = metered(UsageKeys.DECRYPT_COUNT, UsageKeys.DECRYPT_US) { inner.nip44Decrypt(ciphertext, fromPublicKey) } - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = metered(UsageKeys.DECRYPT_COUNT, UsageKeys.DECRYPT_US) { inner.decryptZapEvent(event) } + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = metered(UsageKeys.DECRYPT_COUNT, UsageKeys.DECRYPT_US) { inner.decryptZapEvent(event) } override suspend fun deriveKey(nonce: HexKey): HexKey = inner.deriveKey(nonce) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt index 79d22a9dbe..9715816619 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/FilterByListParams.kt @@ -32,8 +32,8 @@ import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hasMoreHashtagsThan import com.vitorpamplona.quartz.nip10Notes.threadRootIdOrSelf +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.utils.TimeUtils class FilterByListParams( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt index 3d70cf26d2..c13a8124a8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/PrefetchFeedMedia.kt @@ -303,7 +303,7 @@ private class WarmTargets { * `m` mime type (a hashed URL may carry no extension). The decode listener * records their dims like any other image. */ - fun addFileHeaderMedia(event: Event) { + fun addFileMetadataMedia(event: Event) { val urls = event.tags.mapNotNull(UrlTag::parse) if (urls.isEmpty()) return val imageMime = event.tags.firstNotNullOfOrNull(MimeTypeTag::parse)?.startsWith("image/") == true @@ -335,7 +335,7 @@ private fun Note.collectWarmTargets(): WarmTargets? { // NIP-94 file-header convention: the blob is a top-level `url` tag with sibling // `m`/`dim`, not imeta (FileMetadataEvent and the gallery/file kinds). The generic // imetas() above misses these entirely. - targets.addFileHeaderMedia(ev) + targets.addFileMetadataMedia(ev) // NIP-73 external-content scope. Only kind 1111 carries one, so the type check // keeps every other kind out of the tag walk. Reuses scope() — the same accessor diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt index a500753e1b..f7ad534111 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/drawer/DrawerContent.kt @@ -146,7 +146,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.profileContentHeaderModifier import com.vitorpamplona.amethyst.isDebug import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNote -import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserContactCardsFollowerCount +import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserAssertionsFollowerCount import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserInfo import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserStatuses import com.vitorpamplona.amethyst.ui.layouts.PermanentDrawerWidth @@ -587,7 +587,7 @@ fun DisplayFollowerCount( baseAccountUser: Account, accountViewModel: AccountViewModel, ) { - val followerCount by observeUserContactCardsFollowerCount(baseAccountUser.userProfile(), accountViewModel) + val followerCount by observeUserAssertionsFollowerCount(baseAccountUser.userProfile(), accountViewModel) Text( text = followerCount, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt index 3962bce3ac..198ff3adac 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt @@ -57,7 +57,7 @@ import com.vitorpamplona.quartz.nip34Git.pr.GitPullRequestEvent import com.vitorpamplona.quartz.nip34Git.pr.GitPullRequestUpdateEvent import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt index 12c29afce3..a227d40fcb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/MultiSetCompose.kt @@ -106,7 +106,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.bitcoinColor import com.vitorpamplona.amethyst.commons.ui.theme.overPictureBackground import com.vitorpamplona.amethyst.commons.ui.theme.profile35dpModifier import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.UserFinderFilterAssemblerSubscription -import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserContactCardsScore +import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserAssertionsScore import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserPicture import com.vitorpamplona.amethyst.ui.components.CoreSecretMessage import com.vitorpamplona.amethyst.ui.components.ExpandableRichTextViewer @@ -841,7 +841,7 @@ fun ObserveAndRenderBoxedUserCards( accountViewModel: AccountViewModel, subscribe: Boolean = true, ) { - val score by observeUserContactCardsScore(user, accountViewModel, subscribe) + val score by observeUserAssertionsScore(user, accountViewModel, subscribe) score?.let { Box(modifier = Size35Modifier, contentAlignment = Alignment.BottomCenter) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index a05755b51f..29134ae6da 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -140,18 +140,18 @@ import com.vitorpamplona.amethyst.ui.note.types.DisplayBlockedRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayBroadcastRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayContactList import com.vitorpamplona.amethyst.ui.note.types.DisplayDMRelayList -import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList +import com.vitorpamplona.amethyst.ui.note.types.DisplayFavoriteRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayIndexerRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayNIP65RelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList import com.vitorpamplona.amethyst.ui.note.types.DisplayProxyRelayList -import com.vitorpamplona.amethyst.ui.note.types.DisplayRelayFeedsList import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet import com.vitorpamplona.amethyst.ui.note.types.DisplaySearchRelayList +import com.vitorpamplona.amethyst.ui.note.types.DisplayStarterPack import com.vitorpamplona.amethyst.ui.note.types.DisplayTrustedRelayList import com.vitorpamplona.amethyst.ui.note.types.EditState import com.vitorpamplona.amethyst.ui.note.types.EmptyState -import com.vitorpamplona.amethyst.ui.note.types.FileHeaderDisplay +import com.vitorpamplona.amethyst.ui.note.types.FileMetadataDisplay import com.vitorpamplona.amethyst.ui.note.types.FileStorageHeaderDisplay import com.vitorpamplona.amethyst.ui.note.types.PictureDisplay import com.vitorpamplona.amethyst.ui.note.types.RenderAppDefinition @@ -180,6 +180,8 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderCitation import com.vitorpamplona.amethyst.ui.note.types.RenderClassifieds import com.vitorpamplona.amethyst.ui.note.types.RenderCommunity import com.vitorpamplona.amethyst.ui.note.types.RenderCyberspaceBag +import com.vitorpamplona.amethyst.ui.note.types.RenderDvmContentDiscoveryResponse +import com.vitorpamplona.amethyst.ui.note.types.RenderDvmStatus import com.vitorpamplona.amethyst.ui.note.types.RenderEmojiPack import com.vitorpamplona.amethyst.ui.note.types.RenderEntityRating import com.vitorpamplona.amethyst.ui.note.types.RenderExternalReaction @@ -200,14 +202,11 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderLiveActivityChatMessage import com.vitorpamplona.amethyst.ui.note.types.RenderLiveActivityEvent import com.vitorpamplona.amethyst.ui.note.types.RenderLiveChessChallenge import com.vitorpamplona.amethyst.ui.note.types.RenderLiveChessGameEnd -import com.vitorpamplona.amethyst.ui.note.types.RenderLnZap import com.vitorpamplona.amethyst.ui.note.types.RenderLongFormContent import com.vitorpamplona.amethyst.ui.note.types.RenderMeetingRoomEvent import com.vitorpamplona.amethyst.ui.note.types.RenderMeetingSpaceEvent import com.vitorpamplona.amethyst.ui.note.types.RenderMusicPlaylist import com.vitorpamplona.amethyst.ui.note.types.RenderMusicTrack -import com.vitorpamplona.amethyst.ui.note.types.RenderNIP90ContentDiscoveryResponse -import com.vitorpamplona.amethyst.ui.note.types.RenderNIP90Status import com.vitorpamplona.amethyst.ui.note.types.RenderNamedNappletEvent import com.vitorpamplona.amethyst.ui.note.types.RenderNamedSiteEvent import com.vitorpamplona.amethyst.ui.note.types.RenderNipContent @@ -257,21 +256,22 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderWikiMergeAcceptance import com.vitorpamplona.amethyst.ui.note.types.RenderWikiMergeRequest import com.vitorpamplona.amethyst.ui.note.types.RenderWikiRedirect import com.vitorpamplona.amethyst.ui.note.types.RenderZapPoll +import com.vitorpamplona.amethyst.ui.note.types.RenderZapReceipt import com.vitorpamplona.amethyst.ui.note.types.ReplyRenderType import com.vitorpamplona.amethyst.ui.note.types.VideoDisplay import com.vitorpamplona.amethyst.ui.note.types.lists.RenderAppCurationSet import com.vitorpamplona.amethyst.ui.note.types.lists.RenderArticleCurationSet import com.vitorpamplona.amethyst.ui.note.types.lists.RenderBookmarkList +import com.vitorpamplona.amethyst.ui.note.types.lists.RenderBookmarkSet import com.vitorpamplona.amethyst.ui.note.types.lists.RenderFavoriteAlgoFeedsList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderGeohashList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderGitAuthorList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderGitRepositoryList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderGoodWikiAuthorList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderGoodWikiRelayList -import com.vitorpamplona.amethyst.ui.note.types.lists.RenderHashtagList +import com.vitorpamplona.amethyst.ui.note.types.lists.RenderInterestList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderInterestSet import com.vitorpamplona.amethyst.ui.note.types.lists.RenderKindMuteSet -import com.vitorpamplona.amethyst.ui.note.types.lists.RenderLabeledBookmarkList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderMediaFollowList import com.vitorpamplona.amethyst.ui.note.types.lists.RenderMediaStarterPack import com.vitorpamplona.amethyst.ui.note.types.lists.RenderMuteList @@ -367,21 +367,20 @@ import com.vitorpamplona.quartz.nip51Lists.appCurationSet.AppCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent import com.vitorpamplona.quartz.nip51Lists.gitAuthorList.GitAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.gitRepositoryList.GitRepositoryListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiAuthorList.GoodWikiAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiRelayList.GoodWikiRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.kindMuteSet.KindMuteSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaFollowList.MediaFollowListEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent @@ -392,6 +391,7 @@ import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent @@ -1192,7 +1192,7 @@ private fun RenderNoteRow( } is ZapReceiptEvent -> { - RenderLnZap(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) + RenderZapReceipt(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) } is NutzapEvent -> { @@ -1220,7 +1220,7 @@ private fun RenderNoteRow( } is StarterPackEvent -> { - DisplayFollowList(baseNote, true, accountViewModel, nav) + DisplayStarterPack(baseNote, true, accountViewModel, nav) } is ContactListEvent -> { @@ -1252,7 +1252,7 @@ private fun RenderNoteRow( } is FavoriteRelayListEvent -> { - DisplayRelayFeedsList(baseNote, backgroundColor, accountViewModel, nav) + DisplayFavoriteRelayList(baseNote, backgroundColor, accountViewModel, nav) } is IndexerRelayListEvent -> { @@ -1551,7 +1551,7 @@ private fun RenderNoteRow( } is DvmContentDiscoveryResponseEvent -> { - RenderNIP90ContentDiscoveryResponse( + RenderDvmContentDiscoveryResponse( baseNote, makeItShort, canPreview, @@ -1563,7 +1563,7 @@ private fun RenderNoteRow( } is DvmStatusEvent -> { - RenderNIP90Status( + RenderDvmStatus( baseNote, accountViewModel, nav, @@ -1641,7 +1641,7 @@ private fun RenderNoteRow( } is FileMetadataEvent -> { - FileHeaderDisplay(baseNote, true, ContentScale.FillWidth, accountViewModel) + FileMetadataDisplay(baseNote, true, ContentScale.FillWidth, accountViewModel) } // Covers every NIP-71 video kind (21, 22, 34235, 34236) via the shared interface, @@ -1880,7 +1880,7 @@ private fun RenderNoteRow( } is BookmarkSetEvent -> { - RenderLabeledBookmarkList(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) + RenderBookmarkSet(baseNote, quotesLeft, backgroundColor, accountViewModel, nav) } is ArticleCurationSetEvent -> { @@ -1924,7 +1924,7 @@ private fun RenderNoteRow( } is InterestListEvent -> { - RenderHashtagList(baseNote, backgroundColor, accountViewModel, nav) + RenderInterestList(baseNote, backgroundColor, accountViewModel, nav) } is InterestSetEvent -> { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt index a6999b790b..27c3f60fd7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteQuickActionMenu.kt @@ -116,8 +116,8 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.report.ReportNoteDialog import com.vitorpamplona.quartz.experimental.bounties.bountyBaseReward import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.coroutines.launch import org.jetbrains.compose.resources.StringResource diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt index 5faaa6a2e2..415645df86 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateReactionTypeDialog.kt @@ -358,7 +358,7 @@ private fun EmojiSelector( onClick: ((EmojiUrlTag) -> Unit)? = null, ) { LoadAddressableNote( - accountViewModel.account.emoji.getEmojiPackSelectionAddress(), + accountViewModel.account.emoji.getEmojiListAddress(), ) { emptyNote -> emptyNote?.let { usersEmojiList -> val collections by observeNoteEventAndMapNotNull(usersEmojiList, accountViewModel) { event: EmojiListEvent -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt index 753d91f79f..a5af97da5f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt @@ -52,7 +52,7 @@ import com.vitorpamplona.amethyst.commons.ui.note.ScoreTag import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn -import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserContactCardsScore +import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserAssertionsScore import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserInfo import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -565,7 +565,7 @@ fun ObserveAndRenderUserCards( modifier: Modifier = Modifier, accountViewModel: AccountViewModel, ) { - val score by observeUserContactCardsScore(user, accountViewModel) + val score by observeUserAssertionsScore(user, accountViewModel) score?.let { ScoreTag(it, size, modifier) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt index bb78a2b1b1..ea8a60aca9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt @@ -67,7 +67,7 @@ import com.vitorpamplona.amethyst.commons.model.composer.AudienceList import com.vitorpamplona.amethyst.commons.model.composer.AudienceListKind import com.vitorpamplona.amethyst.commons.model.composer.AudienceMember import com.vitorpamplona.amethyst.commons.model.composer.AudienceSelection -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.audience_add_anyway import com.vitorpamplona.amethyst.commons.resources.audience_add_people @@ -545,9 +545,9 @@ private fun MemberBadge( */ @Composable fun rememberAudienceLists(accountViewModel: AccountViewModel): List<AudienceList> { - val peopleLists by accountViewModel.account.peopleLists.uiListFlow + val peopleLists by accountViewModel.account.followSets.uiListFlow .collectAsStateWithLifecycle() - val followPacks by accountViewModel.account.followLists.uiListFlow + val followPacks by accountViewModel.account.starterPacks.uiListFlow .collectAsStateWithLifecycle() return remember(peopleLists, followPacks) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt index dabc6e7890..fd09217ed1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DropDownMenu.kt @@ -281,7 +281,7 @@ fun observeBookmarksFollowsAndAccount( accountViewModel.account.bookmarkState.bookmarks, accountViewModel.account.pinState.pinnedEventIdSet, accountViewModel.showSensitiveContent(), - accountViewModel.account.emoji.getEmojiPackSelectionFlow(), + accountViewModel.account.emoji.getEmojiListFlow(), ) { follows, bookmarks, pinnedIds, showSensitiveContent, emojiSelectionState -> val isEmojiPackInMyList = if (noteIdForEmoji != null) { @@ -312,7 +312,7 @@ fun observeBookmarksFollowsAndAccount( isEmojiPackInMyList = noteIdForEmoji?.let { accountViewModel.account.emoji - .getEmojiPackSelection() + .getEmojiList() ?.isTaggedAddressableNote(it) == true } ?: false, ), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ActivityCardPreviews.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ActivityCardPreviews.kt index d98200b394..d63b6a8880 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ActivityCardPreviews.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ActivityCardPreviews.kt @@ -103,10 +103,10 @@ private object ActivityCardPreviewData { } } - fun lnZapNote(): Note { + fun zapReceiptNote(): Note { val id = "d".repeat(64) // Receipts are signed by the lightning provider; the preview skips the - // embedded request and feeds the decrypted card to RenderLnZapCard directly. + // embedded request and feeds the decrypted card to RenderZapReceiptCard directly. return Note(id).apply { event = null author = null @@ -171,12 +171,12 @@ fun EmojiReactionActivityCardPreview() { @Preview @Composable -fun LnZapActivityCardPreview() { +fun ZapReceiptActivityCardPreview() { val accountViewModel = mockAccountViewModel() ThemeComparisonColumn { - RenderLnZapCard( - note = ActivityCardPreviewData.lnZapNote(), + RenderZapReceiptCard( + note = ActivityCardPreviewData.zapReceiptNote(), card = ZapAmountCommentNotification( user = LocalCache.getOrCreateUser(ActivityCardPreviewData.senderHex), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Emoji.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Emoji.kt index ebdf0422df..d65958b79d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Emoji.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Emoji.kt @@ -181,7 +181,7 @@ private fun EmojiListOptions( emojiPackNote: Note, ) { LoadAddressableNote( - accountViewModel.account.emoji.getEmojiPackSelectionAddress(), + accountViewModel.account.emoji.getEmojiListAddress(), ) { it?.let { usersEmojiList -> val hasAddedThis by observeNoteAndMap(usersEmojiList, accountViewModel) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt index bda74a2880..29017e1a15 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FileHeader.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.quartz.nip31Alts.alt import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent @Composable -fun FileHeaderDisplay( +fun FileMetadataDisplay( note: Note, roundedCorner: Boolean, contentScale: ContentScale, @@ -53,7 +53,7 @@ fun FileHeaderDisplay( // which viewer happens to render it, so an NSFW-tagged archive stays behind the same gate. SensitivityWarning(note = note, accountViewModel = accountViewModel) { if (content == null) { - FileHeaderAttachmentCard(event, fullUrl, mimeType) + FileMetadataAttachmentCard(event, fullUrl, mimeType) } else { ZoomableContentView( content = content, @@ -70,7 +70,7 @@ fun FileHeaderDisplay( * * Kind 1063 is a *generic* file container — its `m` tag can name any type, so unlike a NIP-71 * video event the kind itself asserts nothing about how to render the payload. A null here means - * the file belongs in [FileHeaderAttachmentCard] rather than being pushed into the video player. + * the file belongs in [FileMetadataAttachmentCard] rather than being pushed into the video player. */ internal fun FileMetadataEvent.toMediaContent( note: Note, @@ -128,7 +128,7 @@ internal fun FileMetadataEvent.toMediaContent( /** The link card a kind-1063 header falls back to when [toMediaContent] returns null. */ @Composable -internal fun FileHeaderAttachmentCard( +internal fun FileMetadataAttachmentCard( event: FileMetadataEvent, url: String, mimeType: String?, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt index 2bee2e52d0..8e2aa280a6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90ContentDiscoveryResponse.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hasHashtags import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent @Composable -fun RenderNIP90ContentDiscoveryResponse( +fun RenderDvmContentDiscoveryResponse( note: Note, makeItShort: Boolean, canPreview: Boolean, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt index 6b6bfb0303..19c27a2c83 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/NIP90Status.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip90Dvms.status.DvmStatusEvent @Composable -fun RenderNIP90Status( +fun RenderDvmStatus( note: Note, accountViewModel: AccountViewModel, nav: INav, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt index 64b4fa7b39..1f5a19840b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/PeopleList.kt @@ -56,7 +56,7 @@ import com.vitorpamplona.amethyst.ui.note.UserCompose import com.vitorpamplona.amethyst.ui.note.getGradient import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUserIds -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ProfileCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ProfileCard.kt index 344fc539a2..c12f7659cb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ProfileCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ProfileCard.kt @@ -76,7 +76,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.bitcoinColor import com.vitorpamplona.amethyst.commons.ui.theme.innerPostModifier import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.service.relayClient.reqCommand.account.observeAccountIsHiddenUser -import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserContactCardsFollowerCount +import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserAssertionsFollowerCount import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserInfo import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserIsFollowing import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor @@ -288,7 +288,7 @@ private fun ProfileCardChips( // A self-follow in your own kind:3 is common; "Follows you" on your own card is not a fact. val followsMe by observeUserIsFollowing(author, accountViewModel.account.userProfile(), accountViewModel) val followsYou = followsMe && !accountViewModel.isLoggedUser(author) - val followerCount by observeUserContactCardsFollowerCount(author, accountViewModel) + val followerCount by observeUserAssertionsFollowerCount(author, accountViewModel) // "--" is the placeholder the contact-card observer emits while no trusted // assertion for this user has arrived. Nothing to brag about yet. val followers = followerCount.takeIf { it != "--" } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt index ec1f485c88..3a5e7e4ed6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/RelayList.kt @@ -241,14 +241,14 @@ fun DisplayTrustedRelayList( } @Composable -fun DisplayRelayFeedsList( +fun DisplayFavoriteRelayList( baseNote: Note, backgroundColor: MutableState<Color>, accountViewModel: AccountViewModel, nav: INav, ) { - val relays by accountViewModel.account.relayFeedsListDecryptionCache.observeDecryptedRelayList(baseNote).collectAsStateWithLifecycle( - accountViewModel.account.relayFeedsListDecryptionCache.fastStartValueForRelayList(baseNote), + val relays by accountViewModel.account.favoriteRelayListDecryptionCache.observeDecryptedRelayList(baseNote).collectAsStateWithLifecycle( + accountViewModel.account.favoriteRelayListDecryptionCache.fastStartValueForRelayList(baseNote), ) DisplayRelaySet( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FollowList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/StarterPack.kt similarity index 99% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FollowList.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/StarterPack.kt index ac06818f09..88ca1ebd7e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/FollowList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/StarterPack.kt @@ -66,13 +66,13 @@ import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageHeaderBackground import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip51FollowSets.FollowSetCard import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @OptIn(ExperimentalLayoutApi::class) @Composable -fun DisplayFollowList( +fun DisplayStarterPack( baseNote: Note, makeItShort: Boolean, accountViewModel: AccountViewModel, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt index be61fdda0a..1412044f68 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Wiki.kt @@ -60,11 +60,11 @@ fun RenderWikiContent( ) { val noteEvent = note.event as? WikiArticleEvent ?: return - WikiNoteHeader(noteEvent, note, accountViewModel, nav) + WikiArticleHeader(noteEvent, note, accountViewModel, nav) } @Composable -private fun WikiNoteHeader( +private fun WikiArticleHeader( noteEvent: WikiArticleEvent, note: Note, accountViewModel: AccountViewModel, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt index bc6d1bb5f8..26815bdee9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ZapEvent.kt @@ -97,7 +97,7 @@ fun RenderZappedPost( } @Composable -fun RenderLnZap( +fun RenderZapReceipt( note: Note, quotesLeft: Int, backgroundColor: MutableState<Color>, @@ -108,7 +108,7 @@ fun RenderLnZap( val card by parseAuthorCommentAndAmount(note, accountViewModel) - RenderLnZapCard( + RenderZapReceiptCard( note = note, card = card, recipientKey = zapEvent.zappedAuthor().firstOrNull(), @@ -120,7 +120,7 @@ fun RenderLnZap( } @Composable -fun RenderLnZapCard( +fun RenderZapReceiptCard( note: Note, card: ZapAmountCommentNotification, recipientKey: String?, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt index 2a8a1ce57b..24ccbbe3c7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/BookmarkLists.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSet import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.BookmarkIdTag -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent /** NIP-51 kind 10003: the user's bookmarks — notes, articles, hashtags and links. */ @@ -101,7 +101,7 @@ fun RenderOldBookmarkList( /** NIP-51 kind 30003: "user-defined bookmarks categories, for when bookmarks must be in labeled separate groups". */ @Composable -fun RenderLabeledBookmarkList( +fun RenderBookmarkSet( baseNote: Note, quotesLeft: Int, backgroundColor: MutableState<Color>, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt index b2186cbd21..993591f7cf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/lists/TagLists.kt @@ -36,12 +36,12 @@ import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.tags.hashtags.HashtagTag import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent /** NIP-51 kind 10015: the hashtags this user follows. */ @Composable -fun RenderHashtagList( +fun RenderInterestList( baseNote: Note, backgroundColor: MutableState<Color>, accountViewModel: AccountViewModel, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountSessionManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountSessionManager.kt index b8f38aab80..4b6d470a1c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountSessionManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/AccountSessionManager.kt @@ -303,8 +303,8 @@ class AccountSessionManager( accountSettings.backupKeyPackageRelayList?.let { client.publish(it, toPost) } accountSettings.backupSearchRelayList?.let { client.publish(it, toPost) } accountSettings.backupIndexRelayList?.let { client.publish(it, toPost) } - accountSettings.backupRelayFeedsList?.let { client.publish(it, toPost) } - accountSettings.backupChannelList?.let { client.publish(it, toPost) } + accountSettings.backupFavoriteRelayList?.let { client.publish(it, toPost) } + accountSettings.backupPublicChatList?.let { client.publish(it, toPost) } accountSettings.backupCashuWallet?.let { client.publish(it, toPost) } accountSettings.backupNutzapInfo?.let { client.publish(it, toPost) } } @@ -329,8 +329,8 @@ class AccountSessionManager( backupKeyPackageRelayList = bootstrap.keyPackageRelayList, backupSearchRelayList = bootstrap.searchRelayList, backupIndexRelayList = bootstrap.indexerRelayList, - backupChannelList = bootstrap.channelList, - backupRelayFeedsList = bootstrap.relayFeedsList, + backupPublicChatList = bootstrap.publicChatList, + backupFavoriteRelayList = bootstrap.favoriteRelayList, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt index 8d0618d42d..04e304dcee 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/TopNavFilterState.kt @@ -43,9 +43,9 @@ import com.vitorpamplona.amethyst.service.checkNotInMainThread import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.relay.normalizer.displayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.utils.Log @@ -162,14 +162,14 @@ class TopNavFilterState( val livePeopleListsFlow: Flow<List<FeedDefinition>> = combine( - account.peopleLists.peopleListNotes, - account.followLists.followListNotes, + account.followSets.peopleListNotes, + account.starterPacks.starterPackNotes, ::mergePeopleLists, ).onStart { emit( mergePeopleLists( - account.peopleLists.peopleListNotes.value, - account.followLists.followListNotes.value, + account.followSets.peopleListNotes.value, + account.starterPacks.starterPackNotes.value, ), ) } @@ -247,10 +247,10 @@ class TopNavFilterState( @OptIn(ExperimentalCoroutinesApi::class) val liveInterestFlows: Flow<List<FeedDefinition>> = combine( - account.hashtagList.flow, + account.interestList.flow, account.geohashList.flow, account.communityList.flowNotes, - account.relayFeedsList.flow, + account.favoriteRelayList.flow, combine( account.favoriteAlgoFeedsList.flowNotes, account.interestSets.listFeedFlow, @@ -261,10 +261,10 @@ class TopNavFilterState( }.onStart { emit( mergeInterests( - account.hashtagList.flow.value, + account.interestList.flow.value, account.geohashList.flow.value, account.communityList.flowNotes.value, - account.relayFeedsList.flow.value, + account.favoriteRelayList.flow.value, account.favoriteAlgoFeedsList.flowNotes.value, account.interestSets.listFeedFlow.value, ), 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 6cd968367e..064b4af887 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 @@ -202,7 +202,7 @@ import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip56Reports.ReportType import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent @@ -2144,11 +2144,11 @@ class AccountViewModel( fun hide(user: User) = launchSigner { account.hideUser(user.pubkeyHex) } - fun updateContactCardPetName( + fun updateUserAssertionPetName( user: User, petName: String?, summary: String?, - ) = launchSigner { account.updateContactCardPetName(user.pubkeyHex, petName, summary) } + ) = launchSigner { account.updateUserAssertionPetName(user.pubkeyHex, petName, summary) } fun hide(word: String) = launchSigner { account.hideWord(word) } 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 794e1b3027..e09c5e6e4a 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 @@ -68,10 +68,10 @@ class EventProcessor( private val draftHandler = DraftEventHandler(account, cache) private val giftWrapHandler = GiftWrapEventHandler(account, cache, this) - private val sealHandler = SealedRumorEventHandler(account, cache, this) + private val sealHandler = SealEventHandler(account, cache, this) - private val zapRequest = LnZapRequestEventHandler(account.privateZapsDecryptionCache) - private val zapEvent = LnZapEventHandler(account.privateZapsDecryptionCache) + private val zapRequest = ZapRequestEventHandler(account.privateZapsDecryptionCache) + private val zapEvent = ZapReceiptEventHandler(account.privateZapsDecryptionCache) private val groupEventHandler = GroupEventHandler(account, cache) @@ -389,7 +389,7 @@ class GiftWrapEventHandler( /** * Shared Marmot Welcome handler used by both [GiftWrapEventHandler] * (in case a Welcome arrives directly inside a kind:1059 with no Seal - * layer) and [SealedRumorEventHandler] (the actual production path — + * layer) and [SealEventHandler] (the actual production path — * Welcomes are wrapped GiftWrap → Seal → Welcome per * [com.vitorpamplona.quartz.marmot.mip02Welcome.WelcomeGiftWrap]). */ @@ -453,7 +453,7 @@ private suspend fun processMarmotWelcomeFlow( } } -class SealedRumorEventHandler( +class SealEventHandler( private val account: Account, private val cache: LocalCache, private val eventProcessor: EventProcessor, @@ -465,14 +465,14 @@ class SealedRumorEventHandler( ) { val rumorId = event.innerEventId if (rumorId == null) { - processNewSealedRumor(event, eventNote, publicNote) + processNewSeal(event, eventNote, publicNote) } else { // Replayed seal: re-link the rumor to its delivering envelope so // broadcast can republish the wrap after a cache rebuild. // publicNote is the outermost event of this unwrap chain — the // kind-1059 wrap normally, the seal itself when it arrived bare. publicNote.event?.let { envelope -> cache.getOrCreateNote(rumorId).recordRumorHost(envelope) } - processExistingSealedRumor(rumorId, publicNote) + processExistingSeal(rumorId, publicNote) } } @@ -488,7 +488,7 @@ class SealedRumorEventHandler( } } - private suspend fun processNewSealedRumor( + private suspend fun processNewSeal( event: SealEvent, eventNote: Note, publicNote: Note, @@ -524,7 +524,7 @@ class SealedRumorEventHandler( eventNote.flowSet?.metadata?.invalidateData() } - private suspend fun processExistingSealedRumor( + private suspend fun processExistingSeal( rumorId: String, publicNote: Note, ) { @@ -536,7 +536,7 @@ class SealedRumorEventHandler( } } -class LnZapRequestEventHandler( +class ZapRequestEventHandler( val decryptionCache: PrivateZapCache, ) : EventHandler<ZapRequestEvent> { override suspend fun add( @@ -559,7 +559,7 @@ class LnZapRequestEventHandler( } } -class LnZapEventHandler( +class ZapReceiptEventHandler( val decryptionCache: PrivateZapCache, ) : EventHandler<ZapReceiptEvent> { override suspend fun delete( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt index bb977a4184..90802e1b17 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt @@ -65,10 +65,10 @@ import com.vitorpamplona.quartz.nip01Core.diff.ContentChange import com.vitorpamplona.quartz.nip01Core.diff.EventDiff import com.vitorpamplona.quartz.nip01Core.metadata.MetadataDiff import com.vitorpamplona.quartz.nip02FollowList.ContactListDiff -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListDiff +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListDiff import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListDiff import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListDiff -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListDiff +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListDiff import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListDiff import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayListDiff import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListDiff @@ -130,12 +130,12 @@ private fun headlineOf( is MetadataDiff -> plural(R.plurals.backup_card_profile_lost_fields, counts.removed) is AdvertisedRelayListDiff -> plural(R.plurals.backup_card_nip65_lost, diff.relays.removed.size) is RelayListDiff -> relayListHeadline(conflict.eventType, diff.relays.removed.size) - is ChannelListDiff -> plural(R.plurals.backup_card_leave_chats, diff.channels.removed.size) + is PublicChatListDiff -> plural(R.plurals.backup_card_leave_chats, diff.channels.removed.size) is CommunityListDiff -> plural(R.plurals.backup_card_leave_communities, diff.communities.removed.size) is EphemeralChatListDiff -> plural(R.plurals.backup_card_leave_rooms, diff.rooms.removed.size) is SimpleGroupListDiff -> plural(R.plurals.backup_card_leave_groups, diff.groups.removed.size) is FavoriteAlgoFeedsListDiff -> plural(R.plurals.backup_card_feeds_removed, diff.feeds.removed.size) - is HashtagListDiff -> plural(R.plurals.backup_card_hashtags_unfollowed, diff.hashtags.removed.size) + is InterestListDiff -> plural(R.plurals.backup_card_hashtags_unfollowed, diff.hashtags.removed.size) is GeohashListDiff -> plural(R.plurals.backup_card_places_unfollowed, diff.geohashes.removed.size) is TrustProviderListDiff -> plural(R.plurals.backup_card_trust_services_changed, diff.providers.removed.size + diff.providers.changed.size) is NutzapInfoDiff -> @@ -162,7 +162,7 @@ private fun headlineOf( when { diff is ContactListDiff -> R.plurals.backup_card_and_followed diff is MuteListDiff -> R.plurals.backup_card_and_muted - diff is ChannelListDiff || diff is CommunityListDiff || diff is EphemeralChatListDiff || diff is SimpleGroupListDiff -> R.plurals.backup_card_and_joined + diff is PublicChatListDiff || diff is CommunityListDiff || diff is EphemeralChatListDiff || diff is SimpleGroupListDiff -> R.plurals.backup_card_and_joined conflict.eventType == BackupEventType.BLOCKED_RELAYS -> R.plurals.backup_card_and_blocked else -> R.plurals.backup_card_and_added } @@ -182,12 +182,12 @@ private fun addedToHeadlinedList( is MuteListDiff -> diff.publicMutes.added.size is AdvertisedRelayListDiff -> diff.relays.added.size is RelayListDiff -> if (relayListHasHeadline(type)) diff.relays.added.size else 0 - is ChannelListDiff -> diff.channels.added.size + is PublicChatListDiff -> diff.channels.added.size is CommunityListDiff -> diff.communities.added.size is EphemeralChatListDiff -> diff.rooms.added.size is SimpleGroupListDiff -> diff.groups.added.size is FavoriteAlgoFeedsListDiff -> diff.feeds.added.size - is HashtagListDiff -> diff.hashtags.added.size + is InterestListDiff -> diff.hashtags.added.size is GeohashListDiff -> diff.geohashes.added.size is NutzapInfoDiff -> if (diff.p2pkPubkey == null) diff.mints.added.size else 0 is PaymentTargetsDiff -> diff.targets.added.size diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt index 6587568294..5c67889add 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt @@ -93,7 +93,7 @@ import com.vitorpamplona.quartz.nip01Core.diff.ContentChange import com.vitorpamplona.quartz.nip01Core.diff.ListDiff import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListDiff +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListDiff import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip28PublicChat.list.channels import com.vitorpamplona.quartz.nip37Drafts.privateOutbox.PrivateOutboxRelayListEvent @@ -102,8 +102,8 @@ import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFee import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListDiff import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListDiff -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListDiff +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent @@ -133,11 +133,11 @@ internal fun LazyListScope.listDiffItems( ): Boolean { when (val diff = conflict.diff) { is RelayListDiff -> relayListItems(diff, conflict, nav) - is ChannelListDiff -> publicChatItems(diff, conflict, accountViewModel, nav) + is PublicChatListDiff -> publicChatItems(diff, conflict, accountViewModel, nav) is CommunityListDiff -> communityItems(diff, conflict, accountViewModel, nav) is EphemeralChatListDiff -> ephemeralRoomItems(diff, conflict, nav) is FavoriteAlgoFeedsListDiff -> favoriteFeedItems(diff, conflict, accountViewModel, nav) - is HashtagListDiff -> topicItems(diff.hashtags, (conflict.saved as? InterestListEvent)?.publicHashtags().orEmpty(), diff.privateItems, isPlace = false, nav) + is InterestListDiff -> topicItems(diff.hashtags, (conflict.saved as? InterestListEvent)?.publicHashtags().orEmpty(), diff.privateItems, isPlace = false, nav) is GeohashListDiff -> topicItems(diff.geohashes, (conflict.saved as? GeohashListEvent)?.publicGeohashes().orEmpty(), diff.privateItems, isPlace = true, nav) is TrustProviderListDiff -> trustProviderItems(diff, conflict, accountViewModel, nav) is PaymentTargetsDiff -> paymentTargetItems(diff, conflict) @@ -446,7 +446,7 @@ private fun SpaceTile( } private fun LazyListScope.publicChatItems( - diff: ChannelListDiff, + diff: PublicChatListDiff, conflict: ReplaceableBackupConflict, accountViewModel: AccountViewModel, nav: INav, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt index 58195a5d31..9b390254f7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt @@ -41,10 +41,10 @@ import com.vitorpamplona.quartz.nip01Core.metadata.Birthday import com.vitorpamplona.quartz.nip01Core.metadata.MetadataDiff import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip02FollowList.ContactListDiff -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListDiff +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListDiff import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListDiff import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListDiff -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListDiff +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListDiff import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListDiff import com.vitorpamplona.quartz.nip51Lists.muteList.tags.EventTag import com.vitorpamplona.quartz.nip51Lists.muteList.tags.HashtagTag @@ -104,9 +104,9 @@ fun countsOf(diff: EventDiff): ConflictCounts = is MuteListDiff -> diff.publicMutes.asCounts() + diff.privateItems.asCounts() is AdvertisedRelayListDiff -> diff.relays.asCounts() is RelayListDiff -> diff.relays.asCounts() + diff.privateRelays.asCounts() - is ChannelListDiff -> diff.channels.asCounts() + diff.privateItems.asCounts() + is PublicChatListDiff -> diff.channels.asCounts() + diff.privateItems.asCounts() is CommunityListDiff -> diff.communities.asCounts() + diff.privateItems.asCounts() - is HashtagListDiff -> diff.hashtags.asCounts() + diff.privateItems.asCounts() + is InterestListDiff -> diff.hashtags.asCounts() + diff.privateItems.asCounts() is GeohashListDiff -> diff.geohashes.asCounts() + diff.privateItems.asCounts() is FavoriteAlgoFeedsListDiff -> diff.feeds.asCounts() + diff.privateItems.asCounts() is EphemeralChatListDiff -> diff.rooms.asCounts() + diff.privateItems.asCounts() @@ -330,7 +330,7 @@ fun presentationOf( ) to ContentChange.NONE } is RelayListDiff -> listOf(listGroup(R.string.backup_entry_relay, diff.relays, { ReviewItem.Relay(it) })) to diff.privateRelays - is ChannelListDiff -> + is PublicChatListDiff -> listOf( listGroup( R.string.backup_entry_public_chat, @@ -348,7 +348,7 @@ fun presentationOf( { ReviewItem.Addressable(it.after.address, arrow(it.before.relayHint?.url, it.after.relayHint?.url)) }, ), ) to diff.privateItems - is HashtagListDiff -> listOf(listGroup(R.string.backup_entry_hashtag, diff.hashtags, { ReviewItem.Text("#$it") })) to diff.privateItems + is InterestListDiff -> listOf(listGroup(R.string.backup_entry_hashtag, diff.hashtags, { ReviewItem.Text("#$it") })) to diff.privateItems is GeohashListDiff -> listOf(listGroup(R.string.backup_entry_location, diff.geohashes, { ReviewItem.Text(it) })) to diff.privateItems is FavoriteAlgoFeedsListDiff -> listOf( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt index 8b5d7b0150..805e43fabc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt @@ -86,10 +86,10 @@ import com.vitorpamplona.quartz.experimental.ephemChat.list.EphemeralChatListDif import com.vitorpamplona.quartz.nip01Core.diff.ContentChange import com.vitorpamplona.quartz.nip01Core.metadata.MetadataDiff import com.vitorpamplona.quartz.nip02FollowList.ContactListDiff -import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListDiff +import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListDiff import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListDiff import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListDiff -import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListDiff +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListDiff import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListDiff import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayListDiff import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListDiff @@ -373,11 +373,11 @@ private fun actionLabels(conflict: ReplaceableBackupConflict): Pair<String, Stri stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_relays) } is AdvertisedRelayListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_relays) - is ChannelListDiff -> rejoinLabels(diff.channels.removed.size) + is PublicChatListDiff -> rejoinLabels(diff.channels.removed.size) is CommunityListDiff -> rejoinLabels(diff.communities.removed.size) is EphemeralChatListDiff -> rejoinLabels(diff.rooms.removed.size) is FavoriteAlgoFeedsListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_feeds) - is HashtagListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_topics) + is InterestListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_topics) // Geohashes are places, not topics: the screen counts "places gone" under "Followed // locations", so the button has to agree with the page it sits on. is GeohashListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_places) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt index 15c2317fcd..a951f6deb1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupScreen.kt @@ -101,7 +101,7 @@ fun BookmarkGroupScreen( bookmarkType, broadcastBookmarkGroup = { accountViewModel.launchSigner { - val groupNote = accountViewModel.account.labeledBookmarkLists.getLabeledBookmarkListNote(bookmarkIdentifier) + val groupNote = accountViewModel.account.bookmarkSets.getBookmarkSetNote(bookmarkIdentifier) groupNote?.let { accountViewModel.broadcast(it) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupViewModel.kt index 9cba1b5ad4..c23afd9fb3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/display/BookmarkGroupViewModel.kt @@ -40,8 +40,8 @@ class BookmarkGroupViewModel( val bookmarkGroupIdentifier: String, ) : ViewModel() { val selectedBookmarkGroupFlow = - account.labeledBookmarkLists - .getLabeledBookmarkListFlow(bookmarkGroupIdentifier) + account.bookmarkSets + .getBookmarkSetFlow(bookmarkGroupIdentifier) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(2500), null) fun publicPosts() = @@ -69,7 +69,7 @@ class BookmarkGroupViewModel( .stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) suspend fun deleteBookmarkGroup(groupIdentifier: String) { - account.labeledBookmarkLists.deleteBookmarkList(groupIdentifier, account) + account.bookmarkSets.deleteBookmarkList(groupIdentifier, account) } suspend fun addBookmarkToGroup( @@ -77,7 +77,7 @@ class BookmarkGroupViewModel( bookmark: BookmarkIdTag, isPrivate: Boolean, ) { - account.labeledBookmarkLists.addBookmarkToList( + account.bookmarkSets.addBookmarkToList( bookmark, groupIdentifier, isPrivate, @@ -108,7 +108,7 @@ class BookmarkGroupViewModel( bookmark: BookmarkIdTag, isCurrentlyPrivate: Boolean, ) { - account.labeledBookmarkLists.moveBookmarkInList( + account.bookmarkSets.moveBookmarkInList( bookmark, groupIdentifier, isCurrentlyPrivate, @@ -147,7 +147,7 @@ class BookmarkGroupViewModel( bookmark: BookmarkIdTag, isPrivate: Boolean, ) { - account.labeledBookmarkLists.removeBookmarkFromList( + account.bookmarkSets.removeBookmarkFromList( bookmark, groupIdentifier, isPrivate, @@ -160,7 +160,7 @@ class BookmarkGroupViewModel( deletedEventIds: Set<String>, deletedAddresses: Set<Address>, ) { - account.labeledBookmarkLists.removeDeletedBookmarksFromList( + account.bookmarkSets.removeDeletedBookmarksFromList( groupIdentifier, deletedEventIds, deletedAddresses, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/ListOfBookmarkGroupsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/ListOfBookmarkGroupsScreen.kt index 18556e4e82..727d168bf8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/ListOfBookmarkGroupsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/ListOfBookmarkGroupsScreen.kt @@ -40,7 +40,7 @@ import com.vitorpamplona.amethyst.commons.model.nip51Lists.BookmarkType import com.vitorpamplona.amethyst.commons.model.nip51Lists.GitRepositoryListState import com.vitorpamplona.amethyst.commons.model.nip51Lists.OldBookmarkListState import com.vitorpamplona.amethyst.commons.model.nip51Lists.PinListState -import com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets.BookmarkSet import com.vitorpamplona.amethyst.commons.nip51Lists.ui.ListOfBookmarkGroupsFeedView import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.bookmark_lists @@ -64,7 +64,7 @@ fun ListOfBookmarkGroupsScreen( oldBookmarks = accountViewModel.account.oldBookmarkState, pinnedNotes = accountViewModel.account.pinState, repositories = accountViewModel.account.gitRepositoryListState, - listSource = accountViewModel.account.labeledBookmarkLists.listFeedFlow, + listSource = accountViewModel.account.bookmarkSets.listFeedFlow, openDefaultBookmarks = { nav.nav(Route.Bookmarks) }, openOldBookmarks = { nav.nav(Route.OldBookmarks) }, openPinnedNotes = { nav.nav(Route.PinnedNotes) }, @@ -82,7 +82,7 @@ fun ListOfBookmarkGroupsScreen( }, cloneBookmarkGroup = { bookmarkGroup, customName, customDesc -> accountViewModel.launchSigner { - accountViewModel.account.labeledBookmarkLists.cloneBookmarkList( + accountViewModel.account.bookmarkSets.cloneBookmarkList( currentBookmarkList = bookmarkGroup, customCloneName = customName, customCloneDescription = customDesc, @@ -92,7 +92,7 @@ fun ListOfBookmarkGroupsScreen( }, deleteBookmarkGroup = { bookmarkGroup -> accountViewModel.launchSigner { - accountViewModel.account.labeledBookmarkLists.deleteBookmarkList( + accountViewModel.account.bookmarkSets.deleteBookmarkList( bookmarkListIdentifier = bookmarkGroup.identifier, account = accountViewModel.account, ) @@ -109,7 +109,7 @@ fun ListOfBookmarkGroupsFeed( oldBookmarks: OldBookmarkListState, pinnedNotes: PinListState, repositories: GitRepositoryListState, - listSource: StateFlow<List<LabeledBookmarkList>>, + listSource: StateFlow<List<BookmarkSet>>, openDefaultBookmarks: () -> Unit, openOldBookmarks: () -> Unit, openPinnedNotes: () -> Unit, @@ -117,10 +117,10 @@ fun ListOfBookmarkGroupsFeed( openPodcasts: () -> Unit, addBookmarkGroup: () -> Unit, openBookmarkGroup: (identifier: String, bookmarkType: BookmarkType) -> Unit, - renameBookmarkGroup: (bookmarkGroup: LabeledBookmarkList) -> Unit, - changeBookmarkGroupDescription: (bookmarkGroup: LabeledBookmarkList) -> Unit, - cloneBookmarkGroup: (bookmarkGroup: LabeledBookmarkList, customName: String?, customDesc: String?) -> Unit, - deleteBookmarkGroup: (bookmarkGroup: LabeledBookmarkList) -> Unit, + renameBookmarkGroup: (bookmarkGroup: BookmarkSet) -> Unit, + changeBookmarkGroupDescription: (bookmarkGroup: BookmarkSet) -> Unit, + cloneBookmarkGroup: (bookmarkGroup: BookmarkSet, customName: String?, customDesc: String?) -> Unit, + deleteBookmarkGroup: (bookmarkGroup: BookmarkSet) -> Unit, accountViewModel: AccountViewModel, nav: INav, ) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/metadata/BookmarkGroupMetadataViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/metadata/BookmarkGroupMetadataViewModel.kt index d8e41c8398..1f2f4bc31a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/metadata/BookmarkGroupMetadataViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/list/metadata/BookmarkGroupMetadataViewModel.kt @@ -31,7 +31,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.mediaServers.ServerType -import com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets.BookmarkSet import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.avif_metadata_strip_failed import com.vitorpamplona.amethyst.commons.resources.failed_to_upload_media_no_details @@ -59,7 +59,7 @@ class BookmarkGroupMetadataViewModel : ViewModel() { private lateinit var accountViewModel: AccountViewModel private lateinit var account: Account - var bookmarkGroup by mutableStateOf<LabeledBookmarkList?>(null) + var bookmarkGroup by mutableStateOf<BookmarkSet?>(null) val isNewList by derivedStateOf { bookmarkGroup == null } val name = mutableStateOf(TextFieldValue()) @@ -83,7 +83,7 @@ class BookmarkGroupMetadataViewModel : ViewModel() { } fun load(dTag: String) { - bookmarkGroup = account.labeledBookmarkLists.getBookmarkList(dTag) + bookmarkGroup = account.bookmarkSets.getBookmarkList(dTag) name.value = TextFieldValue(bookmarkGroup?.title ?: "") picture.value = TextFieldValue(bookmarkGroup?.image ?: "") description.value = TextFieldValue(bookmarkGroup?.description ?: "") @@ -95,14 +95,14 @@ class BookmarkGroupMetadataViewModel : ViewModel() { accountViewModel.launchSigner { val bookmarkGroup = bookmarkGroup if (bookmarkGroup == null) { - accountViewModel.account.labeledBookmarkLists.addLabeledBookmarkList( + accountViewModel.account.bookmarkSets.addBookmarkSet( listName = name.value.text, listDescription = description.value.text, listImage = picture.value.text, account = accountViewModel.account, ) } else { - accountViewModel.account.labeledBookmarkLists.updateMetadata( + accountViewModel.account.bookmarkSets.updateMetadata( listName = name.value.text, listDescription = description.value.text, listImage = picture.value.text, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/ArticleBookmarkListManagementScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/ArticleBookmarkListManagementScreen.kt index d1e3f9749c..c562d73658 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/ArticleBookmarkListManagementScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/ArticleBookmarkListManagementScreen.kt @@ -37,7 +37,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.nip51Lists.BookmarkType -import com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets.BookmarkSet import com.vitorpamplona.amethyst.commons.nip51Lists.ui.BookmarkGroupManagementItem import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.article_bookmark_management_title @@ -109,7 +109,7 @@ private fun ListManagementViewBody( accountViewModel: AccountViewModel, nav: INav, ) { - val bookmarkGroups by accountViewModel.account.labeledBookmarkLists.listFeedFlow + val bookmarkGroups by accountViewModel.account.bookmarkSets.listFeedFlow .collectAsStateWithLifecycle() val defaultBookmarks by accountViewModel.account.bookmarkState.bookmarks @@ -146,7 +146,7 @@ private fun ListManagementViewBody( ) } - itemsIndexed(items = bookmarkGroups, key = { _: Int, item: LabeledBookmarkList -> item.identifier }) { _, bookmarkList -> + itemsIndexed(items = bookmarkGroups, key = { _: Int, item: BookmarkSet -> item.identifier }) { _, bookmarkList -> val maybePublicBookmark = bookmarkList.publicArticleBookmarks.firstOrNull { it.address == note.address } val maybePrivateBookmark = bookmarkList.privateArticleBookmarks.firstOrNull { it.address == note.address } BookmarkGroupManagementItem( @@ -159,7 +159,7 @@ private fun ListManagementViewBody( onClick = { nav.nav(Route.BookmarkGroupView(bookmarkList.identifier, BookmarkType.ArticleBookmark)) }, onAddBookmarkToGroup = { shouldBePrivate -> accountViewModel.launchSigner { - accountViewModel.account.labeledBookmarkLists.addBookmarkToList( + accountViewModel.account.bookmarkSets.addBookmarkToList( bookmark = AddressBookmark(address = note.address, relayHint = note.relayHintUrl()), bookmarkListIdentifier = bookmarkList.identifier, isBookmarkPrivate = shouldBePrivate, @@ -169,7 +169,7 @@ private fun ListManagementViewBody( }, onRemoveBookmarkFromGroup = { accountViewModel.launchSigner { - accountViewModel.account.labeledBookmarkLists.removeBookmarkFromList( + accountViewModel.account.bookmarkSets.removeBookmarkFromList( bookmark = AddressBookmark(address = note.address), bookmarkListIdentifier = bookmarkList.identifier, isBookmarkPrivate = maybePrivateBookmark != null, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/PostBookmarkListManagementScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/PostBookmarkListManagementScreen.kt index 12e2a0860a..49564f47a5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/PostBookmarkListManagementScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/bookmarkgroups/membershipManagement/PostBookmarkListManagementScreen.kt @@ -37,7 +37,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.nip51Lists.BookmarkType -import com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets.BookmarkSet import com.vitorpamplona.amethyst.commons.nip51Lists.ui.BookmarkGroupManagementItem import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.bookmarks_title @@ -108,7 +108,7 @@ private fun ListManagementViewBody( accountViewModel: AccountViewModel, nav: INav, ) { - val bookmarkGroups by accountViewModel.account.labeledBookmarkLists.listFeedFlow + val bookmarkGroups by accountViewModel.account.bookmarkSets.listFeedFlow .collectAsStateWithLifecycle() val defaultBookmarks by accountViewModel.account.bookmarkState.bookmarks @@ -145,7 +145,7 @@ private fun ListManagementViewBody( ) } - itemsIndexed(items = bookmarkGroups, key = { _: Int, item: LabeledBookmarkList -> item.identifier }) { _, bookmarkList -> + itemsIndexed(items = bookmarkGroups, key = { _: Int, item: BookmarkSet -> item.identifier }) { _, bookmarkList -> val maybePublicBookmark = bookmarkList.publicPostBookmarks.firstOrNull { it.eventId == note.idHex } val maybePrivateBookmark = bookmarkList.privatePostBookmarks.firstOrNull { it.eventId == note.idHex } BookmarkGroupManagementItem( @@ -158,7 +158,7 @@ private fun ListManagementViewBody( onClick = { nav.nav(Route.BookmarkGroupView(bookmarkList.identifier, BookmarkType.PostBookmark)) }, onAddBookmarkToGroup = { shouldBePrivate -> accountViewModel.launchSigner { - accountViewModel.account.labeledBookmarkLists.addBookmarkToList( + accountViewModel.account.bookmarkSets.addBookmarkToList( bookmark = EventBookmark(eventId = note.idHex, relay = note.relayHintUrl(), author = note.author?.pubkeyHex), bookmarkListIdentifier = bookmarkList.identifier, isBookmarkPrivate = shouldBePrivate, @@ -168,7 +168,7 @@ private fun ListManagementViewBody( }, onRemoveBookmarkFromGroup = { accountViewModel.launchSigner { - accountViewModel.account.labeledBookmarkLists.removeBookmarkFromList( + accountViewModel.account.bookmarkSets.removeBookmarkFromList( bookmark = EventBookmark(eventId = note.idHex), bookmarkListIdentifier = bookmarkList.identifier, isBookmarkPrivate = maybePrivateBookmark != null, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupDiscoveryScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupDiscoveryScreen.kt index afdf3562b4..93ea1bb03c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupDiscoveryScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupDiscoveryScreen.kt @@ -250,7 +250,7 @@ private fun WatchAccountForRelayGroupDiscovery( .collectAsStateWithLifecycle() val joinedServers by accountViewModel.account.relayGroupList.liveRelayGroupServers .collectAsStateWithLifecycle() - val favoriteRelays by accountViewModel.account.relayFeedsList.flow + val favoriteRelays by accountViewModel.account.favoriteRelayList.flow .collectAsStateWithLifecycle() // Discovery only shows groups whose 39000 is signed by the host relay's own key (NIP-29's @@ -349,7 +349,7 @@ private fun RelayRailHeader( val info = loadRelayInfo(relay) val host = relay.displayUrl() val name = info.value.name?.takeIf { it.isNotBlank() } ?: host - val favoriteRelays by accountViewModel.account.relayFeedsList.flow + val favoriteRelays by accountViewModel.account.favoriteRelayList.flow .collectAsStateWithLifecycle() val isFavorite = relay in favoriteRelays diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupMembersScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupMembersScreen.kt index 9d9b4b5e5c..d94934ee10 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupMembersScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/RelayGroupMembersScreen.kt @@ -408,7 +408,7 @@ private fun RelayGroupMemberRow( ) } DropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) { - val declaredRoles = channel.supportedRoles + val declaredRoles = channel.groupRoles if (declaredRoles.isNotEmpty()) { // The relay declares its own role set (kind 39003) — offer exactly those // instead of the built-in admin/moderator pair. Roles are privilege grants, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt index 8d0897ae01..23715d84f2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/relayGroup/datasource/RelayGroupsDiscoverySubAssembler.kt @@ -100,7 +100,7 @@ class RelayGroupsDiscoverySubAssembler( account.relayGroupList.liveRelayGroupServers.value.forEach { server -> RelayUrlNormalizer.normalizeOrNull(server)?.let(::add) } - addAll(account.relayFeedsList.flow.value) + addAll(account.favoriteRelayList.flow.value) } override fun user(key: RelayGroupsDiscoveryQueryState) = key.account.userProfile() @@ -156,7 +156,7 @@ class RelayGroupsDiscoverySubAssembler( } }, key.account.scope.launch(Dispatchers.IO) { - key.account.relayFeedsList.flow.sample(500).collectLatest { + key.account.favoriteRelayList.flow.sample(500).collectLatest { invalidateFilters() } }, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt index b6eb04d860..f4e4212c37 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/ChannelCardCompose.kt @@ -45,7 +45,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.RenderCo import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip99Classifieds.RenderClassifiedsThumb import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingRoomEvent import com.vitorpamplona.quartz.nip53LiveActivities.meetingSpaces.MeetingSpaceEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt index 5d28a436a8..f85d225362 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/DiscoverScreen.kt @@ -88,7 +88,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource.Discove import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.TabItem import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt index 2e09975f62..1e0fdcad4d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/DiscoverFollowSetsFeedFilter.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.amethyst.ui.dal.sortedByDefaultFeedOrder -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent open class DiscoverFollowSetsFeedFilter( val account: Account, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt index d7399581f6..3e249d4a59 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/FollowSetCard.kt @@ -63,7 +63,7 @@ import com.vitorpamplona.amethyst.ui.note.elements.DefaultImageBannerBackground import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.mockAccountViewModel import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt index ef283a4950..a0f559056c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/DvmContentDiscoveryScreen.kt @@ -87,7 +87,7 @@ import com.vitorpamplona.amethyst.ui.screen.RenderFeedState import com.vitorpamplona.amethyst.ui.screen.SaveableFeedState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.DVMCard -import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.dal.NIP90ContentDiscoveryFeedViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.dvms.dal.DvmContentDiscoveryFeedViewModel import com.vitorpamplona.quartz.lightning.LnInvoiceUtil import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent @@ -263,22 +263,22 @@ fun PrepareViewContentDiscoveryModels( accountViewModel: AccountViewModel, nav: INav, ) { - val resultFeedViewModel: NIP90ContentDiscoveryFeedViewModel = + val resultFeedViewModel: DvmContentDiscoveryFeedViewModel = viewModel( key = "NostrNIP90ContentDiscoveryFeedViewModel${dvm.pubkeyHex}$dvmRequestId", - factory = NIP90ContentDiscoveryFeedViewModel.Factory(accountViewModel.account, dvmKey = dvm.pubkeyHex, requestId = dvmRequestId), + factory = DvmContentDiscoveryFeedViewModel.Factory(accountViewModel.account, dvmKey = dvm.pubkeyHex, requestId = dvmRequestId), ) LaunchedEffect(key1 = dvmRequestId, latestResponse.id) { resultFeedViewModel.invalidateData() } - RenderNostrNIP90ContentDiscoveryScreen(resultFeedViewModel, onRefresh, accountViewModel, nav) + RenderNostrDvmContentDiscoveryScreen(resultFeedViewModel, onRefresh, accountViewModel, nav) } @Composable -fun RenderNostrNIP90ContentDiscoveryScreen( - resultFeedViewModel: NIP90ContentDiscoveryFeedViewModel, +fun RenderNostrDvmContentDiscoveryScreen( + resultFeedViewModel: DvmContentDiscoveryFeedViewModel, onRefresh: () -> Unit, accountViewModel: AccountViewModel, nav: INav, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryFeedViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/DvmContentDiscoveryFeedViewModel.kt similarity index 89% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryFeedViewModel.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/DvmContentDiscoveryFeedViewModel.kt index 5bf18acf92..6e16027d13 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryFeedViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/DvmContentDiscoveryFeedViewModel.kt @@ -27,17 +27,17 @@ import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.screen.AndroidFeedViewModel @Stable -class NIP90ContentDiscoveryFeedViewModel( +class DvmContentDiscoveryFeedViewModel( val account: Account, dvmKey: String, requestId: String, -) : AndroidFeedViewModel(NIP90ContentDiscoveryResponseFilter(account, dvmKey, requestId)) { +) : AndroidFeedViewModel(DvmContentDiscoveryResponseFilter(account, dvmKey, requestId)) { class Factory( val account: Account, val dvmKey: String, val requestId: String, ) : ViewModelProvider.Factory { @Suppress("UNCHECKED_CAST") - override fun <T : ViewModel> create(modelClass: Class<T>): T = NIP90ContentDiscoveryFeedViewModel(account, dvmKey, requestId) as T + override fun <T : ViewModel> create(modelClass: Class<T>): T = DvmContentDiscoveryFeedViewModel(account, dvmKey, requestId) as T } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryResponseFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/DvmContentDiscoveryResponseFilter.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryResponseFilter.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/DvmContentDiscoveryResponseFilter.kt index acb70c2ab0..b9c8653a49 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/NIP90ContentDiscoveryResponseFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/dvms/dal/DvmContentDiscoveryResponseFilter.kt @@ -29,7 +29,7 @@ import com.vitorpamplona.amethyst.ui.dal.FilterByListParams import com.vitorpamplona.quartz.nip01Core.tags.events.isTaggedEvent import com.vitorpamplona.quartz.nip90Dvms.contentDiscoveryResponse.DvmContentDiscoveryResponseEvent -open class NIP90ContentDiscoveryResponseFilter( +open class DvmContentDiscoveryResponseFilter( val account: Account, val dvmkey: String, val request: String, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/list/ListOfEmojiPacksScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/list/ListOfEmojiPacksScreen.kt index 3d1af6ad19..e385a772aa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/list/ListOfEmojiPacksScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/list/ListOfEmojiPacksScreen.kt @@ -315,7 +315,7 @@ private fun EmojiListToggleRow( LoadAddressableNote(packAddress) { it?.let { packNote -> LoadAddressableNote( - accountViewModel.account.emoji.getEmojiPackSelectionAddress(), + accountViewModel.account.emoji.getEmojiListAddress(), ) { selectionNote -> selectionNote?.let { usersEmojiList -> val hasAddedThis by observeNoteAndMap(usersEmojiList, accountViewModel) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/EmojiPackSelectionScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/EmojiPackSelectionScreen.kt index 798e89e207..e3774aa912 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/EmojiPackSelectionScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/EmojiPackSelectionScreen.kt @@ -121,7 +121,7 @@ private fun EmojiPackSelectionBody( ) { item { LoadAddressableNote( - address = accountViewModel.account.emoji.getEmojiPackSelectionAddress(), + address = accountViewModel.account.emoji.getEmojiListAddress(), ) { selectionNote -> selectionNote?.let { val hasAddedThis by observeNoteAndMap(it, accountViewModel) { currentNote -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt index 6226d1a680..b23457dc69 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/membershipManagement/MyEmojiListScreen.kt @@ -79,7 +79,7 @@ fun MyEmojiListScreen( nav: INav, ) { LoadAddressableNote( - address = accountViewModel.account.emoji.getEmojiPackSelectionAddress(), + address = accountViewModel.account.emoji.getEmojiListAddress(), ) { selectionNote -> selectionNote?.let { MyEmojiListView( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt index e72a91d271..cad3be3193 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/FollowPackFeedScreen.kt @@ -85,7 +85,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.dal.Follow import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.dal.FollowPackMembersUserFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.followPacks.feed.datasource.FollowPackFeedFilterAssemblerSubscription import com.vitorpamplona.quartz.nip01Core.core.Address -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt index 663afb6994..2a56243e86 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedConversationsFeedFilter.kt @@ -37,7 +37,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip10Notes.TextNoteEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nipA0VoiceMessages.VoiceReplyEvent import com.vitorpamplona.quartz.nipA4PublicMessages.PublicMessageEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt index c89f21f3d7..26a3f6bd6f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackFeedNewThreadFeedFilter.kt @@ -46,7 +46,7 @@ import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent import com.vitorpamplona.quartz.nip18Reposts.RepostEvent import com.vitorpamplona.quartz.nip22Comments.CommentEvent import com.vitorpamplona.quartz.nip23LongContent.LongFormContentEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip84Highlights.HighlightEvent import com.vitorpamplona.quartz.nip99Classifieds.ClassifiedsEvent diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt index a081c0031b..0e6b1ee160 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/dal/FollowPackMembersFeedFilter.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.LocalCache.checkGetOrCreateUser import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent class FollowPackMembersFeedFilter( val followPackNote: AddressableNote, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt index 7c7b968467..13c6fe051f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/feed/datasource/FollowPackFeedFilterSubAssembler.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.home.nip65Follows.filterHo import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.INostrClient import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent class FollowPackFeedFilterSubAssembler( client: INostrClient, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt index 4ff1d00053..5937c2290a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksFeedLoaded.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.ChannelCardCompose -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent @OptIn(ExperimentalFoundationApi::class) @Composable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt index 1c67d0241b..644b0e02b0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/followPacks/list/FollowPacksTopBar.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.ui.navigation.topbars.UserDrawerSearchTopBar import com.vitorpamplona.amethyst.ui.screen.FeedDefinition import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent @Composable fun FollowPacksTopBar( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt index 8733e7a42f..dcc16a37a9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.note.creators.userSuggestions.UserSuggestionState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow @@ -57,7 +57,7 @@ class PeopleListViewModel : ViewModel() { selectedDTag .transformLatest { emitAll( - account.peopleLists.selectListFlow(it).flowOn(Dispatchers.IO), + account.followSets.selectListFlow(it).flowOn(Dispatchers.IO), ) }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null) @@ -79,23 +79,23 @@ class PeopleListViewModel : ViewModel() { } suspend fun deleteFollowSet() { - account.peopleLists.deleteFollowSet(selectedDTag.value, account) + account.followSets.deleteFollowSet(selectedDTag.value, account) } - fun loadNote(): AddressableNote? = account.peopleLists.getPeopleListNote(selectedDTag.value) + fun loadNote(): AddressableNote? = account.followSets.getPeopleListNote(selectedDTag.value) suspend fun removeUserFromSet( user: User, isPrivate: Boolean, ) { - account.peopleLists.removeUserFromSet(user, isPrivate, selectedDTag.value, account) + account.followSets.removeUserFromSet(user, isPrivate, selectedDTag.value, account) } suspend fun addUserToSet( user: User, isPrivate: Boolean, ) { - account.peopleLists.addUserToSet(user, selectedDTag.value, isPrivate, account) + account.followSets.addUserToSet(user, selectedDTag.value, isPrivate, account) } fun hasUserFlow( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt index f54fa456ca..002eb5f4a6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.ui.note.creators.userSuggestions.UserSuggestionState import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow @@ -57,7 +57,7 @@ class FollowPackViewModel : ViewModel() { selectedDTag .transformLatest { emitAll( - account.followLists.selectListFlow(it).flowOn(Dispatchers.IO), + account.starterPacks.selectListFlow(it).flowOn(Dispatchers.IO), ) }.flowOn(Dispatchers.IO) .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), null) @@ -79,17 +79,17 @@ class FollowPackViewModel : ViewModel() { } suspend fun deleteFollowSet() { - account.followLists.deleteFollowSet(selectedDTag.value, account) + account.starterPacks.deleteFollowSet(selectedDTag.value, account) } - fun loadNote(): AddressableNote? = account.followLists.getPeopleListNote(selectedDTag.value) + fun loadNote(): AddressableNote? = account.starterPacks.getPeopleListNote(selectedDTag.value) suspend fun removeUserFromSet(user: User) { - account.followLists.removeUserFromSet(user, selectedDTag.value, account) + account.starterPacks.removeUserFromSet(user, selectedDTag.value, account) } suspend fun addUserToSet(user: User) { - account.followLists.addUserToSet(user, selectedDTag.value, account) + account.starterPacks.addUserToSet(user, selectedDTag.value, account) } fun hasUserFlow(user: User): Flow<Boolean> = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/FollowPackViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/FollowPackViewModel.kt index ad08cf8121..a2bdd2eb2d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/FollowPackViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/FollowPackViewModel.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.list import androidx.compose.runtime.Stable import androidx.lifecycle.ViewModel -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @Stable @@ -33,7 +33,7 @@ class FollowPackViewModel : ViewModel() { this.accountViewModel = accountViewModel } - fun listFlow() = accountViewModel.account.followLists.uiListFlow + fun listFlow() = accountViewModel.account.starterPacks.uiListFlow fun cloneItem( followSet: PeopleList, @@ -41,7 +41,7 @@ class FollowPackViewModel : ViewModel() { customDescription: String?, ) { accountViewModel.launchSigner { - accountViewModel.account.followLists.cloneFollowSet( + accountViewModel.account.starterPacks.cloneFollowSet( currentFollowPack = followSet, customCloneName = customName, customCloneDescription = customDescription, @@ -52,7 +52,7 @@ class FollowPackViewModel : ViewModel() { fun deleteItem(followSet: PeopleList) { accountViewModel.launchSigner { - accountViewModel.account.followLists.deleteFollowSet( + accountViewModel.account.starterPacks.deleteFollowSet( identifierTag = followSet.identifierTag, account = accountViewModel.account, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/PeopleListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/PeopleListViewModel.kt index 94e853c494..808b175ada 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/PeopleListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/PeopleListViewModel.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.list import androidx.compose.runtime.Stable import androidx.lifecycle.ViewModel -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @Stable @@ -33,7 +33,7 @@ class PeopleListViewModel : ViewModel() { this.accountViewModel = accountViewModel } - fun listFlow() = accountViewModel.account.peopleLists.uiListFlow + fun listFlow() = accountViewModel.account.followSets.uiListFlow fun cloneItem( followSet: PeopleList, @@ -41,7 +41,7 @@ class PeopleListViewModel : ViewModel() { customDescription: String?, ) { accountViewModel.launchSigner { - accountViewModel.account.peopleLists.cloneFollowSet( + accountViewModel.account.followSets.cloneFollowSet( currentPeopleList = followSet, customCloneName = customName, customCloneDescription = customDescription, @@ -52,7 +52,7 @@ class PeopleListViewModel : ViewModel() { fun deleteItem(followSet: PeopleList) { accountViewModel.launchSigner { - accountViewModel.account.peopleLists.deleteFollowSet( + accountViewModel.account.followSets.deleteFollowSet( identifierTag = followSet.identifierTag, account = accountViewModel.account, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/FollowPackMetadataViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/FollowPackMetadataViewModel.kt index 695e5e0985..89c0ab56f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/FollowPackMetadataViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/FollowPackMetadataViewModel.kt @@ -31,7 +31,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.mediaServers.ServerType -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.avif_metadata_strip_failed import com.vitorpamplona.amethyst.commons.resources.failed_to_upload_media_no_details @@ -83,7 +83,7 @@ class FollowPackMetadataViewModel : ViewModel() { } fun load(dTag: String) { - peopleList = account.followLists.selectList(dTag) + peopleList = account.starterPacks.selectList(dTag) name.value = TextFieldValue(peopleList?.title ?: "") picture.value = TextFieldValue(peopleList?.image ?: "") description.value = TextFieldValue(peopleList?.description ?: "") @@ -94,14 +94,14 @@ class FollowPackMetadataViewModel : ViewModel() { val peopleList = peopleList if (peopleList == null) { val newListIdentifier = - accountViewModel.account.followLists.addFollowList( + accountViewModel.account.starterPacks.addFollowList( name = name.value.text, desc = description.value.text, image = picture.value.text, account = accountViewModel.account, ) } else { - accountViewModel.account.followLists.updateMetadata( + accountViewModel.account.starterPacks.updateMetadata( name = name.value.text, desc = description.value.text, image = picture.value.text, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/PeopleListMetadataViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/PeopleListMetadataViewModel.kt index 9e5ebac387..70a193bb50 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/PeopleListMetadataViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/metadata/PeopleListMetadataViewModel.kt @@ -31,7 +31,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.commons.model.mediaServers.ServerType -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.avif_metadata_strip_failed import com.vitorpamplona.amethyst.commons.resources.failed_to_upload_media_no_details @@ -83,7 +83,7 @@ class PeopleListMetadataViewModel : ViewModel() { } fun load(dTag: String) { - peopleList = account.peopleLists.selectList(dTag) + peopleList = account.followSets.selectList(dTag) name.value = TextFieldValue(peopleList?.title ?: "") picture.value = TextFieldValue(peopleList?.image ?: "") description.value = TextFieldValue(peopleList?.description ?: "") @@ -95,14 +95,14 @@ class PeopleListMetadataViewModel : ViewModel() { accountViewModel.launchSigner { val peopleList = peopleList if (peopleList == null) { - accountViewModel.account.peopleLists.addFollowList( + accountViewModel.account.followSets.addFollowList( listName = name.value.text, listDescription = description.value.text, listImage = picture.value.text, account = accountViewModel.account, ) } else { - accountViewModel.account.peopleLists.updateMetadata( + accountViewModel.account.followSets.updateMetadata( listName = name.value.text, listDescription = description.value.text, listImage = picture.value.text, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/FollowListAndPackAndUserView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/FollowListAndPackAndUserView.kt index 7f61e68033..4dbd832a96 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/FollowListAndPackAndUserView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/FollowListAndPackAndUserView.kt @@ -63,9 +63,9 @@ fun FollowListAndPackAndUserView( accountViewModel: AccountViewModel, nav: INav, ) { - val followSetsState by accountViewModel.account.peopleLists.uiListFlow + val followSetsState by accountViewModel.account.followSets.uiListFlow .collectAsStateWithLifecycle() - val followPackFeedState by accountViewModel.account.followLists.uiListFlow + val followPackFeedState by accountViewModel.account.starterPacks.uiListFlow .collectAsStateWithLifecycle() val userName by observeUserName(userToAddOrRemove, accountViewModel) @@ -114,7 +114,7 @@ fun FollowListAndPackAndUserView( userIsPublicMember = list.publicMembers.contains(userToAddOrRemove), onRemoveUser = { accountViewModel.launchSigner { - accountViewModel.account.peopleLists.removeUserFromSet( + accountViewModel.account.followSets.removeUserFromSet( userToAddOrRemove, isPrivate = list.privateMembers.contains(userToAddOrRemove), list.identifierTag, @@ -129,7 +129,7 @@ fun FollowListAndPackAndUserView( }, onAddUserToList = { userShouldBePrivate -> accountViewModel.launchSigner { - accountViewModel.account.peopleLists.addUserToSet( + accountViewModel.account.followSets.addUserToSet( userToAddOrRemove, list.identifierTag, userShouldBePrivate, @@ -189,7 +189,7 @@ fun FollowListAndPackAndUserView( }, onRemoveUser = { accountViewModel.launchSigner { - accountViewModel.account.followLists.removeUserFromSet( + accountViewModel.account.starterPacks.removeUserFromSet( userToAddOrRemove, list.identifierTag, accountViewModel.account, @@ -199,7 +199,7 @@ fun FollowListAndPackAndUserView( memberSize = list.publicMembers.size, onAddUserToList = { accountViewModel.launchSigner { - accountViewModel.account.followLists.addUserToSet( + accountViewModel.account.starterPacks.addUserToSet( userToAddOrRemove, list.identifierTag, accountViewModel.account, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/followers/FollowersTabHeader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/followers/FollowersTabHeader.kt index 8f5a8fe47f..ce6c0e9dc2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/followers/FollowersTabHeader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/followers/FollowersTabHeader.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.number_followers import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserContactCardsFollowerCount +import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserAssertionsFollowerCount import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.followers.dal.UserProfileFollowersUserFeedViewModel @@ -38,7 +38,7 @@ fun FollowersTabHeader( followersFeedViewModel: UserProfileFollowersUserFeedViewModel, accountViewModel: AccountViewModel, ) { - val followerCount by observeUserContactCardsFollowerCount(baseUser, accountViewModel) + val followerCount by observeUserAssertionsFollowerCount(baseUser, accountViewModel) if (followerCount == "--") { FollowersTabHeaderLocal(followersFeedViewModel, accountViewModel) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserNicknameCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserNicknameCard.kt index e614a462df..5e666661c5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserNicknameCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserNicknameCard.kt @@ -73,8 +73,8 @@ fun UserNicknameCard( WatchAndLoadMyEmojiList(accountViewModel) EditNicknameDialog( user = baseUser, - contactCards = accountViewModel.account.contactCards, - onSave = { petName, summary -> accountViewModel.updateContactCardPetName(baseUser, petName, summary) }, + userAssertions = accountViewModel.account.userAssertions, + onSave = { petName, summary -> accountViewModel.updateUserAssertionPetName(baseUser, petName, summary) }, onDismiss = { isEditDialogOpen.value = false }, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserProfileDropDownMenu.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserProfileDropDownMenu.kt index 07a9bc477b..78f5d38f66 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserProfileDropDownMenu.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/header/UserProfileDropDownMenu.kt @@ -71,8 +71,8 @@ fun UserProfileDropDownMenu( WatchAndLoadMyEmojiList(accountViewModel) EditNicknameDialog( user = user, - contactCards = accountViewModel.account.contactCards, - onSave = { petName, summary -> accountViewModel.updateContactCardPetName(user, petName, summary) }, + userAssertions = accountViewModel.account.userAssertions, + onSave = { petName, summary -> accountViewModel.updateUserAssertionPetName(user, petName, summary) }, onDismiss = { isNicknameDialogOpen.value = false }, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt index 51a2e0107d..42082044f7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/AllRelayListScreen.kt @@ -109,7 +109,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.connected.ConnectedR import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.connected.renderConnectedItems import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.dm.DMRelayListViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.dm.renderDMItems -import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.feeds.RelayFeedsListViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.feeds.FavoriteRelayListViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.feeds.renderRelayFeedsItems import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.indexer.IndexerRelayListViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.indexer.renderIndexerItems @@ -148,7 +148,7 @@ fun AllRelayListScreen( val broadcastViewModel: BroadcastRelayListViewModel = viewModel() val indexerViewModel: IndexerRelayListViewModel = viewModel() val proxyViewModel: ProxyRelayListViewModel = viewModel() - val relayFeedsViewModel: RelayFeedsListViewModel = viewModel() + val relayFeedsViewModel: FavoriteRelayListViewModel = viewModel() dmViewModel.init(accountViewModel) keyPackageViewModel.init(accountViewModel) @@ -214,7 +214,7 @@ fun MappedAllRelayListView( broadcastViewModel: BroadcastRelayListViewModel, indexerViewModel: IndexerRelayListViewModel, proxyViewModel: ProxyRelayListViewModel, - relayFeedsViewModel: RelayFeedsListViewModel, + relayFeedsViewModel: FavoriteRelayListViewModel, accountViewModel: AccountViewModel, nav: INav, ) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt index 0684f76185..c8b6e75aaf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/KindDisplayName.kt @@ -248,12 +248,11 @@ import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent @@ -261,6 +260,7 @@ import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent @@ -274,7 +274,7 @@ import com.vitorpamplona.quartz.nip53LiveActivities.presence.MeetingRoomPresence import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip54Wiki.WikiArticleEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent @@ -434,7 +434,7 @@ fun kindDisplayName(kind: Int): StringResource? = Bolt12ZapEvent.KIND -> Res.string.kind_zaps NwcRequestEvent.KIND -> Res.string.kind_nwc_request NwcResponseEvent.KIND -> Res.string.kind_nwc_response - LnZapPrivateEvent.KIND -> Res.string.kind_private_zaps + PrivateZapEvent.KIND -> Res.string.kind_private_zaps ZapRequestEvent.KIND -> Res.string.kind_zap_req LongFormContentEvent.KIND -> Res.string.kind_blogs MeetingRoomEvent.KIND -> Res.string.kind_meeting_room diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/RelayFeedsListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/FavoriteRelayListViewModel.kt similarity index 90% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/RelayFeedsListViewModel.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/FavoriteRelayListViewModel.kt index aab6d86fd0..91fd7cf9a6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/RelayFeedsListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/FavoriteRelayListViewModel.kt @@ -25,12 +25,12 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySet import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl @Stable -class RelayFeedsListViewModel : BasicRelaySetupInfoModel() { +class FavoriteRelayListViewModel : BasicRelaySetupInfoModel() { override fun getRelayList(): List<NormalizedRelayUrl> = - account.relayFeedsList.flow.value + account.favoriteRelayList.flow.value .toList() override suspend fun saveRelayList(urlList: List<NormalizedRelayUrl>) { - account.saveRelayFeedsList(urlList) + account.saveFavoriteRelayList(urlList) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/RelayFeedsListView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/RelayFeedsListView.kt index 2c77021427..cf07d2053d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/RelayFeedsListView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/feeds/RelayFeedsListView.kt @@ -45,8 +45,8 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.RelayUrlEditF import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.relaySetupInfoBuilder @Composable -fun RelayFeedsList( - postViewModel: RelayFeedsListViewModel, +fun FavoriteRelayList( + postViewModel: FavoriteRelayListViewModel, accountViewModel: AccountViewModel, onClose: () -> Unit, nav: INav, @@ -71,7 +71,7 @@ fun RelayFeedsList( fun LazyListScope.renderRelayFeedsItems( feedState: List<BasicRelaySetupInfo>, - postViewModel: RelayFeedsListViewModel, + postViewModel: FavoriteRelayListViewModel, accountViewModel: AccountViewModel, nav: INav, dragState: RelayDragState? = null, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index 74d6155773..75050af4ad 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -176,17 +176,17 @@ import com.vitorpamplona.amethyst.ui.note.types.DisplayBlockedRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayBroadcastRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayContactList import com.vitorpamplona.amethyst.ui.note.types.DisplayDMRelayList -import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList +import com.vitorpamplona.amethyst.ui.note.types.DisplayFavoriteRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayIndexerRelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayNIP65RelayList import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList import com.vitorpamplona.amethyst.ui.note.types.DisplayProxyRelayList -import com.vitorpamplona.amethyst.ui.note.types.DisplayRelayFeedsList import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet import com.vitorpamplona.amethyst.ui.note.types.DisplaySearchRelayList +import com.vitorpamplona.amethyst.ui.note.types.DisplayStarterPack import com.vitorpamplona.amethyst.ui.note.types.DisplayTrustedRelayList import com.vitorpamplona.amethyst.ui.note.types.EditState -import com.vitorpamplona.amethyst.ui.note.types.FileHeaderDisplay +import com.vitorpamplona.amethyst.ui.note.types.FileMetadataDisplay import com.vitorpamplona.amethyst.ui.note.types.FileStorageHeaderDisplay import com.vitorpamplona.amethyst.ui.note.types.MAX_THREAD_SECTIONS import com.vitorpamplona.amethyst.ui.note.types.PictureDisplay @@ -223,7 +223,6 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderHighlight import com.vitorpamplona.amethyst.ui.note.types.RenderInteractiveStory import com.vitorpamplona.amethyst.ui.note.types.RenderLearningResource import com.vitorpamplona.amethyst.ui.note.types.RenderLiveActivityChatMessage -import com.vitorpamplona.amethyst.ui.note.types.RenderLnZap import com.vitorpamplona.amethyst.ui.note.types.RenderMeetingRoomEvent import com.vitorpamplona.amethyst.ui.note.types.RenderMeetingSpaceEvent import com.vitorpamplona.amethyst.ui.note.types.RenderMusicPlaylist @@ -263,6 +262,7 @@ import com.vitorpamplona.amethyst.ui.note.types.RenderTextModificationEvent import com.vitorpamplona.amethyst.ui.note.types.RenderTorrent import com.vitorpamplona.amethyst.ui.note.types.RenderTorrentComment import com.vitorpamplona.amethyst.ui.note.types.RenderZapPoll +import com.vitorpamplona.amethyst.ui.note.types.RenderZapReceipt import com.vitorpamplona.amethyst.ui.note.types.ReplyRenderType import com.vitorpamplona.amethyst.ui.note.types.VideoDisplay import com.vitorpamplona.amethyst.ui.note.types.VoiceHeader @@ -343,8 +343,7 @@ import com.vitorpamplona.quartz.nip43RelayMembers.list.RelayMembershipListEvent import com.vitorpamplona.quartz.nip43RelayMembers.removeMember.RelayRemoveMemberEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent @@ -353,6 +352,7 @@ import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent @@ -897,13 +897,13 @@ private fun FullBleedNoteCompose( } else if (noteEvent is BaseVoiceEvent) { VoiceHeader(noteEvent, baseNote, accountViewModel, nav) } else if (noteEvent is FileMetadataEvent) { - FileHeaderDisplay(baseNote, roundedCorner = true, ContentScale.FillWidth, accountViewModel = accountViewModel) + FileMetadataDisplay(baseNote, roundedCorner = true, ContentScale.FillWidth, accountViewModel = accountViewModel) } else if (noteEvent is FileStorageHeaderEvent) { FileStorageHeaderDisplay(baseNote, roundedCorner = true, ContentScale.FillWidth, accountViewModel = accountViewModel) } else if (noteEvent is FollowSetEvent) { DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is StarterPackEvent) { - DisplayFollowList(baseNote, false, accountViewModel, nav) + DisplayStarterPack(baseNote, false, accountViewModel, nav) } else if (noteEvent is ContactListEvent) { DisplayContactList(baseNote, accountViewModel, nav) } else if (noteEvent is AudioTrackEvent) { @@ -978,7 +978,7 @@ private fun FullBleedNoteCompose( } else if (noteEvent is AdvertisedRelayListEvent) { DisplayNIP65RelayList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is ZapReceiptEvent) { - RenderLnZap(baseNote, quotesLeft = 3, backgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav) + RenderZapReceipt(baseNote, quotesLeft = 3, backgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav) } else if (noteEvent is NutzapEvent) { RenderNutzap(baseNote, quotesLeft = 3, backgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav) } else if (noteEvent is OnchainZapEvent) { @@ -996,7 +996,7 @@ private fun FullBleedNoteCompose( } else if (noteEvent is TrustedRelayListEvent) { DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is FavoriteRelayListEvent) { - DisplayRelayFeedsList(baseNote, backgroundColor, accountViewModel, nav) + DisplayFavoriteRelayList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is IndexerRelayListEvent) { DisplayIndexerRelayList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is BroadcastRelayListEvent) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileHeaderCardCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileMetadataCardCompose.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileHeaderCardCompose.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileMetadataCardCompose.kt index 523cb12efd..4b74c1ddf4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileHeaderCardCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/FileMetadataCardCompose.kt @@ -47,7 +47,7 @@ import com.vitorpamplona.amethyst.ui.components.ZoomableContentView import com.vitorpamplona.amethyst.ui.components.collectContentWarningReasons import com.vitorpamplona.amethyst.ui.components.mediaSizingModifier import com.vitorpamplona.amethyst.ui.note.ReactionsRow -import com.vitorpamplona.amethyst.ui.note.types.FileHeaderAttachmentCard +import com.vitorpamplona.amethyst.ui.note.types.FileMetadataAttachmentCard import com.vitorpamplona.amethyst.ui.note.types.toMediaContent import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.nip01Core.core.Event @@ -55,7 +55,7 @@ import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitiveOrNSFW import com.vitorpamplona.quartz.nip94FileMetadata.FileMetadataEvent @Composable -fun FileHeaderCardCompose( +fun FileMetadataCardCompose( baseNote: Note, accountViewModel: AccountViewModel, nav: INav, @@ -70,7 +70,7 @@ fun FileHeaderCardCompose( UserCardHeader(baseNote, accountViewModel, nav) // Image content - FileHeaderCardImage(baseNote, event, backgroundColor, accountViewModel) + FileMetadataCardImage(baseNote, event, backgroundColor, accountViewModel) // Reactions row ReactionsRow( @@ -83,12 +83,12 @@ fun FileHeaderCardCompose( ) // Title and content - FileHeaderCardCaption(event) + FileMetadataCardCaption(event) } } @Composable -private fun FileHeaderCardImage( +private fun FileMetadataCardImage( note: Note, event: FileMetadataEvent, backgroundColor: MutableState<Color>, @@ -108,7 +108,7 @@ private fun FileHeaderCardImage( // Reachable despite VideoFeedFilter admitting only image/video types: the filter accepts on // `urls().any { … }` while this card renders `url()`, the first tag — so a multi-mirror event // whose first URL is unrenderable lands here. The gate wraps it for the same reason it wraps - // the viewer in FileHeaderDisplay: a content warning is about the file, and the card still + // the viewer in FileMetadataDisplay: a content warning is about the file, and the card still // spells out its filename, alt text, MIME and size. Sizing stays on the gate's defaults // (fillMaxWidth, no backdrop) — a link card has no aspect ratio to reserve and no blurhash // to show behind it. @@ -119,7 +119,7 @@ private fun FileHeaderCardImage( preloadUrls = emptyList(), accountViewModel = accountViewModel, ) { - FileHeaderAttachmentCard(event, fullUrl, mimeType) + FileMetadataAttachmentCard(event, fullUrl, mimeType) } return } @@ -145,7 +145,7 @@ private fun FileHeaderCardImage( } @Composable -internal fun FileHeaderCardCaption(videoEvent: FileMetadataEvent) { +internal fun FileMetadataCardCaption(videoEvent: FileMetadataEvent) { val event = (videoEvent as? Event) ?: return val title = videoEvent.summary() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt index d9b3fe531b..7615245745 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt @@ -200,7 +200,7 @@ fun VideoFeedLoaded( } item.event is FileMetadataEvent -> { - FileHeaderCardCompose(item, accountViewModel, nav) + FileMetadataCardCompose(item, accountViewModel, nav) HorizontalDivider( thickness = DividerThickness, diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt index 63bbe4a78b..6f0365319d 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/resourceusage/ResourceUsageLedgerTest.kt @@ -43,7 +43,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.commands.toRelay.ReqCmd import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import io.mockk.every import io.mockk.mockk @@ -650,7 +650,7 @@ class MeteringNostrSignerTest { fromPublicKey: HexKey, ) = "dec44" - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw UnsupportedOperationException("fake") + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = throw UnsupportedOperationException("fake") override suspend fun deriveKey(nonce: HexKey): HexKey = "bb".repeat(32) diff --git a/cli/plans/archive/2026-04-23-nip17-dm.md b/cli/plans/archive/2026-04-23-nip17-dm.md index 28918e37e2..7a46443a45 100644 --- a/cli/plans/archive/2026-04-23-nip17-dm.md +++ b/cli/plans/archive/2026-04-23-nip17-dm.md @@ -42,7 +42,7 @@ DMs); on `list`/`await` it filters by counter-party. | Build `kind:14` chat message template | `ChatMessageEvent.build(msg, to, …)` | `quartz/.../nip17Dm/messages/ChatMessageEvent.kt:51` | | Sign + seal + wrap (one wrap per recipient incl. self) | `NIP17Factory().createMessageNIP17(template, signer)` | `quartz/.../nip17Dm/NIP17Factory.kt:37` | | `GiftWrapEvent.create / unwrapOrNull / recipientPubKey` | `GiftWrapEvent` (kind 1059) | `quartz/.../nip59Giftwrap/wraps/GiftWrapEvent.kt` | -| Inner seal layer (kind 13) | `SealedRumorEvent` | `quartz/.../nip59Giftwrap/seals/SealedRumorEvent.kt` | +| Inner seal layer (kind 13) | `SealEvent` | `quartz/.../nip59Giftwrap/seals/SealEvent.kt` | | NIP-44 v2 encrypt/decrypt (called from wrap/seal) | `Nip44` singleton | `quartz/.../nip44Encryption/Nip44.kt` | | Resolve recipient relay lists (10050 / 10051 / 10002) | `RecipientRelayFetcher.fetchRelayLists` | `quartz/.../marmot/RecipientRelayFetcher.kt:80` | | Publish + per-relay ACK | `Context.publish(event, relays)` | `cli/.../Context.kt:154` | @@ -58,7 +58,7 @@ Everything above is already on the JVM classpath of the `cli` module. | Piece | Status | Current | Target | Notes | |---|---|---|---|---| -| `NIP17Factory`, `GiftWrapEvent`, `SealedRumorEvent`, `Nip44`, `ChatMessageEvent` | ✅ Reuse | `quartz/` | — | Pure protocol; CLI calls directly. | +| `NIP17Factory`, `GiftWrapEvent`, `SealEvent`, `Nip44`, `ChatMessageEvent` | ✅ Reuse | `quartz/` | — | Pure protocol; CLI calls directly. | | `RecipientRelayFetcher.fetchRelayLists` | ✅ Reuse | `quartz/.../marmot/` | — | Already used by `AwaitCommands.awaitKeyPackage`; same call shape. | | `filterGiftWrapsToPubkey` | 📦 Extract | `amethyst/.../service/relayClient/reqCommand/account/nip59GiftWraps/FilterGiftWrapsToPubkey.kt:31` | `commons/.../relayClient/nip17Dm/FilterGiftWrapsToPubkey.kt` | Pure function, no Android deps. Update Android caller (`AccountGiftWrapsEoseManager.kt:55`) in the same commit. | | Per-recipient relay routing (kind:10050 → 10002 read → bootstrap) | 🆕 New (in CLI) | inline inside `Account.computeRelayListToBroadcast` (`amethyst/.../model/Account.kt:908`) | `cli/.../commands/DmCommands.kt` (private helper) | Tiny — three-line fallback. Promoting it to commons can wait until a second consumer appears. | @@ -133,7 +133,7 @@ raw = ctx.drain(filters, timeoutMs = --timeout * 1000 ?: 8_000) ↓ messages = raw.mapNotNull { (relay, event) -> if (event !is GiftWrapEvent) return@mapNotNull null - val sealed = event.unwrapOrNull(ctx.signer) as? SealedRumorEvent ?: return@mapNotNull null + val sealed = event.unwrapOrNull(ctx.signer) as? SealEvent ?: return@mapNotNull null val inner = sealed.unsealOrNull(ctx.signer) as? ChatMessageEvent ?: return@mapNotNull null DecryptedMsg(inner, relay, event.id) }.dedupBy { it.inner.id } diff --git a/commons/plans/2026-05-04-custom-feeds-plan.md b/commons/plans/2026-05-04-custom-feeds-plan.md index 1a54116a6a..f572a0d9cf 100644 --- a/commons/plans/2026-05-04-custom-feeds-plan.md +++ b/commons/plans/2026-05-04-custom-feeds-plan.md @@ -463,7 +463,7 @@ class FeedBuilderState(initial: FeedDefinition?) { - DVM request goes to DVM's advertised relays (from kind 31990 `relay` tags) - Response subscription listens on both user's relays AND DVM's relays - Use `MetadataPreloader` for bulk-fetching author metadata of returned notes -- Reuse existing `NIP90ContentDiscoveryRequestEvent.build()` pattern from Quartz +- Reuse existing `DvmContentDiscoveryRequestEvent.build()` pattern from Quartz ### Phase 7: Publish/Import (kind 31890) @@ -532,7 +532,7 @@ commons/src/commonTest/kotlin/.../feeds/custom/ | `TopFilter` | `amethyst/.../AccountSettings.kt` | Reference; `FeedSource.toTopFilter()` for bridge | | `FavoriteAlgoFeedsOrchestrator` | `amethyst/.../algoFeeds/` | Extract to commons for DVM reuse | | `FavoriteAlgoFeedsListEvent` (kind 10090) | `quartz/.../nip51Lists/` | Pinned feed sync | -| `NIP90ContentDiscoveryRequestEvent` | `quartz/.../nip90Dvms/` | DVM request building | +| `DvmContentDiscoveryRequestEvent` | `quartz/.../nip90Dvms/` | DVM request building | | `AppDefinitionEvent` (kind 31990) | `quartz/.../nip89AppHandlers/` | DVM marketplace discovery | | `NAddress` | `quartz/.../nip19Bech32/entities/` | naddr encode/decode | | `Nip19Parser` | `quartz/.../nip19Bech32/` | Detect pasted naddr | @@ -542,7 +542,7 @@ commons/src/commonTest/kotlin/.../feeds/custom/ | `PinnedNavBarState` | `desktopApp/.../deck/PinnedNavBarState.kt` | Reference pattern for pin state | | `HomeFeed` rendering | `desktopApp/.../home/` | Phase 2 content reuse | | `BaseAddressableEvent` | `quartz/.../nip01Core/core/` | Base for kind 31890 | -| `PeopleListEvent` / `InterestSetEvent` | `quartz/.../nip51Lists/` | Resolve ATag -> members | +| `FollowSetEvent` / `InterestSetEvent` | `quartz/.../nip51Lists/` | Resolve ATag -> members | | `MetadataPreloader` | `commons/.../relayClient/` | Bulk metadata fetch for feed results | | `FeedMetadataCoordinator` | `commons/.../relayClient/` | Coordinate metadata for visible notes | | `ComposeSubscriptionManager` | `commons/.../relayClient/` | Subscription lifecycle | diff --git a/commons/plans/2026-08-30-commons-migration-sweep.md b/commons/plans/2026-08-30-commons-migration-sweep.md index 20982ddae2..4d148d22a9 100644 --- a/commons/plans/2026-08-30-commons-migration-sweep.md +++ b/commons/plans/2026-08-30-commons-migration-sweep.md @@ -934,7 +934,7 @@ measured picture. are handled; the 9 without a dedicated `EventCache` overload (`TextNoteEvent`, `ContactListEvent`, `CommentEvent`, `AdvertisedRelayListEvent`, `BlossomServersEvent`, `BookmarkListEvent`, - `OldBookmarkListEvent`, `ChatMessageRelayListEvent`, `FollowListEvent`) fall + `OldBookmarkListEvent`, `DmRelayListEvent`, `StarterPackEvent`) fall into the generic replaceable/addressable group. - **13 of 13 core read methods match** by name and signature. - **Feed retention is already aligned** — both platforms hold feed content @@ -982,7 +982,7 @@ a deletion: ~500 lines of genuinely Desktop-specific state survive, and the concentrated in five places (metadata, contact list, follow pack, live activity, `clear`) and re-derive cleanly from the event after consume. 4. **Two Desktop-shaped `consume` overloads do not generalize** — the NIP-47 - `LnZapPaymentRequestEvent` one takes a `zappedNote` and an `onResponse` + `NwcRequestEvent` one takes a `zappedNote` and an `onResponse` callback, and the response one drives `paymentTracker` + `appScope`. Android reaches the same tracker through account state. Keep them Desktop-side. 5. **`clear()`** has only 2 production call sites (`Main.kt`, logout/account diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt index f5e80b7685..07b0376e67 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/account/AccountBootstrapEvents.kt @@ -62,8 +62,8 @@ data class AccountBootstrapEvents( val keyPackageRelayList: KeyPackageRelayListEvent, val searchRelayList: SearchRelayListEvent, val indexerRelayList: IndexerRelayListEvent, - val channelList: PublicChatListEvent, - val relayFeedsList: FavoriteRelayListEvent, + val publicChatList: PublicChatListEvent, + val favoriteRelayList: FavoriteRelayListEvent, ) { /** All nine signed events in publication order. */ fun all(): List<com.vitorpamplona.quartz.nip01Core.core.Event> = @@ -75,8 +75,8 @@ data class AccountBootstrapEvents( keyPackageRelayList, searchRelayList, indexerRelayList, - channelList, - relayFeedsList, + publicChatList, + favoriteRelayList, ) } @@ -109,6 +109,6 @@ fun bootstrapAccountEvents( keyPackageRelayList = KeyPackageRelayListEvent.create(DefaultNIP65RelaySet.toList(), signer), searchRelayList = SearchRelayListEvent.create(DefaultSearchRelayList.toList(), signer), indexerRelayList = IndexerRelayListEvent.create(DefaultIndexerRelayList.toList(), signer), - channelList = PublicChatListEvent.create(emptyList(), DefaultChannels, signer), - relayFeedsList = FavoriteRelayListEvent.create(DefaultGlobalRelays, signer), + publicChatList = PublicChatListEvent.create(emptyList(), DefaultChannels, signer), + favoriteRelayList = FavoriteRelayListEvent.create(DefaultGlobalRelays, signer), ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt index f32456f1c1..b1ffb3334d 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/backups/ReplaceableBackupConflict.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip40Expiration.ExpirationTag import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt index 1789346dcf..0954ef7a9e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/cache/EventCache.kt @@ -290,14 +290,13 @@ import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent @@ -307,6 +306,7 @@ import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent @@ -327,9 +327,9 @@ import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent -import com.vitorpamplona.quartz.nip57Zaps.validate.LnZapReceiptValidator import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlEndpointResolver import com.vitorpamplona.quartz.nip57Zaps.validate.LnurlForm +import com.vitorpamplona.quartz.nip57Zaps.validate.ZapReceiptValidator import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent import com.vitorpamplona.quartz.nip58Badges.award.BadgeAwardEvent import com.vitorpamplona.quartz.nip58Badges.definition.BadgeDefinitionEvent @@ -2252,7 +2252,7 @@ open class EventCache : val new = consumeBaseReplaceable(event, relay, wasVerified) if (relay != null && isRelaySignedGroupEvent(event, relay)) { val latest = getOrCreateAddressableNote(event.address()).event as? GroupRolesEvent - latest?.let { getOrCreateRelayGroupChannel(GroupId(it.groupId(), relay)).updateSupportedRoles(it) } + latest?.let { getOrCreateRelayGroupChannel(GroupId(it.groupId(), relay)).updateGroupRoles(it) } } return new } @@ -2712,18 +2712,18 @@ open class EventCache : if (cachedInfo != null) { val result = - LnZapReceiptValidator.validate( + ZapReceiptValidator.validate( receipt = event, expectedNostrPubkey = cachedInfo.nostrPubkey, expectedLnurl = recipientLnurl, ) - if (result is LnZapReceiptValidator.Result.Invalid && - result.reason != LnZapReceiptValidator.Result.Reason.MISMATCHED_LNURL + if (result is ZapReceiptValidator.Result.Invalid && + result.reason != ZapReceiptValidator.Result.Reason.MISMATCHED_LNURL ) { Log.w("ZP") { "dropping zap receipt ${event.id}: ${result.reason} ${result.detail ?: ""}" } return false } - if (result is LnZapReceiptValidator.Result.Invalid) { + if (result is ZapReceiptValidator.Result.Invalid) { Log.w("ZP") { "zap receipt ${event.id} has mismatched lnurl tag (accepting per SHOULD)" } } @@ -2759,18 +2759,18 @@ open class EventCache : return@launch } val result = - LnZapReceiptValidator.validate( + ZapReceiptValidator.validate( receipt = event, expectedNostrPubkey = info.nostrPubkey, expectedLnurl = recipientLnurl, ) - if (result is LnZapReceiptValidator.Result.Invalid && - result.reason != LnZapReceiptValidator.Result.Reason.MISMATCHED_LNURL + if (result is ZapReceiptValidator.Result.Invalid && + result.reason != ZapReceiptValidator.Result.Reason.MISMATCHED_LNURL ) { Log.w("ZP") { "dropping zap receipt ${event.id}: ${result.reason} ${result.detail ?: ""}" } return@launch } - if (result is LnZapReceiptValidator.Result.Invalid) { + if (result is ZapReceiptValidator.Result.Invalid) { Log.w("ZP") { "zap receipt ${event.id} has mismatched lnurl tag (accepting per SHOULD)" } } repliesTo.forEach { it.addZap(zapRequest, note) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt index 1f70bcea4b..da9e804fcb 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip28PublicChats/PublicChatListState.kt @@ -44,9 +44,9 @@ import kotlinx.coroutines.flow.transformLatest import kotlinx.coroutines.launch interface PublicChatListRepository { - fun channelList(): PublicChatListEvent? + fun publicChatList(): PublicChatListEvent? - fun updateChannelListTo(newChannelList: PublicChatListEvent?) + fun updatePublicChatListTo(newPublicChatList: PublicChatListEvent?) } class PublicChatListState( @@ -57,22 +57,22 @@ class PublicChatListState( val settings: PublicChatListRepository, ) { // Creates a long-term reference for this note so that the GC doesn't collect the note it self - val publicChatListNote = cache.getOrCreateAddressableNote(getChannelListAddress()) + val publicChatListNote = cache.getOrCreateAddressableNote(getPublicChatListAddress()) - fun getChannelListAddress() = PublicChatListEvent.createAddress(signer.pubKey) + fun getPublicChatListAddress() = PublicChatListEvent.createAddress(signer.pubKey) - fun getChannelListFlow(): StateFlow<NoteState> = publicChatListNote.flow().metadata.stateFlow + fun getPublicChatListFlow(): StateFlow<NoteState> = publicChatListNote.flow().metadata.stateFlow - fun getChannelList(): PublicChatListEvent? = publicChatListNote.event as? PublicChatListEvent + fun getPublicChatList(): PublicChatListEvent? = publicChatListNote.event as? PublicChatListEvent suspend fun publicChatListWithBackup(note: Note): Set<ChannelTag> { - val event = note.event as? PublicChatListEvent ?: settings.channelList() + val event = note.event as? PublicChatListEvent ?: settings.publicChatList() return event?.let { decryptionCache.channelSet(it) } ?: emptySet() } @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow<Set<ChannelTag>> = - getChannelListFlow() + getPublicChatListFlow() .transformLatest { noteState -> emit(publicChatListWithBackup(noteState.note)) }.onStart { @@ -112,7 +112,7 @@ class PublicChatListState( ) suspend fun follow(channel: PublicChatChannel): PublicChatListEvent { - val publicChatList = getChannelList() + val publicChatList = getPublicChatList() return if (publicChatList == null) { PublicChatListEvent.create(ChannelTag(channel.idHex, channel.relayHintUrl()), true, signer) @@ -122,7 +122,7 @@ class PublicChatListState( } suspend fun follow(channels: List<PublicChatChannel>): PublicChatListEvent { - val publicChatList = getChannelList() + val publicChatList = getPublicChatList() val channelTags = channels.map { ChannelTag(it.idHex, it.relayHintUrl()) } return if (publicChatList == null) { @@ -133,7 +133,7 @@ class PublicChatListState( } suspend fun unfollow(channel: PublicChatChannel): PublicChatListEvent? { - val publicChatList = getChannelList() + val publicChatList = getPublicChatList() return if (publicChatList != null) { PublicChatListEvent.remove(publicChatList, ChannelTag(channel.idHex, channel.relayHintUrl()), signer) @@ -143,7 +143,7 @@ class PublicChatListState( } init { - settings.channelList()?.let { event -> + settings.publicChatList()?.let { event -> Log.d("AccountRegisterObservers") { "Loading saved channel list ${event.toJson()}" } @OptIn(DelicateCoroutinesApi::class) scope.launch(Dispatchers.IO) { @@ -153,10 +153,10 @@ class PublicChatListState( scope.launch(Dispatchers.IO) { Log.d("AccountRegisterObservers", "Channel List Collector Start") - getChannelListFlow().collect { + getPublicChatListFlow().collect { Log.d("AccountRegisterObservers") { "Channel List for ${signer.pubKey}" } (it.note.event as? PublicChatListEvent)?.let { - settings.updateChannelListTo(it) + settings.updatePublicChatListTo(it) } } } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt index d1009af4cc..7849dfd3d0 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip29RelayGroups/RelayGroupChannel.kt @@ -109,9 +109,9 @@ class RelayGroupChannel( * the role names a moderation UI should offer when assigning a role, since the exact * set is relay-defined (NIP-29 §Group management). */ - var supportedRoles: List<RoleTag> = emptyList() + var groupRoles: List<RoleTag> = emptyList() private set - private var supportedRolesUpdatedAt: Long = 0 + private var groupRolesUpdatedAt: Long = 0 /** * Members ∪ admins, recomputed only when a roster event lands. [memberCount] and the discovery @@ -164,7 +164,7 @@ class RelayGroupChannel( event != null || members.isNotEmpty() || admins.isNotEmpty() || - supportedRoles.isNotEmpty() || + groupRoles.isNotEmpty() || pinnedEventIds.isNotEmpty() /** A relay group lives on exactly one relay: its host. */ @@ -237,11 +237,11 @@ class RelayGroupChannel( updateChannelInfo() } - fun updateSupportedRoles(event: GroupRolesEvent) { + fun updateGroupRoles(event: GroupRolesEvent) { // Only newer definitions supersede; equal-or-older is dropped (no redundant emit). - if (event.createdAt <= supportedRolesUpdatedAt) return - supportedRoles = event.roles() - supportedRolesUpdatedAt = event.createdAt + if (event.createdAt <= groupRolesUpdatedAt) return + groupRoles = event.roles() + groupRolesUpdatedAt = event.createdAt updateChannelInfo() } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt index 612e2c5673..eea948a198 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip30CustomEmojis/EmojiPackState.kt @@ -53,13 +53,13 @@ class EmojiPackState( ) // Creates a long-term reference for this note so that the GC doesn't collect the note it self - val emojiPackListNote = cache.getOrCreateAddressableNote(getEmojiPackSelectionAddress()) + val emojiPackListNote = cache.getOrCreateAddressableNote(getEmojiListAddress()) - fun getEmojiPackSelectionAddress() = EmojiListEvent.createAddress(signer.pubKey) + fun getEmojiListAddress() = EmojiListEvent.createAddress(signer.pubKey) - fun getEmojiPackSelection(): EmojiListEvent? = emojiPackListNote.event as? EmojiListEvent + fun getEmojiList(): EmojiListEvent? = emojiPackListNote.event as? EmojiListEvent - fun getEmojiPackSelectionFlow(): StateFlow<NoteState> = emojiPackListNote.flow().metadata.stateFlow + fun getEmojiListFlow(): StateFlow<NoteState> = emojiPackListNote.flow().metadata.stateFlow fun convertEmojiSelectionPack(selection: EmojiListEvent?): List<StateFlow<NoteState>>? = selection?.taggedAddresses()?.map { @@ -71,11 +71,11 @@ class EmojiPackState( @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow<List<StateFlow<NoteState>>?> = - getEmojiPackSelectionFlow() + getEmojiListFlow() .transformLatest { emit(convertEmojiSelectionPack(it.note.event as? EmojiListEvent)) }.onStart { - emit(convertEmojiSelectionPack(getEmojiPackSelection())) + emit(convertEmojiSelectionPack(getEmojiList())) }.flowOn(Dispatchers.IO) .stateIn( scope, @@ -115,7 +115,7 @@ class EmojiPackState( emit( mergePackWithPrivate( convertEmojiSelectionPack( - getEmojiPackSelection(), + getEmojiList(), )?.map { it.value }?.toTypedArray() ?: emptyArray(), ), ) @@ -149,7 +149,7 @@ class EmojiPackState( val eventHint = emojiPack.toEventHint<EmojiPackEvent>() ?: throw IllegalArgumentException("Cannot build event hint for this emoji pack.") - val usersEmojiList = getEmojiPackSelection() + val usersEmojiList = getEmojiList() return if (usersEmojiList == null) { val template = EmojiListEvent.build(listOf(eventHint)) signer.sign(template) @@ -160,7 +160,7 @@ class EmojiPackState( } suspend fun removeEmojiPack(emojiPack: Note): EmojiListEvent? { - val usersEmojiList = getEmojiPackSelection() ?: throw IllegalArgumentException("No emoji pack selection exists to remove from.") + val usersEmojiList = getEmojiList() ?: throw IllegalArgumentException("No emoji pack selection exists to remove from.") val emojiPackEvent = emojiPack.event if (emojiPackEvent !is EmojiPackEvent) return null diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt index 0d36cb6391..e0c991c18a 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/blockPeopleList/BlockPeopleListState.kt @@ -23,12 +23,12 @@ package com.vitorpamplona.amethyst.commons.model.nip51Lists.blockPeopleList import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.cache.LocalCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.FollowSetDecryptionCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.tags.MuteTag import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag import com.vitorpamplona.quartz.nip51Lists.muteList.tags.WordTag -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.IO @@ -42,7 +42,7 @@ import kotlinx.coroutines.flow.stateIn class BlockPeopleListState( val signer: NostrSigner, val cache: LocalCache, - val decryptionCache: PeopleListDecryptionCache, + val decryptionCache: FollowSetDecryptionCache, val scope: CoroutineScope, ) { // Creates a long-term reference for this note so that the GC doesn't collect the note it self diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkList.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/bookmarkSets/BookmarkSet.kt similarity index 94% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkList.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/bookmarkSets/BookmarkSet.kt index a3e8e03d70..3187738854 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/labeledBookmarkLists/LabeledBookmarkList.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/bookmarkSets/BookmarkSet.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists +package com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets import androidx.compose.runtime.Stable import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.AddressBookmark @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.BookmarkIdTag import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.EventBookmark @Stable -data class LabeledBookmarkList( +data class BookmarkSet( val identifier: String, val title: String, val description: String?, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/relayFeeds/RelayFeedsListDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/favoriteRelays/FavoriteRelayListDecryptionCache.kt similarity index 92% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/relayFeeds/RelayFeedsListDecryptionCache.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/favoriteRelays/FavoriteRelayListDecryptionCache.kt index 694897a993..65f7dc608e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/relayFeeds/RelayFeedsListDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/favoriteRelays/FavoriteRelayListDecryptionCache.kt @@ -18,12 +18,12 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.model.nip51Lists.relayFeeds +package com.vitorpamplona.amethyst.commons.model.nip51Lists.favoriteRelays import com.vitorpamplona.amethyst.commons.model.nip51Lists.relayLists.GenericRelayListCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent -class RelayFeedsListDecryptionCache( +class FavoriteRelayListDecryptionCache( signer: NostrSigner, ) : GenericRelayListCache<FavoriteRelayListEvent>(signer) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleListDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/followSets/FollowSetDecryptionCache.kt similarity index 94% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleListDecryptionCache.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/followSets/FollowSetDecryptionCache.kt index e31ca57983..b53e2a351b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleListDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/followSets/FollowSetDecryptionCache.kt @@ -18,18 +18,18 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList +package com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.mutedUserIdSet import com.vitorpamplona.quartz.nip51Lists.muteList.mutedUsers import com.vitorpamplona.quartz.nip51Lists.muteList.mutedUsersAndWords import com.vitorpamplona.quartz.nip51Lists.muteList.mutedWordSet import com.vitorpamplona.quartz.nip51Lists.muteList.mutedWords -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent -class PeopleListDecryptionCache( +class FollowSetDecryptionCache( val signer: NostrSigner, ) { val cachedPrivateLists = PrivateTagArrayEventCache<FollowSetEvent>(signer) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleList.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/followSets/PeopleList.kt similarity index 96% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleList.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/followSets/PeopleList.kt index d0366e3dd9..8e412478c5 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/peopleList/PeopleList.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/followSets/PeopleList.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList +package com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets import androidx.compose.runtime.Stable import com.vitorpamplona.amethyst.commons.model.User diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/hashtagLists/HashtagListDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/interestLists/InterestListDecryptionCache.kt similarity index 86% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/hashtagLists/HashtagListDecryptionCache.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/interestLists/InterestListDecryptionCache.kt index db80d69a1b..2fcd45b9c0 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/hashtagLists/HashtagListDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip51Lists/interestLists/InterestListDecryptionCache.kt @@ -18,14 +18,14 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.commons.model.nip51Lists.hashtagLists +package com.vitorpamplona.amethyst.commons.model.nip51Lists.interestLists import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEventCache -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.hashtagSet +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.hashtagSet -class HashtagListDecryptionCache( +class InterestListDecryptionCache( val signer: NostrSigner, ) { val cachedPrivateLists = PrivateTagArrayEventCache<InterestListEvent>(signer) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardDecryptionCache.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserAssertionDecryptionCache.kt similarity index 98% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardDecryptionCache.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserAssertionDecryptionCache.kt index 61bb8a3705..7fd54fb060 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardDecryptionCache.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserAssertionDecryptionCache.kt @@ -34,7 +34,7 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.users.summary * reading them requires the account's main key ([signer]); cards signed by any * other key never decrypt here. */ -class ContactCardDecryptionCache( +class UserAssertionDecryptionCache( val signer: NostrSigner, ) { val cachedPrivateCards = PrivateTagArrayEventCache<UserAssertionEvent>(signer, cacheSize = 100) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardsState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserAssertionsState.kt similarity index 98% rename from commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardsState.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserAssertionsState.kt index ce8635472b..1837e2334c 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/ContactCardsState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/nip85TrustedAssertions/UserAssertionsState.kt @@ -51,10 +51,10 @@ import kotlinx.coroutines.flow.mapLatest * account itself ([signer]'s pubkey). */ @Stable -class ContactCardsState( +class UserAssertionsState( val signer: NostrSigner, val cache: ICacheProvider, - val decryptionCache: ContactCardDecryptionCache, + val decryptionCache: UserAssertionDecryptionCache, val emojiPacks: EmojiPackState, ) { private val accountUser: User? by lazy { cache.getOrCreateUser(signer.pubKey) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/FeedDecryptionCaches.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/FeedDecryptionCaches.kt index 2df60e89d5..ce85cb0878 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/FeedDecryptionCaches.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/FeedDecryptionCaches.kt @@ -20,16 +20,16 @@ */ package com.vitorpamplona.amethyst.commons.model.topNavFeeds +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.FollowSetDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.geohashLists.GeohashListDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.hashtagLists.HashtagListDecryptionCache +import com.vitorpamplona.amethyst.commons.model.nip51Lists.interestLists.InterestListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.muteList.MuteListDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleListDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip72Communities.CommunityListDecryptionCache class FeedDecryptionCaches( - val peopleListCache: PeopleListDecryptionCache, + val peopleListCache: FollowSetDecryptionCache, val muteListCache: MuteListDecryptionCache, val communityListCache: CommunityListDecryptionCache, - val hashtagCache: HashtagListDecryptionCache, + val hashtagCache: InterestListDecryptionCache, val geohashCache: GeohashListDecryptionCache, ) diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt index d48e5704a0..bf9b8604aa 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/model/topNavFeeds/noteBased/NoteFeedFlow.kt @@ -35,11 +35,11 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.Mute import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt index 1147d8eeaf..2c582e00c6 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKinds.kt @@ -111,7 +111,7 @@ object NotificationKinds { myPubKeyHex: HexKey, isTargetAuthoredByMe: (targetNoteId: HexKey) -> Boolean = { false }, ): Boolean { - // Own events never notify — except zap receipts (LnZap/Nutzap/Onchain) + // Own events never notify — except zap receipts (ZapReceipt/Nutzap/Onchain) // which are signed by the LNURL provider or the payer, not by us. if (event.pubKey == myPubKeyHex && event !is ZapReceiptEvent && diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt index 6026a0bba8..e03dbe41b1 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBasicAccountInfoFromKeys.kt @@ -31,7 +31,7 @@ import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt index 5d4a10c7a8..8b78c54e1c 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterBookmarksAndReportsFromKey.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent import com.vitorpamplona.quartz.nip62RequestToVanish.RequestToVanishEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt index fc0436f6a0..ce5bfa014e 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/account/metadata/FilterFollowsAndMutesFromKey.kt @@ -28,9 +28,9 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListEvent import com.vitorpamplona.quartz.nip30CustomEmoji.selection.EmojiListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent import com.vitorpamplona.quartz.nip58Badges.profile.ProfileBadgesEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt index 237c08b2f9..837719a7ef 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/assemblers/ContactCardFilters.kt @@ -28,14 +28,14 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.dTag.DTag import com.vitorpamplona.quartz.nip85TrustedAssertions.users.UserAssertionEvent -val ContactCardKindList = listOf(UserAssertionEvent.KIND) +val UserAssertionKindList = listOf(UserAssertionEvent.KIND) /** * Kind:30382 cards *about* [targets], written by [trustedAccounts] (the account * itself plus its WoT trust providers). Fetches nicknames and scores for the * users currently on screen. */ -fun filterContactCardsToTargetKeysFromTrustedAccountsInTheRelay( +fun filterUserAssertionsToTargetKeysFromTrustedAccountsInTheRelay( targets: Set<HexKey>, trustedAccounts: List<HexKey>, relay: NormalizedRelayUrl, @@ -49,7 +49,7 @@ fun filterContactCardsToTargetKeysFromTrustedAccountsInTheRelay( ExplainedFilter( purpose = SubPurpose.PROFILE_METADATA, accountPubKeys = listOfNotNull(accountPubKey), - kinds = ContactCardKindList, + kinds = UserAssertionKindList, authors = trustedAccounts, // kind:30382 addresses the target user in the d-tag tags = mapOf(DTag.TAG_NAME to targets.sorted()), @@ -68,7 +68,7 @@ fun filterContactCardsToTargetKeysFromTrustedAccountsInTheRelay( * "Observing Profiles" — explained as *"profiles of the people currently on screen"* — made every * logged-in account look like it was watching somebody. */ -fun filterContactCardsByAuthorInTheRelay( +fun filterUserAssertionsByAuthorInTheRelay( relay: NormalizedRelayUrl, authors: List<HexKey>, since: Long?, @@ -81,7 +81,7 @@ fun filterContactCardsByAuthorInTheRelay( purpose = SubPurpose.ACCOUNT_DATA, // This variant fetches the accounts' OWN contact cards, so the authors are the owners. accountPubKeys = authors, - kinds = ContactCardKindList, + kinds = UserAssertionKindList, authors = authors, limit = limit, since = since, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt index 714813a311..6492b4e3ee 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAllCommunities.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent fun filterFollowSetsAllCommunities( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt index bcb5f3d944..86ea1eb063 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByAuthors.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent fun filterFollowSetsAuthors( relay: NormalizedRelayUrl, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt index 65483bc063..b1589dc89b 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByCommunity.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip72ModCommunities.approval.CommunityPostApprovalEvent fun filterFollowSetsByCommunity( diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt index 8973d4358d..9b51e44710 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByGeohash.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent fun filterFollowSetsByGeohash( relay: NormalizedRelayUrl, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt index 21749a61e7..b228a62731 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsByHashtag.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hashtagAlts -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent fun filterFollowSetsByHashtag( relay: NormalizedRelayUrl, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt index c62c7bf76e..b6b59bb3c4 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/discover/nip51FollowSets/FilterFollowSetsGlobal.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.ExplainedFil import com.vitorpamplona.amethyst.commons.relayClient.subscriptions.SubPurpose import com.vitorpamplona.amethyst.commons.relays.SincePerRelayMap import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent fun filterFollowSetsGlobal( relays: GlobalTopNavPerRelayFilterSet, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt index 1ebb50c63b..444f4e1695 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/profile/FilterUserProfileLists.kt @@ -29,9 +29,9 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip89AppHandlers.recommendation.AppRecommendationEvent val UserProfileListKinds = diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/UserCardsSubAssembler.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/UserCardsSubAssembler.kt index 9c4ffbc31e..bee7470979 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/UserCardsSubAssembler.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/relayClient/user/watchers/UserCardsSubAssembler.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.commons.relayClient.user.watchers import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider import com.vitorpamplona.amethyst.commons.model.toHexSet -import com.vitorpamplona.amethyst.commons.relayClient.assemblers.filterContactCardsToTargetKeysFromTrustedAccountsInTheRelay +import com.vitorpamplona.amethyst.commons.relayClient.assemblers.filterUserAssertionsToTargetKeysFromTrustedAccountsInTheRelay import com.vitorpamplona.amethyst.commons.relayClient.eoseManagers.SingleSubEoseManager import com.vitorpamplona.amethyst.commons.relayClient.user.UserFinderQueryState import com.vitorpamplona.amethyst.commons.relays.MutableTime @@ -103,14 +103,14 @@ class UserCardsSubAssembler( val groups = groupByRelayPresence(lastUsersOnFilter, relay) val trustedAccounts = trustedUsersInThisRelay.sorted() listOfNotNull( - filterContactCardsToTargetKeysFromTrustedAccountsInTheRelay( + filterUserAssertionsToTargetKeysFromTrustedAccountsInTheRelay( accountPubKey = soleAccountPubKey, targets = groups.usersWithoutEose.toHexSet(), trustedAccounts = trustedAccounts, relay = relay, since = null, ), - filterContactCardsToTargetKeysFromTrustedAccountsInTheRelay( + filterUserAssertionsToTargetKeysFromTrustedAccountsInTheRelay( accountPubKey = soleAccountPubKey, targets = groups.usersWithEose.toHexSet(), trustedAccounts = trustedAccounts, diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt index 34b7ce090f..fb790f0858 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/KindRegistry.kt @@ -32,7 +32,7 @@ import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelMetadataEvent import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent import com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt index 214e789056..71636dfc37 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/search/RenderableKinds.kt @@ -47,8 +47,8 @@ import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent import com.vitorpamplona.quartz.nip51Lists.PinListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt index d050ab8e93..b831f2d452 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/model/privateChats/ChatPreviewTest.kt @@ -37,7 +37,7 @@ class ChatPreviewTest { private val ciphertext = "0tyoSVovKSK9uDKLUVMs137TD0b+vz+fjoJN+gG3Bk4=?iv=6r6yPQ==" - private fun privateDm( + private fun encryptedDm( author: String = other, recipient: String = me, ) = EncryptedDmEvent( @@ -63,7 +63,7 @@ class ChatPreviewTest { @Test fun nip04DmCarriesCiphertext() { - assertTrue(privateDm().hasEncryptedContent()) + assertTrue(encryptedDm().hasEncryptedContent()) } @Test @@ -129,14 +129,14 @@ class ChatPreviewTest { fun decryptedDmRendersThePlaintext() { assertEquals( ChatPreview.Body("hi!"), - chatPreviewOf(privateDm(), decrypted = "hi!", myPubKey = me, canDecrypt = true), + chatPreviewOf(encryptedDm(), decrypted = "hi!", myPubKey = me, canDecrypt = true), ) } /** The regression under test: the raw base64 blob must never become the preview. */ @Test fun pendingDmNeverFallsThroughToCiphertext() { - val preview = chatPreviewOf(privateDm(), decrypted = null, myPubKey = me, canDecrypt = true) + val preview = chatPreviewOf(encryptedDm(), decrypted = null, myPubKey = me, canDecrypt = true) assertEquals(ChatPreview.Decrypting, preview) assertFalse(preview is ChatPreview.Body) @@ -146,7 +146,7 @@ class ChatPreviewTest { fun readOnlyAccountCannotEverDecrypt() { assertEquals( ChatPreview.Undecryptable, - chatPreviewOf(privateDm(), decrypted = null, myPubKey = me, canDecrypt = false), + chatPreviewOf(encryptedDm(), decrypted = null, myPubKey = me, canDecrypt = false), ) } @@ -155,7 +155,7 @@ class ChatPreviewTest { assertEquals( ChatPreview.Undecryptable, chatPreviewOf( - privateDm(author = other, recipient = stranger), + encryptedDm(author = other, recipient = stranger), decrypted = null, myPubKey = me, canDecrypt = true, @@ -168,7 +168,7 @@ class ChatPreviewTest { assertEquals( ChatPreview.Decrypting, chatPreviewOf( - privateDm(author = me, recipient = other), + encryptedDm(author = me, recipient = other), decrypted = null, myPubKey = me, canDecrypt = true, diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt index f9aee77c88..e472f7c54e 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/moderation/notifications/NotificationKindsTest.kt @@ -139,7 +139,7 @@ class NotificationKindsTest { sig = someSig, ) - private fun privateDm( + private fun encryptedDm( author: String, pTag: String = me, ): EncryptedDmEvent = @@ -266,9 +266,9 @@ class NotificationKindsTest { @Test fun myOwnZapReceiptStillAccepted() { - // LnZap receipts are signed by the LNURL provider, not by us, + // ZapReceipt receipts are signed by the LNURL provider, not by us, // so `pubKey == me` never applies — but even if it did the - // helper explicitly allows LnZap/Nutzap/OnchainZap own-events. + // helper explicitly allows ZapReceipt/Nutzap/OnchainZap own-events. assertTrue(acceptsFor(zapReceipt(pTag = me))) } @@ -280,8 +280,8 @@ class NotificationKindsTest { // DMs -------------------------------------------------------------------- @Test - fun privateDmAccepted() { - assertTrue(acceptsFor(privateDm(author = alice))) + fun encryptedDmAccepted() { + assertTrue(acceptsFor(encryptedDm(author = alice))) } @Test diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt index aa5d930cff..586a158653 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletBrokerTest.kt @@ -42,7 +42,7 @@ import com.vitorpamplona.quartz.nip01Core.crypto.verify import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.async @@ -137,7 +137,7 @@ class NappletBrokerTest { fromPublicKey: HexKey, ): String = throw NotImplementedError() - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt index d0f61a9ad3..f8937547c1 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/onchain/OnchainZapSenderTest.kt @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.builder.OnchainZapBuilder import com.vitorpamplona.quartz.nipBCOnchainZaps.chain.BitcoinAddressTx @@ -228,7 +228,7 @@ class OnchainZapSenderTest { fromPublicKey: HexKey, ) = inner.nip44Decrypt(ciphertext, fromPublicKey) - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = inner.decryptZapEvent(event) + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = inner.decryptZapEvent(event) override suspend fun deriveKey(nonce: HexKey): HexKey = inner.deriveKey(nonce) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt index 5c27c8c828..afb4eba786 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModelTest.kt @@ -35,7 +35,7 @@ import com.vitorpamplona.nestsclient.transport.WebTransportSession import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -589,7 +589,7 @@ class NestViewModelTest { fromPublicKey: String, ): String = error("not used") - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = error("not used") + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = error("not used") override suspend fun deriveKey(nonce: String): String = error("not used") diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/BookmarkGroupItem.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/BookmarkGroupItem.kt index 6d2ea0334b..cb27ce2c4a 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/BookmarkGroupItem.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/BookmarkGroupItem.kt @@ -50,7 +50,7 @@ import androidx.compose.ui.unit.sp import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.nip51Lists.BookmarkType -import com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets.BookmarkSet import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.bookmark_list_articles_btn_label import com.vitorpamplona.amethyst.commons.resources.bookmark_list_clone_btn_label @@ -85,7 +85,7 @@ import com.vitorpamplona.amethyst.commons.ui.theme.StdVertSpacer @Composable fun BookmarkGroupItem( modifier: Modifier = Modifier, - bookmarkList: LabeledBookmarkList, + bookmarkList: BookmarkSet, onClick: (bookmarkItemType: BookmarkType) -> Unit, onRename: () -> Unit, onDescriptionChange: () -> Unit, diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/ListOfBookmarkGroupsFeedView.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/ListOfBookmarkGroupsFeedView.kt index fe891a2366..d208a1694f 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/ListOfBookmarkGroupsFeedView.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/ListOfBookmarkGroupsFeedView.kt @@ -46,7 +46,7 @@ import com.vitorpamplona.amethyst.commons.model.nip51Lists.BookmarkType import com.vitorpamplona.amethyst.commons.model.nip51Lists.GitRepositoryListState import com.vitorpamplona.amethyst.commons.model.nip51Lists.OldBookmarkListState import com.vitorpamplona.amethyst.commons.model.nip51Lists.PinListState -import com.vitorpamplona.amethyst.commons.model.nip51Lists.labeledBookmarkLists.LabeledBookmarkList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.bookmarkSets.BookmarkSet import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.bookmark_list_icon_label import com.vitorpamplona.amethyst.commons.resources.bookmarks_explainer @@ -73,17 +73,17 @@ fun ListOfBookmarkGroupsFeedView( oldBookmarks: OldBookmarkListState, pinnedNotes: PinListState, repositories: GitRepositoryListState, - groupListFeedSource: StateFlow<List<LabeledBookmarkList>>, + groupListFeedSource: StateFlow<List<BookmarkSet>>, openDefaultBookmarks: () -> Unit, openOldBookmarks: () -> Unit, openPinnedNotes: () -> Unit, openRepositories: () -> Unit, openPodcasts: () -> Unit, onOpenItem: (String, BookmarkType) -> Unit, - onRenameItem: (targetBookmarkGroup: LabeledBookmarkList) -> Unit, - onItemDescriptionChange: (bookmarkGroup: LabeledBookmarkList) -> Unit, - onItemClone: (bookmarkGroup: LabeledBookmarkList, customName: String?, customDesc: String?) -> Unit, - onDeleteItem: (bookmarkGroup: LabeledBookmarkList) -> Unit, + onRenameItem: (targetBookmarkGroup: BookmarkSet) -> Unit, + onItemDescriptionChange: (bookmarkGroup: BookmarkSet) -> Unit, + onItemClone: (bookmarkGroup: BookmarkSet, customName: String?, customDesc: String?) -> Unit, + onDeleteItem: (bookmarkGroup: BookmarkSet) -> Unit, listState: LazyListState = rememberLazyListState(), ) { val bookmarkGroupFeedState by groupListFeedSource.collectAsStateWithLifecycle() @@ -119,7 +119,7 @@ fun ListOfBookmarkGroupsFeedView( itemsIndexed( bookmarkGroupFeedState, - key = { _: Int, item: LabeledBookmarkList -> item.identifier }, + key = { _: Int, item: BookmarkSet -> item.identifier }, ) { _, groupItem -> BookmarkGroupItem( modifier = Modifier.fillMaxSize().animateItem(), diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/PeopleListItem.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/PeopleListItem.kt index 2cee4e8d6a..c73b4f9c9a 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/PeopleListItem.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip51Lists/ui/PeopleListItem.kt @@ -51,7 +51,7 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.LocalCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleList +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.PeopleList import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.cancel import com.vitorpamplona.amethyst.commons.resources.follow_set_copy_action_btn_label diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip85TrustedAssertions/ui/EditNicknameDialog.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip85TrustedAssertions/ui/EditNicknameDialog.kt index b24c98cbb5..400f75d209 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip85TrustedAssertions/ui/EditNicknameDialog.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/nip85TrustedAssertions/ui/EditNicknameDialog.kt @@ -41,7 +41,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.nip30CustomEmojis.EmojiSuggestionState -import com.vitorpamplona.amethyst.commons.model.nip85TrustedAssertions.ContactCardsState +import com.vitorpamplona.amethyst.commons.model.nip85TrustedAssertions.UserAssertionsState import com.vitorpamplona.amethyst.commons.nip30CustomEmojis.ui.ShowEmojiSuggestionList import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.nickname_cancel @@ -62,31 +62,31 @@ import org.jetbrains.compose.resources.stringResource * Typing `:` offers the account's NIP-30 custom emojis; the mappings for any * shortcode used are embedded (also encrypted) so the nickname renders with them. * - * Shared by every front end: the caller supplies the account's [contactCards] + * Shared by every front end: the caller supplies the account's [userAssertions] * and publishes the result in [onSave] (e.g. through its outbox relays). On * Android, compose `WatchAndLoadMyEmojiList` alongside so the emoji packs load. */ @Composable fun EditNicknameDialog( user: User, - contactCards: ContactCardsState, + userAssertions: UserAssertionsState, onSave: (petName: String?, summary: String?) -> Unit, onDismiss: () -> Unit, ) { val nickname = rememberTextFieldState() val summary = rememberTextFieldState() - val emojiSuggestions = remember(contactCards) { EmojiSuggestionState(contactCards.emojiPacks) } + val emojiSuggestions = remember(userAssertions) { EmojiSuggestionState(userAssertions.emojiPacks) } // which field the emoji autocomplete should insert into: the last one edited val emojiTarget = remember { mutableStateOf<TextFieldState?>(null) } // Prefill with the card's current encrypted values, if any. Decryption can // be slow on external signers, so don't clobber anything already typed. LaunchedEffect(user) { - contactCards + userAssertions .petName(user.pubkeyHex) ?.takeIf { nickname.text.isEmpty() } ?.let { nickname.setTextAndPlaceCursorAtEnd(it) } - contactCards + userAssertions .summary(user.pubkeyHex) ?.takeIf { summary.text.isEmpty() } ?.let { summary.setTextAndPlaceCursorAtEnd(it) } diff --git a/desktopApp/plans/2026-05-12-feat-desktop-wallet-zapping-test-coverage-plan.md b/desktopApp/plans/2026-05-12-feat-desktop-wallet-zapping-test-coverage-plan.md index 13e2a9b82d..d3a4161b94 100644 --- a/desktopApp/plans/2026-05-12-feat-desktop-wallet-zapping-test-coverage-plan.md +++ b/desktopApp/plans/2026-05-12-feat-desktop-wallet-zapping-test-coverage-plan.md @@ -17,7 +17,7 @@ origin: desktopApp/plans/2026-05-12-wallet-zapping-phase1-2-plan.md 1. **mockk callback capture**: Use `slot<(Event, NormalizedRelayUrl) -> Unit>()` + `capture(slot)` to intercept relay subscription callbacks and feed simulated wallet responses 2. **GlobalScope.launch problem**: NwcPaymentHandler uses `GlobalScope.launch(Dispatchers.IO)` inside callbacks — tests need real time via `withTimeout(5.seconds)` to await (or refactor to inject scope) -3. **LnZapPaymentResponseEvent.createResponse()** exists — build real encrypted test responses with deterministic keys, no need to mock encryption +3. **NwcResponseEvent.createResponse()** exists — build real encrypted test responses with deterministic keys, no need to mock encryption 4. **runTest auto-advances virtual time** — timeout tests resolve instantly without real delays 5. **Codebase prefers anonymous objects** over mockk for complex interfaces (see RelayConnectionManagerTest) @@ -35,7 +35,7 @@ methods, wallet column state management, and zap dialog logic. | NIP-47 URI parsing | quartz | `Nip47WalletConnectTest.kt` | Complete | | NWC request serialization | quartz | `RequestTest.kt` (50+ cases) | Complete | | NWC response parsing | quartz | `ResponseTest.kt` (50+ cases) | Complete | -| NWC event encryption | quartz | `LnZapPaymentRequestEventTest.kt` | Complete | +| NWC event encryption | quartz | `NwcRequestEventTest.kt` | Complete | | Alby interop | quartz | `AlbyInteropTest.kt` (60+ cases) | Complete | | Account management | desktopApp | `AccountManager*Test.kt` (5 files) | Complete | | Cache pipeline | desktopApp | `DesktopCachePipelineTest.kt` | Complete | @@ -187,9 +187,9 @@ class NwcPaymentHandlerTest { **Challenge:** The `subscribeOnRelay` callback runs asynchronously. Tests must capture the `onEvent` lambda and invoke it with a simulated -`LnZapPaymentResponseEvent`. This requires building encrypted response +`NwcResponseEvent`. This requires building encrypted response events using the wallet's signer — similar to -`quartz/nip47WalletConnect/LnZapPaymentRequestEventTest.kt`. +`quartz/nip47WalletConnect/NwcRequestEventTest.kt`. **Alternative (simpler):** If capturing the relay callback is too complex, extract the response processing logic into a testable pure function and @@ -349,7 +349,7 @@ class NwcRpcIntegrationTest { val requestEvent = client.getBalance() // 2. Verify request is properly encrypted - assertEquals(LnZapPaymentRequestEvent.KIND, requestEvent.kind) + assertEquals(NwcRequestEvent.KIND, requestEvent.kind) assertTrue(requestEvent.content.isNotBlank()) // 3. Wallet decrypts and verifies method @@ -357,7 +357,7 @@ class NwcRpcIntegrationTest { assertIs<GetBalanceMethod>(decryptedRequest) // 4. Wallet builds encrypted response - val responseEvent = LnZapPaymentResponseEvent.create( + val responseEvent = NwcResponseEvent.create( request = requestEvent, response = GetBalanceSuccessResponse( result = GetBalanceSuccessResponse.GetBalanceResult(balance = 125000), @@ -429,7 +429,7 @@ extraction needed). | Mocking relay callback is complex | Medium | Extract response processing into pure function, test that directly | | Compose state testing without Compose | Medium | Extract state holder class (Option A) | | `formatSats` is private | Low | Change to `internal` visibility | -| Encrypted response building may need quartz test utils | Low | Use same pattern as `LnZapPaymentRequestEventTest.kt` | +| Encrypted response building may need quartz test utils | Low | Use same pattern as `NwcRequestEventTest.kt` | ## Sources @@ -437,4 +437,4 @@ extraction needed). - NIP-47 protocol tests: `quartz/src/commonTest/.../nip47WalletConnect/` (13 files) - Test framework: kotlin.test + mockk 1.14.9 + kotlinx-coroutines-test 1.10.2 - Mock pattern: `AccountManagerBunkerLoginTest.kt` (relaxed mockk + coEvery) -- Crypto test pattern: `LnZapPaymentRequestEventTest.kt` (deterministic KeyPair) +- Crypto test pattern: `NwcRequestEventTest.kt` (deterministic KeyPair) diff --git a/desktopApp/plans/2026-07-23-feat-desktop-moderation-safety-plan.md b/desktopApp/plans/2026-07-23-feat-desktop-moderation-safety-plan.md index 62f1e5fc80..a2fc90ef6a 100644 --- a/desktopApp/plans/2026-07-23-feat-desktop-moderation-safety-plan.md +++ b/desktopApp/plans/2026-07-23-feat-desktop-moderation-safety-plan.md @@ -30,7 +30,7 @@ cruxes**, de-risking the whole feature: → Crux 2 resolved: reuse `invalidateData()`, don't invent a bus. 3. **Concrete APIs confirmed** (see Research Insights under Technical Approach): `MuteListEvent.create/add/remove(MuteTag, isPrivate, signer)` where `MuteTag ∈ - {UserTag, HashtagTag(word), EventTag(thread)}`; `PeopleListEvent.addUser/ + {UserTag, HashtagTag(word), EventTag(thread)}`; `FollowSetEvent.addUser/ removeUser` for blocks; publish via `signer.sign(template)` + `relayManager.broadcastToAll(signed)` (precedent `reactToNote`/`repostNote` in `desktopApp/.../ui/NoteActions.kt`). @@ -85,7 +85,7 @@ enforcement, reusing quartz protocol and the existing spam-collapse reveal: `isAcceptable`, so DMs get filtered for free once the predicate is real. - **Actions:** `hideUser`/`showUser`/`blockUser`/`hideWord`/`hideThread` on `DesktopIAccount` build → sign → publish an updated `MuteListEvent`/ - `PeopleListEvent`. + `FollowSetEvent`. - **Report:** `report(note|user, type, comment)` reuses quartz `ReportEvent.build` (kind 1984) + `ReportType`, published to the account's public + private outbox (match Android). New `ReportNoteDialog` ported to desktop Compose, wired into @@ -103,7 +103,7 @@ enforcement, reusing quartz protocol and the existing spam-collapse reveal: flowchart TD subgraph relays[Relays] K10000[kind 10000 MuteListEvent - encrypted] - K10001[kind 10001 PeopleListEvent - block] + K10001[kind 10001 FollowSetEvent - block] K1068[content notes, some content-warning tagged] end K10000 & K10001 --> SUB[Main.kt account subscription] @@ -130,7 +130,7 @@ flowchart TD | Report types | `ReportType` enum (SPAM/PROFANITY/IMPERSONATION/NUDITY/ILLEGAL/MALWARE/VIOLENCE/…) | `quartz/.../nip56Reports/ReportType.kt` | | CW detection | `Event.isSensitiveOrNSFW()`, `contentWarningReason()` | `quartz/.../nip36SensitiveContent/EventExt.kt` | | Hidden check | `Note.isHiddenFor(liveHiddenUsers)` (users+words+threads) | `quartz/.../Note.kt` | -| Mute/block events | `MuteListEvent` (10000), `PeopleListEvent` (10001) | `quartz/.../nip51Lists/…` | +| Mute/block events | `MuteListEvent` (10000), `FollowSetEvent` (10001) | `quartz/.../nip51Lists/…` | | Reveal primitive | `SpamCheckedNoteRender` `forceReveal` + `rememberSaveable(id)` | `desktopApp/.../ui/note/SpamCheckedNoteRender.kt` | ### Android references to port @@ -183,7 +183,7 @@ MuteListEvent.remove(earlierVersion, mute, signer) // reading private entries requires the signer: earlierVersion.privateTags(signer) // throws SignerExceptions.UnauthorizedDecryptionException on read-only // block (kind 10001) -PeopleListEvent.addUser(...) / removeUser(...) +FollowSetEvent.addUser(...) / removeUser(...) ``` MuteTag subtypes: `UserTag` (pubkey), `HashtagTag` (word), `EventTag` (thread root). Enforcement then reads these via `Note.isHiddenFor(liveHiddenUsers)`. diff --git a/desktopApp/plans/2026-07-27-feat-desktop-profile-actions-plan.md b/desktopApp/plans/2026-07-27-feat-desktop-profile-actions-plan.md index 5cdbf395ce..11e777743e 100644 --- a/desktopApp/plans/2026-07-27-feat-desktop-profile-actions-plan.md +++ b/desktopApp/plans/2026-07-27-feat-desktop-profile-actions-plan.md @@ -44,13 +44,13 @@ Open Desktop Messages for this pubkey via the existing deck-column pattern. (`ShareMenu.kt:56`) shape. No auth required; own + others. ## Action 3 — Add to follow-pack (kind 39089) — mostly REUSE -- **Picker source:** `FollowPacksState.allPacks: StateFlow<List<FollowListEvent>>` +- **Picker source:** `FollowPacksState.allPacks: StateFlow<List<StarterPackEvent>>` (`followpacks/FollowPacksState.kt:84`) — zero-packs returns `emptyList()`. -- **Add member:** `FollowListEvent.add(earlierVersion, person = UserTag(pubKey, relayHint), signer)` - (`quartz nip51Lists/followList/FollowListEvent.kt:116`; `UserTag` from `muteList/tags/UserTag.kt:35`). +- **Add member:** `StarterPackEvent.add(earlierVersion, person = UserTag(pubKey, relayHint), signer)` + (`quartz nip51Lists/starterPack/StarterPackEvent.kt:116`; `UserTag` from `muteList/tags/UserTag.kt:35`). Publish via `relayManager.broadcastToAll(event)` + `cache.consume(event, relay, wasVerified=false)` (pattern in `FollowPackDetailScreen.kt:178-192`). -- **Thin `commons/actions/FollowPackActions.kt`** = pure builder wrapping `FollowListEvent.add` +- **Thin `commons/actions/FollowPackActions.kt`** = pure builder wrapping `StarterPackEvent.add` (returns the signed event; desktop layer publishes). No hand-rolled tag assembly. - **Zero-packs → offer "Create new pack"** (reuse `FollowPackEditor`); no dead-end modal. - **Stale-list guard:** disable until the target pack's current 39089 has loaded (`add` onto a stale @@ -58,33 +58,33 @@ Open Desktop Messages for this pubkey via the existing deck-column pattern. - **Modal caveat:** the picker must NOT use `rememberSubscription` (broken in AlertDialog); the `allPacks` StateFlow is already hoisted, so read it directly. -## Action 4 — Block (`PeopleListEvent` kind 30000, d=`mute`) +## Action 4 — Block (`FollowSetEvent` kind 30000, d=`mute`) **Much of this already exists on moderation-safety — Block is mostly wiring, mirroring mute.** > **Revision of parent's "extract to commons" default:** moderation-safety keeps the *mute* write > **inline** on `DesktopIAccount.updateMuteList` (not a commons builder). To avoid the architecture > reviewer's "two parallel patterns" smell, Block should be **inline and symmetric with mute** — NOT -> a `commons/actions/BlockActions.kt`. The quartz `PeopleListEvent.addUser` IS the shared builder; a +> a `commons/actions/BlockActions.kt`. The quartz `FollowSetEvent.addUser` IS the shared builder; a > commons wrapper adds nothing. (If a commons home is later wanted, extract mute + block *together*.) **Already present (REUSE, no changes):** -- `PeopleListEvent` (quartz `nip51Lists/peopleList/PeopleListEvent.kt`): `KIND=30000`, +- `FollowSetEvent` (quartz `nip51Lists/followSet/FollowSetEvent.kt`): `KIND=30000`, `BLOCK_LIST_D_TAG="mute"`, `createBlockAddress(pubKey)`; `addUser(earlierVersion, pubKeyHex, relayHint, isPrivate, signer)`, `removeUser(earlierVersion, pubKeyHex, isUserPrivate, signer)`, `remove/removeAll`. -- `PeopleListDecryptionCache(signer)` (commons) — `userIdSet(event)` merges public+private, +- `FollowSetDecryptionCache(signer)` (commons) — `userIdSet(event)` merges public+private, **fail-closed** (`privateTags` → null / `UnauthorizedDecryptionException` on read-only). - `DesktopHiddenUsersState` **already loads the own kind-30000 block list** - (`blockListNote = cache.getOrCreateAddressableNote(PeopleListEvent.createBlockAddress(signer.pubKey))`). + (`blockListNote = cache.getOrCreateAddressableNote(FollowSetEvent.createBlockAddress(signer.pubKey))`). - `publishAndConfirmDetailed(event, relays, timeout): Map<relay,Boolean>` (quartz `NostrClientPublishExt.kt`); `DmSendTracker.sendBatch` shows the confirmed-publish + status pattern. **WIRE (new, small):** -- `DesktopHiddenUsersState.currentBlockList(): PeopleListEvent?` — mirror the existing - `currentMuteList()` (`blockListNote.event as? PeopleListEvent`). +- `DesktopHiddenUsersState.currentBlockList(): FollowSetEvent?` — mirror the existing + `currentMuteList()` (`blockListNote.event as? FollowSetEvent`). - `DesktopIAccount.blockUser(pubkeyHex)` / `unblockUser(pubkeyHex)` + private `updateBlockList(tag, isPrivate, add)` — **mirror `updateMuteList` exactly**: load - `currentBlockList()`, `PeopleListEvent.addUser/removeUser` (or `create` **only if null**), + `currentBlockList()`, `FollowSetEvent.addUser/removeUser` (or `create` **only if null**), `localCache.justConsumeMyOwnEvent(event)` (optimistic), then publish. - Publish Block via **`publishAndConfirmDetailed`** (Block is security-relevant; Desktop NIP-42 AUTH is partial so fire-and-forget `broadcastToAll` — what `publishModeration` uses for mute — risks @@ -106,7 +106,7 @@ moderation-safety already merges mute ∪ block: `DesktopHiddenUsersState.assemb ## Acceptance criteria - [ ] DM opens the correct 1:1 room (`ChatroomKey(setOf(pubkey))` + `selectRoom`); graceful when target has no inbox relays / read-only. - [ ] Share yields a valid `npub` / `nostr:` link via `toNpub()`/`toNProfile()` + `copyToClipboard`. -- [ ] Add-to-list adds to a chosen pack (39089, `FollowListEvent.add`) and persists; zero-packs offers create-new; disabled until pack loaded. +- [ ] Add-to-list adds to a chosen pack (39089, `StarterPackEvent.add`) and persists; zero-packs offers create-new; disabled until pack loaded. - [ ] Block (30000, d=`mute`) hides user across feeds/threads/replies/profile (via existing `LiveHiddenUsers`); Unblock reverses. - [ ] Block round-trip preserves prior private entries (test mirrors `MuteListEventTest.add_eventTagPreservesPriorUserAndWordTags`); disabled until `currentBlockList()` loaded; decrypt-fail is fail-closed. - [ ] Block publish confirmed via `publishAndConfirmDetailed` (not fire-and-forget); optimistic UI rolls back on total failure. @@ -117,7 +117,7 @@ moderation-safety already merges mute ∪ block: `DesktopHiddenUsersState.assemb ## Open questions 1. **Block write location:** inline on `DesktopIAccount` symmetric with mute (recommended, overrides parent's "extract to commons") — confirm, or still want a `commons/actions` home (then extract mute+block together)? 2. Fold Block into a combined "block & mute" (Android-style dialog) or keep standalone? (parent Open Q #1) — note enforcement effect is identical since `LiveHiddenUsers` already unions both. -3. Add-member to a 39089 pack: `FollowListEvent.add` inline in `FollowPackActions` builder — any existing desktop add-member path to prefer? (agent found none.) +3. Add-member to a 39089 pack: `StarterPackEvent.add` inline in `FollowPackActions` builder — any existing desktop add-member path to prefer? (agent found none.) ### Resolved by research - ✅ moderation-safety already loads the own kind-30000 list and unions mute ∪ block in `LiveHiddenUsers` — **enforcement needs no new code** (retires parent Open Q #3 / #6). @@ -127,9 +127,9 @@ moderation-safety already merges mute ∪ block: `DesktopHiddenUsersState.assemb - Parent plan. Branch `origin/feat/desktop-moderation-safety`: `DesktopIAccount.kt` (`updateMuteList`, `hideUser/showUser`, `publishModeration`, header menu ~L350-390), `DesktopHiddenUsersState.kt` (`currentMuteList`, loads block via `createBlockAddress`, `assemble()`). -- quartz `nip51Lists/peopleList/PeopleListEvent.kt` (KIND 30000, d=`mute`, `addUser/removeUser`), - commons `PeopleListDecryptionCache.kt`, commons `IAccount.kt` (`LiveHiddenUsers.isUserHidden`), +- quartz `nip51Lists/followSet/FollowSetEvent.kt` (KIND 30000, d=`mute`, `addUser/removeUser`), + commons `FollowSetDecryptionCache.kt`, commons `IAccount.kt` (`LiveHiddenUsers.isUserHidden`), quartz `NostrClientPublishExt.kt` (`publishAndConfirm`/`Detailed`), `DmSendTracker.kt`. -- Packs/DM/share: `followpacks/FollowPacksState.kt` (`allPacks`), quartz `FollowListEvent.kt` +- Packs/DM/share: `followpacks/FollowPacksState.kt` (`allPacks`), quartz `StarterPackEvent.kt` (`add`), `ChatroomKey.kt`, `ui/chats/ChatroomListState.kt` (`selectRoom`, `fetchMetadataIfNeeded`), `ShareMenu.kt` (`copyToClipboard`), `nip19Bech32/ByteArrayExt.kt` (`toNpub`/`toNProfile`). diff --git a/desktopApp/plans/2026-07-27-feat-desktop-profile-parity-plan.md b/desktopApp/plans/2026-07-27-feat-desktop-profile-parity-plan.md index cecd64ede7..f6b948a473 100644 --- a/desktopApp/plans/2026-07-27-feat-desktop-profile-parity-plan.md +++ b/desktopApp/plans/2026-07-27-feat-desktop-profile-parity-plan.md @@ -20,11 +20,11 @@ Android (`amethyst/`), for both viewing and editing. Six parallel research/review agents (codebase-grounding, architecture, security, simplicity, flow-gaps, past-learnings) verified this plan against source. Key changes folded in: -1. **CORRECTION — Block list kind was wrong.** Block is **`PeopleListEvent` kind 30000, - d-tag `"mute"`** — *not* 30382. Kind 30382 is already **NIP-85 `ContactCardEvent` +1. **CORRECTION — Block list kind was wrong.** Block is **`FollowSetEvent` kind 30000, + d-tag `"mute"`** — *not* 30382. Kind 30382 is already **NIP-85 `UserAssertionEvent` (WoT/GrapeRank)** in this codebase; using it would collide with the WoT feature. -2. **Don't hand-roll Block.** `PeopleListEvent.addUser(earlierVersion, isPrivate=true)` + - `BlockPeopleListState` + `PeopleListDecryptionCache` already exist and do a correct, +2. **Don't hand-roll Block.** `FollowSetEvent.addUser(earlierVersion, isPrivate=true)` + + `BlockPeopleListState` + `FollowSetDecryptionCache` already exist and do a correct, fail-closed decrypt→merge→encrypt round-trip. The new commons builder is a **thin adapter**; **never call `create()` on an already-existing (replaceable) list** — that silently un-blocks everyone. @@ -54,7 +54,7 @@ Phases 2 and 3 are unpacked in dedicated grounded sub-plans (Phase 1/4 need no f enforcement code, no commons extraction** (retires Open Q #3 & #6, and the "unify enforcement now" task). 2. **Block is inline, not a commons builder.** moderation-safety keeps *mute* inline on `DesktopIAccount.updateMuteList`; Block mirrors it (`blockUser/unblockUser/updateBlockList`) using - quartz `PeopleListEvent.addUser/removeUser`. This overrides the "extract Block to `commons/actions/`" + quartz `FollowSetEvent.addUser/removeUser`. This overrides the "extract Block to `commons/actions/`" line below and resolves the architecture reviewer's two-parallel-patterns smell. (`FollowPackActions` may still be a thin commons builder.) 3. **`observeEvents` is a fallback, not a requirement.** Existing Desktop tabs use a cache-scan @@ -69,7 +69,7 @@ Phases 2 and 3 are unpacked in dedicated grounded sub-plans (Phase 1/4 need no f | mute/block/report missing on Desktop | mute + report built on **unmerged** `feat/desktop-moderation-safety` (`DesktopIAccount.hideUser/showUser/report`, desktop `ReportNoteDialog`, header overflow menu, `DesktopHiddenUsersState`, feed enforcement, NIP-36 blur). **Not in this worktree** (currently on `main`). | Build on top; do NOT re-implement mute/report. **Resolve the base first** (see Base Strategy). | | Extract mute/block/report to `commons` | moderation-safety put mute/report **desktop-local** on `DesktopIAccount` | New builders (Block, Add-to-pack) → `commons/actions/` (matches `FollowActions`/`ReportAction`). Route Block's **write** through `DesktopIAccount` symmetric with `updateMuteList`. Unify **enforcement** now; extract shared `HiddenUsersState` as follow-up. | | Rich-text bio needs extraction (open Q) | `DesktopRichTextViewer` + commons `RichTextParser` already render feed cards | **Reuse as-is** (~5-line wrap). Resolved. | -| Block = NIP-51 kind **30382** | 30382 = NIP-85 `ContactCardEvent` (WoT). Block = `PeopleListEvent` **30000**, d=`mute` | **Corrected throughout.** | +| Block = NIP-51 kind **30382** | 30382 = NIP-85 `UserAssertionEvent` (WoT). Block = `FollowSetEvent` **30000**, d=`mute` | **Corrected throughout.** | ## Base & Branch Strategy @@ -107,7 +107,7 @@ Phases 1–2 (banner, bio, CLINK, tabs) **don't depend on moderation-safety** an - **DM** → open Desktop Messages for this pubkey. - **Share** (copy `npub` / `nostr:` link). - **Add to list / follow-pack** (reuse Desktop Follow Packs). -- **Block** — `PeopleListEvent` **kind 30000, d=`mute`** (encrypted), distinct from the mute list; +- **Block** — `FollowSetEvent` **kind 30000, d=`mute`** (encrypted), distinct from the mute list; + Unblock. (Reuses existing quartz builder — see Technical Approach.) - **Edit Profile:** add the missing **CLINK offer** field (`noffer1…`). @@ -159,7 +159,7 @@ Write-path template must guard `pubKeyHex == account.signer.pubKey` (self) and ` | Edit dialog (add CLINK) | `desktopApp/.../desktop/ui/profile/EditProfileScreen.kt` + commons `profile/EditProfileFields.kt` | | Follow Packs (add-to-list target) | `desktopApp/.../desktop/followpacks/` | | Desktop Messages (DM target) | `desktopApp/.../desktop/ui/chats/` (`ChatroomListState.selectRoom(build1on1(pubkey))`) | -| **Block — reuse, don't rebuild** | quartz `nip51Lists/peopleList/PeopleListEvent.kt` (`KIND=30000`, `BLOCK_LIST_D_TAG="mute"`, `addUser(earlierVersion, isPrivate=true)`); Android `blockPeopleList/BlockPeopleListState.kt`; commons `PeopleListDecryptionCache.kt` | +| **Block — reuse, don't rebuild** | quartz `nip51Lists/followSet/FollowSetEvent.kt` (`KIND=30000`, `BLOCK_LIST_D_TAG="mute"`, `addUser(earlierVersion, isPrivate=true)`); Android `blockPeopleList/BlockPeopleListState.kt`; commons `FollowSetDecryptionCache.kt` | | Zap decryption | quartz `PrivateZapCache(signer)` / `PrivateZapRequestBuilder.decryptZapEvent`; Android `UserProfileZapsViewModel` | | Commons actions (pattern) | `commons/.../actions/FollowActions.kt`, `commons/.../model/nip56Reports/ReportAction.kt` | @@ -193,7 +193,7 @@ if (!account.isWriteable()) return // read-only/watch-only: no-op, U // 2. NIP-51 lists (Block): reuse existing decrypt→merge→encrypt; NEVER create() an existing list val current = blockListState.getBlockList() // must be LOADED from relays first (see guard) -val event = PeopleListEvent.addUser(earlierVersion = current, pubKeyHex, relayHint, isPrivate = true, signer) +val event = FollowSetEvent.addUser(earlierVersion = current, pubKeyHex, relayHint, isPrivate = true, signer) // fail-closed: addUser throws UnauthorizedDecryptionException rather than dropping private entries // 3. publish. Block = security-relevant → confirm, don't fire-and-forget @@ -247,7 +247,7 @@ account.justConsumeMyOwnEvent(event) // optimistic local apply, symmetric wit - **Add to list:** `commons/actions/FollowPackActions.kt` (build/publish kind 39089) + pack-picker modal; **zero-packs → offer "Create new pack"** (no dead-end). - **Block:** thin `commons/actions/BlockActions.kt` adapter over - `PeopleListEvent.addUser(earlierVersion, isPrivate=true)`; route write through `DesktopIAccount` + `FollowSetEvent.addUser(earlierVersion, isPrivate=true)`; route write through `DesktopIAccount` symmetric with `updateMuteList`; add to header overflow menu; enforce via unified hidden-set. ### Phase 4 — Tests & manual sheet @@ -334,9 +334,9 @@ Every tab defines **loading / empty / populated**; Followers + Zaps add a fourth - `amethyst/.../profile/mutual/dal/UserProfileMutualFeedFilter.kt` ### Verified shared / quartz -- `quartz/.../nip51Lists/peopleList/PeopleListEvent.kt` (KIND 30000, d=`mute`, `addUser`) +- `quartz/.../nip51Lists/followSet/FollowSetEvent.kt` (KIND 30000, d=`mute`, `addUser`) - `amethyst/.../model/nip51Lists/blockPeopleList/BlockPeopleListState.kt` -- `commons/.../model/nip51Lists/peopleList/PeopleListDecryptionCache.kt` +- `commons/.../model/nip51Lists/followSets/FollowSetDecryptionCache.kt` - quartz `PrivateZapCache` / `PrivateZapRequestBuilder.decryptZapEvent` - `commons/.../actions/FollowActions.kt`, `commons/.../model/nip56Reports/ReportAction.kt` - `commons/.../richtext/RichTextParser.kt`, `desktopApp/.../ui/note/DesktopRichTextViewer.kt` diff --git a/desktopApp/plans/2026-07-27-feat-desktop-profile-tabs-plan.md b/desktopApp/plans/2026-07-27-feat-desktop-profile-tabs-plan.md index 583efaa3fa..c7dfd9a6bc 100644 --- a/desktopApp/plans/2026-07-27-feat-desktop-profile-tabs-plan.md +++ b/desktopApp/plans/2026-07-27-feat-desktop-profile-tabs-plan.md @@ -56,7 +56,7 @@ override val privateZapsDecryptionCache: IPrivateZapsDecryptionCache = PrivateZa lazily decrypts per event via `signer.decryptZapEvent`. Gate on `isWriteable()`; decrypt **own-profile only** (Android `UserProfileZapsViewModel:71-85`: `if (user.pubkeyHex == account.pubKey)` decrypt else fall back to `zapRequest.pubKey`). Lazy per row — a NIP-46 bunker does one round-trip -per zap. Kinds: `LnZapEvent.KIND=9735`, `OnchainZapEvent.KIND=8333`. +per zap. Kinds: `ZapReceiptEvent.KIND=9735`, `OnchainZapEvent.KIND=8333`. ## Per-tab implementation diff --git a/desktopApp/plans/2026-08-06-shared-metadata-loading-upstream-reconciliation-plan.md b/desktopApp/plans/2026-08-06-shared-metadata-loading-upstream-reconciliation-plan.md index e30caa24c7..562dca4e0b 100644 --- a/desktopApp/plans/2026-08-06-shared-metadata-loading-upstream-reconciliation-plan.md +++ b/desktopApp/plans/2026-08-06-shared-metadata-loading-upstream-reconciliation-plan.md @@ -23,7 +23,7 @@ Upstream re-architected the same subsystem but **also completed the model-sharin - `watchers/UserWatcherSubAssembler.kt` — commons `BaseEoseManager`; reads `account.indexerRelayList.flow.value`; calls `filterUserMetadataForKey(...)`. - `watchers/FilterUserMetadataForKey.kt` — emits `ExplainedFilter(PROFILE_METADATA, …)`; reads `LocalCache.relayHints.hintsForKey(...)` **statically** (the one non-injected cache ref). - `watchers/UserReportsSubAssembler.kt` — commons `SingleSubEoseManager`; reads `account.declaredFollowsPerOutboxRelay.value`, `account.userProfile().pubkeyHex`. -- `watchers/UserCardsSubAssembler.kt` — commons `SingleSubEoseManager`; reads `account.homeRelays.flow.value`, `account.trustProviderList.liveUserRankProvider`, `…liveUserFollowerCount`, `account.userProfile().pubkeyHex`; emits `filterContactCardsToTargetKeysFromTrustedAccountsInTheRelay(...)` (already in commons `assemblers/ContactCardFilters.kt`). +- `watchers/UserCardsSubAssembler.kt` — commons `SingleSubEoseManager`; reads `account.homeRelays.flow.value`, `account.trustProviderList.liveUserRankProvider`, `…liveUserFollowerCount`, `account.userProfile().pubkeyHex`; emits `filterUserAssertionsToTargetKeysFromTrustedAccountsInTheRelay(...)` (already in commons `assemblers/ContactCardFilters.kt`). ### Event side — `amethyst/.../reqCommand/event/` - `EventFinderFilterAssembler.kt` — `EventFinderQueryState(note, override val account: Account) : AccountScopedQuery`; groups `NoteEventLoaderSubAssembler`, `EventWatcherSubAssembler`, `AddressableAuthorRelayLoaderSubAssembler(cache, ::allKeys, userFinder)`. diff --git a/desktopApp/plans/archive/2026-05-09-embedded-local-relay-plan.md b/desktopApp/plans/archive/2026-05-09-embedded-local-relay-plan.md index 72cfbb3080..6d675db17a 100644 --- a/desktopApp/plans/archive/2026-05-09-embedded-local-relay-plan.md +++ b/desktopApp/plans/archive/2026-05-09-embedded-local-relay-plan.md @@ -290,7 +290,7 @@ SQLiteEventStore's `DeletionRequestModule` already handles this via BEFORE INSER - When kind 5 event inserted → trigger deletes referenced events - Trigger also prevents re-insertion of deleted events -**Desktop hook**: In `DesktopLocalCache.consume()`, when a `DeletionEvent` is consumed, the write-through to `LocalRelayStore.enqueue()` handles it — the store's trigger does the rest. +**Desktop hook**: In `DesktopLocalCache.consume()`, when a `DeletionRequestEvent` is consumed, the write-through to `LocalRelayStore.enqueue()` handles it — the store's trigger does the rest. #### Pruning Strategy Add to `LocalRelayStore`: diff --git a/desktopApp/plans/archive/2026-05-11-wallet-zapping-brainstorm.md b/desktopApp/plans/archive/2026-05-11-wallet-zapping-brainstorm.md index 102d27904e..a9435ffd03 100644 --- a/desktopApp/plans/archive/2026-05-11-wallet-zapping-brainstorm.md +++ b/desktopApp/plans/archive/2026-05-11-wallet-zapping-brainstorm.md @@ -44,7 +44,7 @@ - Biometric auth for sensitive operations ### Shared Infrastructure (Already in quartz/commons) -- **NIP-57:** `LnZapEvent`, `LnZapRequestEvent`, `LnZapPrivateEvent`, private zap encryption +- **NIP-57:** `ZapReceiptEvent`, `ZapRequestEvent`, `PrivateZapEvent`, private zap encryption - **NIP-47:** `Nip47Client`, request/response events, full RPC method set - **NIP-60:** `CashuWalletEvent`, `CashuTokenEvent`, `CashuSpendingHistoryEvent` (skeleton) - **NIP-61:** `NutzapEvent`, `NutzapInfoEvent` (skeleton) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt index 39db2557dd..40736a1fa6 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/cache/DesktopLocalCache.kt @@ -58,7 +58,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcRequestEvent import com.vitorpamplona.quartz.nip47WalletConnect.events.NwcResponseEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent @@ -331,7 +331,7 @@ class DesktopLocalCache : ICacheProvider { } is LongFormContentEvent -> { - consumeLongTextNote(event, relay) + consumeLongFormContent(event, relay) } is BookmarkListEvent -> { @@ -343,7 +343,7 @@ class DesktopLocalCache : ICacheProvider { } is StarterPackEvent -> { - consumeFollowList(event) + consumeStarterPack(event) } is CommentEvent -> { @@ -355,7 +355,7 @@ class DesktopLocalCache : ICacheProvider { } is DmRelayListEvent -> { - consumeChatMessageRelayList(event, relay) + consumeDmRelayList(event, relay) } is BlossomServersEvent -> { @@ -435,7 +435,7 @@ class DesktopLocalCache : ICacheProvider { * indexer fan-out. Mirrors [consumeAdvertisedRelayList]; emits nothing to * the event stream because the UI doesn't render kind 10050s directly. */ - private fun consumeChatMessageRelayList( + private fun consumeDmRelayList( event: DmRelayListEvent, relay: NormalizedRelayUrl?, ): Boolean { @@ -738,7 +738,7 @@ class DesktopLocalCache : ICacheProvider { * Consumes a kind 30023 long-form text note event. * Creates Note in cache like TextNoteEvent. */ - private fun consumeLongTextNote( + private fun consumeLongFormContent( event: LongFormContentEvent, relay: NormalizedRelayUrl?, ): Boolean { @@ -788,7 +788,7 @@ class DesktopLocalCache : ICacheProvider { private val _followPackVersion = MutableStateFlow(0L) val followPackVersion: StateFlow<Long> = _followPackVersion.asStateFlow() - private fun consumeFollowList(event: StarterPackEvent): Boolean { + private fun consumeStarterPack(event: StarterPackEvent): Boolean { val address = event.address() val addressableNote = getOrCreateAddressableNote(address) val author = getOrCreateUser(event.pubKey) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt index 440f4aee46..662984deaf 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/BulkFollowAction.kt @@ -25,7 +25,7 @@ import com.vitorpamplona.amethyst.desktop.cache.DesktopLocalCache import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent data class BulkFollowPreview( val totalMembers: Int, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt index d08cf586f1..50ab804017 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPackEditor.kt @@ -21,7 +21,7 @@ package com.vitorpamplona.amethyst.desktop.followpacks import com.vitorpamplona.quartz.nip01Core.core.Address -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent /** * Lightweight helpers for follow-pack viewing actions. diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt index baac2023fc..cbb0465f48 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/FollowPacksState.kt @@ -28,7 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.SubscriptionListener import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt index ad675bc830..fb3f820b52 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/DiscoverScreen.kt @@ -71,7 +71,7 @@ import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.amethyst.desktop.ui.ZapFeedback import com.vitorpamplona.amethyst.desktop.ui.live.LivesSection -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.coroutines.launch import java.awt.Toolkit import java.awt.datatransfer.StringSelection diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt index 16f8d6b122..be3285ac81 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowAllConfirmDialog.kt @@ -42,7 +42,7 @@ import com.vitorpamplona.amethyst.desktop.followpacks.BulkFollowAction import com.vitorpamplona.amethyst.desktop.followpacks.BulkFollowPreview import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.coroutines.delay import kotlinx.coroutines.launch diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt index 4dfd5696ad..33a0c974bc 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackBrowseAllScreen.kt @@ -53,7 +53,7 @@ import com.vitorpamplona.amethyst.desktop.followpacks.FollowPackEditor import com.vitorpamplona.amethyst.desktop.followpacks.FollowPacksState import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip19Bech32.decodePublicKeyAsHexOrNull -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent /** * Search-all view for follow packs. diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt index 5a0524f2ab..f684915b26 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackComponents.kt @@ -62,7 +62,7 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.ui.components.UserAvatar import com.vitorpamplona.amethyst.desktop.cache.DesktopLocalCache import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent /** * Stack of overlapping circular avatars for pack members. diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt index b7f82a76b3..f925e3ab3e 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/FollowPackDetailScreen.kt @@ -68,7 +68,7 @@ import com.vitorpamplona.amethyst.desktop.followpacks.subscribeMetadataFor import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import kotlinx.coroutines.launch /** diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt index 255e223ef7..1821eaf2d7 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/followpacks/ui/RenderFollowPackCard.kt @@ -58,7 +58,7 @@ import com.vitorpamplona.amethyst.desktop.model.DesktopIAccount import com.vitorpamplona.amethyst.desktop.network.RelayConnectionManager import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress as NAddressEntity /** diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt index b298746177..ed87d85e64 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/model/DesktopHiddenUsersState.kt @@ -23,11 +23,11 @@ package com.vitorpamplona.amethyst.desktop.model import com.vitorpamplona.amethyst.commons.model.LiveHiddenUsers import com.vitorpamplona.amethyst.commons.model.NoteState import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider +import com.vitorpamplona.amethyst.commons.model.nip51Lists.followSets.FollowSetDecryptionCache import com.vitorpamplona.amethyst.commons.model.nip51Lists.muteList.MuteListDecryptionCache -import com.vitorpamplona.amethyst.commons.model.nip51Lists.peopleList.PeopleListDecryptionCache import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.utils.DualCase import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -48,7 +48,7 @@ import kotlinx.coroutines.flow.stateIn * feeds to [com.vitorpamplona.amethyst.commons.model.Note.isHiddenFor]. * * Both lists carry a mix of public tags and an NIP-44-encrypted private section; - * the shared [MuteListDecryptionCache]/[PeopleListDecryptionCache] handle the + * the shared [MuteListDecryptionCache]/[FollowSetDecryptionCache] handle the * async decrypt (and are no-ops for read-only accounts, which simply see the * public portion). The result is exposed as a hot [StateFlow] so feeds can * re-filter live: when the list events change (or decryption resolves), a new @@ -65,7 +65,7 @@ class DesktopHiddenUsersState( private val showSensitiveContent: StateFlow<Boolean?> = MutableStateFlow(null), ) { private val muteCache = MuteListDecryptionCache(signer) - private val blockCache = PeopleListDecryptionCache(signer) + private val blockCache = FollowSetDecryptionCache(signer) // Strong refs so the GC keeps these addressable notes (and their decrypt caches) alive. private val muteListNote = cache.getOrCreateAddressableNote(MuteListEvent.createAddress(signer.pubKey)) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt index 7264e2d71b..a690bd1032 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/UserProfileScreen.kt @@ -125,8 +125,8 @@ import com.vitorpamplona.quartz.nip39ExtIdentities.TwitterIdentity import com.vitorpamplona.quartz.nip39ExtIdentities.identityClaims import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.EventBookmark -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt index 6c6e49ad14..257baa799b 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt @@ -376,7 +376,7 @@ private fun RenderBechSegment( .NAddress .parse(segment.segmentText) } - if (naddr != null && naddr.kind == com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent.KIND) { + if (naddr != null && naddr.kind == com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent.KIND) { val followPacks = com.vitorpamplona.amethyst.desktop.ui.deck.LocalFollowPacksState.current val relayManager = com.vitorpamplona.amethyst.desktop.ui.deck.LocalRelayManager.current if (localCache != null && relayManager != null && followPacks != null) { diff --git a/docs/TODO.md b/docs/TODO.md index 979b4c9996..a9711dbd38 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -5,7 +5,7 @@ **Question:** What happens when a conversation with an npub has both NIP-04 (kind 4) and NIP-17 (kind 14/15 in GiftWrap) messages? **Current behavior to investigate:** -- NIP-04 messages use `PrivateDmEvent.chatroomKey(pubKey)` → creates a `ChatroomKey` based on recipient +- NIP-04 messages use `EncryptedDmEvent.chatroomKey(pubKey)` → creates a `ChatroomKey` based on recipient - NIP-17 messages use `ChatMessageEvent.chatroomKey(pubKey)` → also creates a `ChatroomKey` based on group members - Do these produce the **same** `ChatroomKey` for 1-on-1 chats? If yes, both message types merge into one conversation. If no, they appear as separate conversations. - Android Amethyst handles this — check how `Account.kt` merges them diff --git a/docs/brainstorms/2026-03-16-desktop-media-brainstorm.md b/docs/brainstorms/2026-03-16-desktop-media-brainstorm.md index 7793b10901..e3d503140a 100644 --- a/docs/brainstorms/2026-03-16-desktop-media-brainstorm.md +++ b/docs/brainstorms/2026-03-16-desktop-media-brainstorm.md @@ -136,7 +136,7 @@ ExoPlayer is Android-only (Media3). VLCJ wraps VLC's libvlc via JNA — supports | BlossomServersEvent | `quartz/nipB7Blossom/` | Ready (kind 10063) | | BlossomUri | `quartz/nipB7Blossom/` | Ready (blossom: URI parsing) | | BlossomUploadResult | `quartz/nipB7Blossom/` | Ready | -| FileHeaderEvent (NIP-94) | `quartz/nip94FileMetadata/` | Ready (kind 1063) | +| FileMetadataEvent (NIP-94) | `quartz/nip94FileMetadata/` | Ready (kind 1063) | | BlurhashTag | `quartz/nip94FileMetadata/tags/` | Ready | | DimensionTag | `quartz/nip94FileMetadata/tags/` | Ready | | IMetaTag/Builder (NIP-92) | `quartz/nip92IMeta/` | Ready | diff --git a/docs/brainstorms/2026-03-19-dm-encryption-badge-brainstorm.md b/docs/brainstorms/2026-03-19-dm-encryption-badge-brainstorm.md index e106e509db..221f8a1500 100644 --- a/docs/brainstorms/2026-03-19-dm-encryption-badge-brainstorm.md +++ b/docs/brainstorms/2026-03-19-dm-encryption-badge-brainstorm.md @@ -24,7 +24,7 @@ Users need to know which messages are truly private (NIP-17: relay can't see sen ## Implementation The badge goes in `MessageWithReactions` in ChatPane.kt, in the `detailRow` slot of `ChatMessageCompose`. Check `note.event` type: -- `is PrivateDmEvent` → NIP-04 → lock-open gray +- `is EncryptedDmEvent` → NIP-04 → lock-open gray - `is ChatMessageEvent` or `is ChatMessageEncryptedFileHeaderEvent` → NIP-17 → lock primary - else → no badge diff --git a/docs/changelog/v0.31.04.md b/docs/changelog/v0.31.04.md index ef95bfdc15..4f28425146 100644 --- a/docs/changelog/v0.31.04.md +++ b/docs/changelog/v0.31.04.md @@ -3,7 +3,7 @@ - Login with QR by [@greenart7c3](https://github.com/greenart7c3) - Adds full nip19 parsing on key decoding capabilities by [@vitorpamplona](https://github.com/vitorpamplona) - Speeds up RichText rendering parsers by [@vitorpamplona](https://github.com/vitorpamplona) -- added message to LnZapEvent and interface by [@believethehype](https://github.com/believethehype) +- added message to ZapReceiptEvent and interface by [@believethehype](https://github.com/believethehype) - Faster processing of Contact List events by [@vitorpamplona](https://github.com/vitorpamplona) - Faster user in follow list algo by [@vitorpamplona](https://github.com/vitorpamplona) diff --git a/docs/changelog/v0.76.01.md b/docs/changelog/v0.76.01.md index 592371ba62..8e6a2a72e8 100644 --- a/docs/changelog/v0.76.01.md +++ b/docs/changelog/v0.76.01.md @@ -14,7 +14,7 @@ Adds support for Zap Split setup and payment via NWC and manually via wallet cal - Updated translations for cs/de/sv - Forces valid hexes in p- and e- tags when receiving the event - Stops accepting space as a Valid hex char and requires an even number of chars (padding) -- Forces the ZapRequest to exist when processing the LnZapEvent +- Forces the ZapRequest to exist when processing the ZapReceiptEvent - Fixes some long NIP-19 cutting off in notes - Updates to Finnish, Swedish, Czech and German translations - Adds Bengali, Bangladesh translations diff --git a/docs/changelog/v1.03.00.md b/docs/changelog/v1.03.00.md index 5b4cfbe6f7..2a2942030b 100644 --- a/docs/changelog/v1.03.00.md +++ b/docs/changelog/v1.03.00.md @@ -12,7 +12,7 @@ Improvements: - Improves the list of visible authors on live stream bubbles - Adds the error status to the URL normalizer to avoid checking it again - Adds a follow list state from kind 3 to keep following users in memory. -- Moves from RelationshipStatus to ContactCard as per NIP update +- Moves from RelationshipStatus to UserAssertion as per NIP update Fixes: - Removes crashing relay URIs with null-encoded bytes (%00) diff --git a/docs/changelog/v1.12.00.md b/docs/changelog/v1.12.00.md index efc05f16c2..f350e4e6ed 100644 --- a/docs/changelog/v1.12.00.md +++ b/docs/changelog/v1.12.00.md @@ -267,7 +267,7 @@ Highlights: - **Amethyst → commons migration (KMP/iOS).** - Moves shared, CLI-safe code out of the Android app into `commons`. - Decryption caches (Mute/People/Community, Hashtag, Favorite-algo, Trust-provider). - - Models: InterestSet, LabeledBookmarkList, NwcWalletEntry, CashuToken, OwnedEmojiPack. + - Models: InterestSet, BookmarkSet, NwcWalletEntry, CashuToken, OwnedEmojiPack. - The link-preview fetcher, relay broadcast tracker, and CLI-safe util extensions. - `HtmlParser` made KMP (dropped its Java `Charset` dependency). - A consolidated package taxonomy with a new architecture doc. diff --git a/docs/changelog/v1.12.02.md b/docs/changelog/v1.12.02.md index 3a8cb91df0..0c6e2f4b50 100644 --- a/docs/changelog/v1.12.02.md +++ b/docs/changelog/v1.12.02.md @@ -20,7 +20,7 @@ Highlights: - Adds a pausable, resumable full-text-search reindex to the SQLite and filesystem event stores, and clamps non-positive reindex batch sizes. - Indexes direct message content (NIP-17 ChatMessageEvent). -- Indexes zap comments (LnZap request/receipt, on-chain zap, and nutzap). +- Indexes zap comments (ZapReceipt request/receipt, on-chain zap, and nutzap). - Makes polls, code snippets, audio, and git/torrent replies and interest sets searchable. - Indexes parsed JSON fields of profile, channel, and app-handler events. - Indexes natural-language fields of more event kinds, and makes the remaining text-bearing events searchable. diff --git a/docs/plans/2026-06-10-feat-desktop-dm-reliability-plan.md b/docs/plans/2026-06-10-feat-desktop-dm-reliability-plan.md index 3046cbb196..9bb432f044 100644 --- a/docs/plans/2026-06-10-feat-desktop-dm-reliability-plan.md +++ b/docs/plans/2026-06-10-feat-desktop-dm-reliability-plan.md @@ -381,7 +381,7 @@ The bulk of the change lives in `quartz/.../nip01Core/relay/client/` (publish pa **Scope:** 1. **Shared `rumorCreatedAt` across recipient wraps** (R9): - - In `NIP17Factory.createWraps` (currently `quartz/.../nip17Dm/NIP17Factory.kt:43-72`), compute `rumorCreatedAt = TimeUtils.now()` once before the per-recipient `mapNotNullAsync` loop. Pass into every `SealedRumorEvent.create(...)` so all seals encode the same rumor (same `rumor.id`). + - In `NIP17Factory.createWraps` (currently `quartz/.../nip17Dm/NIP17Factory.kt:43-72`), compute `rumorCreatedAt = TimeUtils.now()` once before the per-recipient `mapNotNullAsync` loop. Pass into every `SealEvent.create(...)` so all seals encode the same rumor (same `rumor.id`). - Same `rumorId` becomes the dedupe anchor + receipt target across all recipients of a group message. 2. **Self-copy gift wrap to own DM relays** (R10): @@ -476,7 +476,7 @@ ComposeUI(send button click) → RecipientRelayFetcher.fetch([indexer relays]) → NIP17Factory.createWraps(text, recipients, signer) ── shared rumor_created_at (Phase 5) → for each recipient (parallel): - → SealedRumorEvent.create(rumor, recipient, signer) + → SealEvent.create(rumor, recipient, signer) → signer.sign(seal) (bunker round-trip if Remote) ── batch via Phase 6 capability → signer.nip44Encrypt(rumor, recipient) (bunker round-trip)── batch via Phase 6 capability → GiftWrapEvent.create(seal, recipient, ephemeralKey) diff --git a/docs/plans/archive/2026-03-18-feat-desktop-cache-navigation-persistence-plan.md b/docs/plans/archive/2026-03-18-feat-desktop-cache-navigation-persistence-plan.md index 40c4f29743..abc58a5be8 100644 --- a/docs/plans/archive/2026-03-18-feat-desktop-cache-navigation-persistence-plan.md +++ b/docs/plans/archive/2026-03-18-feat-desktop-cache-navigation-persistence-plan.md @@ -124,8 +124,8 @@ Start with 4 new event kinds (kind 9734 required for zap processing). Add remain | 0 | `MetadataEvent` | Done | Already exists (`consumeMetadata`) | | 1 | `TextNoteEvent` | 1 | Core feed content | | 7 | `ReactionEvent` | 1 | Reaction counts on Note | -| 9734 | `LnZapRequestEvent` | 1 | Required before kind 9735 can process | -| 9735 | `LnZapEvent` | 1 | Zap counts on Note | +| 9734 | `ZapRequestEvent` | 1 | Required before kind 9735 can process | +| 9735 | `ZapReceiptEvent` | 1 | Zap counts on Note | Each consume method follows Android's pattern. Use `event.tagsWithoutCitations()` for reply parsing (handles both NIP-10 marked and legacy positional tags, excluding inline nostr: citations): @@ -410,7 +410,7 @@ rememberSubscription(configuredRelays, feedMode, followedUsers, relayManager = r | UserProfileScreen | Parameterized (pubkey) | — | Uses existing kinds | | SearchResultsList | Parameterized (query) | — | Uses DesktopSearchFeedFilter | | BookmarksScreen | Singleton | 30078 (BookmarkList) | Bookmark state from events | -| ReadsScreen | Singleton | 30023 (LongTextNote) | Articles feed | +| ReadsScreen | Singleton | 30023 (LongFormContent) | Articles feed | | NotificationsScreen | Singleton | — | Uses DesktopNotificationFeedFilter | **FeedNoteCard rewrite** — done alongside FeedScreen migration (first screen). All subsequent screen migrations benefit. diff --git a/docs/plans/archive/2026-03-22-feat-clean-cache-single-source-of-truth-plan.md b/docs/plans/archive/2026-03-22-feat-clean-cache-single-source-of-truth-plan.md index efd1a1f98a..a72899608b 100644 --- a/docs/plans/archive/2026-03-22-feat-clean-cache-single-source-of-truth-plan.md +++ b/docs/plans/archive/2026-03-22-feat-clean-cache-single-source-of-truth-plan.md @@ -166,7 +166,7 @@ Four-phase migration: FeedScreen first (proves pattern), then expand cache cover ##### 1a. Expand `DesktopLocalCache.consume()` coverage -Currently handles: MetadataEvent, TextNoteEvent, ReactionEvent, LnZapRequestEvent, LnZapEvent. +Currently handles: MetadataEvent, TextNoteEvent, ReactionEvent, ZapRequestEvent, ZapReceiptEvent. **Add support for:** @@ -174,7 +174,7 @@ Currently handles: MetadataEvent, TextNoteEvent, ReactionEvent, LnZapRequestEven |------------|------|--------|-------| | `RepostEvent` | 6 | `consumeRepost()` | `Note.addBoost()` on target | | `ContactListEvent` | 3 | `consumeContactList()` | Updates `_followedUsers` StateFlow | -| `LongTextNoteEvent` | 30023 | `consumeLongTextNote()` | Creates Note like TextNote | +| `LongFormContentEvent` | 30023 | `consumeLongFormContent()` | Creates Note like TextNote | | `BookmarkListEvent` | 30001 | `consumeBookmarkList()` | Stores on `addressableNotes` or dedicated field | **File:** `desktopApp/.../cache/DesktopLocalCache.kt` @@ -461,7 +461,7 @@ when (val state = feedState) { ##### Phase 1 Acceptance Criteria -- [ ] `DesktopLocalCache.consume()` handles RepostEvent, ContactListEvent, LongTextNoteEvent, BookmarkListEvent +- [ ] `DesktopLocalCache.consume()` handles RepostEvent, ContactListEvent, LongFormContentEvent, BookmarkListEvent - [ ] consume() uses kind-based registry dispatch (not growing `when` block) - [ ] `followedUsers` is `MutableStateFlow` (not `@Volatile`) - [ ] Coordinator scope uses `SupervisorJob` + `CoroutineExceptionHandler` @@ -513,7 +513,7 @@ Apply the proven pattern from Phase 1 to all other screens. Each screen gets at ##### 2d. ReadsScreen - `DesktopFeedViewModel(DesktopReadsFeedFilter(cache), cache)` -- **Card rendering:** ReadsScreen needs `LongFormNoteCard` that extracts title/summary/topics from `Note.event as? LongTextNoteEvent`. Separate composable, not FeedNoteCard. +- **Card rendering:** ReadsScreen needs `LongFormNoteCard` that extracts title/summary/topics from `Note.event as? LongFormContentEvent`. Separate composable, not FeedNoteCard. **File:** `desktopApp/.../ui/ReadsScreen.kt` @@ -523,7 +523,7 @@ Apply the proven pattern from Phase 1 to all other screens. Each screen gets at ```kotlin fun Note.toNotificationItem(): NotificationItem? = when (event) { is ReactionEvent -> NotificationItem.Reaction(this) - is LnZapEvent -> NotificationItem.Zap(this) + is ZapReceiptEvent -> NotificationItem.Zap(this) is TextNoteEvent -> if (isReply) NotificationItem.Reply(this) else NotificationItem.Mention(this) else -> null } diff --git a/docs/plans/archive/2026-03-24-feat-article-highlights-notes-plan.md b/docs/plans/archive/2026-03-24-feat-article-highlights-notes-plan.md index 6c663793cc..64c71fbebc 100644 --- a/docs/plans/archive/2026-03-24-feat-article-highlights-notes-plan.md +++ b/docs/plans/archive/2026-03-24-feat-article-highlights-notes-plan.md @@ -286,7 +286,7 @@ Track mouse via `Modifier.pointerInput` + `awaitPointerEventScope` (pattern from object HighlightPublishAction { suspend fun publish( highlightText: String, - articleEvent: LongTextNoteEvent, + articleEvent: LongFormContentEvent, note: String?, signer: NostrSigner, ): HighlightEvent { @@ -323,8 +323,8 @@ object HighlightPublishAction { ##### NIP-09 Deletion for Published Highlights ```kotlin -suspend fun deleteHighlight(eventId: String, signer: NostrSigner): DeletionEvent { - return DeletionEvent.create( +suspend fun deleteHighlight(eventId: String, signer: NostrSigner): DeletionRequestEvent { + return DeletionRequestEvent.create( deleteEvents = listOf(eventId), deleteKinds = listOf(9802), reason = "User deleted highlight", diff --git a/docs/plans/archive/2026-04-21-feat-relay-config-parity-plan.md b/docs/plans/archive/2026-04-21-feat-relay-config-parity-plan.md index 51320c1701..4e5093464d 100644 --- a/docs/plans/archive/2026-04-21-feat-relay-config-parity-plan.md +++ b/docs/plans/archive/2026-04-21-feat-relay-config-parity-plan.md @@ -115,12 +115,12 @@ fun DmRelayEditor( - Simple relay list (no read/write split — DM relays are all-or-nothing) - Warning banner if empty: "No DM relays configured — DMs will use connected relays as fallback" -- "Save" builds `ChatMessageRelayListEvent` → sign → publish +- "Save" builds `DmRelayListEvent` → sign → publish - Security: highlight that these relays see your DM metadata **Data flow:** 1. Read current: `accountRelays.dmRelayList` StateFlow -2. Save: build `ChatMessageRelayListEvent.create(relays, signer)` → publish +2. Save: build `DmRelayListEvent.create(relays, signer)` → publish **Integration:** - Replace "DM Relays — coming soon" placeholder in `RelayConfigTab` @@ -197,7 +197,7 @@ All editors follow the same pattern — reuse `RelayListEditor` for the add/remo | Kind | Event Class | Tag Format | |------|------------|------------| | 10002 | `AdvertisedRelayListEvent` | `["r", "wss://...", "read"\|"write"]` | -| 10050 | `ChatMessageRelayListEvent` | `["relay", "wss://..."]` | +| 10050 | `DmRelayListEvent` | `["relay", "wss://..."]` | | 10007 | `SearchRelayListEvent` | `["relay", "wss://..."]` | | 10006 | `BlockedRelayListEvent` | `["relay", "wss://..."]` | @@ -214,7 +214,7 @@ All editors follow the same pattern — reuse `RelayListEditor` for the add/remo ### Phase 3b: DM Relays - [ ] DM section shows current kind 10050 relays - [ ] Warning if empty -- [ ] Save signs + publishes ChatMessageRelayListEvent +- [ ] Save signs + publishes DmRelayListEvent - [ ] Shows publish confirmation ### Phase 3c: Search Relays diff --git a/docs/plans/archive/2026-04-21-feat-relay-subscription-wiring-plan.md b/docs/plans/archive/2026-04-21-feat-relay-subscription-wiring-plan.md index 3226771755..95697cce76 100644 --- a/docs/plans/archive/2026-04-21-feat-relay-subscription-wiring-plan.md +++ b/docs/plans/archive/2026-04-21-feat-relay-subscription-wiring-plan.md @@ -144,7 +144,7 @@ val blockedRelayList: StateFlow<Set<NormalizedRelayUrl>> = _blockedRelayList.asS fun consumeIfRelevant(event: Event): Boolean { return when (event.kind) { - ChatMessageRelayListEvent.KIND -> { consumeDmRelayList(event as ChatMessageRelayListEvent); true } + DmRelayListEvent.KIND -> { consumeDmRelayList(event as DmRelayListEvent); true } SearchRelayListEvent.KIND -> { consumeSearchRelayList(event); true } BlockedRelayListEvent.KIND -> { consumeBlockedRelayList(event); true } else -> false diff --git a/docs/plans/archive/2026-04-22-feat-relay-subscription-wiring-plan.md b/docs/plans/archive/2026-04-22-feat-relay-subscription-wiring-plan.md index 497ceecb91..b69d557e79 100644 --- a/docs/plans/archive/2026-04-22-feat-relay-subscription-wiring-plan.md +++ b/docs/plans/archive/2026-04-22-feat-relay-subscription-wiring-plan.md @@ -61,10 +61,10 @@ private var lastDmCreatedAt = 0L fun consumeIfRelevant(event: Event): Boolean { return when (event.kind) { - ChatMessageRelayListEvent.KIND -> { + DmRelayListEvent.KIND -> { if (event.createdAt > lastDmCreatedAt) { lastDmCreatedAt = event.createdAt - consumeDmRelayList(event as ChatMessageRelayListEvent) + consumeDmRelayList(event as DmRelayListEvent) } true } diff --git a/docs/plans/archive/2026-04-23-feat-desktop-multi-account-support-plan.md b/docs/plans/archive/2026-04-23-feat-desktop-multi-account-support-plan.md index 43ecaa7cbd..68844ec0ae 100644 --- a/docs/plans/archive/2026-04-23-feat-desktop-multi-account-support-plan.md +++ b/docs/plans/archive/2026-04-23-feat-desktop-multi-account-support-plan.md @@ -399,7 +399,7 @@ The KMP expert found that `AccountSessionManager` and `AccountCacheState` **cann - Use `#p` tag filters (not `authors`) — listening *for* the account, not *from* it - **Exclude kind 7 reactions** — too noisy for background counts. Use NIP-45 count query at foreground activation if needed - **Include kind 6 reposts** — same filter as kind 1 mentions, relatively rare, worth tracking -- NIP-65 `readRelaysNorm()` for general notifications; kind 10050 `ChatMessageRelayListEvent` for DM-specific inbox relays +- NIP-65 `readRelaysNorm()` for general notifications; kind 10050 `DmRelayListEvent` for DM-specific inbox relays - Max 5 relay connections per inactive account (3 inbox + 2 DM) - Always set `since` field — prevents relay flooding on reconnect - Separate `RelayAuthenticator` for background connections (don't reuse active account's) diff --git a/docs/plans/archive/2026-05-04-fix-bunker-timeouts-and-decryption-plan.md b/docs/plans/archive/2026-05-04-fix-bunker-timeouts-and-decryption-plan.md index 1c6acd5ace..fbc4bc0c94 100644 --- a/docs/plans/archive/2026-05-04-fix-bunker-timeouts-and-decryption-plan.md +++ b/docs/plans/archive/2026-05-04-fix-bunker-timeouts-and-decryption-plan.md @@ -221,7 +221,7 @@ No `since` → relay reconnection replays old events. This is GOOD for our retry Current code: ```kotlin decryptedContent = when (event) { - is PrivateDmEvent -> { + is EncryptedDmEvent -> { try { event.decryptContent(account.signer) } catch (_: Exception) { @@ -245,7 +245,7 @@ if (eventContent != null) { ```kotlin decryptedContent = when (event) { - is PrivateDmEvent -> { + is EncryptedDmEvent -> { try { event.decryptContent(account.signer) } catch (_: Exception) { diff --git a/docs/plans/archive/2026-05-22-feat-desktop-note-action-bar-ux-plan.md b/docs/plans/archive/2026-05-22-feat-desktop-note-action-bar-ux-plan.md index 1ccfdf5fac..a333621aa3 100644 --- a/docs/plans/archive/2026-05-22-feat-desktop-note-action-bar-ux-plan.md +++ b/docs/plans/archive/2026-05-22-feat-desktop-note-action-bar-ux-plan.md @@ -146,7 +146,7 @@ val zapEntries = note.zaps.mapNotNull { (request, receipt) -> val sender = request.author?.toBestDisplayName() ?: request.event?.pubKey?.take(8) ?: return@mapNotNull null - val amount = (receipt?.event as? LnZapEvent)?.amount?.toLong() + val amount = (receipt?.event as? ZapReceiptEvent)?.amount?.toLong() ?: return@mapNotNull null Triple(sender, amount, request.event?.content?.ifBlank { null }) }.sortedByDescending { it.second } diff --git a/docs/plans/archive/2026-06-02-fix-desktop-feed-review-findings-plan.md b/docs/plans/archive/2026-06-02-fix-desktop-feed-review-findings-plan.md index d61e49c14a..17697b2eaa 100644 --- a/docs/plans/archive/2026-06-02-fix-desktop-feed-review-findings-plan.md +++ b/docs/plans/archive/2026-06-02-fix-desktop-feed-review-findings-plan.md @@ -39,8 +39,8 @@ Eight parallel agents resolved all 5 open questions and surfaced 3 plan revision debounce. - **Q4 — NoteActions.kt:264 formatSats:** sats, safe to swap to `amount.toZapAmount()`. Inputs are hardcoded preset amounts (line 111 - `ZAP_AMOUNTS = listOf(21L, 100L, ...)`) and `LnZapEvent.amount` which is - already sats (`LnZapEvent.kt:69`). + `ZAP_AMOUNTS = listOf(21L, 100L, ...)`) and `ZapReceiptEvent.amount` which is + already sats (`ZapReceiptEvent.kt:69`). - **Q5 — WalletColumnScreen.kt:979 formatSats:** intentional. Wallet shows precise balance with locale-aware grouping (`1,000,000`). Leave + add `// intentional` comment to prevent future drift. @@ -378,7 +378,7 @@ zapCount = if (note.zapsAmount > BigDecimal.ZERO) showAmount(note.zapsAmount) el **Edit:** `NoteActions.kt:264` — swap to `amount.toZapAmount()`. Verified sats (not msats): inputs are `ZAP_AMOUNTS = listOf(21L, 100L, 500L, 1000L, 5000L, 10000L)` -at line 111 + `LnZapEvent.amount` which is sats per `LnZapEvent.kt:69`. +at line 111 + `ZapReceiptEvent.amount` which is sats per `ZapReceiptEvent.kt:69`. **Delete the private `formatSats` fun if no remaining references** (run `grep -n formatSats desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/NoteActions.kt` after swap). diff --git a/quartz/plans/2026-06-12-giftwrap-deletion-requests.md b/quartz/plans/2026-06-12-giftwrap-deletion-requests.md index d2791d65db..f392c4d991 100644 --- a/quartz/plans/2026-06-12-giftwrap-deletion-requests.md +++ b/quartz/plans/2026-06-12-giftwrap-deletion-requests.md @@ -46,7 +46,7 @@ special case describes — does nothing. `GiftWrapEvent.recipientPubKey()` at unseal time, so the validation below works after the wrap note is GC'd. -3. **Live cascade (amethyst `LocalCache.consume(DeletionEvent)`):** the +3. **Live cascade (amethyst `LocalCache.consume(DeletionRequestEvent)`):** the wrap note that knew its `innerEventId` is GC'd by the time a deletion arrives, so find the rumor by reverse lookup: scan notes for `note.rumorHost?.id == deletedId` (precedent: the addressable pass in diff --git a/quartz/plans/2026-07-11-concord-event-classes.md b/quartz/plans/2026-07-11-concord-event-classes.md index 82e57ac9a4..76b1a1ce32 100644 --- a/quartz/plans/2026-07-11-concord-event-classes.md +++ b/quartz/plans/2026-07-11-concord-event-classes.md @@ -10,7 +10,7 @@ Two problems: 1. **Duplicates standard Nostr kinds.** `ConcordKinds.MESSAGE=9`, `REACTION=7`, `DELETE=5`, `COMMENT=1111`, `EDIT=3302` shadow `ChatEvent.KIND`, - `ReactionEvent.KIND`, `DeletionEvent.KIND`, `CommentEvent.KIND`. Concord chat + `ReactionEvent.KIND`, `DeletionRequestEvent.KIND`, `CommentEvent.KIND`. Concord chat rumors *are* those standard events (they already parse back as `ChatEvent` etc. on read) — the build side should reuse the classes, not re-derive by number. @@ -37,7 +37,7 @@ binding. Introduce a binding-tag package and reuse the standard builders: | message (9) | `ChatEvent.build` | `channel` + `epoch` | | reply (9 + q) | `ChatEvent.build` + `q`/`p` | `channel` + `epoch` | | reaction (7) | `ReactionEvent.build` | `channel` + `epoch` | -| delete (5) | `DeletionEvent.build` | `channel` + `epoch` | +| delete (5) | `DeletionRequestEvent.build` | `channel` + `epoch` | `ChannelChat` keeps its public API (returns unsigned rumors via `RumorAssembler`) but builds tags from the standard event's DSL + the binding ext. Delete diff --git a/quartz/plans/archive/2026-06-09-clink.md b/quartz/plans/archive/2026-06-09-clink.md index 3529780fe0..fff712d54a 100644 --- a/quartz/plans/archive/2026-06-09-clink.md +++ b/quartz/plans/archive/2026-06-09-clink.md @@ -59,7 +59,7 @@ tags, `["e", reqId]` on responses, NIP-44 JSON content, GFY error codes | NIP-44 encrypt/decrypt | ✅ Reuse | `quartz/.../nip44Encryption/` + `signer.nip44Encrypt/Decrypt` | Use as-is | | Bech32 + TLV codec | ✅ Reuse | `nip19Bech32/bech32/`, `tlv/TlvBuilder.kt`, `tlv/Tlv.kt` | Use the codec; do NOT reuse `Nip19Parser` | | Entity TLV pattern (reference) | 📦 Mirror | `nip19Bech32/entities/NProfile.kt` | Copy shape into new Clink entities | -| Encrypted req/resp event pattern | 📦 Mirror | `nip47WalletConnect/events/LnZapPaymentRequestEvent.kt` (kind 23194) | Clone for kinds 21001/2/3, client + server | +| Encrypted req/resp event pattern | 📦 Mirror | `nip47WalletConnect/events/NwcRequestEvent.kt` (kind 23194) | Clone for kinds 21001/2/3, client + server | | Request/response over relay | ✅ Reuse | `Nip47Client.responseFilter()`, `relayClient/reqCommand/nwc/` | Same filter-by-`e`-tag pattern | | BOLT-11 parsing | ✅ Reuse | `quartz/.../lightning/LnInvoiceUtil.kt` | Use as-is | | LN payment execution | ✅ Reuse | `amethyst/.../service/ZapPaymentHandler.kt`, `NwcSignerState` | Add CLINK routes | @@ -85,7 +85,7 @@ with `events/`, `pointers/`, `rpc/` subfolders. 3. **Events** — `OfferEvent(21001)`, `DebitEvent(21002)`, `ManageEvent(21003)`, each `isContentEncoded() = true`, with `createRequest()` / `createResponse()` companions that NIP-44-encrypt JSON and set `p` / `clink_version` / `e` tags - (direct analogue of `LnZapPaymentRequestEvent`). Register in `EventFactory`. + (direct analogue of `NwcRequestEvent`). Register in `EventFactory`. 4. **DTOs + errors** — Jackson request/response classes per spec, shared `GfyError(code, message, range?, retryAfter?, delta?)`, Offers error model (`code` 1..5, `range`, `latest`). diff --git a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestNip44EventTest.kt similarity index 98% rename from quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt rename to quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestNip44EventTest.kt index e3e0232e4f..8758bed7ad 100644 --- a/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt +++ b/quartz/src/androidDeviceTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestNip44EventTest.kt @@ -35,7 +35,7 @@ import kotlin.test.assertEquals import kotlin.test.assertIs @RunWith(AndroidJUnit4::class) -class LnZapPaymentRequestNip44EventTest { +class NwcRequestNip44EventTest { @Test fun testCreateRequestWithNip44() = runTest { diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/SignerResult.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/SignerResult.kt index 2191d6a903..63dae210a5 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/SignerResult.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/SignerResult.kt @@ -22,7 +22,7 @@ package com.vitorpamplona.quartz.nip55AndroidSigner.api import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent sealed interface SignerResult<T : IResult> { sealed interface RequestAddressed<T : IResult> : SignerResult<T> { @@ -83,7 +83,7 @@ data class DecryptionResult( ) : IResult data class ZapEventDecryptionResult( - val privateEvent: LnZapPrivateEvent, + val privateEvent: PrivateZapEvent, ) : IResult data class DerivationResult( diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/background/queries/DecryptZapQuery.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/background/queries/DecryptZapQuery.kt index b41c591e9c..bb9cf0c4f7 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/background/queries/DecryptZapQuery.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/background/queries/DecryptZapQuery.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip55AndroidSigner.api.SignerResult import com.vitorpamplona.quartz.nip55AndroidSigner.api.ZapEventDecryptionResult import com.vitorpamplona.quartz.nip55AndroidSigner.api.background.utils.getStringByName import com.vitorpamplona.quartz.nip55AndroidSigner.api.background.utils.query -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent class DecryptZapQuery( val loggedInUser: HexKey, @@ -45,7 +45,7 @@ class DecryptZapQuery( val decryptedEventAsJson = cursor.getStringByName("result") if (!decryptedEventAsJson.isNullOrBlank()) { if (decryptedEventAsJson.startsWith("{")) { - val event = Event.fromJsonOrNull(decryptedEventAsJson) as? LnZapPrivateEvent + val event = Event.fromJsonOrNull(decryptedEventAsJson) as? PrivateZapEvent if (event != null) { if (event.verify()) { SignerResult.RequestAddressed.Successful(ZapEventDecryptionResult(event)) diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/responses/DecryptZapResponse.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/responses/DecryptZapResponse.kt index 38b7253126..f39e730a00 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/responses/DecryptZapResponse.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/api/foreground/intents/responses/DecryptZapResponse.kt @@ -24,11 +24,11 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip55AndroidSigner.api.SignerResult import com.vitorpamplona.quartz.nip55AndroidSigner.api.ZapEventDecryptionResult import com.vitorpamplona.quartz.nip55AndroidSigner.api.foreground.intents.results.IntentResult -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent class DecryptZapResponse { companion object { - fun assemble(event: LnZapPrivateEvent): IntentResult = + fun assemble(event: PrivateZapEvent): IntentResult = IntentResult( result = event.toJson(), ) @@ -40,7 +40,7 @@ class DecryptZapResponse { val eventJson = intent.result return if (!eventJson.isNullOrBlank()) { if (eventJson.startsWith("{")) { - val event = Event.fromJsonOrNull(eventJson) as? LnZapPrivateEvent + val event = Event.fromJsonOrNull(eventJson) as? PrivateZapEvent if (event != null) { SignerResult.RequestAddressed.Successful(ZapEventDecryptionResult(event)) } else { diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt index c5d1a6c388..218ca03dbc 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip55AndroidSigner/client/NostrSignerExternal.kt @@ -36,7 +36,7 @@ import com.vitorpamplona.quartz.nip55AndroidSigner.api.SignerResult import com.vitorpamplona.quartz.nip55AndroidSigner.api.ZapEventDecryptionResult import com.vitorpamplona.quartz.nip55AndroidSigner.client.handlers.BackgroundRequestHandler import com.vitorpamplona.quartz.nip55AndroidSigner.client.handlers.ForegroundRequestHandler -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent class NostrSignerExternal( @@ -163,7 +163,7 @@ class NostrSignerExternal( throw convertExceptions("Could not derive key", result) } - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent { + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent { if (!event.isPrivateZap()) throw SignerExceptions.NothingToDecrypt() val result = backgroundQuery.decryptZapEvent(event) ?: foregroundQuery.decryptZapEvent(event) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt index fd07f11def..a4f4695cd4 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/kinds/KindNames.kt @@ -161,21 +161,20 @@ import com.vitorpamplona.quartz.nip51Lists.appCurationSet.AppCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent import com.vitorpamplona.quartz.nip51Lists.gitAuthorList.GitAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.gitRepositoryList.GitRepositoryListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiAuthorList.GoodWikiAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiRelayList.GoodWikiRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.kindMuteSet.KindMuteSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaFollowList.MediaFollowListEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent @@ -186,6 +185,7 @@ import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent @@ -204,7 +204,7 @@ import com.vitorpamplona.quartz.nip54Wiki.WikiMergeAcceptanceEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeRequestEvent import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent @@ -452,7 +452,7 @@ object KindNames { ZapReceiptEvent.KIND to KindName("Zaps", "57"), NwcRequestEvent.KIND to KindName("NWC Request", "47"), NwcResponseEvent.KIND to KindName("NWC Response", "47"), - LnZapPrivateEvent.KIND to KindName("Private Zaps", "57"), + PrivateZapEvent.KIND to KindName("Private Zaps", "57"), ZapRequestEvent.KIND to KindName("Zap Req", "57"), LongFormContentEvent.KIND to KindName("Blogs", "23"), MeetingRoomEvent.KIND to KindName("Meeting Room", "53"), diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt index a1c6d5fb53..4110efe500 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/MarmotInboundProcessor.kt @@ -379,7 +379,7 @@ class MarmotInboundProcessor( /** * Process a WelcomeEvent after NIP-59 gift wrap unwrapping. * - * Called by the platform layer after unwrapping a GiftWrap → SealedRumor → WelcomeEvent. + * Called by the platform layer after unwrapping a GiftWrap → Seal → WelcomeEvent. * * Flow: * 1. Extract welcome bytes and KeyPackage event ID diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt index 2f4cc00f48..9558c6fc4d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/marmot/mip02Welcome/WelcomeGiftWrap.kt @@ -81,7 +81,7 @@ object WelcomeGiftWrap { // Step 2: Create a Rumor from the unsigned event and seal it (kind:13) val rumor = Rumor.create(welcomeRumor) - val sealedRumor = + val sealEvent = SealEvent.create( rumor = rumor, encryptTo = recipientPubKey, @@ -90,7 +90,7 @@ object WelcomeGiftWrap { // Step 3: Gift wrap (kind:1059) with an ephemeral key to the recipient return GiftWrapEvent.create( - event = sealedRumor, + event = sealEvent, recipientPubKey = recipientPubKey, ) } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt index b87513ce80..bf50e9cd50 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSigner.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.nip01Core.signers import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip04Dm.crypto.EncryptedInfo -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent abstract class NostrSigner( @@ -67,7 +67,7 @@ abstract class NostrSigner( fromPublicKey: HexKey, ): String - abstract suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent + abstract suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent abstract suspend fun deriveKey(nonce: HexKey): HexKey diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt index acb512e5c6..006fd3791c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerInternal.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.toHexKey import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CancellationException @@ -89,7 +89,7 @@ class NostrSignerInternal( // always ready override fun hasForegroundSupport() = true - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent { + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent { if (!event.isPrivateZap()) throw SignerExceptions.NothingToDecrypt() return runWrapErrors { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt index 90566d4e7c..a821b95976 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/signers/NostrSignerSync.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair import com.vitorpamplona.quartz.nip04Dm.crypto.EncryptedInfo import com.vitorpamplona.quartz.nip04Dm.crypto.Nip04 import com.vitorpamplona.quartz.nip44Encryption.Nip44 -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.PrivateZapRequestBuilder import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nipBCOnchainZaps.psbt.Psbt @@ -129,7 +129,7 @@ class NostrSignerSync( ) } - fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = PrivateZapRequestBuilder().decryptZapEvent(event, this) + fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = PrivateZapRequestBuilder().decryptZapEvent(event, this) /** * NIP-BC `sign_psbt`: sign the key-path P2TR inputs of [psbtHex] this key diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt index 3e9e00597d..770c08923d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip13Pow/signer/PoWNostrSigner.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip13Pow.miner.PoWMiner import com.vitorpamplona.quartz.nip13Pow.tags.PoWTag -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent /** @@ -98,7 +98,7 @@ class PoWNostrSigner( fromPublicKey: HexKey, ): String = signer.nip44Decrypt(ciphertext, fromPublicKey) - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = signer.decryptZapEvent(event) + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = signer.decryptZapEvent(event) override suspend fun deriveKey(nonce: HexKey): HexKey = signer.deriveKey(nonce) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/ChannelListDiff.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListDiff.kt similarity index 84% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/ChannelListDiff.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListDiff.kt index 69ab74f29c..3143cb4363 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/ChannelListDiff.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListDiff.kt @@ -28,9 +28,15 @@ import com.vitorpamplona.quartz.nip28PublicChat.list.tags.ChannelTag /** Changes to the joined public chats: public channels as parsed tags, private ones as a whole. */ @Immutable -class ChannelListDiff( +class PublicChatListDiff( val channels: ListDiff<ChannelTag>, val privateItems: ContentChange, ) : EventDiff { override fun removesData() = privateItems.publicRemovalsAreLoss(channels.hasRemovals()) || privateItems.isRemoval() } + +@Deprecated( + "Renamed to PublicChatListDiff. Follows the ChannelListEvent to PublicChatListEvent rename (NIP-51 public chats list).", + ReplaceWith("PublicChatListDiff", "com.vitorpamplona.quartz.nip28PublicChat.list.PublicChatListDiff"), +) +typealias ChannelListDiff = PublicChatListDiff diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListEvent.kt index 08cdbbb345..78dd9fc4eb 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip28PublicChat/list/PublicChatListEvent.kt @@ -50,11 +50,11 @@ class PublicChatListEvent( content: String, sig: HexKey, ) : PrivateTagArrayEvent(id, pubKey, createdAt, KIND, tags, content, sig), - DiffableEvent<ChannelListDiff>, + DiffableEvent<PublicChatListDiff>, EventHintProvider { - override fun diffFrom(older: Event): ChannelListDiff? { + override fun diffFrom(older: Event): PublicChatListDiff? { if (older !is PublicChatListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null - return ChannelListDiff( + return PublicChatListDiff( ListDiff.of(older.tags.channels(), tags.channels(), { it.eventId }, { a, b -> a.relay == b.relay }), privateItemsChangeFrom(older), ) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt index f58bd0ad69..5a7820cc32 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/signer/NostrSignerRemote.kt @@ -40,7 +40,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestNip44Encrypt import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestPing import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestSign import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.utils.Hex import com.vitorpamplona.quartz.utils.Log @@ -325,7 +325,7 @@ class NostrSignerRemote( throw convertExceptions("Could not get public key", result) } - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent { + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent { TODO("Not yet implemented") } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt index e6176a77fb..139530d089 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractor.kt @@ -71,14 +71,14 @@ import com.vitorpamplona.quartz.nip51Lists.appCurationSet.AppCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent @@ -607,7 +607,7 @@ object SearchFieldExtractor { // kinds 1111/1311 -- body-only kinds whose indexableContent() // concatenates the `t` tags INTO the body. The funnel already // carries them in the hashtag role, so passing the body alone - // stops the same words being indexed twice (the ContactCard + // stops the same words being indexed twice (the UserAssertion // reasoning above, applied to the two chat/comment kinds). is CommentEvent -> { tiers(event, null, null, event.content) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/BookmarkSetEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/bookmarkSet/BookmarkSetEvent.kt similarity index 97% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/BookmarkSetEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/bookmarkSet/BookmarkSetEvent.kt index 01494372a3..318f74f5c5 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/BookmarkSetEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/bookmarkSet/BookmarkSetEvent.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList +package com.vitorpamplona.quartz.nip51Lists.bookmarkSet import androidx.compose.runtime.Immutable import com.vitorpamplona.quartz.nip01Core.core.Address @@ -335,9 +335,3 @@ class BookmarkSetEvent( } } } - -@Deprecated( - "Renamed to BookmarkSetEvent. NIP-51 names kind 30003 bookmark sets.", - ReplaceWith("BookmarkSetEvent", "com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent"), -) -typealias LabeledBookmarkListEvent = BookmarkSetEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/bookmarkSet/TagArrayBuilderExt.kt similarity index 97% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/TagArrayBuilderExt.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/bookmarkSet/TagArrayBuilderExt.kt index 5754f4f9f2..568b662ff4 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/bookmarkSet/TagArrayBuilderExt.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList +package com.vitorpamplona.quartz.nip51Lists.bookmarkSet import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.BookmarkIdTag diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/Deprecated.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/Deprecated.kt new file mode 100644 index 0000000000..f4ba91cd99 --- /dev/null +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/Deprecated.kt @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +@file:Suppress("DEPRECATION") + +package com.vitorpamplona.quartz.nip51Lists.followList + +import com.vitorpamplona.quartz.nip01Core.core.HexKey +import com.vitorpamplona.quartz.nip01Core.core.TagArray +import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder +import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.description as movedDescription +import com.vitorpamplona.quartz.nip51Lists.starterPack.followIdSet as movedFollowIdSet +import com.vitorpamplona.quartz.nip51Lists.starterPack.followIds as movedFollowIds +import com.vitorpamplona.quartz.nip51Lists.starterPack.follows as movedFollows +import com.vitorpamplona.quartz.nip51Lists.starterPack.image as movedImage +import com.vitorpamplona.quartz.nip51Lists.starterPack.people as movedPeople +import com.vitorpamplona.quartz.nip51Lists.starterPack.person as movedPerson +import com.vitorpamplona.quartz.nip51Lists.starterPack.personFirst as movedPersonFirst +import com.vitorpamplona.quartz.nip51Lists.starterPack.removePerson as movedRemovePerson +import com.vitorpamplona.quartz.nip51Lists.starterPack.title as movedTitle + +// This package was renamed to com.vitorpamplona.quartz.nip51Lists.starterPack (NIP-51 kind 39089 is a starter pack). +// Everything below forwards to it and will be removed in a future release. + +private const val MOVED = "Moved to com.vitorpamplona.quartz.nip51Lists.starterPack" + +@Deprecated( + "Renamed to StarterPackEvent and moved to com.vitorpamplona.quartz.nip51Lists.starterPack. NIP-51 kind 39089 is a starter pack.", + ReplaceWith("StarterPackEvent", "com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent"), +) +typealias FollowListEvent = StarterPackEvent + +@Deprecated(MOVED, ReplaceWith("title(title)", "com.vitorpamplona.quartz.nip51Lists.starterPack.title")) +fun TagArrayBuilder<StarterPackEvent>.title(title: String) = movedTitle(title) + +@Deprecated(MOVED, ReplaceWith("description(desc)", "com.vitorpamplona.quartz.nip51Lists.starterPack.description")) +fun TagArrayBuilder<StarterPackEvent>.description(desc: String) = movedDescription(desc) + +@Deprecated(MOVED, ReplaceWith("image(imageUrl)", "com.vitorpamplona.quartz.nip51Lists.starterPack.image")) +fun TagArrayBuilder<StarterPackEvent>.image(imageUrl: String) = movedImage(imageUrl) + +@Deprecated(MOVED, ReplaceWith("people(peoples)", "com.vitorpamplona.quartz.nip51Lists.starterPack.people")) +fun TagArrayBuilder<StarterPackEvent>.people(peoples: List<UserTag>) = movedPeople(peoples) + +@Deprecated(MOVED, ReplaceWith("person(person)", "com.vitorpamplona.quartz.nip51Lists.starterPack.person")) +fun TagArrayBuilder<StarterPackEvent>.person(person: UserTag) = movedPerson(person) + +@Deprecated(MOVED, ReplaceWith("person(pubkey, relayHint)", "com.vitorpamplona.quartz.nip51Lists.starterPack.person")) +fun TagArrayBuilder<StarterPackEvent>.person( + pubkey: HexKey, + relayHint: NormalizedRelayUrl?, +) = movedPerson(pubkey, relayHint) + +@Deprecated(MOVED, ReplaceWith("personFirst(pubkey, relayHint)", "com.vitorpamplona.quartz.nip51Lists.starterPack.personFirst")) +fun TagArrayBuilder<StarterPackEvent>.personFirst( + pubkey: HexKey, + relayHint: NormalizedRelayUrl?, +) = movedPersonFirst(pubkey, relayHint) + +@Deprecated(MOVED, ReplaceWith("removePerson(pubkey)", "com.vitorpamplona.quartz.nip51Lists.starterPack.removePerson")) +fun TagArrayBuilder<StarterPackEvent>.removePerson(pubkey: HexKey) = movedRemovePerson(pubkey) + +@Deprecated(MOVED, ReplaceWith("follows()", "com.vitorpamplona.quartz.nip51Lists.starterPack.follows")) +fun TagArray.follows() = movedFollows() + +@Deprecated(MOVED, ReplaceWith("followIds()", "com.vitorpamplona.quartz.nip51Lists.starterPack.followIds")) +fun TagArray.followIds() = movedFollowIds() + +@Deprecated(MOVED, ReplaceWith("followIdSet()", "com.vitorpamplona.quartz.nip51Lists.starterPack.followIdSet")) +fun TagArray.followIdSet() = movedFollowIdSet() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/FollowSetEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/FollowSetEvent.kt similarity index 98% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/FollowSetEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/FollowSetEvent.kt index d10d7de69b..fe0353dd48 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/FollowSetEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/FollowSetEvent.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.peopleList +package com.vitorpamplona.quartz.nip51Lists.followSet import androidx.compose.runtime.Immutable import com.vitorpamplona.quartz.nip01Core.core.Address @@ -415,9 +415,3 @@ class FollowSetEvent( ) } } - -@Deprecated( - "Renamed to FollowSetEvent. NIP-51 names kind 30000 follow sets.", - ReplaceWith("FollowSetEvent", "com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent"), -) -typealias PeopleListEvent = FollowSetEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/TagArrayBuilderExt.kt similarity index 97% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayBuilderExt.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/TagArrayBuilderExt.kt index 9a07db2fec..18e1ef4cba 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/TagArrayBuilderExt.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.peopleList +package com.vitorpamplona.quartz.nip51Lists.followSet import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/TagArrayExt.kt similarity index 96% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayExt.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/TagArrayExt.kt index bad2b2563c..d0cd484542 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/TagArrayExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followSet/TagArrayExt.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.peopleList +package com.vitorpamplona.quartz.nip51Lists.followSet import com.vitorpamplona.quartz.nip01Core.core.TagArray import com.vitorpamplona.quartz.nip51Lists.muteList.tags.MuteTag diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/Deprecated.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/Deprecated.kt new file mode 100644 index 0000000000..417d0575b9 --- /dev/null +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/Deprecated.kt @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +@file:Suppress("DEPRECATION") + +package com.vitorpamplona.quartz.nip51Lists.hashtagList + +import com.vitorpamplona.quartz.nip01Core.core.TagArray +import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListDiff +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.followHashTag as movedFollowHashTag +import com.vitorpamplona.quartz.nip51Lists.interestList.hashtagList as movedHashtagList +import com.vitorpamplona.quartz.nip51Lists.interestList.hashtagSet as movedHashtagSet +import com.vitorpamplona.quartz.nip51Lists.interestList.hashtags as movedHashtags + +// This package was renamed to com.vitorpamplona.quartz.nip51Lists.interestList (NIP-51 kind 10015 is the interests list). +// Everything below forwards to it and will be removed in a future release. + +private const val MOVED = "Moved to com.vitorpamplona.quartz.nip51Lists.interestList" + +@Deprecated( + "Renamed to InterestListEvent and moved to com.vitorpamplona.quartz.nip51Lists.interestList. NIP-51 kind 10015 is the interests list.", + ReplaceWith("InterestListEvent", "com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent"), +) +typealias HashtagListEvent = InterestListEvent + +@Deprecated( + "Renamed to InterestListDiff and moved to com.vitorpamplona.quartz.nip51Lists.interestList. NIP-51 kind 10015 is the interests list.", + ReplaceWith("InterestListDiff", "com.vitorpamplona.quartz.nip51Lists.interestList.InterestListDiff"), +) +typealias HashtagListDiff = InterestListDiff + +@Deprecated(MOVED, ReplaceWith("followHashTag(hashtag)", "com.vitorpamplona.quartz.nip51Lists.interestList.followHashTag")) +fun TagArrayBuilder<InterestListEvent>.followHashTag(hashtag: String) = movedFollowHashTag(hashtag) + +@Deprecated(MOVED, ReplaceWith("hashtags(hashtags)", "com.vitorpamplona.quartz.nip51Lists.interestList.hashtags")) +fun TagArrayBuilder<InterestListEvent>.hashtags(hashtags: List<String>) = movedHashtags(hashtags) + +@Deprecated(MOVED, ReplaceWith("hashtagList()", "com.vitorpamplona.quartz.nip51Lists.interestList.hashtagList")) +fun TagArray.hashtagList() = movedHashtagList() + +@Deprecated(MOVED, ReplaceWith("hashtagSet()", "com.vitorpamplona.quartz.nip51Lists.interestList.hashtagSet")) +fun TagArray.hashtagSet() = movedHashtagSet() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/HashtagListDiff.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/InterestListDiff.kt similarity index 95% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/HashtagListDiff.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/InterestListDiff.kt index 21faacdee8..34284ce4db 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/HashtagListDiff.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/InterestListDiff.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.hashtagList +package com.vitorpamplona.quartz.nip51Lists.interestList import androidx.compose.runtime.Immutable import com.vitorpamplona.quartz.nip01Core.diff.ContentChange @@ -27,7 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.diff.ListDiff /** Changes to the followed hashtags: public ones, and the private ones as a whole. */ @Immutable -class HashtagListDiff( +class InterestListDiff( val hashtags: ListDiff<String>, val privateItems: ContentChange, ) : EventDiff { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/InterestListEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/InterestListEvent.kt similarity index 95% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/InterestListEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/InterestListEvent.kt index 950fb6c7a9..eaac7eaab7 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/InterestListEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/InterestListEvent.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.hashtagList +package com.vitorpamplona.quartz.nip51Lists.interestList import androidx.compose.runtime.Immutable import com.vitorpamplona.quartz.nip01Core.core.Address @@ -49,10 +49,10 @@ class InterestListEvent( content: String, sig: HexKey, ) : PrivateTagArrayEvent(id, pubKey, createdAt, KIND, tags, content, sig), - DiffableEvent<HashtagListDiff> { - override fun diffFrom(older: Event): HashtagListDiff? { + DiffableEvent<InterestListDiff> { + override fun diffFrom(older: Event): InterestListDiff? { if (older !is InterestListEvent || older.pubKey != pubKey || older.dTag() != dTag()) return null - return HashtagListDiff( + return InterestListDiff( ListDiff.of(older.publicHashtags(), publicHashtags(), { it.lowercase() }), privateItemsChangeFrom(older), ) @@ -216,9 +216,3 @@ class InterestListEvent( } } } - -@Deprecated( - "Renamed to InterestListEvent. NIP-51 names kind 10015 the interests list.", - ReplaceWith("InterestListEvent", "com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent"), -) -typealias HashtagListEvent = InterestListEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/TagArrayBuilderExt.kt similarity index 96% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayBuilderExt.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/TagArrayBuilderExt.kt index 70977ca9b7..4de4cce0d9 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/TagArrayBuilderExt.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.hashtagList +package com.vitorpamplona.quartz.nip51Lists.interestList import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder import com.vitorpamplona.quartz.nip01Core.tags.hashtags.HashtagTag diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/TagArrayExt.kt similarity index 96% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayExt.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/TagArrayExt.kt index ec7d75dd35..9819d231a8 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/hashtagList/TagArrayExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/interestList/TagArrayExt.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.hashtagList +package com.vitorpamplona.quartz.nip51Lists.interestList import com.vitorpamplona.quartz.nip01Core.core.TagArray import com.vitorpamplona.quartz.nip01Core.tags.hashtags.HashtagTag diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/Deprecated.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/Deprecated.kt new file mode 100644 index 0000000000..e420c86082 --- /dev/null +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/labeledBookmarkList/Deprecated.kt @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +@file:Suppress("DEPRECATION") + +package com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList + +import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder +import com.vitorpamplona.quartz.nip51Lists.bookmarkList.tags.BookmarkIdTag +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.bookmarks as movedBookmarks +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.description as movedDescription +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.image as movedImage +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.name as movedName +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.title as movedTitle + +// This package was renamed to com.vitorpamplona.quartz.nip51Lists.bookmarkSet (NIP-51 kind 30003 is a bookmark set). +// Everything below forwards to it and will be removed in a future release. + +private const val MOVED = "Moved to com.vitorpamplona.quartz.nip51Lists.bookmarkSet" + +@Deprecated( + "Renamed to BookmarkSetEvent and moved to com.vitorpamplona.quartz.nip51Lists.bookmarkSet. NIP-51 kind 30003 is a bookmark set.", + ReplaceWith("BookmarkSetEvent", "com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent"), +) +typealias LabeledBookmarkListEvent = BookmarkSetEvent + +@Deprecated(MOVED, ReplaceWith("name(name)", "com.vitorpamplona.quartz.nip51Lists.bookmarkSet.name")) +fun TagArrayBuilder<BookmarkSetEvent>.name(name: String) = movedName(name) + +@Deprecated(MOVED, ReplaceWith("title(title)", "com.vitorpamplona.quartz.nip51Lists.bookmarkSet.title")) +fun TagArrayBuilder<BookmarkSetEvent>.title(title: String) = movedTitle(title) + +@Deprecated(MOVED, ReplaceWith("bookmarks(bookmarks)", "com.vitorpamplona.quartz.nip51Lists.bookmarkSet.bookmarks")) +fun TagArrayBuilder<BookmarkSetEvent>.bookmarks(bookmarks: List<BookmarkIdTag>) = movedBookmarks(bookmarks) + +@Deprecated(MOVED, ReplaceWith("description(listDescription)", "com.vitorpamplona.quartz.nip51Lists.bookmarkSet.description")) +fun TagArrayBuilder<BookmarkSetEvent>.description(listDescription: String) = movedDescription(listDescription) + +@Deprecated(MOVED, ReplaceWith("image(url)", "com.vitorpamplona.quartz.nip51Lists.bookmarkSet.image")) +fun TagArrayBuilder<BookmarkSetEvent>.image(url: String) = movedImage(url) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/mediaStarterPack/MediaStarterPackEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/mediaStarterPack/MediaStarterPackEvent.kt index 9cec42f0c3..5d862bfc41 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/mediaStarterPack/MediaStarterPackEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/mediaStarterPack/MediaStarterPackEvent.kt @@ -31,11 +31,11 @@ import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.nip01Core.tags.dTag.dTag import com.vitorpamplona.quartz.nip50Search.IndexableFieldVisitor import com.vitorpamplona.quartz.nip50Search.SearchableEvent -import com.vitorpamplona.quartz.nip51Lists.followList.followIdSet -import com.vitorpamplona.quartz.nip51Lists.followList.followIds -import com.vitorpamplona.quartz.nip51Lists.followList.follows import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag import com.vitorpamplona.quartz.nip51Lists.remove +import com.vitorpamplona.quartz.nip51Lists.starterPack.followIdSet +import com.vitorpamplona.quartz.nip51Lists.starterPack.followIds +import com.vitorpamplona.quartz.nip51Lists.starterPack.follows import com.vitorpamplona.quartz.nip51Lists.tags.DescriptionTag import com.vitorpamplona.quartz.nip51Lists.tags.ImageTag import com.vitorpamplona.quartz.nip51Lists.tags.TitleTag diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/Deprecated.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/Deprecated.kt new file mode 100644 index 0000000000..0e973677cc --- /dev/null +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/peopleList/Deprecated.kt @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +@file:Suppress("DEPRECATION") + +package com.vitorpamplona.quartz.nip51Lists.peopleList + +import com.vitorpamplona.quartz.nip01Core.core.TagArray +import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent +import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag +import com.vitorpamplona.quartz.nip51Lists.followSet.description as movedDescription +import com.vitorpamplona.quartz.nip51Lists.followSet.image as movedImage +import com.vitorpamplona.quartz.nip51Lists.followSet.name as movedName +import com.vitorpamplona.quartz.nip51Lists.followSet.peoples as movedPeoples +import com.vitorpamplona.quartz.nip51Lists.followSet.title as movedTitle +import com.vitorpamplona.quartz.nip51Lists.followSet.userIdSet as movedUserIdSet +import com.vitorpamplona.quartz.nip51Lists.followSet.userIds as movedUserIds +import com.vitorpamplona.quartz.nip51Lists.followSet.users as movedUsers +import com.vitorpamplona.quartz.nip51Lists.followSet.usersAndWords as movedUsersAndWords +import com.vitorpamplona.quartz.nip51Lists.followSet.wordSet as movedWordSet +import com.vitorpamplona.quartz.nip51Lists.followSet.words as movedWords + +// This package was renamed to com.vitorpamplona.quartz.nip51Lists.followSet (NIP-51 kind 30000 is a follow set). +// Everything below forwards to it and will be removed in a future release. + +private const val MOVED = "Moved to com.vitorpamplona.quartz.nip51Lists.followSet" + +@Deprecated( + "Renamed to FollowSetEvent and moved to com.vitorpamplona.quartz.nip51Lists.followSet. NIP-51 kind 30000 is a follow set.", + ReplaceWith("FollowSetEvent", "com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent"), +) +typealias PeopleListEvent = FollowSetEvent + +@Deprecated(MOVED, ReplaceWith("name(name)", "com.vitorpamplona.quartz.nip51Lists.followSet.name")) +fun TagArrayBuilder<FollowSetEvent>.name(name: String) = movedName(name) + +@Deprecated(MOVED, ReplaceWith("title(name)", "com.vitorpamplona.quartz.nip51Lists.followSet.title")) +fun TagArrayBuilder<FollowSetEvent>.title(name: String) = movedTitle(name) + +@Deprecated(MOVED, ReplaceWith("description(desc)", "com.vitorpamplona.quartz.nip51Lists.followSet.description")) +fun TagArrayBuilder<FollowSetEvent>.description(desc: String) = movedDescription(desc) + +@Deprecated(MOVED, ReplaceWith("image(url)", "com.vitorpamplona.quartz.nip51Lists.followSet.image")) +fun TagArrayBuilder<FollowSetEvent>.image(url: String) = movedImage(url) + +@Deprecated(MOVED, ReplaceWith("peoples(peoples)", "com.vitorpamplona.quartz.nip51Lists.followSet.peoples")) +fun TagArrayBuilder<FollowSetEvent>.peoples(peoples: List<UserTag>) = movedPeoples(peoples) + +@Deprecated(MOVED, ReplaceWith("usersAndWords()", "com.vitorpamplona.quartz.nip51Lists.followSet.usersAndWords")) +fun TagArray.usersAndWords() = movedUsersAndWords() + +@Deprecated(MOVED, ReplaceWith("users()", "com.vitorpamplona.quartz.nip51Lists.followSet.users")) +fun TagArray.users() = movedUsers() + +@Deprecated(MOVED, ReplaceWith("userIds()", "com.vitorpamplona.quartz.nip51Lists.followSet.userIds")) +fun TagArray.userIds() = movedUserIds() + +@Deprecated(MOVED, ReplaceWith("userIdSet()", "com.vitorpamplona.quartz.nip51Lists.followSet.userIdSet")) +fun TagArray.userIdSet() = movedUserIdSet() + +@Deprecated(MOVED, ReplaceWith("words()", "com.vitorpamplona.quartz.nip51Lists.followSet.words")) +fun TagArray.words() = movedWords() + +@Deprecated(MOVED, ReplaceWith("wordSet()", "com.vitorpamplona.quartz.nip51Lists.followSet.wordSet")) +fun TagArray.wordSet() = movedWordSet() diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt index b3c2dee634..0e8a9db9ab 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt @@ -25,6 +25,7 @@ import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.SoftwareAss import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.appId import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.assets import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.channel +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.isNip82SoftwareRelease import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.version import com.vitorpamplona.quartz.nip01Core.core.Address import com.vitorpamplona.quartz.nip01Core.core.BaseAddressableEvent @@ -70,15 +71,20 @@ class ReleaseArtifactSetEvent( EventHintProvider, AddressHintProvider, SearchableEvent { - override fun indexableContent() = listOfNotNull(title(), description()).joinToString("\n") + override fun indexableContent() = listOfNotNull(title(), description(), searchableReleaseNotes()).joinToString("\n") // The read path: the same fields indexableContent() joins, handed over without // building the joined string a scan would throw away. override fun forEachIndexableField(visitor: IndexableFieldVisitor) { if (!visitor.visit(title())) return - visitor.visit(description()) + if (!visitor.visit(description())) return + visitor.visit(searchableReleaseNotes()) } + // Only NIP-82 releases carry release notes in `content`. A NIP-51 set may keep + // encrypted private items there, which must never reach the index. + private fun searchableReleaseNotes() = if (isNip82SoftwareRelease()) content.ifBlank { null } else null + override fun eventHints() = tags.mapNotNull(EventBookmark::parseAsHint) override fun linkedEventIds() = tags.mapNotNull(EventBookmark::parseId) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/StarterPackEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/StarterPackEvent.kt similarity index 95% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/StarterPackEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/StarterPackEvent.kt index c38841df66..81fc1f760f 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/StarterPackEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/StarterPackEvent.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.followList +package com.vitorpamplona.quartz.nip51Lists.starterPack import androidx.compose.runtime.Immutable import com.vitorpamplona.quartz.nip01Core.core.Address @@ -184,9 +184,3 @@ class StarterPackEvent( } } } - -@Deprecated( - "Renamed to StarterPackEvent. Kind 39089 is a NIP-51 starter pack. The NIP-02 follow list is kind 3 (ContactListEvent).", - ReplaceWith("StarterPackEvent", "com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent"), -) -typealias FollowListEvent = StarterPackEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayBuilderExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/TagArrayBuilderExt.kt similarity index 97% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayBuilderExt.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/TagArrayBuilderExt.kt index 6b5cf9bc13..4fcace3cf1 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayBuilderExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/TagArrayBuilderExt.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.followList +package com.vitorpamplona.quartz.nip51Lists.starterPack import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayExt.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/TagArrayExt.kt similarity index 96% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayExt.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/TagArrayExt.kt index e8f8a00bea..69303a2097 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/followList/TagArrayExt.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/starterPack/TagArrayExt.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.quartz.nip51Lists.followList +package com.vitorpamplona.quartz.nip51Lists.starterPack import com.vitorpamplona.quartz.nip01Core.core.TagArray import com.vitorpamplona.quartz.nip51Lists.muteList.tags.UserTag diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt index bae51c5c4f..3c36ab0fa2 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/IPrivateZapsDecryptionCache.kt @@ -25,7 +25,7 @@ package com.vitorpamplona.quartz.nip57Zaps * Used by Note.kt for checking private zap status. */ interface IPrivateZapsDecryptionCache { - fun cachedPrivateZap(event: ZapRequestEvent): LnZapPrivateEvent? + fun cachedPrivateZap(event: ZapRequestEvent): PrivateZapEvent? - suspend fun decryptPrivateZap(event: ZapRequestEvent): LnZapPrivateEvent? + suspend fun decryptPrivateZap(event: ZapRequestEvent): PrivateZapEvent? } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt index 57eb0a796c..29319eb223 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapCache.kt @@ -43,16 +43,16 @@ class PrivateZapCache( decryptionCache.remove(event) } - override fun cachedPrivateZap(event: ZapRequestEvent): LnZapPrivateEvent? = decryptionCache[event]?.cached() + override fun cachedPrivateZap(event: ZapRequestEvent): PrivateZapEvent? = decryptionCache[event]?.cached() override suspend fun decryptPrivateZap(event: ZapRequestEvent) = decryptionCache[event]?.decrypt(event) } class PrivateZapDecryptCache( signer: NostrSigner, -) : DecryptCache<ZapRequestEvent, LnZapPrivateEvent>(signer) { +) : DecryptCache<ZapRequestEvent, PrivateZapEvent>(signer) { override suspend fun decryptAndParse( event: ZapRequestEvent, signer: NostrSigner, - ): LnZapPrivateEvent = signer.decryptZapEvent(event) + ): PrivateZapEvent = signer.decryptZapEvent(event) } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapPrivateEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapEvent.kt similarity index 87% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapPrivateEvent.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapEvent.kt index 09c88dd2a3..163f2415a1 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapPrivateEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapEvent.kt @@ -34,7 +34,7 @@ import com.vitorpamplona.quartz.nip01Core.tags.people.PTag import com.vitorpamplona.quartz.utils.TimeUtils @Immutable -class LnZapPrivateEvent( +class PrivateZapEvent( id: HexKey, pubKey: HexKey, createdAt: Long, @@ -66,13 +66,19 @@ class LnZapPrivateEvent( tags: Array<Array<String>> = emptyArray(), content: String = "", createdAt: Long = TimeUtils.now(), - ): LnZapPrivateEvent = signer.sign(createdAt, KIND, tags, content) + ): PrivateZapEvent = signer.sign(createdAt, KIND, tags, content) fun create( signer: NostrSignerSync, tags: Array<Array<String>> = emptyArray(), content: String = "", createdAt: Long = TimeUtils.now(), - ): LnZapPrivateEvent = signer.sign(createdAt, KIND, tags, content) + ): PrivateZapEvent = signer.sign(createdAt, KIND, tags, content) } } + +@Deprecated( + "Renamed to PrivateZapEvent. Follows the NIP-57 zap naming (ZapRequestEvent, ZapReceiptEvent).", + ReplaceWith("PrivateZapEvent", "com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent"), +) +typealias LnZapPrivateEvent = PrivateZapEvent diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt index 595dc24600..a26cc784bd 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/PrivateZapRequestBuilder.kt @@ -56,7 +56,7 @@ class PrivateZapRequestBuilder { val fullTagsNoAnon = tags.filter { t -> t.getOrNull(0) != "anon" }.toTypedArray() - val privateEvent = LnZapPrivateEvent.create(signer, fullTagsNoAnon, content) + val privateEvent = PrivateZapEvent.create(signer, fullTagsNoAnon, content) val noteJson = privateEvent.toJson() val encryptedContent = @@ -75,7 +75,7 @@ class PrivateZapRequestBuilder { fun decryptZapEvent( event: ZapRequestEvent, signer: NostrSignerSync, - ): LnZapPrivateEvent { + ): PrivateZapEvent { if (signer.keyPair.privKey == null) throw SignerExceptions.ReadOnlyException() val recipientPK = event.zappedAuthor().firstOrNull() @@ -129,12 +129,12 @@ class PrivateZapRequestBuilder { encNote: String, privateKey: ByteArray, pubKey: HexKey, - ): LnZapPrivateEvent = + ): PrivateZapEvent = try { val note = PrivateZapEncryption.decryptPrivateZapMessage(encNote, privateKey, pubKey.hexToByteArray()) val decryptedEvent = fromJson(note) if (decryptedEvent.kind == 9733) { - decryptedEvent as LnZapPrivateEvent + decryptedEvent as PrivateZapEvent } else { throw IllegalStateException("The decrypted event is not a private zap.") } diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnurlEndpointResolver.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnurlEndpointResolver.kt index 5b1841ada5..cb9cab5e9c 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnurlEndpointResolver.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnurlEndpointResolver.kt @@ -24,7 +24,7 @@ package com.vitorpamplona.quartz.nip57Zaps.validate * Resolves an LNURL-pay URL to its [LnurlEndpointInfo]. Implementations should * consult [LnurlEndpointCache] first and only fall through to a network fetch * on a miss. Lives in quartz so that pure-logic verifiers (e.g. - * [LnZapReceiptValidator]) can be wired against an abstract interface without + * [ZapReceiptValidator]) can be wired against an abstract interface without * depending on OkHttp. */ fun interface LnurlEndpointResolver { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidator.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/ZapReceiptValidator.kt similarity index 95% rename from quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidator.kt rename to quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/ZapReceiptValidator.kt index da42cdb131..b7f812289d 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidator.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/ZapReceiptValidator.kt @@ -45,7 +45,7 @@ import com.vitorpamplona.quartz.utils.BigDecimal * check on the receipt's signer pubkey is non-negotiable when an * `expectedNostrPubkey` is provided. */ -object LnZapReceiptValidator { +object ZapReceiptValidator { sealed class Result { data object Valid : Result() @@ -153,3 +153,9 @@ object LnZapReceiptValidator { ?.get(1) ?.takeIf { it.isNotBlank() } } + +@Deprecated( + "Renamed to ZapReceiptValidator. Validates NIP-57 zap receipts (ZapReceiptEvent).", + ReplaceWith("ZapReceiptValidator", "com.vitorpamplona.quartz.nip57Zaps.validate.ZapReceiptValidator"), +) +typealias LnZapReceiptValidator = ZapReceiptValidator diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt index 48c72d8de2..3e9cd2ee4b 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip89AppHandlers/clientTag/NostrSignerWithClientTag.kt @@ -24,7 +24,7 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.core.HexKey import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent /** @@ -94,7 +94,7 @@ class NostrSignerWithClientTag( fromPublicKey: HexKey, ): String = inner.nip44Decrypt(ciphertext, fromPublicKey) - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = inner.decryptZapEvent(event) + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = inner.decryptZapEvent(event) override suspend fun deriveKey(nonce: HexKey): HexKey = inner.deriveKey(nonce) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt index d852130e87..06f5682286 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/utils/EventFactory.kt @@ -261,21 +261,20 @@ import com.vitorpamplona.quartz.nip51Lists.appCurationSet.AppCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.articleCurationSet.ArticleCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.BookmarkListEvent import com.vitorpamplona.quartz.nip51Lists.bookmarkList.OldBookmarkListEvent +import com.vitorpamplona.quartz.nip51Lists.bookmarkSet.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.favoriteAlgoFeedsList.FavoriteAlgoFeedsListEvent -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.followSet.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent import com.vitorpamplona.quartz.nip51Lists.gitAuthorList.GitAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.gitRepositoryList.GitRepositoryListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiAuthorList.GoodWikiAuthorListEvent import com.vitorpamplona.quartz.nip51Lists.goodWikiRelayList.GoodWikiRelayListEvent -import com.vitorpamplona.quartz.nip51Lists.hashtagList.InterestListEvent +import com.vitorpamplona.quartz.nip51Lists.interestList.InterestListEvent import com.vitorpamplona.quartz.nip51Lists.interestSet.InterestSetEvent import com.vitorpamplona.quartz.nip51Lists.kindMuteSet.KindMuteSetEvent -import com.vitorpamplona.quartz.nip51Lists.labeledBookmarkList.BookmarkSetEvent import com.vitorpamplona.quartz.nip51Lists.mediaFollowList.MediaFollowListEvent import com.vitorpamplona.quartz.nip51Lists.mediaStarterPack.MediaStarterPackEvent import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent -import com.vitorpamplona.quartz.nip51Lists.peopleList.FollowSetEvent import com.vitorpamplona.quartz.nip51Lists.pictureCurationSet.PictureCurationSetEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent @@ -286,6 +285,7 @@ import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent import com.vitorpamplona.quartz.nip51Lists.simpleGroupList.SimpleGroupListEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip51Lists.videoCurationSet.VideoCurationSetEvent import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent import com.vitorpamplona.quartz.nip52Calendar.appt.time.CalendarTimeSlotEvent @@ -304,7 +304,7 @@ import com.vitorpamplona.quartz.nip54Wiki.WikiMergeAcceptanceEvent import com.vitorpamplona.quartz.nip54Wiki.WikiMergeRequestEvent import com.vitorpamplona.quartz.nip54Wiki.WikiRedirectEvent import com.vitorpamplona.quartz.nip56Reports.ReportEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip58Badges.accepted.AcceptedBadgeSetEvent @@ -725,7 +725,7 @@ class EventFactory { NwcInfoEvent.KIND -> NwcInfoEvent(id, pubKey, createdAt, tags, content, sig) NwcNotificationEvent.KIND -> NwcNotificationEvent(id, pubKey, createdAt, tags, content, sig) NwcNotificationEvent.LEGACY_KIND -> NwcNotificationEvent(id, pubKey, createdAt, tags, content, sig) - LnZapPrivateEvent.KIND -> LnZapPrivateEvent(id, pubKey, createdAt, tags, content, sig) + PrivateZapEvent.KIND -> PrivateZapEvent(id, pubKey, createdAt, tags, content, sig) ZapRequestEvent.KIND -> ZapRequestEvent(id, pubKey, createdAt, tags, content, sig) LongFormContentEvent.KIND -> LongFormContentEvent(id, pubKey, createdAt, tags, content, sig) MarketplaceEvent.KIND -> MarketplaceEvent(id, pubKey, createdAt, tags, content, sig) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt index 25990b13ff..6f5166d193 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt @@ -207,6 +207,32 @@ class SoftwareApplicationEventTest { assertEquals("notes", template.content) } + @Test + fun searchIndex_includesReleaseNotesOnlyForNip82() { + val nip82 = + ReleaseArtifactSetEvent( + id = "0".repeat(64), + pubKey = "1".repeat(64), + createdAt = 0, + tags = arrayOf(arrayOf("d", "com.example.app@1.0.0"), arrayOf("i", "com.example.app"), arrayOf("version", "1.0.0")), + content = "Fixed the crash on startup", + sig = "", + ) + assertEquals("Fixed the crash on startup", nip82.indexableContent()) + + // A NIP-51 set can carry encrypted private items in content: never index it. + val nip51 = + ReleaseArtifactSetEvent( + id = "0".repeat(64), + pubKey = "1".repeat(64), + createdAt = 0, + tags = arrayOf(arrayOf("d", "some-uuid"), arrayOf("title", "My Release")), + content = "ciphertext?iv=abc", + sig = "", + ) + assertEquals("My Release", nip51.indexableContent()) + } + @Test fun parses_realWorldAmethystEvent() { // Real NIP-82 event published for Amethyst — used as a regression fixture so renderer diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/ContactCardPetNameTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/UserAssertionPetNameTest.kt similarity index 99% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/ContactCardPetNameTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/UserAssertionPetNameTest.kt index 1f58771e64..fb330c5182 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/ContactCardPetNameTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip85TrustedAssertions/UserAssertionPetNameTest.kt @@ -32,7 +32,7 @@ import kotlin.test.assertEquals import kotlin.test.assertNull import kotlin.test.assertTrue -class ContactCardPetNameTest { +class UserAssertionPetNameTest { val signer = NostrSignerInternal(KeyPair()) val targetUser = "e88a691e98d9987c964521dff60025f60700378a4879180dcbbb4a5027850411" diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt index 496def0887..9abb9aa952 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/QueryAssemblerTest.kt @@ -980,7 +980,7 @@ class QueryAssemblerTest : BaseDBTest() { } @Test - fun testContactCardDownloadFromTrustedKeys() = + fun testUserAssertionDownloadFromTrustedKeys() = forEachDB { db -> val filter = Filter( diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt index 5226a302ce..0a2bdce894 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorConcurrencyTest.kt @@ -30,7 +30,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestConnect import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequestSign import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponse import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponseEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.launch @@ -101,7 +101,7 @@ class BunkerRequestProcessorConcurrencyTest { fromPublicKey: HexKey, ) = "" - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt index bc5598a518..ea7339b628 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/BunkerRequestProcessorTest.kt @@ -40,7 +40,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponseEvent import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponseGetRelays import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponsePong import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponsePublicKey -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import kotlinx.coroutines.test.runTest import kotlin.test.Test @@ -116,7 +116,7 @@ class BunkerRequestProcessorTest { return "nip44dec:$ciphertext" } - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() @@ -371,7 +371,7 @@ class BunkerRequestProcessorTest { fromPublicKey: HexKey, ) = "" - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt index 0e631bc3e1..db6c888430 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip46RemoteSigner/server/NostrConnectSignerServiceTest.kt @@ -38,7 +38,7 @@ import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponse import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponseEvent import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponsePublicKey import com.vitorpamplona.quartz.nip46RemoteSigner.NostrConnectEvent -import com.vitorpamplona.quartz.nip57Zaps.LnZapPrivateEvent +import com.vitorpamplona.quartz.nip57Zaps.PrivateZapEvent import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.utils.RandomInstance import com.vitorpamplona.quartz.utils.TimeUtils @@ -112,7 +112,7 @@ class NostrConnectSignerServiceTest { fromPublicKey: HexKey, ) = ciphertext - override suspend fun decryptZapEvent(event: ZapRequestEvent): LnZapPrivateEvent = throw NotImplementedError() + override suspend fun decryptZapEvent(event: ZapRequestEvent): PrivateZapEvent = throw NotImplementedError() override suspend fun deriveKey(nonce: HexKey): HexKey = throw NotImplementedError() diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestNip44EventTest.kt similarity index 98% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestNip44EventTest.kt index edc3143ba5..1a6c7ae24f 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/LnZapPaymentRequestNip44EventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip47WalletConnect/NwcRequestNip44EventTest.kt @@ -32,7 +32,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertIs -class LnZapPaymentRequestNip44EventTest { +class NwcRequestNip44EventTest { @Test fun testCreateRequestWithNip44() = runTest { diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt index 5d044ecb52..51b77ca13f 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip50Search/SearchFieldExtractorTest.kt @@ -153,7 +153,7 @@ class SearchFieldExtractorTest { } @Test - fun contactCardsDecomposeIntoPetnameSummaryAndTopics() { + fun userAssertionsDecomposeIntoPetnameSummaryAndTopics() { // A provider's petname for a person is that provider's NAME for them, // so it lands where kind 0's name does. topics() reads `t` tags, so // the tiers() funnel carries them once, as hashtags. @@ -177,7 +177,7 @@ class SearchFieldExtractorTest { } @Test - fun contactCardsCarryTopicsEvenWithNoPublicPetname() { + fun userAssertionsCarryTopicsEvenWithNoPublicPetname() { // THE SHAPE THIS LIBRARY ITSELF PUBLISHES: build() puts petname and // summary in the NIP-44 content, so a card's only public text is its // topics. They must still reach the backend -- through the hashtag @@ -189,7 +189,7 @@ class SearchFieldExtractorTest { } @Test - fun contactCardsWithNoPublicTextExtractNothing() { + fun userAssertionsWithNoPublicTextExtractNothing() { // The petname and summary of a private card live in the NIP-44 // encrypted content, which is never indexed -- so a card carrying only // scores has nothing to search. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt index 5111ca4c15..484ecb6f2f 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip51Lists/relayLists/RelayListPublicEntriesTest.kt @@ -60,7 +60,7 @@ class RelayListPublicEntriesTest { ) @Test - fun relayFeedsListKeepsTheSurvivorPublic() = + fun favoriteRelayListKeepsTheSurvivorPublic() = runTest { val before = publicListFromAnotherClient<FavoriteRelayListEvent>(FavoriteRelayListEvent.KIND) val after = FavoriteRelayListEvent.updateRelayList(before, listOf(damus), signer, 1740669817) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestAnonTagTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestAnonTagTest.kt similarity index 99% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestAnonTagTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestAnonTagTest.kt index 9592029d3c..8bf0e14306 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestAnonTagTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestAnonTagTest.kt @@ -37,7 +37,7 @@ import kotlin.test.assertTrue * (encrypted `anon`) requests use throwaway keys — tagging anything derived * from them is either useless or, for the decrypted sender, a doxxing risk. */ -class LnZapRequestAnonTagTest { +class ZapRequestAnonTagTest { private val signer = NostrSignerInternal( "nsec10g0wheggqn9dawlc0yuv6adnat6n09anr7eyykevw2dm8xa5fffs0wsdsr".nsecToKeyPair(), diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestGroupTagTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestGroupTagTest.kt similarity index 99% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestGroupTagTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestGroupTagTest.kt index 07451237b4..14bce2e8e9 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestGroupTagTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestGroupTagTest.kt @@ -39,7 +39,7 @@ import kotlin.test.assertTrue * their rooms) never matches it — so a zap on a group message would be invisible exactly where it was * meant to be seen. Reactions already copy the tag (`ReactionAction`); this pins the same rule for zaps. */ -class LnZapRequestGroupTagTest { +class ZapRequestGroupTagTest { private val signer = DeterministicSigner( "nsec10g0wheggqn9dawlc0yuv6adnat6n09anr7eyykevw2dm8xa5fffs0wsdsr".nsecToKeyPair(), diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestKindTagTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestKindTagTest.kt similarity index 99% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestKindTagTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestKindTagTest.kt index 1ba8c3c279..38e125424d 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/LnZapRequestKindTagTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/ZapRequestKindTagTest.kt @@ -32,7 +32,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -class LnZapRequestKindTagTest { +class ZapRequestKindTagTest { private val signer = DeterministicSigner( "nsec10g0wheggqn9dawlc0yuv6adnat6n09anr7eyykevw2dm8xa5fffs0wsdsr".nsecToKeyPair(), diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidatorTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/ZapReceiptValidatorTest.kt similarity index 70% rename from quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidatorTest.kt rename to quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/ZapReceiptValidatorTest.kt index ef3344b0b0..5487d552e0 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/LnZapReceiptValidatorTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/nip57Zaps/validate/ZapReceiptValidatorTest.kt @@ -26,7 +26,7 @@ import kotlin.test.assertEquals import kotlin.test.assertIs import kotlin.test.assertTrue -class LnZapReceiptValidatorTest { +class ZapReceiptValidatorTest { // Mainnet 100,000 sat invoice (= 100_000_000 msats). From LnInvoiceUtilTest. private val invoice100kSats = "lnbc1m1pjt9u0qsp553q90pj5mafzv20w45eqavned9tgwhl4q99n9s5ppcw24nzw3zeqpp5002kd3ktym67du86kj665fgaev7ka8ys7j5yz5fg686lr5e2gfkshp5dkk27nnuax05az3pk2r6ytxtvwn5j4xzsq9ajprhc7crjkmgvr3qxqyjw5qcqpjrzjqtzxvfsuxe4l92pf97tt4rcgpy2xalkmlwexh899wqxf83l8nwv4xzh0gvqq89qqqqqqqqlgqqqqq0gqvs9qxpqysgqx5mz04wd7kqu5zhhel9enr036hjrp4gga0nz084p2asjl36a0zmrk6mhqa249zsgqref2rlvhffm73u7rxgr47gden6rugup4ksvpzsqvds4pz" @@ -80,99 +80,99 @@ class LnZapReceiptValidatorTest { @Test fun `valid receipt passes all checks`() { - val result = LnZapReceiptValidator.validate(receipt(), providerPubkey, lnurlOfRecipient) - assertEquals(LnZapReceiptValidator.Result.Valid, result) + val result = ZapReceiptValidator.validate(receipt(), providerPubkey, lnurlOfRecipient) + assertEquals(ZapReceiptValidator.Result.Valid, result) } @Test fun `missing zap request fails with MISSING_ZAP_REQUEST`() { val r = receipt(description = null) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) - val invalid = assertIs<LnZapReceiptValidator.Result.Invalid>(result) - assertEquals(LnZapReceiptValidator.Result.Reason.MISSING_ZAP_REQUEST, invalid.reason) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) + val invalid = assertIs<ZapReceiptValidator.Result.Invalid>(result) + assertEquals(ZapReceiptValidator.Result.Reason.MISSING_ZAP_REQUEST, invalid.reason) } @Test fun `wrong signer fails with MISMATCHED_NOSTR_PUBKEY`() { val attackerPubkey = "1".repeat(64) - val result = LnZapReceiptValidator.validate(receipt(signerPubkey = attackerPubkey), providerPubkey, lnurlOfRecipient) - val invalid = assertIs<LnZapReceiptValidator.Result.Invalid>(result) - assertEquals(LnZapReceiptValidator.Result.Reason.MISMATCHED_NOSTR_PUBKEY, invalid.reason) + val result = ZapReceiptValidator.validate(receipt(signerPubkey = attackerPubkey), providerPubkey, lnurlOfRecipient) + val invalid = assertIs<ZapReceiptValidator.Result.Invalid>(result) + assertEquals(ZapReceiptValidator.Result.Reason.MISMATCHED_NOSTR_PUBKEY, invalid.reason) } @Test fun `null expected pubkey skips the check`() { val attackerPubkey = "1".repeat(64) - val result = LnZapReceiptValidator.validate(receipt(signerPubkey = attackerPubkey), null, lnurlOfRecipient) - assertEquals(LnZapReceiptValidator.Result.Valid, result) + val result = ZapReceiptValidator.validate(receipt(signerPubkey = attackerPubkey), null, lnurlOfRecipient) + assertEquals(ZapReceiptValidator.Result.Valid, result) } @Test fun `missing bolt11 fails with MISSING_OR_BAD_BOLT11`() { - val result = LnZapReceiptValidator.validate(receipt(bolt11 = null), providerPubkey, lnurlOfRecipient) - val invalid = assertIs<LnZapReceiptValidator.Result.Invalid>(result) - assertEquals(LnZapReceiptValidator.Result.Reason.MISSING_OR_BAD_BOLT11, invalid.reason) + val result = ZapReceiptValidator.validate(receipt(bolt11 = null), providerPubkey, lnurlOfRecipient) + val invalid = assertIs<ZapReceiptValidator.Result.Invalid>(result) + assertEquals(ZapReceiptValidator.Result.Reason.MISSING_OR_BAD_BOLT11, invalid.reason) } @Test fun `mismatched amount fails with MISMATCHED_AMOUNT`() { // bolt11 is 100,000,000 msats; request claims 50,000,000. val r = receipt(description = zapRequestJson(amountMillisats = 50_000_000L)) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) - val invalid = assertIs<LnZapReceiptValidator.Result.Invalid>(result) - assertEquals(LnZapReceiptValidator.Result.Reason.MISMATCHED_AMOUNT, invalid.reason) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) + val invalid = assertIs<ZapReceiptValidator.Result.Invalid>(result) + assertEquals(ZapReceiptValidator.Result.Reason.MISMATCHED_AMOUNT, invalid.reason) } @Test fun `missing amount tag is accepted when not strict`() { val r = receipt(description = zapRequestJson(amountMillisats = null)) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient, strictAmount = false) - assertEquals(LnZapReceiptValidator.Result.Valid, result) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient, strictAmount = false) + assertEquals(ZapReceiptValidator.Result.Valid, result) } @Test fun `missing amount tag fails when strict`() { val r = receipt(description = zapRequestJson(amountMillisats = null)) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient, strictAmount = true) - val invalid = assertIs<LnZapReceiptValidator.Result.Invalid>(result) - assertEquals(LnZapReceiptValidator.Result.Reason.MISMATCHED_AMOUNT, invalid.reason) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient, strictAmount = true) + val invalid = assertIs<ZapReceiptValidator.Result.Invalid>(result) + assertEquals(ZapReceiptValidator.Result.Reason.MISMATCHED_AMOUNT, invalid.reason) } @Test fun `mismatched lnurl fails with MISMATCHED_LNURL`() { val r = receipt(description = zapRequestJson(lnurl = "other@example.org")) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) - val invalid = assertIs<LnZapReceiptValidator.Result.Invalid>(result) - assertEquals(LnZapReceiptValidator.Result.Reason.MISMATCHED_LNURL, invalid.reason) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) + val invalid = assertIs<ZapReceiptValidator.Result.Invalid>(result) + assertEquals(ZapReceiptValidator.Result.Reason.MISMATCHED_LNURL, invalid.reason) } @Test fun `missing lnurl tag is accepted`() { val r = receipt(description = zapRequestJson(lnurl = null)) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) - assertEquals(LnZapReceiptValidator.Result.Valid, result) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) + assertEquals(ZapReceiptValidator.Result.Valid, result) } @Test fun `lnurl tag in URL form matches lud16 expectation`() { val r = receipt(description = zapRequestJson(lnurl = lnurlUrl)) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) - assertEquals(LnZapReceiptValidator.Result.Valid, result) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) + assertEquals(ZapReceiptValidator.Result.Valid, result) } @Test fun `lnurl tag in bech32 form matches lud16 expectation`() { val bech32 = LnurlForm.urlToBech32(lnurlUrl) val r = receipt(description = zapRequestJson(lnurl = bech32)) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) - assertEquals(LnZapReceiptValidator.Result.Valid, result) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) + assertEquals(ZapReceiptValidator.Result.Valid, result) } @Test fun `pubkey check is case-insensitive`() { val r = receipt(signerPubkey = providerPubkey.uppercase()) - val result = LnZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) - assertEquals(LnZapReceiptValidator.Result.Valid, result) + val result = ZapReceiptValidator.validate(r, providerPubkey, lnurlOfRecipient) + assertEquals(ZapReceiptValidator.Result.Valid, result) } } diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt index 76022f4303..6460a74a65 100644 --- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt +++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/jackson/JacksonMapperTest.kt @@ -23,7 +23,7 @@ package com.vitorpamplona.quartz.nip01Core.jackson import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor import kotlin.test.Test import kotlin.test.assertContentEquals diff --git a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt index a3ee938277..f33431cd8f 100644 --- a/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt +++ b/quartz/src/jvmAndroidTest/kotlin/com/vitorpamplona/quartz/nip01Core/kotlinSerialization/KotlinSerializationMapperTest.kt @@ -39,7 +39,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.signers.EventTemplate import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerRequest import com.vitorpamplona.quartz.nip46RemoteSigner.BunkerResponse -import com.vitorpamplona.quartz.nip51Lists.followList.StarterPackEvent +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor import kotlin.test.Test import kotlin.test.assertContentEquals From 08169f8497690818c8817f221d1471f353ea8bc5 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 21:12:49 +0000 Subject: [PATCH 50/57] refactor(commons): move the napplet wire protocol and scheduled posts to commonMain Tier 4 of the commons migration sweep: two jvmAndroid groups that were each pinned by a single JVM API. Napplet: NappletProtocolJson (and NappletIdentityWatch, NappletRequestRouter, which only waited on it) used java.util.Base64 and System.currentTimeMillis. Now kotlin.io.encoding.Base64 and TimeUtils.now(). The decoder uses PaddingOption.PRESENT_OPTIONAL because java.util.Base64.getDecoder() accepted unpadded input; a test pins that. Scheduled posts: ScheduledPostStore was pinned by java.io.File and a POSIX chmod. It now takes an okio Path + FileSystem (plus a String constructor, the FileSystemNip95BlobStore shape, so callers need no okio). Owner-only permissions are a new expect fun restrictFileToOwner: Files.setPosix... on jvmAndroid, chmod(0600) on iOS. The temp-file swap is FileSystem.atomicMove, which replaces an existing target everywhere, so the rename/delete/rename fallback is gone. The work gate, publisher and notifier came along. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjQQN9CgWHVtNCSWqnKoqY --- .../com/vitorpamplona/amethyst/AppModules.kt | 2 +- .../napplet/NappletProtocolJsonTest.kt | 7 ++ .../ScheduledPostWorkGateTest.kt | 2 +- .../commons/napplet/NappletIdentityWatch.kt | 0 .../commons/napplet/NappletRequestRouter.kt | 0 .../napplet/protocol/NappletProtocolJson.kt | 20 +++-- .../scheduledposts/ScheduledPostNotifier.kt | 0 .../scheduledposts/ScheduledPostPublisher.kt | 0 .../scheduledposts/ScheduledPostStore.kt | 78 +++++++++---------- .../scheduledposts/ScheduledPostWorkGate.kt | 0 .../amethyst/commons/util/OwnerOnlyFile.kt | 34 ++++++++ .../commons/util/OwnerOnlyFile.ios.kt | 40 ++++++++++ .../commons/util/OwnerOnlyFile.jvmAndroid.kt | 42 ++++++++++ .../scheduledposts/ScheduledPostStoreTest.kt | 2 +- .../DesktopScheduledPostStore.kt | 2 +- .../HeadlessScheduledPublish.kt | 2 +- 16 files changed, 175 insertions(+), 56 deletions(-) rename commons/src/{jvmAndroid => commonMain}/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletIdentityWatch.kt (100%) rename commons/src/{jvmAndroid => commonMain}/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRequestRouter.kt (100%) rename commons/src/{jvmAndroid => commonMain}/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt (97%) rename commons/src/{jvmAndroid => commonMain}/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostNotifier.kt (100%) rename commons/src/{jvmAndroid => commonMain}/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostPublisher.kt (100%) rename commons/src/{jvmAndroid => commonMain}/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt (88%) rename commons/src/{jvmAndroid => commonMain}/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostWorkGate.kt (100%) create mode 100644 commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.kt create mode 100644 commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt create mode 100644 commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt index 3e0c5f6a6e..934226f2c8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/AppModules.kt @@ -1154,7 +1154,7 @@ class AppModules( // Local store for posts the user has scheduled to publish later. Backed by a // single JSON file under the app's private filesDir; read by ScheduledPostWorker. val scheduledPostStore = - ScheduledPostStore(File(appContext.filesDir, ScheduledPostStore.FILE_NAME)) + ScheduledPostStore(File(appContext.filesDir, ScheduledPostStore.FILE_NAME).path) // Organizes cache clearing val trimmingService by diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/napplet/NappletProtocolJsonTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/napplet/NappletProtocolJsonTest.kt index 1f2422de4b..93399e85a2 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/napplet/NappletProtocolJsonTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/napplet/NappletProtocolJsonTest.kt @@ -184,6 +184,13 @@ class NappletProtocolJsonTest { assertEquals("Hi", up.bytes.decodeToString()) } + @Test + fun uploadAcceptsUnpaddedBase64() { + // java.util.Base64 decoded "SGk" (no '=') as "Hi"; the commonMain decoder must too. + val up = NappletProtocolJson.decodeRequest("""{"type":"upload.upload","request":{"dataBase64":"SGk"}}""") as NappletRequest.UploadBlob + assertEquals("Hi", up.bytes.decodeToString()) + } + @Test fun unknownTypeDecodesToNull() { assertNull(NappletProtocolJson.decodeRequest("""{"type":"inc.emit","id":"1"}""")) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/scheduledposts/ScheduledPostWorkGateTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/scheduledposts/ScheduledPostWorkGateTest.kt index e346274630..d3028575ea 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/scheduledposts/ScheduledPostWorkGateTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/scheduledposts/ScheduledPostWorkGateTest.kt @@ -57,7 +57,7 @@ class ScheduledPostWorkGateTest { decisions.clear() } - private fun newStore() = ScheduledPostStore(file) + private fun newStore() = ScheduledPostStore(file.path) private fun TestScope.startGate(store: ScheduledPostStore) = ScheduledPostWorkGate( diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletIdentityWatch.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletIdentityWatch.kt similarity index 100% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletIdentityWatch.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletIdentityWatch.kt diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRequestRouter.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRequestRouter.kt similarity index 100% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRequestRouter.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/NappletRequestRouter.kt diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt similarity index 97% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt index 027cae99df..af171f6188 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt @@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.commons.napplet.protocol import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter +import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonNull import kotlinx.serialization.json.JsonObject @@ -37,7 +38,7 @@ import kotlinx.serialization.json.long import kotlinx.serialization.json.put import kotlinx.serialization.json.putJsonArray import kotlinx.serialization.json.putJsonObject -import java.util.Base64 +import kotlin.io.encoding.Base64 /** * Marshals the KMP-pure [NappletRequest] / [NappletResponse] types to and from the wire the @@ -45,10 +46,10 @@ import java.util.Base64 * (`@napplet/shim` / `@napplet/nap`): requests are `{ "type": "<domain>.<action>", "id", ...fields }` * and replies are `{ "type": "<domain>.<action>.result", "id", ...fields }`. * - * Lives in `commons/jvmAndroid` (not in any single front end) because the wire contract is identical + * Lives in `commons/commonMain` (not in any single front end) because the wire contract is identical * across hosts: the Android `:napplet` WebView host and a future desktop host both marshal through - * here. It depends only on `quartz` (Event/Filter), kotlinx.serialization, and `java.util.Base64` - * (available on Android API 26+ and the JVM) — no platform-UI or process APIs. + * here. It depends only on `quartz` (Event/Filter), kotlinx.serialization and `kotlin.io.encoding` + * — no platform-UI or process APIs. * * This is the only place the boundary parses untrusted applet input, so it is deliberately * strict: an unrecognized `type` decodes to `null` (the broker denies it) and a malformed/short @@ -58,6 +59,9 @@ import java.util.Base64 object NappletProtocolJson { private val json = Json { ignoreUnknownKeys = true } + // Accepts unpadded input, as java.util.Base64's decoder did before this moved to commonMain. + private val lenientBase64 = Base64.withPadding(Base64.PaddingOption.PRESENT_OPTIONAL) + /** The `type` discriminant of a request envelope, used to build the matching `.result` type. */ fun readType(envelopeJson: String): String? = json.parseToJsonElement(envelopeJson).jsonObject.str("type") @@ -166,7 +170,7 @@ object NappletProtocolJson { kind = t.kindOf(), tags = decodeTags(t), content = t.str("content") ?: "", - createdAt = t["created_at"]?.jsonPrimitive?.long ?: (System.currentTimeMillis() / 1000), + createdAt = t["created_at"]?.jsonPrimitive?.long ?: TimeUtils.now(), ) } // NIP-07 nip44.encrypt/decrypt: crypto only, no publish. `peer` is the counterparty @@ -194,7 +198,7 @@ object NappletProtocolJson { // The Blob in `request.data` is inlined as base64 `request.dataBase64` by shell.html. val request = o.getValue("request").jsonObject NappletRequest.UploadBlob( - bytes = Base64.getDecoder().decode(request.req("dataBase64")), + bytes = lenientBase64.decode(request.req("dataBase64")), contentType = request.str("mimeType") ?: "application/octet-stream", filename = request.str("filename"), ) @@ -275,7 +279,7 @@ object NappletProtocolJson { } is NappletResponse.Bytes -> { put("ok", true) - put("bytes", Base64.getEncoder().encodeToString(response.bytes)) + put("bytes", Base64.encode(response.bytes)) put("mime", response.contentType) } is NappletResponse.ResourceInfo -> { @@ -301,7 +305,7 @@ object NappletProtocolJson { put("url", item.url) put("ok", item.resource != null) item.resource?.let { - put("bytes", Base64.getEncoder().encodeToString(it.bytes)) + put("bytes", Base64.encode(it.bytes)) put("mime", it.contentType) } item.error?.let { put("error", it) } diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostNotifier.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostNotifier.kt similarity index 100% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostNotifier.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostNotifier.kt diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostPublisher.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostPublisher.kt similarity index 100% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostPublisher.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostPublisher.kt diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt similarity index 88% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt index d19e8e7a6c..ec34e46725 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt @@ -20,21 +20,31 @@ */ package com.vitorpamplona.amethyst.commons.scheduledposts +import com.vitorpamplona.amethyst.commons.util.platformFileSystem +import com.vitorpamplona.amethyst.commons.util.restrictFileToOwner import com.vitorpamplona.quartz.utils.Log +import com.vitorpamplona.quartz.utils.TimeUtils import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.serialization.json.Json -import java.io.File -import java.nio.file.Files -import java.nio.file.attribute.PosixFilePermission +import okio.FileSystem +import okio.Path +import okio.Path.Companion.toPath class ScheduledPostStore( - private val storageFile: File, - private val nowSec: () -> Long = { System.currentTimeMillis() / 1000 }, + private val storageFile: Path, + private val nowSec: () -> Long = { TimeUtils.now() }, + private val fileSystem: FileSystem = platformFileSystem, ) { + /** Takes the platform's own path string, so callers need no okio of their own. */ + constructor( + storagePath: String, + nowSec: () -> Long = { TimeUtils.now() }, + ) : this(storagePath.toPath(), nowSec) + /** * `encodeDefaults = true` so this writes the same bytes Jackson did — kotlinx * omits a value equal to its default, which would silently drop `"version":1` @@ -214,7 +224,7 @@ class ScheduledPostStore( */ suspend fun publishNow( id: String, - nowSec: Long = System.currentTimeMillis() / 1000, + nowSec: Long = TimeUtils.now(), ): Boolean = mutex.withLock { ensureLoaded() @@ -336,8 +346,8 @@ class ScheduledPostStore( private fun reloadFromDiskLocked() { val fromDisk = try { - if (storageFile.exists() && storageFile.length() > 0) { - json.decodeFromString<ScheduledPostFile>(storageFile.readText()).posts.toMutableList() + if (hasContent()) { + json.decodeFromString<ScheduledPostFile>(readText()).posts.toMutableList() } else { // File vanished — treat as no external state; keep current in-memory. return @@ -354,8 +364,8 @@ class ScheduledPostStore( if (loaded) return posts = try { - if (storageFile.exists() && storageFile.length() > 0) { - json.decodeFromString<ScheduledPostFile>(storageFile.readText()).posts.toMutableList() + if (hasContent()) { + json.decodeFromString<ScheduledPostFile>(readText()).posts.toMutableList() } else { mutableListOf() } @@ -367,7 +377,7 @@ class ScheduledPostStore( // Secure a pre-existing file up front (an older build may have left it at the // 0644 umask default) so it's owner-only even if nothing mutates the store // this session. - if (storageFile.exists()) restrictToOwner(storageFile) + if (fileSystem.exists(storageFile)) restrictFileToOwner(storageFile, TAG) var dirty = purgeStale(nowSec()) // Recover claims stranded by a crash-mid-publish so they aren't lost forever. if (recoverStuckClaimsLocked(nowSec())) dirty = true @@ -412,48 +422,30 @@ class ScheduledPostStore( private fun persist() { val snapshot = posts.toList() _flow.value = snapshot - storageFile.parentFile?.mkdirs() - val tmp = File(storageFile.parentFile, storageFile.name + ".tmp") + val tmp = "$storageFile.tmp".toPath() try { - tmp.writeText(json.encodeToString(ScheduledPostFile(version = 1, posts = snapshot))) + storageFile.parent?.let { fileSystem.createDirectories(it) } + fileSystem.write(tmp) { writeUtf8(json.encodeToString(ScheduledPostFile(version = 1, posts = snapshot))) } // Restrict to owner-only BEFORE the rename so the store is never briefly // world-readable. It holds pre-signed events + the account's pubkey, which // must not leak to other local users on a shared machine. - restrictToOwner(tmp) - if (!tmp.renameTo(storageFile)) { - if (!storageFile.delete()) { - Log.w(TAG) { "Failed to delete existing $storageFile before rename retry" } - } - if (!tmp.renameTo(storageFile)) { - Log.e(TAG) { "Failed to rename $tmp to $storageFile" } - if (!tmp.delete()) { - Log.w(TAG) { "Failed to clean up temp file $tmp after rename failure" } - } - } - } + restrictFileToOwner(tmp, TAG) + // Replaces an existing target, including on Windows, where a plain rename + // onto an existing file fails. + fileSystem.atomicMove(tmp, storageFile) } catch (e: Exception) { Log.e(TAG, "Failed to persist scheduled posts to $storageFile", e) - if (!tmp.delete()) { - Log.w(TAG) { "Failed to clean up temp file $tmp after persist exception" } + try { + fileSystem.delete(tmp) + } catch (e: Exception) { + Log.w(TAG) { "Failed to clean up temp file $tmp after persist exception: ${e.message}" } } } } - /** - * Best-effort chmod to `0600` (owner read/write only). No-op on filesystems - * without POSIX permissions (e.g. Windows), where confidentiality relies on the - * per-user home directory instead. Never throws. - */ - private fun restrictToOwner(file: File) { - try { - Files.setPosixFilePermissions( - file.toPath(), - setOf(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE), - ) - } catch (e: Exception) { - Log.w(TAG) { "Could not restrict permissions on $file: ${e.message}" } - } - } + private fun hasContent(): Boolean = (fileSystem.metadataOrNull(storageFile)?.size ?: 0L) > 0L + + private fun readText(): String = fileSystem.read(storageFile) { readUtf8() } companion object { private const val TAG = "ScheduledPostStore" diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostWorkGate.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostWorkGate.kt similarity index 100% rename from commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostWorkGate.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostWorkGate.kt diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.kt new file mode 100644 index 0000000000..05934c55ca --- /dev/null +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.kt @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.util + +import okio.Path + +/** + * Restricts the file at [path] to owner read/write (`0600`), best-effort. Never throws. + * + * Silent where the filesystem has no POSIX permissions (Windows), where the user profile's + * ACLs apply instead; logs under [tag] when a POSIX filesystem refuses. + */ +expect fun restrictFileToOwner( + path: Path, + tag: String, +) diff --git a/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt b/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt new file mode 100644 index 0000000000..42b3c0c516 --- /dev/null +++ b/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.util + +import com.vitorpamplona.quartz.utils.Log +import kotlinx.cinterop.ExperimentalForeignApi +import kotlinx.cinterop.convert +import okio.Path +import platform.posix.S_IRUSR +import platform.posix.S_IWUSR +import platform.posix.chmod +import platform.posix.errno + +@OptIn(ExperimentalForeignApi::class) +actual fun restrictFileToOwner( + path: Path, + tag: String, +) { + if (chmod(path.toString(), (S_IRUSR or S_IWUSR).convert()) != 0) { + Log.w(tag) { "Could not restrict permissions on $path: errno $errno" } + } +} diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt new file mode 100644 index 0000000000..5d4d16c3b7 --- /dev/null +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.util + +import com.vitorpamplona.quartz.utils.Log +import okio.Path +import java.nio.file.Files +import java.nio.file.attribute.PosixFilePermission + +actual fun restrictFileToOwner( + path: Path, + tag: String, +) { + try { + Files.setPosixFilePermissions( + path.toNioPath(), + setOf(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE), + ) + } catch (_: UnsupportedOperationException) { + // Windows: no POSIX permissions; the user profile's NTFS ACLs apply instead. + } catch (e: Exception) { + Log.w(tag) { "Could not restrict permissions on $path: ${e.message}" } + } +} diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStoreTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStoreTest.kt index 6033715624..bf0fdb92e2 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStoreTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStoreTest.kt @@ -47,7 +47,7 @@ class ScheduledPostStoreTest { file = File(temp.root, "scheduled_posts.json") } - private fun newStore(now: () -> Long = { System.currentTimeMillis() / 1000 }) = ScheduledPostStore(file, now) + private fun newStore(now: () -> Long = { System.currentTimeMillis() / 1000 }) = ScheduledPostStore(file.path, now) private fun samplePost( id: String = "id-1", diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/DesktopScheduledPostStore.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/DesktopScheduledPostStore.kt index ebd05606b5..96ccc66328 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/DesktopScheduledPostStore.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/DesktopScheduledPostStore.kt @@ -52,7 +52,7 @@ object DesktopScheduledPostStore { if (file.exists()) { setOwnerOnly(file, PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE) } - return ScheduledPostStore(file) + return ScheduledPostStore(file.path) } private fun setDirPermissions(dir: File) = diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/HeadlessScheduledPublish.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/HeadlessScheduledPublish.kt index 9c5fb8ee77..49b554ba66 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/HeadlessScheduledPublish.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/service/scheduledposts/HeadlessScheduledPublish.kt @@ -82,7 +82,7 @@ fun runHeadlessPublish(): Int { } private fun headlessDrain(log: (String) -> Unit): Int { - val store = ScheduledPostStore(File(scheduledDir(), ScheduledPostStore.FILE_NAME)) + val store = ScheduledPostStore(File(scheduledDir(), ScheduledPostStore.FILE_NAME).path) // Build a plain OkHttp client for websockets — no Tor, no proxy. Headless mode // reads no settings, so we cannot know Tor preferences; scheduled posts that From 150177f5a0220bf6e84d23e6f839186cc989f8b4 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 21:13:01 +0000 Subject: [PATCH 51/57] fix(strings): move the cordn and backup strings to commonsUI, and write the rule down The 2026-09-22 move left Android res/ with only the ~190 strings a platform API reads synchronously. The cordn UI and the backup-conflict review then added 447 keys back to it. All of them move with tools/strings-migrate (1,131 elements across the locales that translate them), and the 18 files that read them now use Res.string/Res.plurals. The parts that were not a rename: - stringRes(context, ...) in the suspend attachment/voice senders becomes loadStringRes; adminFailureText becomes suspend (its only caller is already inside scope.launch). - The backup review held labels as @StringRes Int (DiffGroup.label, the ReviewRow *Res fields, eventTypeName/Explainer, the tile/hero/lane params). They are StringResource / PluralStringResource now. - rememberPresentation resolved labels inside remember {} through LocalResources. Compose resources have no blocking accessor, so the 16 labels presentationOf writes into item text are resolved in composition into a map, and that map is the remember key. - androidx pluralStringResource -> the compose-resources one. The rule is now in .claude/CLAUDE.md ("Strings"), commonsUI/ARCHITECTURE.md and the android-expert and find-missing-translations skills: new strings go in commonsUI composeResources, Android-only screens included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjQQN9CgWHVtNCSWqnKoqY --- .claude/CLAUDE.md | 42 ++ .claude/skills/android-expert/SKILL.md | 21 +- .../skills/find-missing-translations/SKILL.md | 7 + .../loggedIn/backups/BackupConflictCards.kt | 131 ++-- .../backups/BackupConflictEventViews.kt | 197 +++--- .../backups/BackupConflictListViews.kt | 156 +++-- .../backups/BackupConflictPresentation.kt | 328 ++++++---- .../backups/BackupConflictReviewScreen.kt | 86 ++- .../chats/cordnGroup/CordnComposer.kt | 5 +- .../cordnGroup/CordnCreateGroupScreen.kt | 149 +++-- .../cordnGroup/CordnCreateMembersScreen.kt | 58 +- .../chats/cordnGroup/CordnGroupChatScreen.kt | 78 ++- .../chats/cordnGroup/CordnGroupInfoScreen.kt | 161 +++-- .../chats/cordnGroup/CordnGroupListScreen.kt | 26 +- .../cordnGroup/CordnInvitationsScreen.kt | 51 +- .../chats/cordnGroup/CordnMessageRow.kt | 61 +- .../settings/cordn/CordnBackupScreen.kt | 45 +- .../settings/cordn/CordnCoordinatorsScreen.kt | 114 ++-- .../settings/cordn/CordnKeyPackagesScreen.kt | 50 +- .../settings/cordn/CordnLinkScreen.kt | 16 +- .../settings/cordn/CordnMigrateScreen.kt | 7 +- .../src/main/res/values-hi-rIN/strings.xml | 318 ---------- .../src/main/res/values-hu-rHU/strings.xml | 318 ---------- .../src/main/res/values-pl-rPL/strings.xml | 378 ------------ amethyst/src/main/res/values/strings.xml | 570 ------------------ commonsUI/ARCHITECTURE.md | 5 +- .../values-hi-rIN/strings.xml | 318 ++++++++++ .../values-hu-rHU/strings.xml | 318 ++++++++++ .../values-pl-rPL/strings.xml | 378 ++++++++++++ .../composeResources/values/strings.xml | 570 ++++++++++++++++++ 30 files changed, 2777 insertions(+), 2185 deletions(-) diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 6038af56e7..886a0dfe3e 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -285,6 +285,48 @@ Quartz uses expect/actual for platform-specific implementations (e.g. crypto backed by `secp256k1-kmp-jni-android` on Android and `secp256k1-kmp-jni-jvm` on JVM). See `/kotlin-multiplatform` for the expect/actual and source-set patterns. +## Strings + +**MANDATORY: every new user-visible string goes in `commonsUI` Compose resources**, +`commonsUI/src/commonMain/composeResources/values/strings.xml` — **never** in +`amethyst/src/main/res/values/strings.xml`, even for an Android-only screen. A +screen cannot move to `commonsUI` (or be rendered by Desktop) while its labels +live in Android `res/`, and every key added there has to be migrated back out +later. (The 2026-09-22 move emptied Android `res/` down to ~190 keys; the next two +features put 447 back.) + +- Reference it as `Res.string.my_key` / `Res.plurals.my_key`, importing + `com.vitorpamplona.amethyst.commons.resources.Res` **and** the per-key accessor + `com.vitorpamplona.amethyst.commons.resources.my_key` (Compose resources generates + each key as an extension property). +- Read it with `stringRes(Res.string.x)` / `pluralStringRes(Res.plurals.x, n, …)` + in composition — the app-side `ui.stringRes` overloads delegate to the + commonsUI bridge (`commons/ui/StringRes.kt`), so one import serves both kinds. +- Outside composition there is **no blocking accessor**: use `loadStringRes(…)` + from a coroutine (or make the function `suspend`), or resolve the label in + composition and pass it down as a `String`. A `runBlocking` bridge is ruled out. +- Hold a string reference as `StringResource` / `PluralStringResource`, not a + `@StringRes Int`. +- Format arguments must be positional (`%1$s`, `%2$d`) — compose-resources does + not format bare `%s`/`%d`. +- Escaping is not Android's: write `'` and `"` bare (no `\'`), and never wrap a + value in quotes to keep its whitespace. `.claude/hooks/compose_escaping_check.py` + checks this before a push. + +The **only** strings that stay in Android `res/` are the ones a platform API +reads synchronously under a deadline, where a `suspend` read cannot run: a +foreground service's `startForeground` notification, a notification channel +created during service startup, PiP `RemoteAction`s, napplet capability labels +read in the sandbox process, and `AndroidManifest.xml` / `res/xml` references. +Most of those are *copies* of a key that also lives in `commonsUI`. See +`commons/plans/2026-09-22-strings-to-compose-resources.md` ("the +synchronous-platform tier"). If you think a new string belongs in that tier, +say why in the PR. + +To move keys that already landed in Android `res/`, use +`tools/strings-migrate/migrate.py <keys…>`. It moves every locale byte-for-byte, +so Crowdin sees a pure move. Then repoint `R.string.x` → `Res.string.x`. + ## Icons The Material Symbols font bundled at diff --git a/.claude/skills/android-expert/SKILL.md b/.claude/skills/android-expert/SKILL.md index e2483221d0..19b79ec6a1 100644 --- a/.claude/skills/android-expert/SKILL.md +++ b/.claude/skills/android-expert/SKILL.md @@ -875,18 +875,33 @@ fun ProfileScreen( ### 3. Resource Access +**Strings do not go in `amethyst/src/main/res`.** New user-visible strings live in +`commonsUI/src/commonMain/composeResources/values/strings.xml` and are read as +`Res.string.x`, even on an Android-only screen. See "Strings" in `.claude/CLAUDE.md` +for the rule and the small platform tier that is the only exception. + ```kotlin +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.button_clicked +import com.vitorpamplona.amethyst.commons.resources.button_label +import com.vitorpamplona.amethyst.commons.ui.loadStringRes +import com.vitorpamplona.amethyst.ui.stringRes + @Composable fun LocalizedButton() { val context = LocalContext.current + val scope = rememberCoroutineScope() Button( onClick = { - val message = context.getString(R.string.button_clicked) - Toast.makeText(context, message, Toast.LENGTH_SHORT).show() + // No blocking accessor outside composition: read it from a coroutine, + // or resolve it in composition and capture the String. + scope.launch { + Toast.makeText(context, loadStringRes(Res.string.button_clicked), Toast.LENGTH_SHORT).show() + } } ) { - Text(stringResource(R.string.button_label)) + Text(stringRes(Res.string.button_label)) } } ``` diff --git a/.claude/skills/find-missing-translations/SKILL.md b/.claude/skills/find-missing-translations/SKILL.md index b41533cf3e..7547c5c46d 100644 --- a/.claude/skills/find-missing-translations/SKILL.md +++ b/.claude/skills/find-missing-translations/SKILL.md @@ -26,6 +26,13 @@ There are two separate `strings.xml` trees, each with its own default `values/` | **amethyst** (Android app) | `amethyst/src/main/res/values/strings.xml` | `amethyst/src/main/res/values-<locale>/strings.xml` | | **commonsUI** (KMP Compose resources, shared by Android + Desktop) | `commonsUI/src/commonMain/composeResources/values/strings.xml` | `commonsUI/src/commonMain/composeResources/values-<locale>/strings.xml` | +**New keys go in the `commonsUI` tree, always.** The amethyst tree is frozen at +the small synchronous-platform tier (foreground-service and notification-channel +text, PiP actions, napplet capability labels, manifest references). If you find +a new feature key in it, it belongs in `commonsUI`. Move it with +`tools/strings-migrate/migrate.py` rather than translating it where it is. See +"Strings" in `.claude/CLAUDE.md`. + The `commonsUI` tree appeared when shared event-renderer composables were extracted out of `amethyst/` into `commons/` — now `commonsUI/` since the UI split (Compose Multiplatform `stringResource`). It is **not** a copy of the amethyst tree — the vast majority of its keys are commons-only; only a small handful overlap. Every diff/count/translate command below works on either tree by swapping the base path — **run the whole technique once per tree** and report them separately (each maps to its own Crowdin file, so the counts should reconcile against two different Crowdin UI numbers). **Locale-qualifier caveat:** `commons` uses the same region-qualified locale dirs as amethyst for our four targets (`values-cs`, `values-de-rDE`, `values-sv-rSE`, `values-pt-rBR`), but the *full* set of locale dirs differs between trees. Enumerate `values-*` under each tree's own base rather than assuming they match. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt index bb977a4184..769c911ae4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictCards.kt @@ -43,17 +43,57 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.backups.BackupEventType import com.vitorpamplona.amethyst.commons.model.backups.ReplaceableBackupConflict import com.vitorpamplona.amethyst.commons.model.navigation.Route +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.backup_card_accept +import com.vitorpamplona.amethyst.commons.resources.backup_card_and_added +import com.vitorpamplona.amethyst.commons.resources.backup_card_and_blocked +import com.vitorpamplona.amethyst.commons.resources.backup_card_and_followed +import com.vitorpamplona.amethyst.commons.resources.backup_card_and_joined +import com.vitorpamplona.amethyst.commons.resources.backup_card_and_muted +import com.vitorpamplona.amethyst.commons.resources.backup_card_app_settings +import com.vitorpamplona.amethyst.commons.resources.backup_card_concord_emptied +import com.vitorpamplona.amethyst.commons.resources.backup_card_concord_rewritten +import com.vitorpamplona.amethyst.commons.resources.backup_card_dm_relays_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_feeds_removed +import com.vitorpamplona.amethyst.commons.resources.backup_card_follows_dropped +import com.vitorpamplona.amethyst.commons.resources.backup_card_hashtags_unfollowed +import com.vitorpamplona.amethyst.commons.resources.backup_card_indexer_relays_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_key_package_relays_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_leave_chats +import com.vitorpamplona.amethyst.commons.resources.backup_card_leave_communities +import com.vitorpamplona.amethyst.commons.resources.backup_card_leave_groups +import com.vitorpamplona.amethyst.commons.resources.backup_card_leave_rooms +import com.vitorpamplona.amethyst.commons.resources.backup_card_mutes_visible +import com.vitorpamplona.amethyst.commons.resources.backup_card_nip65_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_nutzap_key_removed +import com.vitorpamplona.amethyst.commons.resources.backup_card_nutzap_key_replaced +import com.vitorpamplona.amethyst.commons.resources.backup_card_nutzap_mints_removed +import com.vitorpamplona.amethyst.commons.resources.backup_card_offers_removed +import com.vitorpamplona.amethyst.commons.resources.backup_card_payment_targets_removed +import com.vitorpamplona.amethyst.commons.resources.backup_card_places_unfollowed +import com.vitorpamplona.amethyst.commons.resources.backup_card_private_outbox_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_profile_lost_fields +import com.vitorpamplona.amethyst.commons.resources.backup_card_relay_feeds_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_search_relays_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_trust_services_changed +import com.vitorpamplona.amethyst.commons.resources.backup_card_trusted_lost +import com.vitorpamplona.amethyst.commons.resources.backup_card_unblocked +import com.vitorpamplona.amethyst.commons.resources.backup_card_wallet_emptied +import com.vitorpamplona.amethyst.commons.resources.backup_card_wallet_rewritten +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_count_added +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_count_changed +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_count_removed +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_title +import com.vitorpamplona.amethyst.commons.resources.backup_review_changed_by_other_app import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.note.timeAgoNoDot @@ -79,6 +119,9 @@ import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListDiff import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataDiff import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListDiff import com.vitorpamplona.quartz.nipB1Bolt12Zaps.offer.Bolt12OfferListDiff +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringResource +import org.jetbrains.compose.resources.pluralStringResource /** * Cards at the top of Home's feed, one per open [ReplaceableBackupConflict]: the user @@ -125,34 +168,34 @@ private fun headlineOf( when (diff) { // Counted, not "shrank": a version that drops 3 follows and adds 100 still raises // a conflict, and calling that a shrink contradicts the card's own bar. - is ContactListDiff -> plural(R.plurals.backup_card_follows_dropped, diff.follows.removed.size) - is MuteListDiff -> plural(R.plurals.backup_card_mutes_visible, diff.publicMutes.removed.size) - is MetadataDiff -> plural(R.plurals.backup_card_profile_lost_fields, counts.removed) - is AdvertisedRelayListDiff -> plural(R.plurals.backup_card_nip65_lost, diff.relays.removed.size) + is ContactListDiff -> plural(Res.plurals.backup_card_follows_dropped, diff.follows.removed.size) + is MuteListDiff -> plural(Res.plurals.backup_card_mutes_visible, diff.publicMutes.removed.size) + is MetadataDiff -> plural(Res.plurals.backup_card_profile_lost_fields, counts.removed) + is AdvertisedRelayListDiff -> plural(Res.plurals.backup_card_nip65_lost, diff.relays.removed.size) is RelayListDiff -> relayListHeadline(conflict.eventType, diff.relays.removed.size) - is ChannelListDiff -> plural(R.plurals.backup_card_leave_chats, diff.channels.removed.size) - is CommunityListDiff -> plural(R.plurals.backup_card_leave_communities, diff.communities.removed.size) - is EphemeralChatListDiff -> plural(R.plurals.backup_card_leave_rooms, diff.rooms.removed.size) - is SimpleGroupListDiff -> plural(R.plurals.backup_card_leave_groups, diff.groups.removed.size) - is FavoriteAlgoFeedsListDiff -> plural(R.plurals.backup_card_feeds_removed, diff.feeds.removed.size) - is HashtagListDiff -> plural(R.plurals.backup_card_hashtags_unfollowed, diff.hashtags.removed.size) - is GeohashListDiff -> plural(R.plurals.backup_card_places_unfollowed, diff.geohashes.removed.size) - is TrustProviderListDiff -> plural(R.plurals.backup_card_trust_services_changed, diff.providers.removed.size + diff.providers.changed.size) + is ChannelListDiff -> plural(Res.plurals.backup_card_leave_chats, diff.channels.removed.size) + is CommunityListDiff -> plural(Res.plurals.backup_card_leave_communities, diff.communities.removed.size) + is EphemeralChatListDiff -> plural(Res.plurals.backup_card_leave_rooms, diff.rooms.removed.size) + is SimpleGroupListDiff -> plural(Res.plurals.backup_card_leave_groups, diff.groups.removed.size) + is FavoriteAlgoFeedsListDiff -> plural(Res.plurals.backup_card_feeds_removed, diff.feeds.removed.size) + is HashtagListDiff -> plural(Res.plurals.backup_card_hashtags_unfollowed, diff.hashtags.removed.size) + is GeohashListDiff -> plural(Res.plurals.backup_card_places_unfollowed, diff.geohashes.removed.size) + is TrustProviderListDiff -> plural(Res.plurals.backup_card_trust_services_changed, diff.providers.removed.size + diff.providers.changed.size) is NutzapInfoDiff -> when { - diff.p2pkPubkey?.after == null && diff.p2pkPubkey != null -> stringRes(R.string.backup_card_nutzap_key_removed) - diff.p2pkPubkey != null -> stringRes(R.string.backup_card_nutzap_key_replaced) - else -> plural(R.plurals.backup_card_nutzap_mints_removed, diff.mints.removed.size) + diff.p2pkPubkey?.after == null && diff.p2pkPubkey != null -> stringRes(Res.string.backup_card_nutzap_key_removed) + diff.p2pkPubkey != null -> stringRes(Res.string.backup_card_nutzap_key_replaced) + else -> plural(Res.plurals.backup_card_nutzap_mints_removed, diff.mints.removed.size) } - is PaymentTargetsDiff -> plural(R.plurals.backup_card_payment_targets_removed, diff.targets.removed.size) - is Bolt12OfferListDiff -> plural(R.plurals.backup_card_offers_removed, diff.offers.removed.size) - is CashuWalletDiff -> encryptedHeadline(R.string.backup_card_wallet_emptied, R.string.backup_card_wallet_rewritten, diff.wallet) - is ConcordCommunityListDiff -> encryptedHeadline(R.string.backup_card_concord_emptied, R.string.backup_card_concord_rewritten, diff.communities) - is AppSpecificDataDiff -> stringRes(R.string.backup_card_app_settings) + is PaymentTargetsDiff -> plural(Res.plurals.backup_card_payment_targets_removed, diff.targets.removed.size) + is Bolt12OfferListDiff -> plural(Res.plurals.backup_card_offers_removed, diff.offers.removed.size) + is CashuWalletDiff -> encryptedHeadline(Res.string.backup_card_wallet_emptied, Res.string.backup_card_wallet_rewritten, diff.wallet) + is ConcordCommunityListDiff -> encryptedHeadline(Res.string.backup_card_concord_emptied, Res.string.backup_card_concord_rewritten, diff.communities) + is AppSpecificDataDiff -> stringRes(Res.string.backup_card_app_settings) else -> null } // A headline counting removed items reads wrong when only encrypted items were lost. - if (specific.isNullOrEmpty()) return stringRes(R.string.backup_conflict_title, stringRes(eventTypeName(conflict.eventType))) + if (specific.isNullOrEmpty()) return stringRes(Res.string.backup_conflict_title, stringRes(eventTypeName(conflict.eventType))) // Headlines lead with the loss; what the other app added to the same list is said too, // so a list that dropped 3 and gained 40 doesn't read as if it only shrank. The wording // follows the headline's: following people, muting, joining chats, blocking relays. @@ -160,11 +203,11 @@ private fun headlineOf( if (added <= 0) return specific val tail = when { - diff is ContactListDiff -> R.plurals.backup_card_and_followed - diff is MuteListDiff -> R.plurals.backup_card_and_muted - diff is ChannelListDiff || diff is CommunityListDiff || diff is EphemeralChatListDiff || diff is SimpleGroupListDiff -> R.plurals.backup_card_and_joined - conflict.eventType == BackupEventType.BLOCKED_RELAYS -> R.plurals.backup_card_and_blocked - else -> R.plurals.backup_card_and_added + diff is ContactListDiff -> Res.plurals.backup_card_and_followed + diff is MuteListDiff -> Res.plurals.backup_card_and_muted + diff is ChannelListDiff || diff is CommunityListDiff || diff is EphemeralChatListDiff || diff is SimpleGroupListDiff -> Res.plurals.backup_card_and_joined + conflict.eventType == BackupEventType.BLOCKED_RELAYS -> Res.plurals.backup_card_and_blocked + else -> Res.plurals.backup_card_and_added } return pluralStringResource(tail, added, specific, added) } @@ -208,7 +251,7 @@ private fun relayListHasHeadline(type: BackupEventType): Boolean = /** The count's plural, or "" when nothing of that kind was removed. */ @Composable private fun plural( - id: Int, + id: PluralStringResource, count: Int, ): String = if (count > 0) pluralStringResource(id, count, count) else "" @@ -218,21 +261,21 @@ private fun relayListHeadline( removed: Int, ): String = when (type) { - BackupEventType.DM_RELAYS -> plural(R.plurals.backup_card_dm_relays_lost, removed) - BackupEventType.KEY_PACKAGE_RELAYS -> plural(R.plurals.backup_card_key_package_relays_lost, removed) - BackupEventType.SEARCH_RELAYS -> plural(R.plurals.backup_card_search_relays_lost, removed) - BackupEventType.INDEXER_RELAYS -> plural(R.plurals.backup_card_indexer_relays_lost, removed) - BackupEventType.RELAY_FEEDS -> plural(R.plurals.backup_card_relay_feeds_lost, removed) - BackupEventType.PRIVATE_OUTBOX_RELAYS -> plural(R.plurals.backup_card_private_outbox_lost, removed) - BackupEventType.TRUSTED_RELAYS -> plural(R.plurals.backup_card_trusted_lost, removed) - BackupEventType.BLOCKED_RELAYS -> plural(R.plurals.backup_card_unblocked, removed) + BackupEventType.DM_RELAYS -> plural(Res.plurals.backup_card_dm_relays_lost, removed) + BackupEventType.KEY_PACKAGE_RELAYS -> plural(Res.plurals.backup_card_key_package_relays_lost, removed) + BackupEventType.SEARCH_RELAYS -> plural(Res.plurals.backup_card_search_relays_lost, removed) + BackupEventType.INDEXER_RELAYS -> plural(Res.plurals.backup_card_indexer_relays_lost, removed) + BackupEventType.RELAY_FEEDS -> plural(Res.plurals.backup_card_relay_feeds_lost, removed) + BackupEventType.PRIVATE_OUTBOX_RELAYS -> plural(Res.plurals.backup_card_private_outbox_lost, removed) + BackupEventType.TRUSTED_RELAYS -> plural(Res.plurals.backup_card_trusted_lost, removed) + BackupEventType.BLOCKED_RELAYS -> plural(Res.plurals.backup_card_unblocked, removed) else -> "" } @Composable private fun encryptedHeadline( - emptied: Int, - rewritten: Int, + emptied: StringResource, + rewritten: StringResource, change: ContentChange, ): String = if (change == ContentChange.CLEARED) stringRes(emptied) else stringRes(rewritten) @@ -262,7 +305,7 @@ private fun LeadConflictCard( Column(Modifier.weight(1f)) { Text(headlineOf(conflict, counts), style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold, maxLines = 3, overflow = TextOverflow.Ellipsis) Text( - stringRes(R.string.backup_review_changed_by_other_app, timeAgoNoDot(conflict.cause.createdAt)), + stringRes(Res.string.backup_review_changed_by_other_app, timeAgoNoDot(conflict.cause.createdAt)), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.placeholderText, ) @@ -296,9 +339,9 @@ private fun LeadConflictCard( private fun CountChips(counts: ConflictCounts) { val tones = conflictTones() Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - if (counts.removed > 0) StatusTag(stringRes(R.string.backup_conflict_count_removed, counts.removed.toString()), tones.removed) - if (counts.added > 0) StatusTag(stringRes(R.string.backup_conflict_count_added, counts.added.toString()), tones.added) - if (counts.changed > 0) StatusTag(stringRes(R.string.backup_conflict_count_changed, counts.changed.toString()), tones.changed) + if (counts.removed > 0) StatusTag(stringRes(Res.string.backup_conflict_count_removed, counts.removed.toString()), tones.removed) + if (counts.added > 0) StatusTag(stringRes(Res.string.backup_conflict_count_added, counts.added.toString()), tones.added) + if (counts.changed > 0) StatusTag(stringRes(Res.string.backup_conflict_count_changed, counts.changed.toString()), tones.changed) } } @@ -342,6 +385,6 @@ private fun AcceptButton(onAccept: () -> Unit) { modifier = Modifier.height(36.dp), contentPadding = PaddingValues(horizontal = 14.dp), ) { - Text(stringRes(R.string.backup_card_accept), fontWeight = FontWeight.SemiBold) + Text(stringRes(Res.string.backup_card_accept), fontWeight = FontWeight.SemiBold) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictEventViews.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictEventViews.kt index 419bd3b2a2..1916f09286 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictEventViews.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictEventViews.kt @@ -62,7 +62,6 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.backups.ReplaceableBackupConflict @@ -70,6 +69,67 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.navigation.routeFor import com.vitorpamplona.amethyst.commons.model.nip29RelayGroups.RelayGroupChannel +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.backup_entry_hashtag +import com.vitorpamplona.amethyst.commons.resources.backup_entry_mint +import com.vitorpamplona.amethyst.commons.resources.backup_entry_nutzap_key +import com.vitorpamplona.amethyst.commons.resources.backup_entry_person +import com.vitorpamplona.amethyst.commons.resources.backup_entry_profile_field +import com.vitorpamplona.amethyst.commons.resources.backup_entry_thread +import com.vitorpamplona.amethyst.commons.resources.backup_entry_word +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_about +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_banner +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_birthday +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_bot +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_clink_offer +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_display_name +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_lud06 +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_lud16 +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_name +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_nip05 +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_picture +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_pronouns +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_website +import com.vitorpamplona.amethyst.commons.resources.backup_review_demoted_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_dropped_count +import com.vitorpamplona.amethyst.commons.resources.backup_review_dropped_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_gone +import com.vitorpamplona.amethyst.commons.resources.backup_review_inbox +import com.vitorpamplona.amethyst.commons.resources.backup_review_inbox_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_review_joined +import com.vitorpamplona.amethyst.commons.resources.backup_review_kept_count +import com.vitorpamplona.amethyst.commons.resources.backup_review_key_removed +import com.vitorpamplona.amethyst.commons.resources.backup_review_key_replaced +import com.vitorpamplona.amethyst.commons.resources.backup_review_key_warning +import com.vitorpamplona.amethyst.commons.resources.backup_review_left +import com.vitorpamplona.amethyst.commons.resources.backup_review_left_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_names_and_more +import com.vitorpamplona.amethyst.commons.resources.backup_review_new +import com.vitorpamplona.amethyst.commons.resources.backup_review_new_count +import com.vitorpamplona.amethyst.commons.resources.backup_review_new_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_newly_muted +import com.vitorpamplona.amethyst.commons.resources.backup_review_not_set +import com.vitorpamplona.amethyst.commons.resources.backup_review_nothing_here +import com.vitorpamplona.amethyst.commons.resources.backup_review_outbox +import com.vitorpamplona.amethyst.commons.resources.backup_review_outbox_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_review_private_added_body +import com.vitorpamplona.amethyst.commons.resources.backup_review_private_added_title +import com.vitorpamplona.amethyst.commons.resources.backup_review_private_changed_body +import com.vitorpamplona.amethyst.commons.resources.backup_review_private_changed_title +import com.vitorpamplona.amethyst.commons.resources.backup_review_private_wiped_body +import com.vitorpamplona.amethyst.commons.resources.backup_review_private_wiped_title +import com.vitorpamplona.amethyst.commons.resources.backup_review_renamed +import com.vitorpamplona.amethyst.commons.resources.backup_review_renamed_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_saved +import com.vitorpamplona.amethyst.commons.resources.backup_review_search_people +import com.vitorpamplona.amethyst.commons.resources.backup_review_tab_dropped +import com.vitorpamplona.amethyst.commons.resources.backup_review_tab_edited +import com.vitorpamplona.amethyst.commons.resources.backup_review_tab_new +import com.vitorpamplona.amethyst.commons.resources.backup_review_units_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_unmuted +import com.vitorpamplona.amethyst.commons.resources.backup_review_unmuted_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_review_was_named +import com.vitorpamplona.amethyst.commons.resources.backup_review_words_and_hashtags import com.vitorpamplona.amethyst.commons.ui.components.RobohashFallbackAsyncImage import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings @@ -111,6 +171,7 @@ import com.vitorpamplona.quartz.nip61Nutzaps.info.tags.NutzapMintTag import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListDiff import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.nip65RelayList.tags.AdvertisedRelayType +import org.jetbrains.compose.resources.StringResource private const val GRID_COLUMNS = 4 private const val PEOPLE_PREVIEW = 6 @@ -168,7 +229,7 @@ private fun LazyListScope.followListItems( item(key = "follow-hero", contentType = "hero") { val tones = conflictTones() Column(Pad.padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) { - HeroCounts(stringRes(R.string.backup_review_saved), saved, stringRes(R.string.backup_review_new), new) + HeroCounts(stringRes(Res.string.backup_review_saved), saved, stringRes(Res.string.backup_review_new), new) SplitBar( listOf( BarSegment(saved - dropped, tones.kept), @@ -177,9 +238,9 @@ private fun LazyListScope.followListItems( ), ) Row(horizontalArrangement = Arrangement.spacedBy(14.dp)) { - LegendItem(tones.kept, stringRes(R.string.backup_review_kept_count, (saved - dropped).toString())) - LegendItem(tones.removed, stringRes(R.string.backup_review_dropped_count, dropped.toString())) - LegendItem(tones.added, stringRes(R.string.backup_review_new_count, gained.toString())) + LegendItem(tones.kept, stringRes(Res.string.backup_review_kept_count, (saved - dropped).toString())) + LegendItem(tones.removed, stringRes(Res.string.backup_review_dropped_count, dropped.toString())) + LegendItem(tones.added, stringRes(Res.string.backup_review_new_count, gained.toString())) } } } @@ -188,9 +249,9 @@ private fun LazyListScope.followListItems( ReviewTabs( labels = listOf( - stringRes(R.string.backup_review_tab_dropped, dropped.toString()), - stringRes(R.string.backup_review_tab_new, gained.toString()), - stringRes(R.string.backup_review_tab_edited, edited.toString()), + stringRes(Res.string.backup_review_tab_dropped, dropped.toString()), + stringRes(Res.string.backup_review_tab_new, gained.toString()), + stringRes(Res.string.backup_review_tab_edited, edited.toString()), ), selected = ui.tab, onSelect = { @@ -223,7 +284,7 @@ private fun LazyListScope.followListItems( if (filtered.isEmpty()) { item(key = "follow-empty", contentType = "note") { - DetailText(stringRes(R.string.backup_review_nothing_here), Pad.padding(vertical = 24.dp)) + DetailText(stringRes(Res.string.backup_review_nothing_here), Pad.padding(vertical = 24.dp)) } } } @@ -359,7 +420,7 @@ private fun PeopleSearch( singleLine = true, shape = RoundedCornerShape(14.dp), leadingIcon = { Icon(symbol = MaterialSymbols.Search, contentDescription = null) }, - placeholder = { Text(stringRes(R.string.backup_review_search_people, count.toString())) }, + placeholder = { Text(stringRes(Res.string.backup_review_search_people, count.toString())) }, ) } @@ -388,15 +449,15 @@ private fun LazyListScope.muteListItems( Icon(symbol = MaterialSymbols.Shield, contentDescription = null, tint = tones.removed, modifier = Modifier.size(44.dp)) Column { Text( - stringRes(R.string.backup_review_unmuted, removed.size.toString()), + stringRes(Res.string.backup_review_unmuted, removed.size.toString()), fontSize = 30.sp, lineHeight = 32.sp, fontWeight = FontWeight.Bold, color = tones.removed, ) - Text(stringRes(R.string.backup_review_unmuted_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) + Text(stringRes(Res.string.backup_review_unmuted_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) if (added.isNotEmpty()) { - Text(stringRes(R.string.backup_review_newly_muted, added.size.toString()), style = MaterialTheme.typography.bodySmall, color = tones.added) + Text(stringRes(Res.string.backup_review_newly_muted, added.size.toString()), style = MaterialTheme.typography.bodySmall, color = tones.added) } } } @@ -406,17 +467,17 @@ private fun LazyListScope.muteListItems( item(key = "mute-tiles", contentType = "tiles") { val tones = conflictTones() Row(Pad.padding(top = 12.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - StatTile("−${people.size}", stringRes(R.string.backup_entry_person), tones.removed, Modifier.weight(1f)) - StatTile("−${words.size}", stringRes(R.string.backup_entry_word), tones.removed, Modifier.weight(1f)) - StatTile("−${hashtags.size}", stringRes(R.string.backup_entry_hashtag), tones.removed, Modifier.weight(1f)) - StatTile("−${threads.size}", stringRes(R.string.backup_entry_thread), tones.removed, Modifier.weight(1f)) + StatTile("−${people.size}", stringRes(Res.string.backup_entry_person), tones.removed, Modifier.weight(1f)) + StatTile("−${words.size}", stringRes(Res.string.backup_entry_word), tones.removed, Modifier.weight(1f)) + StatTile("−${hashtags.size}", stringRes(Res.string.backup_entry_hashtag), tones.removed, Modifier.weight(1f)) + StatTile("−${threads.size}", stringRes(Res.string.backup_entry_thread), tones.removed, Modifier.weight(1f)) } } if (people.isNotEmpty()) { item(key = "mute-people", contentType = "facepile") { Column(Pad.padding(top = 18.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { - SectionCaption(stringRes(R.string.backup_entry_person)) + SectionCaption(stringRes(Res.string.backup_entry_person)) FacePile(people, accountViewModel) { ui.showAllPeople = !ui.showAllPeople } } } @@ -427,7 +488,7 @@ private fun LazyListScope.muteListItems( item(key = "mute-words", contentType = "pills") { val tones = conflictTones() Column(Pad.padding(top = 18.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { - SectionCaption(stringRes(R.string.backup_review_words_and_hashtags)) + SectionCaption(stringRes(Res.string.backup_review_words_and_hashtags)) FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { (words.map { "\"$it\"" } + hashtags).forEach { StruckPill(it, tones.removed) } } @@ -436,7 +497,7 @@ private fun LazyListScope.muteListItems( } if (threads.isNotEmpty()) { - item(key = "mute-threads-caption", contentType = "caption") { SectionCaption(stringRes(R.string.backup_entry_thread), Pad.padding(top = 18.dp)) } + item(key = "mute-threads-caption", contentType = "caption") { SectionCaption(stringRes(Res.string.backup_entry_thread), Pad.padding(top = 18.dp)) } items(threads, key = { "mute-thread-$it" }, contentType = { "note" }) { id -> LoadNote(id) { note -> if (note != null) { @@ -463,7 +524,7 @@ private fun FacePile( val names = people.take(2).map { observedName(it, accountViewModel) } val summary = if (people.size > 2) { - stringRes(R.string.backup_review_names_and_more, names.joinToString(", "), (people.size - 2).toString()) + stringRes(Res.string.backup_review_names_and_more, names.joinToString(", "), (people.size - 2).toString()) } else { names.joinToString(", ") } @@ -564,9 +625,9 @@ internal fun PrivateItemsCard( val tones = conflictTones() val (title, body) = when (change) { - ContentChange.CLEARED -> R.string.backup_review_private_wiped_title to R.string.backup_review_private_wiped_body - ContentChange.ADDED -> R.string.backup_review_private_added_title to R.string.backup_review_private_added_body - else -> R.string.backup_review_private_changed_title to R.string.backup_review_private_changed_body + ContentChange.CLEARED -> Res.string.backup_review_private_wiped_title to Res.string.backup_review_private_wiped_body + ContentChange.ADDED -> Res.string.backup_review_private_added_title to Res.string.backup_review_private_added_body + else -> Res.string.backup_review_private_changed_title to Res.string.backup_review_private_changed_body } Row( modifier @@ -592,28 +653,28 @@ internal fun PrivateItemsCard( // --------------------------------------------------------------------------------------- private class ProfileField( - val labelRes: Int, + val labelRes: StringResource, val change: ValueChange<String>, val isImage: Boolean = false, ) private fun profileFields(diff: MetadataDiff): List<ProfileField> = listOfNotNull( - diff.picture?.let { ProfileField(R.string.backup_profile_field_picture, it, isImage = true) }, - diff.banner?.let { ProfileField(R.string.backup_profile_field_banner, it, isImage = true) }, - diff.name?.let { ProfileField(R.string.backup_profile_field_name, it) }, - diff.displayName?.let { ProfileField(R.string.backup_profile_field_display_name, it) }, - diff.about?.let { ProfileField(R.string.backup_profile_field_about, it) }, - diff.nip05?.let { ProfileField(R.string.backup_profile_field_nip05, it) }, - diff.website?.let { ProfileField(R.string.backup_profile_field_website, it) }, - diff.lud16?.let { ProfileField(R.string.backup_profile_field_lud16, it) }, - diff.lud06?.let { ProfileField(R.string.backup_profile_field_lud06, it) }, - diff.clinkOffer?.let { ProfileField(R.string.backup_profile_field_clink_offer, it) }, - diff.pronouns?.let { ProfileField(R.string.backup_profile_field_pronouns, it) }, - diff.bot?.let { ProfileField(R.string.backup_profile_field_bot, ValueChange(it.before?.toString(), it.after?.toString())) }, + diff.picture?.let { ProfileField(Res.string.backup_profile_field_picture, it, isImage = true) }, + diff.banner?.let { ProfileField(Res.string.backup_profile_field_banner, it, isImage = true) }, + diff.name?.let { ProfileField(Res.string.backup_profile_field_name, it) }, + diff.displayName?.let { ProfileField(Res.string.backup_profile_field_display_name, it) }, + diff.about?.let { ProfileField(Res.string.backup_profile_field_about, it) }, + diff.nip05?.let { ProfileField(Res.string.backup_profile_field_nip05, it) }, + diff.website?.let { ProfileField(Res.string.backup_profile_field_website, it) }, + diff.lud16?.let { ProfileField(Res.string.backup_profile_field_lud16, it) }, + diff.lud06?.let { ProfileField(Res.string.backup_profile_field_lud06, it) }, + diff.clinkOffer?.let { ProfileField(Res.string.backup_profile_field_clink_offer, it) }, + diff.pronouns?.let { ProfileField(Res.string.backup_profile_field_pronouns, it) }, + diff.bot?.let { ProfileField(Res.string.backup_profile_field_bot, ValueChange(it.before?.toString(), it.after?.toString())) }, diff.birthday?.let { ProfileField( - R.string.backup_profile_field_birthday, + Res.string.backup_profile_field_birthday, ValueChange( it.before?.let { b -> listOfNotNull(b.year, b.month, b.day).joinToString("-") }, it.after?.let { a -> listOfNotNull(a.year, a.month, a.day).joinToString("-") }, @@ -636,8 +697,8 @@ private fun LazyListScope.profileItems( item(key = "profile-cards", contentType = "profile-cards") { val tones = conflictTones() Row(Pad.padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(10.dp)) { - MiniProfileCard(saved, pubKey, stringRes(R.string.backup_review_saved), MaterialTheme.colorScheme.outlineVariant, accountViewModel, Modifier.weight(1f)) - MiniProfileCard(incoming, pubKey, stringRes(R.string.backup_review_new), tones.removed.copy(alpha = 0.5f), accountViewModel, Modifier.weight(1f)) + MiniProfileCard(saved, pubKey, stringRes(Res.string.backup_review_saved), MaterialTheme.colorScheme.outlineVariant, accountViewModel, Modifier.weight(1f)) + MiniProfileCard(incoming, pubKey, stringRes(Res.string.backup_review_new), tones.removed.copy(alpha = 0.5f), accountViewModel, Modifier.weight(1f)) } } @@ -656,7 +717,7 @@ private fun LazyListScope.profileItems( } } // Linked identities and fields this app doesn't model use the generic sections. - genericDiffItems(buildRows(presentation, skipGroups = setOf(R.string.backup_entry_profile_field)), accountViewModel, nav) + genericDiffItems(buildRows(presentation, skipGroups = setOf(Res.string.backup_entry_profile_field)), accountViewModel, nav) } @Composable @@ -735,10 +796,10 @@ private fun FlowRowDiff( FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(6.dp), itemVerticalAlignment = Alignment.CenterVertically) { if (before != null) DiffChip(clip(before), tones.removed, struck = true) when { - after == null -> StatusTag(stringRes(R.string.backup_review_gone), tones.removed) + after == null -> StatusTag(stringRes(Res.string.backup_review_gone), tones.removed) before == null -> { DiffChip(clip(after), tones.added, struck = false) - StatusTag(stringRes(R.string.backup_review_new_tag), tones.added) + StatusTag(stringRes(Res.string.backup_review_new_tag), tones.added) } else -> { Text("→", color = MaterialTheme.colorScheme.placeholderText) @@ -779,7 +840,7 @@ private fun ImageThumb( contentAlignment = Alignment.Center, ) { if (url == null) { - Text(stringRes(R.string.backup_review_not_set), style = MaterialTheme.typography.labelSmall, color = color) + Text(stringRes(Res.string.backup_review_not_set), style = MaterialTheme.typography.labelSmall, color = color) } else { MyAsyncImage( imageUrl = url, @@ -843,14 +904,14 @@ private fun LazyListScope.nip65Items( val outbox = lane(saved, new, writes) val inbox = lane(saved, new, reads) - laneItems("outbox", stringRes = R.string.backup_review_outbox, subRes = R.string.backup_review_outbox_explainer, rows = outbox, nav = nav) - laneItems("inbox", stringRes = R.string.backup_review_inbox, subRes = R.string.backup_review_inbox_explainer, rows = inbox, nav = nav) + laneItems("outbox", stringRes = Res.string.backup_review_outbox, subRes = Res.string.backup_review_outbox_explainer, rows = outbox, nav = nav) + laneItems("inbox", stringRes = Res.string.backup_review_inbox, subRes = Res.string.backup_review_inbox_explainer, rows = inbox, nav = nav) } private fun LazyListScope.laneItems( key: String, - stringRes: Int, - subRes: Int, + stringRes: StringResource, + subRes: StringResource, rows: List<LaneRow>, nav: INav, ) { @@ -873,9 +934,9 @@ private fun LaneRelayRow( val (color, tag) = when (row.state) { LaneState.KEPT -> tones.kept to null - LaneState.DROPPED -> tones.removed to R.string.backup_review_dropped_tag - LaneState.ADDED -> tones.added to R.string.backup_review_new_tag - LaneState.DEMOTED -> tones.changed to R.string.backup_review_demoted_tag + LaneState.DROPPED -> tones.removed to Res.string.backup_review_dropped_tag + LaneState.ADDED -> tones.added to Res.string.backup_review_new_tag + LaneState.DEMOTED -> tones.changed to Res.string.backup_review_demoted_tag } Row( Pad @@ -933,12 +994,12 @@ private fun LazyListScope.nutzapItems( ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { Icon(symbol = MaterialSymbols.Key, contentDescription = null, tint = tones.changed) - Text(stringRes(if (key.after == null) R.string.backup_review_key_removed else R.string.backup_review_key_replaced), style = MaterialTheme.typography.titleSmall) + Text(stringRes(if (key.after == null) Res.string.backup_review_key_removed else Res.string.backup_review_key_replaced), style = MaterialTheme.typography.titleSmall) } Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) { - KeyColumn(key.before, stringRes(R.string.backup_review_saved), tones.kept) + KeyColumn(key.before, stringRes(Res.string.backup_review_saved), tones.kept) Text("→", fontSize = 24.sp, color = MaterialTheme.colorScheme.placeholderText, modifier = Modifier.padding(horizontal = 18.dp)) - KeyColumn(key.after, stringRes(R.string.backup_review_new), tones.changed) + KeyColumn(key.after, stringRes(Res.string.backup_review_new), tones.changed) } if (key.after != null) { Row( @@ -950,7 +1011,7 @@ private fun LazyListScope.nutzapItems( horizontalArrangement = Arrangement.spacedBy(8.dp), ) { Icon(symbol = MaterialSymbols.Warning, contentDescription = null, tint = tones.changed, modifier = Modifier.size(18.dp)) - Text(stringRes(R.string.backup_review_key_warning), style = MaterialTheme.typography.bodySmall, color = tones.changed) + Text(stringRes(Res.string.backup_review_key_warning), style = MaterialTheme.typography.bodySmall, color = tones.changed) } } } @@ -976,10 +1037,10 @@ private fun LazyListScope.nutzapItems( } + diff.mints.added.map { Triple(it.mintUrl, it.units.joinToString(), LaneState.ADDED) } if (mintRows.isNotEmpty()) { - item(key = "nutzap-mints", contentType = "caption") { SectionCaption(stringRes(R.string.backup_entry_mint), Pad.padding(top = 18.dp, bottom = 6.dp)) } + item(key = "nutzap-mints", contentType = "caption") { SectionCaption(stringRes(Res.string.backup_entry_mint), Pad.padding(top = 18.dp, bottom = 6.dp)) } items(mintRows, key = { "mint-" + it.first }, contentType = { "mint" }) { (url, units, state) -> MintRow(url, units, state) } } - genericDiffItems(buildRows(presentation, skipGroups = setOf(R.string.backup_entry_mint, R.string.backup_entry_nutzap_key)), accountViewModel, nav) + genericDiffItems(buildRows(presentation, skipGroups = setOf(Res.string.backup_entry_mint, Res.string.backup_entry_nutzap_key)), accountViewModel, nav) } @Composable @@ -993,7 +1054,7 @@ private fun KeyColumn( KeyFingerprint(hex, color) } else { Box(Modifier.size(96.dp).clip(RoundedCornerShape(18.dp)).border(2.dp, color, RoundedCornerShape(18.dp)), contentAlignment = Alignment.Center) { - Text(stringRes(R.string.backup_review_not_set), style = MaterialTheme.typography.labelSmall, color = color) + Text(stringRes(Res.string.backup_review_not_set), style = MaterialTheme.typography.labelSmall, color = color) } } StatusTag(label, color) @@ -1010,9 +1071,9 @@ private fun MintRow( val (color, tag) = when (state) { LaneState.KEPT -> MaterialTheme.colorScheme.onSurface to null - LaneState.DROPPED -> tones.removed to R.string.backup_review_dropped_tag - LaneState.ADDED -> tones.added to R.string.backup_review_new_tag - LaneState.DEMOTED -> tones.changed to R.string.backup_review_units_tag + LaneState.DROPPED -> tones.removed to Res.string.backup_review_dropped_tag + LaneState.ADDED -> tones.added to Res.string.backup_review_new_tag + LaneState.DEMOTED -> tones.changed to Res.string.backup_review_units_tag } Row( Pad @@ -1083,21 +1144,21 @@ private fun LazyListScope.groupItems( StatTile( diff.groups.removed.size .toString(), - stringRes(R.string.backup_review_left), + stringRes(Res.string.backup_review_left), tones.removed, Modifier.weight(1f), ) StatTile( diff.groups.added.size .toString(), - stringRes(R.string.backup_review_joined), + stringRes(Res.string.backup_review_joined), tones.added, Modifier.weight(1f), ) StatTile( diff.groups.changed.size .toString(), - stringRes(R.string.backup_review_renamed), + stringRes(Res.string.backup_review_renamed), tones.changed, Modifier.weight(1f), ) @@ -1165,7 +1226,7 @@ private fun GroupTileContent( Column { Text(name, style = MaterialTheme.typography.titleSmall, maxLines = 1, overflow = TextOverflow.Ellipsis) Text( - tile.oldName?.let { stringRes(R.string.backup_review_was_named, it) } ?: tile.group.relayUrl + tile.oldName?.let { stringRes(Res.string.backup_review_was_named, it) } ?: tile.group.relayUrl .removePrefix("wss://") .removeSuffix("/"), style = MaterialTheme.typography.labelSmall, @@ -1176,9 +1237,9 @@ private fun GroupTileContent( } } when (tile.state) { - LaneState.DROPPED -> StatusTag(stringRes(R.string.backup_review_left_tag), tones.removed, Modifier.align(Alignment.TopEnd)) - LaneState.ADDED -> StatusTag(stringRes(R.string.backup_review_new_tag), tones.added, Modifier.align(Alignment.TopEnd)) - LaneState.DEMOTED -> StatusTag(stringRes(R.string.backup_review_renamed_tag), tones.changed, Modifier.align(Alignment.TopEnd)) + LaneState.DROPPED -> StatusTag(stringRes(Res.string.backup_review_left_tag), tones.removed, Modifier.align(Alignment.TopEnd)) + LaneState.ADDED -> StatusTag(stringRes(Res.string.backup_review_new_tag), tones.added, Modifier.align(Alignment.TopEnd)) + LaneState.DEMOTED -> StatusTag(stringRes(Res.string.backup_review_renamed_tag), tones.changed, Modifier.align(Alignment.TopEnd)) LaneState.KEPT -> {} } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt index 55473cce27..b2e854c06b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictListViews.kt @@ -48,13 +48,11 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbol import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols @@ -63,6 +61,53 @@ import com.vitorpamplona.amethyst.commons.model.backups.ReplaceableBackupConflic import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.navigation.routeFor +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.backup_review_allowed_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_concord_body +import com.vitorpamplona.amethyst.commons.resources.backup_review_demoted_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_dropped_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_encrypted_added +import com.vitorpamplona.amethyst.commons.resources.backup_review_encrypted_changed +import com.vitorpamplona.amethyst.commons.resources.backup_review_encrypted_cleared +import com.vitorpamplona.amethyst.commons.resources.backup_review_feed +import com.vitorpamplona.amethyst.commons.resources.backup_review_hashtags_you_follow +import com.vitorpamplona.amethyst.commons.resources.backup_review_joined +import com.vitorpamplona.amethyst.commons.resources.backup_review_kept +import com.vitorpamplona.amethyst.commons.resources.backup_review_left +import com.vitorpamplona.amethyst.commons.resources.backup_review_left_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_listed_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_moved_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_new +import com.vitorpamplona.amethyst.commons.resources.backup_review_new_count_caption +import com.vitorpamplona.amethyst.commons.resources.backup_review_new_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_newly_blocked +import com.vitorpamplona.amethyst.commons.resources.backup_review_no_longer_blocked +import com.vitorpamplona.amethyst.commons.resources.backup_review_offer +import com.vitorpamplona.amethyst.commons.resources.backup_review_offers_gone +import com.vitorpamplona.amethyst.commons.resources.backup_review_payment_targets_gone +import com.vitorpamplona.amethyst.commons.resources.backup_review_payments_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_review_places_gone +import com.vitorpamplona.amethyst.commons.resources.backup_review_places_you_follow +import com.vitorpamplona.amethyst.commons.resources.backup_review_receiving_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_saved +import com.vitorpamplona.amethyst.commons.resources.backup_review_searching_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_service +import com.vitorpamplona.amethyst.commons.resources.backup_review_service_followers +import com.vitorpamplona.amethyst.commons.resources.backup_review_service_rank +import com.vitorpamplona.amethyst.commons.resources.backup_review_service_topics +import com.vitorpamplona.amethyst.commons.resources.backup_review_services_changed +import com.vitorpamplona.amethyst.commons.resources.backup_review_services_changed_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_review_still_blocked +import com.vitorpamplona.amethyst.commons.resources.backup_review_storing_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_topics_gone +import com.vitorpamplona.amethyst.commons.resources.backup_review_trust_warning +import com.vitorpamplona.amethyst.commons.resources.backup_review_trusted_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_unblocked +import com.vitorpamplona.amethyst.commons.resources.backup_review_unblocked_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_review_untrusted_tag +import com.vitorpamplona.amethyst.commons.resources.backup_review_wallet_body +import com.vitorpamplona.amethyst.commons.resources.backup_type_communities +import com.vitorpamplona.amethyst.commons.resources.backup_type_public_chats import com.vitorpamplona.amethyst.commons.ui.components.RobohashFallbackAsyncImage import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings @@ -118,6 +163,9 @@ import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListEve import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.offer.Bolt12OfferListDiff import com.vitorpamplona.quartz.nipB1Bolt12Zaps.offer.Bolt12OfferListEvent +import org.jetbrains.compose.resources.PluralStringResource +import org.jetbrains.compose.resources.StringResource +import org.jetbrains.compose.resources.pluralStringResource /** * Per-event layouts for the account's other lists: each relay list framed by what it is @@ -142,8 +190,8 @@ internal fun LazyListScope.listDiffItems( is TrustProviderListDiff -> trustProviderItems(diff, conflict, accountViewModel, nav) is PaymentTargetsDiff -> paymentTargetItems(diff, conflict) is Bolt12OfferListDiff -> offerItems(diff, conflict) - is CashuWalletDiff -> encryptedOnlyItems(MaterialSymbols.AccountBalanceWallet, diff.wallet, R.string.backup_review_wallet_body) - is ConcordCommunityListDiff -> encryptedOnlyItems(MaterialSymbols.Groups, diff.communities, R.string.backup_review_concord_body) + is CashuWalletDiff -> encryptedOnlyItems(MaterialSymbols.AccountBalanceWallet, diff.wallet, Res.string.backup_review_wallet_body) + is ConcordCommunityListDiff -> encryptedOnlyItems(MaterialSymbols.Groups, diff.communities, Res.string.backup_review_concord_body) else -> return false } return true @@ -193,15 +241,15 @@ private fun fateColor(fate: ItemFate): Color { private fun <T> LazyListScope.countTiles( items: List<Pair<T, ItemFate>>, - removedCaption: Int, - addedCaption: Int, + removedCaption: StringResource, + addedCaption: StringResource, ) { item(key = "count-tiles", contentType = "tiles") { val tones = conflictTones() Row(Pad.padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { StatTile(items.count { it.second == ItemFate.DROPPED }.toString(), stringRes(removedCaption), tones.removed, Modifier.weight(1f)) StatTile(items.count { it.second == ItemFate.ADDED }.toString(), stringRes(addedCaption), tones.added, Modifier.weight(1f)) - StatTile(items.count { it.second == ItemFate.KEPT || it.second == ItemFate.CHANGED }.toString(), stringRes(R.string.backup_review_kept), tones.kept, Modifier.weight(1f)) + StatTile(items.count { it.second == ItemFate.KEPT || it.second == ItemFate.CHANGED }.toString(), stringRes(Res.string.backup_review_kept), tones.kept, Modifier.weight(1f)) } } } @@ -218,20 +266,20 @@ private fun LazyListScope.privateItemsCard(change: ContentChange) { /** How a relay list's rows are presented: its icon and what a kept or dropped relay is called. */ private class RelayFraming( val icon: MaterialSymbol, - val keptTag: Int, - val droppedTag: Int = R.string.backup_review_dropped_tag, + val keptTag: StringResource, + val droppedTag: StringResource = Res.string.backup_review_dropped_tag, ) private fun framingOf(type: BackupEventType): RelayFraming = when (type) { - BackupEventType.DM_RELAYS -> RelayFraming(MaterialSymbols.Mail, R.string.backup_review_receiving_tag) - BackupEventType.KEY_PACKAGE_RELAYS -> RelayFraming(MaterialSymbols.Key, R.string.backup_review_listed_tag) - BackupEventType.SEARCH_RELAYS -> RelayFraming(MaterialSymbols.Search, R.string.backup_review_searching_tag) - BackupEventType.INDEXER_RELAYS -> RelayFraming(MaterialSymbols.Dns, R.string.backup_review_listed_tag) - BackupEventType.RELAY_FEEDS -> RelayFraming(MaterialSymbols.CellTower, R.string.backup_review_listed_tag) - BackupEventType.PRIVATE_OUTBOX_RELAYS -> RelayFraming(MaterialSymbols.Lock, R.string.backup_review_storing_tag) - BackupEventType.TRUSTED_RELAYS -> RelayFraming(MaterialSymbols.Shield, R.string.backup_review_trusted_tag, R.string.backup_review_untrusted_tag) - else -> RelayFraming(MaterialSymbols.Dns, R.string.backup_review_listed_tag) + BackupEventType.DM_RELAYS -> RelayFraming(MaterialSymbols.Mail, Res.string.backup_review_receiving_tag) + BackupEventType.KEY_PACKAGE_RELAYS -> RelayFraming(MaterialSymbols.Key, Res.string.backup_review_listed_tag) + BackupEventType.SEARCH_RELAYS -> RelayFraming(MaterialSymbols.Search, Res.string.backup_review_searching_tag) + BackupEventType.INDEXER_RELAYS -> RelayFraming(MaterialSymbols.Dns, Res.string.backup_review_listed_tag) + BackupEventType.RELAY_FEEDS -> RelayFraming(MaterialSymbols.CellTower, Res.string.backup_review_listed_tag) + BackupEventType.PRIVATE_OUTBOX_RELAYS -> RelayFraming(MaterialSymbols.Lock, Res.string.backup_review_storing_tag) + BackupEventType.TRUSTED_RELAYS -> RelayFraming(MaterialSymbols.Shield, Res.string.backup_review_trusted_tag, Res.string.backup_review_untrusted_tag) + else -> RelayFraming(MaterialSymbols.Dns, Res.string.backup_review_listed_tag) } private fun savedRelaysOf(event: Event): List<NormalizedRelayUrl> = @@ -277,8 +325,8 @@ private fun RelayFateRow( when (fate) { ItemFate.KEPT -> framing.keptTag ItemFate.DROPPED -> framing.droppedTag - ItemFate.ADDED -> R.string.backup_review_new_tag - ItemFate.CHANGED -> R.string.backup_review_demoted_tag + ItemFate.ADDED -> Res.string.backup_review_new_tag + ItemFate.CHANGED -> Res.string.backup_review_demoted_tag } Row( Pad @@ -320,14 +368,14 @@ private fun LazyListScope.blockedRelayItems( Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(16.dp)) { Icon(symbol = MaterialSymbols.LockOpen, contentDescription = null, tint = tones.changed, modifier = Modifier.size(44.dp)) Column { - Text(stringRes(R.string.backup_review_unblocked, unblocked.size.toString()), fontSize = 30.sp, lineHeight = 32.sp, fontWeight = FontWeight.Bold, color = tones.changed) - Text(stringRes(R.string.backup_review_unblocked_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) + Text(stringRes(Res.string.backup_review_unblocked, unblocked.size.toString()), fontSize = 30.sp, lineHeight = 32.sp, fontWeight = FontWeight.Bold, color = tones.changed) + Text(stringRes(Res.string.backup_review_unblocked_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) } } } } if (unblocked.isNotEmpty()) { - item(key = "unblocked-caption", contentType = "caption") { SectionCaption(stringRes(R.string.backup_review_no_longer_blocked), Pad.padding(top = 18.dp)) } + item(key = "unblocked-caption", contentType = "caption") { SectionCaption(stringRes(Res.string.backup_review_no_longer_blocked), Pad.padding(top = 18.dp)) } items(unblocked, key = { "unblocked-" + it.url }, contentType = { "relay-row" }) { url -> val tones = conflictTones() Row( @@ -346,12 +394,12 @@ private fun LazyListScope.blockedRelayItems( Icon(symbol = MaterialSymbols.LockOpen, contentDescription = null, tint = tones.changed, modifier = Modifier.size(18.dp)) } Text(url.url.removePrefix("wss://").removeSuffix("/"), modifier = Modifier.weight(1f), style = MaterialTheme.typography.bodyMedium, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis) - StatusTag(stringRes(R.string.backup_review_allowed_tag), tones.changed) + StatusTag(stringRes(Res.string.backup_review_allowed_tag), tones.changed) } } } if (newlyBlocked.isNotEmpty()) { - item(key = "newly-blocked-caption", contentType = "caption") { SectionCaption(stringRes(R.string.backup_review_newly_blocked), Pad.padding(top = 18.dp)) } + item(key = "newly-blocked-caption", contentType = "caption") { SectionCaption(stringRes(Res.string.backup_review_newly_blocked), Pad.padding(top = 18.dp)) } items(newlyBlocked, key = { "newly-blocked-" + it.url }, contentType = { "relay-row" }) { url -> RelayFateRow(url, ItemFate.ADDED, framingOf(BackupEventType.BLOCKED_RELAYS), nav) } @@ -359,7 +407,7 @@ private fun LazyListScope.blockedRelayItems( if (stillBlocked.isNotEmpty()) { item(key = "still-blocked", contentType = "chips") { Column(Pad.padding(top = 18.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { - SectionCaption(stringRes(R.string.backup_review_still_blocked)) + SectionCaption(stringRes(Res.string.backup_review_still_blocked)) FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { stillBlocked.forEach { url -> Row( @@ -392,7 +440,7 @@ private fun <T> LazyListScope.spaceGrid( key: (T) -> String, content: @Composable (T, ItemFate, Modifier) -> Unit, ) { - countTiles(items, R.string.backup_review_left, R.string.backup_review_joined) + countTiles(items, Res.string.backup_review_left, Res.string.backup_review_joined) items(items.chunked(2), key = { keyPrefix + key(it.first().first) }, contentType = { "space-row" }) { row -> Row(Pad.padding(top = 10.dp).fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) { row.forEach { (item, fate) -> content(item, fate, Modifier.weight(1f)) } @@ -436,9 +484,9 @@ private fun SpaceTile( } val tag = when (fate) { - ItemFate.DROPPED -> R.string.backup_review_left_tag to tones.removed - ItemFate.ADDED -> R.string.backup_review_new_tag to tones.added - ItemFate.CHANGED -> R.string.backup_review_moved_tag to tones.changed + ItemFate.DROPPED -> Res.string.backup_review_left_tag to tones.removed + ItemFate.ADDED -> Res.string.backup_review_new_tag to tones.added + ItemFate.CHANGED -> Res.string.backup_review_moved_tag to tones.changed ItemFate.KEPT -> null } tag?.let { (res, color) -> StatusTag(stringRes(res), color, Modifier.align(Alignment.TopEnd)) } @@ -459,7 +507,7 @@ private fun LazyListScope.publicChatItems( val current = state?.channel ?: channel SpaceTile( name = current.toBestDisplayName(), - subtitle = stringRes(R.string.backup_type_public_chats), + subtitle = stringRes(Res.string.backup_type_public_chats), robot = tag.eventId, picture = channel.profilePicture(), fate = fate, @@ -525,7 +573,7 @@ private fun AddressableSpaceTile( } SpaceTile( name = name ?: address.dTag.ifBlank { address.toValue().toShortDisplay() }, - subtitle = stringRes(if (address.kind == AppDefinitionEvent.KIND) R.string.backup_review_feed else R.string.backup_type_communities), + subtitle = stringRes(if (address.kind == AppDefinitionEvent.KIND) Res.string.backup_review_feed else Res.string.backup_type_communities), robot = address.toValue(), picture = picture, fate = fate, @@ -543,7 +591,7 @@ private fun LazyListScope.ephemeralRoomItems( ) { val saved = (conflict.saved as? EphemeralChatListEvent)?.publicRooms().orEmpty() val rooms = fates(saved, diff.rooms) { it } - countTiles(rooms, R.string.backup_review_left, R.string.backup_review_joined) + countTiles(rooms, Res.string.backup_review_left, Res.string.backup_review_joined) items(rooms, key = { "room-" + it.first.toKey() }, contentType = { "room-row" }) { (room, fate) -> RoomRow(room, fate, nav) } privateItemsCard(diff.privateItems) } @@ -582,8 +630,8 @@ private fun RoomRow( ) } when (fate) { - ItemFate.DROPPED -> StatusTag(stringRes(R.string.backup_review_left_tag), color) - ItemFate.ADDED -> StatusTag(stringRes(R.string.backup_review_new_tag), color) + ItemFate.DROPPED -> StatusTag(stringRes(Res.string.backup_review_left_tag), color) + ItemFate.ADDED -> StatusTag(stringRes(Res.string.backup_review_new_tag), color) else -> {} } } @@ -602,11 +650,11 @@ private fun LazyListScope.topicItems( nav: INav, ) { val topics = fates(saved, diff) { it.lowercase() } - countTiles(topics, if (isPlace) R.string.backup_review_places_gone else R.string.backup_review_topics_gone, R.string.backup_review_new_count_caption) + countTiles(topics, if (isPlace) Res.string.backup_review_places_gone else Res.string.backup_review_topics_gone, Res.string.backup_review_new_count_caption) item(key = "topic-cloud", contentType = "cloud") { val tones = conflictTones() Column(Pad.padding(top = 18.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) { - SectionCaption(stringRes(if (isPlace) R.string.backup_review_places_you_follow else R.string.backup_review_hashtags_you_follow)) + SectionCaption(stringRes(if (isPlace) Res.string.backup_review_places_you_follow else Res.string.backup_review_hashtags_you_follow)) FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp), itemVerticalAlignment = Alignment.CenterVertically) { topics.forEach { (topic, fate) -> val color = fateColor(fate) @@ -706,15 +754,15 @@ private fun LazyListScope.trustProviderItems( Icon(symbol = MaterialSymbols.Group, contentDescription = null, tint = tones.changed) } Column { - Text(stringRes(R.string.backup_review_services_changed, affected.toString(), services.size.toString()), fontSize = 24.sp, lineHeight = 28.sp, fontWeight = FontWeight.Bold) - Text(stringRes(R.string.backup_review_services_changed_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) + Text(stringRes(Res.string.backup_review_services_changed, affected.toString(), services.size.toString()), fontSize = 24.sp, lineHeight = 28.sp, fontWeight = FontWeight.Bold) + Text(stringRes(Res.string.backup_review_services_changed_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) } } } } item(key = "trust-header", contentType = "table-header") { Row(Pad.padding(top = 16.dp, bottom = 4.dp).padding(horizontal = 12.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - listOf(R.string.backup_review_service, R.string.backup_review_saved, R.string.backup_review_new).forEachIndexed { index, res -> + listOf(Res.string.backup_review_service, Res.string.backup_review_saved, Res.string.backup_review_new).forEachIndexed { index, res -> Text(stringRes(res).uppercase(), Modifier.weight(if (index == 0) 1.1f else 1f), style = MaterialTheme.typography.labelSmall, fontWeight = FontWeight.Bold, color = MaterialTheme.colorScheme.placeholderText) } } @@ -732,7 +780,7 @@ private fun LazyListScope.trustProviderItems( horizontalArrangement = Arrangement.spacedBy(8.dp), ) { Icon(symbol = MaterialSymbols.Warning, contentDescription = null, tint = tones.changed, modifier = Modifier.size(18.dp)) - Text(stringRes(R.string.backup_review_trust_warning), style = MaterialTheme.typography.bodySmall, color = tones.changed) + Text(stringRes(Res.string.backup_review_trust_warning), style = MaterialTheme.typography.bodySmall, color = tones.changed) } } privateItemsCard(diff.privateItems) @@ -771,9 +819,9 @@ private fun ServiceTableRow( @Composable private fun serviceLabel(type: String): String = when (type) { - "rank" -> stringRes(R.string.backup_review_service_rank) - "followers" -> stringRes(R.string.backup_review_service_followers) - "t" -> stringRes(R.string.backup_review_service_topics) + "rank" -> stringRes(Res.string.backup_review_service_rank) + "followers" -> stringRes(Res.string.backup_review_service_followers) + "t" -> stringRes(Res.string.backup_review_service_topics) else -> type.replace('_', ' ').replaceFirstChar { it.uppercase() } } @@ -826,7 +874,7 @@ private fun LazyListScope.paymentTargetItems( ) { val saved = (conflict.saved as? PaymentTargetsEvent)?.paymentTargets().orEmpty() val targets = fates(saved, diff.targets) { it } - moneyHero(targets.count { it.second == ItemFate.DROPPED }, R.plurals.backup_review_payment_targets_gone) + moneyHero(targets.count { it.second == ItemFate.DROPPED }, Res.plurals.backup_review_payment_targets_gone) items(targets, key = { "target-" + it.first.type + ":" + it.first.authority }, contentType = { "money-row" }) { (target, fate) -> PaymentTargetRow(target, fate) } } @@ -836,15 +884,15 @@ private fun LazyListScope.offerItems( ) { val saved = (conflict.saved as? Bolt12OfferListEvent)?.offers().orEmpty() val offers = fates(saved, diff.offers) { it } - moneyHero(offers.count { it.second == ItemFate.DROPPED }, R.plurals.backup_review_offers_gone) + moneyHero(offers.count { it.second == ItemFate.DROPPED }, Res.plurals.backup_review_offers_gone) items(offers, key = { "offer-" + it.first }, contentType = { "money-row" }) { (offer, fate) -> - MoneyRow(stringRes(R.string.backup_review_offer), offer.toShortDisplay(prefixSize = 4), fate) + MoneyRow(stringRes(Res.string.backup_review_offer), offer.toShortDisplay(prefixSize = 4), fate) } } private fun LazyListScope.moneyHero( dropped: Int, - headline: Int, + headline: PluralStringResource, ) { item(key = "money-hero", contentType = "hero") { val tones = conflictTones() @@ -856,7 +904,7 @@ private fun LazyListScope.moneyHero( } Column { Text(pluralStringResource(headline, dropped, dropped), fontSize = 24.sp, lineHeight = 28.sp, fontWeight = FontWeight.Bold, color = color) - Text(stringRes(R.string.backup_review_payments_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) + Text(stringRes(Res.string.backup_review_payments_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.placeholderText) } } } @@ -902,8 +950,8 @@ private fun MoneyRow( ) } when (fate) { - ItemFate.DROPPED -> StatusTag(stringRes(R.string.backup_review_dropped_tag), color) - ItemFate.ADDED -> StatusTag(stringRes(R.string.backup_review_new_tag), color) + ItemFate.DROPPED -> StatusTag(stringRes(Res.string.backup_review_dropped_tag), color) + ItemFate.ADDED -> StatusTag(stringRes(Res.string.backup_review_new_tag), color) else -> {} } } @@ -916,15 +964,15 @@ private fun MoneyRow( private fun LazyListScope.encryptedOnlyItems( icon: MaterialSymbol, change: ContentChange, - body: Int, + body: StringResource, ) { item(key = "encrypted-hero", contentType = "hero") { val tones = conflictTones() val (color, headline) = when (change) { - ContentChange.CLEARED -> tones.removed to R.string.backup_review_encrypted_cleared - ContentChange.ADDED -> tones.added to R.string.backup_review_encrypted_added - else -> tones.changed to R.string.backup_review_encrypted_changed + ContentChange.CLEARED -> tones.removed to Res.string.backup_review_encrypted_cleared + ContentChange.ADDED -> tones.added to Res.string.backup_review_encrypted_added + else -> tones.changed to Res.string.backup_review_encrypted_changed } Column(Pad.padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(14.dp)) { TintedPanel(color.copy(alpha = 0.12f)) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt index 58195a5d31..ff28dfa6c3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt @@ -23,9 +23,98 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.backups import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.remember -import androidx.compose.ui.platform.LocalResources -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.model.backups.BackupEventType +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_relay_read_only +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_relay_read_write +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_relay_write_only +import com.vitorpamplona.amethyst.commons.resources.backup_entry_algo_feed +import com.vitorpamplona.amethyst.commons.resources.backup_entry_chat_room +import com.vitorpamplona.amethyst.commons.resources.backup_entry_community +import com.vitorpamplona.amethyst.commons.resources.backup_entry_hashtag +import com.vitorpamplona.amethyst.commons.resources.backup_entry_identity_claim +import com.vitorpamplona.amethyst.commons.resources.backup_entry_location +import com.vitorpamplona.amethyst.commons.resources.backup_entry_mint +import com.vitorpamplona.amethyst.commons.resources.backup_entry_nutzap_key +import com.vitorpamplona.amethyst.commons.resources.backup_entry_offer +import com.vitorpamplona.amethyst.commons.resources.backup_entry_other +import com.vitorpamplona.amethyst.commons.resources.backup_entry_payment_target +import com.vitorpamplona.amethyst.commons.resources.backup_entry_person +import com.vitorpamplona.amethyst.commons.resources.backup_entry_profile_field +import com.vitorpamplona.amethyst.commons.resources.backup_entry_public_chat +import com.vitorpamplona.amethyst.commons.resources.backup_entry_relay +import com.vitorpamplona.amethyst.commons.resources.backup_entry_relay_group +import com.vitorpamplona.amethyst.commons.resources.backup_entry_thread +import com.vitorpamplona.amethyst.commons.resources.backup_entry_trust_provider +import com.vitorpamplona.amethyst.commons.resources.backup_entry_word +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_about +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_banner +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_birthday +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_bot +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_clink_offer +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_display_name +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_lud06 +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_lud16 +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_name +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_nip05 +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_picture +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_pronouns +import com.vitorpamplona.amethyst.commons.resources.backup_profile_field_website +import com.vitorpamplona.amethyst.commons.resources.backup_type_app_settings +import com.vitorpamplona.amethyst.commons.resources.backup_type_app_settings_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_blocked_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_blocked_relays_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_bolt12_offers +import com.vitorpamplona.amethyst.commons.resources.backup_type_bolt12_offers_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_cashu_wallet +import com.vitorpamplona.amethyst.commons.resources.backup_type_cashu_wallet_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_communities +import com.vitorpamplona.amethyst.commons.resources.backup_type_communities_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_concord_communities +import com.vitorpamplona.amethyst.commons.resources.backup_type_concord_communities_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_dm_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_dm_relays_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_ephemeral_chats +import com.vitorpamplona.amethyst.commons.resources.backup_type_ephemeral_chats_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_favorite_algo_feeds +import com.vitorpamplona.amethyst.commons.resources.backup_type_favorite_algo_feeds_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_follow_list +import com.vitorpamplona.amethyst.commons.resources.backup_type_follow_list_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_geohashes +import com.vitorpamplona.amethyst.commons.resources.backup_type_geohashes_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_hashtags +import com.vitorpamplona.amethyst.commons.resources.backup_type_hashtags_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_indexer_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_indexer_relays_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_key_package_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_key_package_relays_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_mute_list +import com.vitorpamplona.amethyst.commons.resources.backup_type_mute_list_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_nutzap_info +import com.vitorpamplona.amethyst.commons.resources.backup_type_nutzap_info_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_other +import com.vitorpamplona.amethyst.commons.resources.backup_type_other_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_outbox_inbox_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_outbox_inbox_relays_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_payment_targets +import com.vitorpamplona.amethyst.commons.resources.backup_type_payment_targets_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_private_outbox_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_private_outbox_relays_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_profile +import com.vitorpamplona.amethyst.commons.resources.backup_type_profile_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_public_chats +import com.vitorpamplona.amethyst.commons.resources.backup_type_public_chats_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_relay_feeds +import com.vitorpamplona.amethyst.commons.resources.backup_type_relay_feeds_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_relay_groups +import com.vitorpamplona.amethyst.commons.resources.backup_type_relay_groups_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_search_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_search_relays_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_trust_providers +import com.vitorpamplona.amethyst.commons.resources.backup_type_trust_providers_explainer +import com.vitorpamplona.amethyst.commons.resources.backup_type_trusted_relays +import com.vitorpamplona.amethyst.commons.resources.backup_type_trusted_relays_explainer +import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.quartz.concord.cord02Community.ConcordCommunityListDiff import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId import com.vitorpamplona.quartz.experimental.ephemChat.list.EphemeralChatListDiff @@ -61,6 +150,7 @@ import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListDiff import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataDiff import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListDiff import com.vitorpamplona.quartz.nipB1Bolt12Zaps.offer.Bolt12OfferListDiff +import org.jetbrains.compose.resources.StringResource private const val MAX_VALUE_LENGTH = 80 @@ -168,7 +258,7 @@ sealed interface ReviewItem { /** One labelled group of differences (people, relays, profile fields…) of a conflict. */ @Immutable class DiffGroup( - val label: Int, + val label: StringResource, val removed: List<ReviewItem>, val added: List<ReviewItem>, val changed: List<ReviewItem>, @@ -189,7 +279,7 @@ class DiffPresentation( /** A group from a [ListDiff] of an event's parsed items. */ private fun <T> listGroup( - label: Int, + label: StringResource, diff: ListDiff<T>, item: (T) -> ReviewItem, change: (ItemChange<T>) -> ReviewItem, @@ -197,7 +287,7 @@ private fun <T> listGroup( /** A group whose items can't change, only be added or removed (hashtags, plain relays…). */ private fun <T> listGroup( - label: Int, + label: StringResource, diff: ListDiff<T>, item: (T) -> ReviewItem, ) = listGroup(label, diff, item) { item(it.after) } @@ -212,7 +302,7 @@ private inline fun <reified T> ListDiff<*>.only() = /** A group from single-valued fields: a field set only after is added, only before is removed. */ private fun fieldGroup( - label: Int, + label: StringResource, fields: List<Pair<String, ValueChange<String>?>>, ): DiffGroup { val removed = mutableListOf<ReviewItem>() @@ -242,14 +332,38 @@ private fun arrow( */ @Composable fun rememberPresentation(diff: EventDiff): DiffPresentation { - val resources = LocalResources.current - return remember(diff, resources) { presentationOf(diff) { resources.getString(it) } } + // Compose resources resolve only in composition (or suspended), so the few labels + // [presentationOf] writes into item text are resolved here and handed in. The map + // compares by value, so a recomposition with the same locale keeps the cached result. + val labels = PRESENTATION_LABELS.associateWith { stringRes(it) } + return remember(diff, labels) { presentationOf(diff) { labels.getValue(it) } } } +/** Every label [presentationOf] resolves through its `str` parameter. */ +private val PRESENTATION_LABELS = + listOf( + Res.string.backup_profile_field_name, + Res.string.backup_profile_field_display_name, + Res.string.backup_profile_field_about, + Res.string.backup_profile_field_picture, + Res.string.backup_profile_field_banner, + Res.string.backup_profile_field_website, + Res.string.backup_profile_field_nip05, + Res.string.backup_profile_field_lud16, + Res.string.backup_profile_field_lud06, + Res.string.backup_profile_field_clink_offer, + Res.string.backup_profile_field_pronouns, + Res.string.backup_profile_field_birthday, + Res.string.backup_profile_field_bot, + Res.string.backup_conflict_relay_read_write, + Res.string.backup_conflict_relay_read_only, + Res.string.backup_conflict_relay_write_only, + ) + /** Turns each event's own diff into typed, labelled groups. [str] resolves the labels. */ fun presentationOf( diff: EventDiff, - str: (Int) -> String, + str: (StringResource) -> String, ): DiffPresentation { val (groups, content) = when (diff) { @@ -258,31 +372,31 @@ fun presentationOf( val bot = diff.bot?.let { ValueChange(it.before?.toString(), it.after?.toString()) } listOf( fieldGroup( - R.string.backup_entry_profile_field, + Res.string.backup_entry_profile_field, listOf( - str(R.string.backup_profile_field_name) to diff.name, - str(R.string.backup_profile_field_display_name) to diff.displayName, - str(R.string.backup_profile_field_about) to diff.about, - str(R.string.backup_profile_field_picture) to diff.picture, - str(R.string.backup_profile_field_banner) to diff.banner, - str(R.string.backup_profile_field_website) to diff.website, - str(R.string.backup_profile_field_nip05) to diff.nip05, - str(R.string.backup_profile_field_lud16) to diff.lud16, - str(R.string.backup_profile_field_lud06) to diff.lud06, - str(R.string.backup_profile_field_clink_offer) to diff.clinkOffer, - str(R.string.backup_profile_field_pronouns) to diff.pronouns, - str(R.string.backup_profile_field_birthday) to birthday, - str(R.string.backup_profile_field_bot) to bot, + str(Res.string.backup_profile_field_name) to diff.name, + str(Res.string.backup_profile_field_display_name) to diff.displayName, + str(Res.string.backup_profile_field_about) to diff.about, + str(Res.string.backup_profile_field_picture) to diff.picture, + str(Res.string.backup_profile_field_banner) to diff.banner, + str(Res.string.backup_profile_field_website) to diff.website, + str(Res.string.backup_profile_field_nip05) to diff.nip05, + str(Res.string.backup_profile_field_lud16) to diff.lud16, + str(Res.string.backup_profile_field_lud06) to diff.lud06, + str(Res.string.backup_profile_field_clink_offer) to diff.clinkOffer, + str(Res.string.backup_profile_field_pronouns) to diff.pronouns, + str(Res.string.backup_profile_field_birthday) to birthday, + str(Res.string.backup_profile_field_bot) to bot, ), ), listGroup( - R.string.backup_entry_identity_claim, + Res.string.backup_entry_identity_claim, diff.identityClaims, { ReviewItem.Text(it.platformIdentity()) }, { ReviewItem.Text(it.after.platformIdentity(), arrow(it.before.proof, it.after.proof)) }, ), listGroup( - R.string.backup_entry_other, + Res.string.backup_entry_other, diff.otherFields, { ReviewItem.Text(it.first, clip(it.second)) }, { ReviewItem.Text(it.after.first, clip(it.before.second) + " → " + clip(it.after.second)) }, @@ -292,7 +406,7 @@ fun presentationOf( is ContactListDiff -> listOf( listGroup( - R.string.backup_entry_person, + Res.string.backup_entry_person, diff.follows, { ReviewItem.Person(it.pubKey, it.petname) }, { @@ -308,32 +422,32 @@ fun presentationOf( ) to ContentChange.NONE is MuteListDiff -> listOf( - listGroup(R.string.backup_entry_person, diff.publicMutes.only<UserTag>(), { ReviewItem.Person(it.pubKey) }), - listGroup(R.string.backup_entry_word, diff.publicMutes.only<WordTag>(), { ReviewItem.Text("\"" + it.word + "\"") }), - listGroup(R.string.backup_entry_hashtag, diff.publicMutes.only<HashtagTag>(), { ReviewItem.Text("#" + it.hashtag) }), - listGroup(R.string.backup_entry_thread, diff.publicMutes.only<EventTag>(), { ReviewItem.Thread(it.eventId) }), + listGroup(Res.string.backup_entry_person, diff.publicMutes.only<UserTag>(), { ReviewItem.Person(it.pubKey) }), + listGroup(Res.string.backup_entry_word, diff.publicMutes.only<WordTag>(), { ReviewItem.Text("\"" + it.word + "\"") }), + listGroup(Res.string.backup_entry_hashtag, diff.publicMutes.only<HashtagTag>(), { ReviewItem.Text("#" + it.hashtag) }), + listGroup(Res.string.backup_entry_thread, diff.publicMutes.only<EventTag>(), { ReviewItem.Thread(it.eventId) }), ) to diff.privateItems is AdvertisedRelayListDiff -> { val types = mapOf( - AdvertisedRelayType.BOTH to str(R.string.backup_conflict_relay_read_write), - AdvertisedRelayType.READ to str(R.string.backup_conflict_relay_read_only), - AdvertisedRelayType.WRITE to str(R.string.backup_conflict_relay_write_only), + AdvertisedRelayType.BOTH to str(Res.string.backup_conflict_relay_read_write), + AdvertisedRelayType.READ to str(Res.string.backup_conflict_relay_read_only), + AdvertisedRelayType.WRITE to str(Res.string.backup_conflict_relay_write_only), ) listOf( listGroup( - R.string.backup_entry_relay, + Res.string.backup_entry_relay, diff.relays, { ReviewItem.Relay(it.relayUrl, types[it.type]) }, { ReviewItem.Relay(it.after.relayUrl, arrow(types[it.before.type], types[it.after.type])) }, ), ) to ContentChange.NONE } - is RelayListDiff -> listOf(listGroup(R.string.backup_entry_relay, diff.relays, { ReviewItem.Relay(it) })) to diff.privateRelays + is RelayListDiff -> listOf(listGroup(Res.string.backup_entry_relay, diff.relays, { ReviewItem.Relay(it) })) to diff.privateRelays is ChannelListDiff -> listOf( listGroup( - R.string.backup_entry_public_chat, + Res.string.backup_entry_public_chat, diff.channels, { ReviewItem.PublicChat(it.eventId) }, { ReviewItem.PublicChat(it.after.eventId, arrow(it.before.relay?.url, it.after.relay?.url)) }, @@ -342,28 +456,28 @@ fun presentationOf( is CommunityListDiff -> listOf( listGroup( - R.string.backup_entry_community, + Res.string.backup_entry_community, diff.communities, { ReviewItem.Addressable(it.address) }, { ReviewItem.Addressable(it.after.address, arrow(it.before.relayHint?.url, it.after.relayHint?.url)) }, ), ) to diff.privateItems - is HashtagListDiff -> listOf(listGroup(R.string.backup_entry_hashtag, diff.hashtags, { ReviewItem.Text("#$it") })) to diff.privateItems - is GeohashListDiff -> listOf(listGroup(R.string.backup_entry_location, diff.geohashes, { ReviewItem.Text(it) })) to diff.privateItems + is HashtagListDiff -> listOf(listGroup(Res.string.backup_entry_hashtag, diff.hashtags, { ReviewItem.Text("#$it") })) to diff.privateItems + is GeohashListDiff -> listOf(listGroup(Res.string.backup_entry_location, diff.geohashes, { ReviewItem.Text(it) })) to diff.privateItems is FavoriteAlgoFeedsListDiff -> listOf( listGroup( - R.string.backup_entry_algo_feed, + Res.string.backup_entry_algo_feed, diff.feeds, { ReviewItem.Addressable(it.address) }, { ReviewItem.Addressable(it.after.address, arrow(it.before.relayHint?.url, it.after.relayHint?.url)) }, ), ) to diff.privateItems - is EphemeralChatListDiff -> listOf(listGroup(R.string.backup_entry_chat_room, diff.rooms, { ReviewItem.ChatRoom(it) })) to diff.privateItems + is EphemeralChatListDiff -> listOf(listGroup(Res.string.backup_entry_chat_room, diff.rooms, { ReviewItem.ChatRoom(it) })) to diff.privateItems is SimpleGroupListDiff -> listOf( listGroup( - R.string.backup_entry_relay_group, + Res.string.backup_entry_relay_group, diff.groups, { ReviewItem.Text(it.name ?: it.groupId, it.relayUrl) }, { ReviewItem.Text(it.after.name ?: it.after.groupId, arrow(it.before.name, it.after.name)) }, @@ -372,7 +486,7 @@ fun presentationOf( is TrustProviderListDiff -> listOf( listGroup( - R.string.backup_entry_trust_provider, + Res.string.backup_entry_trust_provider, diff.providers, { ReviewItem.Person(it.pubkey, it.service.type) }, { ReviewItem.Person(it.after.pubkey, it.after.service.type + ": " + arrow(it.before.relayUrl.url, it.after.relayUrl.url)) }, @@ -381,19 +495,19 @@ fun presentationOf( is NutzapInfoDiff -> listOf( listGroup( - R.string.backup_entry_mint, + Res.string.backup_entry_mint, diff.mints, { ReviewItem.Text(it.mintUrl, it.units.joinToString().ifEmpty { null }) }, { ReviewItem.Text(it.after.mintUrl, arrow(it.before.units.joinToString(), it.after.units.joinToString())) }, ), - listGroup(R.string.backup_entry_relay, diff.relays, { ReviewItem.Relay(it) }), + listGroup(Res.string.backup_entry_relay, diff.relays, { ReviewItem.Relay(it) }), nutzapKeyGroup(diff.p2pkPubkey), ) to ContentChange.NONE is PaymentTargetsDiff -> listOf( - listGroup(R.string.backup_entry_payment_target, diff.targets, { ReviewItem.Text(it.type, clip(it.authority)) }), + listGroup(Res.string.backup_entry_payment_target, diff.targets, { ReviewItem.Text(it.type, clip(it.authority)) }), ) to ContentChange.NONE - is Bolt12OfferListDiff -> listOf(listGroup(R.string.backup_entry_offer, diff.offers, { ReviewItem.Text(clip(it)) })) to ContentChange.NONE + is Bolt12OfferListDiff -> listOf(listGroup(Res.string.backup_entry_offer, diff.offers, { ReviewItem.Text(clip(it)) })) to ContentChange.NONE is CashuWalletDiff -> emptyList<DiffGroup>() to diff.wallet is ConcordCommunityListDiff -> emptyList<DiffGroup>() to diff.communities is AppSpecificDataDiff -> emptyList<DiffGroup>() to diff.data @@ -404,13 +518,13 @@ fun presentationOf( private fun nutzapKeyGroup(change: ValueChange<HexKey>?): DiffGroup { val none = emptyList<ReviewItem>() - if (change == null) return DiffGroup(R.string.backup_entry_nutzap_key, none, none, none) + if (change == null) return DiffGroup(Res.string.backup_entry_nutzap_key, none, none, none) val before = change.before val after = change.after return when { - before != null && after == null -> DiffGroup(R.string.backup_entry_nutzap_key, listOf(ReviewItem.Text(before)), none, none) - before == null && after != null -> DiffGroup(R.string.backup_entry_nutzap_key, none, listOf(ReviewItem.Text(after)), none) - else -> DiffGroup(R.string.backup_entry_nutzap_key, none, none, listOf(ReviewItem.Text(arrow(before, after)))) + before != null && after == null -> DiffGroup(Res.string.backup_entry_nutzap_key, listOf(ReviewItem.Text(before)), none, none) + before == null && after != null -> DiffGroup(Res.string.backup_entry_nutzap_key, none, listOf(ReviewItem.Text(after)), none) + else -> DiffGroup(Res.string.backup_entry_nutzap_key, none, none, listOf(ReviewItem.Text(arrow(before, after)))) } } @@ -422,64 +536,64 @@ fun clip(text: String?): String { return if (oneLine.length > MAX_VALUE_LENGTH) oneLine.take(MAX_VALUE_LENGTH) + "…" else oneLine } -fun eventTypeName(type: BackupEventType): Int = +fun eventTypeName(type: BackupEventType): StringResource = when (type) { - BackupEventType.PROFILE -> R.string.backup_type_profile - BackupEventType.FOLLOW_LIST -> R.string.backup_type_follow_list - BackupEventType.MUTE_LIST -> R.string.backup_type_mute_list - BackupEventType.OUTBOX_INBOX_RELAYS -> R.string.backup_type_outbox_inbox_relays - BackupEventType.DM_RELAYS -> R.string.backup_type_dm_relays - BackupEventType.KEY_PACKAGE_RELAYS -> R.string.backup_type_key_package_relays - BackupEventType.SEARCH_RELAYS -> R.string.backup_type_search_relays - BackupEventType.INDEXER_RELAYS -> R.string.backup_type_indexer_relays - BackupEventType.RELAY_FEEDS -> R.string.backup_type_relay_feeds - BackupEventType.BLOCKED_RELAYS -> R.string.backup_type_blocked_relays - BackupEventType.TRUSTED_RELAYS -> R.string.backup_type_trusted_relays - BackupEventType.PRIVATE_OUTBOX_RELAYS -> R.string.backup_type_private_outbox_relays - BackupEventType.APP_SETTINGS -> R.string.backup_type_app_settings - BackupEventType.PUBLIC_CHATS -> R.string.backup_type_public_chats - BackupEventType.COMMUNITIES -> R.string.backup_type_communities - BackupEventType.HASHTAGS -> R.string.backup_type_hashtags - BackupEventType.GEOHASHES -> R.string.backup_type_geohashes - BackupEventType.FAVORITE_ALGO_FEEDS -> R.string.backup_type_favorite_algo_feeds - BackupEventType.EPHEMERAL_CHATS -> R.string.backup_type_ephemeral_chats - BackupEventType.RELAY_GROUPS -> R.string.backup_type_relay_groups - BackupEventType.CONCORD_COMMUNITIES -> R.string.backup_type_concord_communities - BackupEventType.TRUST_PROVIDERS -> R.string.backup_type_trust_providers - BackupEventType.CASHU_WALLET -> R.string.backup_type_cashu_wallet - BackupEventType.NUTZAP_INFO -> R.string.backup_type_nutzap_info - BackupEventType.PAYMENT_TARGETS -> R.string.backup_type_payment_targets - BackupEventType.BOLT12_OFFERS -> R.string.backup_type_bolt12_offers - BackupEventType.OTHER -> R.string.backup_type_other + BackupEventType.PROFILE -> Res.string.backup_type_profile + BackupEventType.FOLLOW_LIST -> Res.string.backup_type_follow_list + BackupEventType.MUTE_LIST -> Res.string.backup_type_mute_list + BackupEventType.OUTBOX_INBOX_RELAYS -> Res.string.backup_type_outbox_inbox_relays + BackupEventType.DM_RELAYS -> Res.string.backup_type_dm_relays + BackupEventType.KEY_PACKAGE_RELAYS -> Res.string.backup_type_key_package_relays + BackupEventType.SEARCH_RELAYS -> Res.string.backup_type_search_relays + BackupEventType.INDEXER_RELAYS -> Res.string.backup_type_indexer_relays + BackupEventType.RELAY_FEEDS -> Res.string.backup_type_relay_feeds + BackupEventType.BLOCKED_RELAYS -> Res.string.backup_type_blocked_relays + BackupEventType.TRUSTED_RELAYS -> Res.string.backup_type_trusted_relays + BackupEventType.PRIVATE_OUTBOX_RELAYS -> Res.string.backup_type_private_outbox_relays + BackupEventType.APP_SETTINGS -> Res.string.backup_type_app_settings + BackupEventType.PUBLIC_CHATS -> Res.string.backup_type_public_chats + BackupEventType.COMMUNITIES -> Res.string.backup_type_communities + BackupEventType.HASHTAGS -> Res.string.backup_type_hashtags + BackupEventType.GEOHASHES -> Res.string.backup_type_geohashes + BackupEventType.FAVORITE_ALGO_FEEDS -> Res.string.backup_type_favorite_algo_feeds + BackupEventType.EPHEMERAL_CHATS -> Res.string.backup_type_ephemeral_chats + BackupEventType.RELAY_GROUPS -> Res.string.backup_type_relay_groups + BackupEventType.CONCORD_COMMUNITIES -> Res.string.backup_type_concord_communities + BackupEventType.TRUST_PROVIDERS -> Res.string.backup_type_trust_providers + BackupEventType.CASHU_WALLET -> Res.string.backup_type_cashu_wallet + BackupEventType.NUTZAP_INFO -> Res.string.backup_type_nutzap_info + BackupEventType.PAYMENT_TARGETS -> Res.string.backup_type_payment_targets + BackupEventType.BOLT12_OFFERS -> Res.string.backup_type_bolt12_offers + BackupEventType.OTHER -> Res.string.backup_type_other } -fun eventTypeExplainer(type: BackupEventType): Int = +fun eventTypeExplainer(type: BackupEventType): StringResource = when (type) { - BackupEventType.PROFILE -> R.string.backup_type_profile_explainer - BackupEventType.FOLLOW_LIST -> R.string.backup_type_follow_list_explainer - BackupEventType.MUTE_LIST -> R.string.backup_type_mute_list_explainer - BackupEventType.OUTBOX_INBOX_RELAYS -> R.string.backup_type_outbox_inbox_relays_explainer - BackupEventType.DM_RELAYS -> R.string.backup_type_dm_relays_explainer - BackupEventType.KEY_PACKAGE_RELAYS -> R.string.backup_type_key_package_relays_explainer - BackupEventType.SEARCH_RELAYS -> R.string.backup_type_search_relays_explainer - BackupEventType.INDEXER_RELAYS -> R.string.backup_type_indexer_relays_explainer - BackupEventType.RELAY_FEEDS -> R.string.backup_type_relay_feeds_explainer - BackupEventType.BLOCKED_RELAYS -> R.string.backup_type_blocked_relays_explainer - BackupEventType.TRUSTED_RELAYS -> R.string.backup_type_trusted_relays_explainer - BackupEventType.PRIVATE_OUTBOX_RELAYS -> R.string.backup_type_private_outbox_relays_explainer - BackupEventType.APP_SETTINGS -> R.string.backup_type_app_settings_explainer - BackupEventType.PUBLIC_CHATS -> R.string.backup_type_public_chats_explainer - BackupEventType.COMMUNITIES -> R.string.backup_type_communities_explainer - BackupEventType.HASHTAGS -> R.string.backup_type_hashtags_explainer - BackupEventType.GEOHASHES -> R.string.backup_type_geohashes_explainer - BackupEventType.FAVORITE_ALGO_FEEDS -> R.string.backup_type_favorite_algo_feeds_explainer - BackupEventType.EPHEMERAL_CHATS -> R.string.backup_type_ephemeral_chats_explainer - BackupEventType.RELAY_GROUPS -> R.string.backup_type_relay_groups_explainer - BackupEventType.CONCORD_COMMUNITIES -> R.string.backup_type_concord_communities_explainer - BackupEventType.TRUST_PROVIDERS -> R.string.backup_type_trust_providers_explainer - BackupEventType.CASHU_WALLET -> R.string.backup_type_cashu_wallet_explainer - BackupEventType.NUTZAP_INFO -> R.string.backup_type_nutzap_info_explainer - BackupEventType.PAYMENT_TARGETS -> R.string.backup_type_payment_targets_explainer - BackupEventType.BOLT12_OFFERS -> R.string.backup_type_bolt12_offers_explainer - BackupEventType.OTHER -> R.string.backup_type_other_explainer + BackupEventType.PROFILE -> Res.string.backup_type_profile_explainer + BackupEventType.FOLLOW_LIST -> Res.string.backup_type_follow_list_explainer + BackupEventType.MUTE_LIST -> Res.string.backup_type_mute_list_explainer + BackupEventType.OUTBOX_INBOX_RELAYS -> Res.string.backup_type_outbox_inbox_relays_explainer + BackupEventType.DM_RELAYS -> Res.string.backup_type_dm_relays_explainer + BackupEventType.KEY_PACKAGE_RELAYS -> Res.string.backup_type_key_package_relays_explainer + BackupEventType.SEARCH_RELAYS -> Res.string.backup_type_search_relays_explainer + BackupEventType.INDEXER_RELAYS -> Res.string.backup_type_indexer_relays_explainer + BackupEventType.RELAY_FEEDS -> Res.string.backup_type_relay_feeds_explainer + BackupEventType.BLOCKED_RELAYS -> Res.string.backup_type_blocked_relays_explainer + BackupEventType.TRUSTED_RELAYS -> Res.string.backup_type_trusted_relays_explainer + BackupEventType.PRIVATE_OUTBOX_RELAYS -> Res.string.backup_type_private_outbox_relays_explainer + BackupEventType.APP_SETTINGS -> Res.string.backup_type_app_settings_explainer + BackupEventType.PUBLIC_CHATS -> Res.string.backup_type_public_chats_explainer + BackupEventType.COMMUNITIES -> Res.string.backup_type_communities_explainer + BackupEventType.HASHTAGS -> Res.string.backup_type_hashtags_explainer + BackupEventType.GEOHASHES -> Res.string.backup_type_geohashes_explainer + BackupEventType.FAVORITE_ALGO_FEEDS -> Res.string.backup_type_favorite_algo_feeds_explainer + BackupEventType.EPHEMERAL_CHATS -> Res.string.backup_type_ephemeral_chats_explainer + BackupEventType.RELAY_GROUPS -> Res.string.backup_type_relay_groups_explainer + BackupEventType.CONCORD_COMMUNITIES -> Res.string.backup_type_concord_communities_explainer + BackupEventType.TRUST_PROVIDERS -> Res.string.backup_type_trust_providers_explainer + BackupEventType.CASHU_WALLET -> Res.string.backup_type_cashu_wallet_explainer + BackupEventType.NUTZAP_INFO -> Res.string.backup_type_nutzap_info_explainer + BackupEventType.PAYMENT_TARGETS -> Res.string.backup_type_payment_targets_explainer + BackupEventType.BOLT12_OFFERS -> Res.string.backup_type_bolt12_offers_explainer + BackupEventType.OTHER -> Res.string.backup_type_other_explainer } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt index 8b5d7b0150..6497b54846 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictReviewScreen.kt @@ -59,11 +59,34 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.model.backups.BackupEventType import com.vitorpamplona.amethyst.commons.model.backups.ReplaceableBackupConflict import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.model.navigation.routeFor +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.backup_action_block_again +import com.vitorpamplona.amethyst.commons.resources.backup_action_keep_count +import com.vitorpamplona.amethyst.commons.resources.backup_action_rejoin +import com.vitorpamplona.amethyst.commons.resources.backup_action_remute +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_count +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_feeds +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_places +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_profile +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_providers +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_relays +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_topics +import com.vitorpamplona.amethyst.commons.resources.backup_action_restore_wallet +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_added +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_changed +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_keep_new +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_private_added +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_private_changed +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_private_cleared +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_removed +import com.vitorpamplona.amethyst.commons.resources.backup_conflict_restore_mine +import com.vitorpamplona.amethyst.commons.resources.backup_review_changed_by_other_app +import com.vitorpamplona.amethyst.commons.resources.backup_review_title_cleared +import com.vitorpamplona.amethyst.commons.resources.backup_review_title_updated import com.vitorpamplona.amethyst.commons.ui.insets.imePaddingSafe import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton @@ -97,22 +120,23 @@ import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletDiff import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListDiff import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListDiff import com.vitorpamplona.quartz.nip85TrustedAssertions.list.TrustProviderListDiff +import org.jetbrains.compose.resources.StringResource /** A row of the review list, flattened so hundreds of entries scroll lazily. */ @Immutable internal sealed interface ReviewRow { class Section( - val titleRes: Int, + val titleRes: StringResource, val count: Int, val tone: Tone, ) : ReviewRow class Note( - val textRes: Int, + val textRes: StringResource, ) : ReviewRow class Group( - val labelRes: Int, + val labelRes: StringResource, ) : ReviewRow class Entry( @@ -124,15 +148,15 @@ internal enum class Tone { REMOVED, ADDED, CHANGED } internal fun buildRows( presentation: DiffPresentation, - skipGroups: Set<Int> = emptySet(), + skipGroups: Set<StringResource> = emptySet(), ): List<ReviewRow> { val rows = mutableListOf<ReviewRow>() fun section( - titleRes: Int, + titleRes: StringResource, count: Int, tone: Tone, - contentNote: Int?, + contentNote: StringResource?, items: (DiffGroup) -> List<ReviewItem>, ) { if (count == 0 && contentNote == null) return @@ -149,9 +173,9 @@ internal fun buildRows( } val content = presentation.content - section(R.string.backup_conflict_removed, presentation.removedCount, Tone.REMOVED, R.string.backup_conflict_private_cleared.takeIf { content == ContentChange.CLEARED }) { it.removed } - section(R.string.backup_conflict_added, presentation.addedCount, Tone.ADDED, R.string.backup_conflict_private_added.takeIf { content == ContentChange.ADDED }) { it.added } - section(R.string.backup_conflict_changed, presentation.changedCount, Tone.CHANGED, R.string.backup_conflict_private_changed.takeIf { content == ContentChange.CHANGED }) { it.changed } + section(Res.string.backup_conflict_removed, presentation.removedCount, Tone.REMOVED, Res.string.backup_conflict_private_cleared.takeIf { content == ContentChange.CLEARED }) { it.removed } + section(Res.string.backup_conflict_added, presentation.addedCount, Tone.ADDED, Res.string.backup_conflict_private_added.takeIf { content == ContentChange.ADDED }) { it.added } + section(Res.string.backup_conflict_changed, presentation.changedCount, Tone.CHANGED, Res.string.backup_conflict_private_changed.takeIf { content == ContentChange.CHANGED }) { it.changed } return rows } @@ -268,7 +292,7 @@ internal fun LazyListScope.genericDiffItems( } @Composable -internal fun GroupLabel(labelRes: Int) { +internal fun GroupLabel(labelRes: StringResource) { Text( text = stringRes(labelRes), style = MaterialTheme.typography.labelLarge, @@ -339,7 +363,7 @@ internal fun eventTitle(conflict: ReplaceableBackupConflict): String { val name = stringRes(eventTypeName(conflict.eventType)).replaceFirstChar { it.uppercase() } // Says what happened to it, not just what it is: "Community list updated". val emptied = conflict.incoming.tags.isEmpty() && conflict.incoming.content.isEmpty() - return stringRes(if (emptied) R.string.backup_review_title_cleared else R.string.backup_review_title_updated, name) + return stringRes(if (emptied) Res.string.backup_review_title_cleared else Res.string.backup_review_title_updated, name) } /** The two choices, worded for what they do to this event: "Keep 120" / "Restore 523". */ @@ -348,48 +372,48 @@ private fun actionLabels(conflict: ReplaceableBackupConflict): Pair<String, Stri when (val diff = conflict.diff) { is ContactListDiff -> { val (saved, new) = conflict.followCounts - stringRes(R.string.backup_action_keep_count, new.toString()) to stringRes(R.string.backup_action_restore_count, saved.toString()) + stringRes(Res.string.backup_action_keep_count, new.toString()) to stringRes(Res.string.backup_action_restore_count, saved.toString()) } is MuteListDiff -> { val removed = diff.publicMutes.removed.size - stringRes(R.string.backup_conflict_keep_new) to - if (removed > 0) stringRes(R.string.backup_action_remute, removed.toString()) else stringRes(R.string.backup_conflict_restore_mine) + stringRes(Res.string.backup_conflict_keep_new) to + if (removed > 0) stringRes(Res.string.backup_action_remute, removed.toString()) else stringRes(Res.string.backup_conflict_restore_mine) } is SimpleGroupListDiff -> { val removed = diff.groups.removed.size - stringRes(R.string.backup_conflict_keep_new) to - if (removed > 0) stringRes(R.string.backup_action_rejoin, removed.toString()) else stringRes(R.string.backup_conflict_restore_mine) + stringRes(Res.string.backup_conflict_keep_new) to + if (removed > 0) stringRes(Res.string.backup_action_rejoin, removed.toString()) else stringRes(Res.string.backup_conflict_restore_mine) } - is MetadataDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_profile) + is MetadataDiff -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_profile) is RelayListDiff -> if (conflict.eventType == BackupEventType.BLOCKED_RELAYS && diff.relays.removed.isNotEmpty()) { - stringRes(R.string.backup_conflict_keep_new) to + stringRes(Res.string.backup_conflict_keep_new) to stringRes( - R.string.backup_action_block_again, + Res.string.backup_action_block_again, diff.relays.removed.size .toString(), ) } else { - stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_relays) + stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_relays) } - is AdvertisedRelayListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_relays) + is AdvertisedRelayListDiff -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_relays) is ChannelListDiff -> rejoinLabels(diff.channels.removed.size) is CommunityListDiff -> rejoinLabels(diff.communities.removed.size) is EphemeralChatListDiff -> rejoinLabels(diff.rooms.removed.size) - is FavoriteAlgoFeedsListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_feeds) - is HashtagListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_topics) + is FavoriteAlgoFeedsListDiff -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_feeds) + is HashtagListDiff -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_topics) // Geohashes are places, not topics: the screen counts "places gone" under "Followed // locations", so the button has to agree with the page it sits on. - is GeohashListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_places) - is TrustProviderListDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_providers) - is CashuWalletDiff -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_action_restore_wallet) - else -> stringRes(R.string.backup_conflict_keep_new) to stringRes(R.string.backup_conflict_restore_mine) + is GeohashListDiff -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_places) + is TrustProviderListDiff -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_providers) + is CashuWalletDiff -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_action_restore_wallet) + else -> stringRes(Res.string.backup_conflict_keep_new) to stringRes(Res.string.backup_conflict_restore_mine) } @Composable private fun rejoinLabels(removed: Int): Pair<String, String> = - stringRes(R.string.backup_conflict_keep_new) to - if (removed > 0) stringRes(R.string.backup_action_rejoin, removed.toString()) else stringRes(R.string.backup_conflict_restore_mine) + stringRes(Res.string.backup_conflict_keep_new) to + if (removed > 0) stringRes(Res.string.backup_action_rejoin, removed.toString()) else stringRes(Res.string.backup_conflict_restore_mine) /** When the other app changed it, and what the event is for. */ @Composable @@ -399,7 +423,7 @@ private fun BackupConflictIntro( ) { Column(modifier, verticalArrangement = Arrangement.spacedBy(2.dp)) { Text( - text = stringRes(R.string.backup_review_changed_by_other_app, timeAgoNoDot(conflict.cause.createdAt)), + text = stringRes(Res.string.backup_review_changed_by_other_app, timeAgoNoDot(conflict.cause.createdAt)), style = MaterialTheme.typography.labelLarge, color = conflictTones().removed, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnComposer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnComposer.kt index 0e19b487cb..c892f3d020 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnComposer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnComposer.kt @@ -42,12 +42,13 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.chats.ui.ThinSendButton import com.vitorpamplona.amethyst.commons.model.cordnGroups.CordnGroupChatroom import com.vitorpamplona.amethyst.commons.model.nip30CustomEmojis.EmojiPackState import com.vitorpamplona.amethyst.commons.model.nip30CustomEmojis.EmojiSuggestionState import com.vitorpamplona.amethyst.commons.nip30CustomEmojis.ui.ShowEmojiSuggestionList +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.cordn_composer_hint import com.vitorpamplona.amethyst.commons.ui.text.currentWord import com.vitorpamplona.amethyst.commons.ui.text.replaceCurrentWord import com.vitorpamplona.amethyst.commons.ui.theme.EditFieldBorder @@ -233,7 +234,7 @@ internal fun CordnComposer( shape = EditFieldBorder, placeholder = { Text( - text = stringRes(R.string.cordn_composer_hint), + text = stringRes(Res.string.cordn_composer_hint), color = MaterialTheme.colorScheme.placeholderText, ) }, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt index 6deedde2d4..0b78b0ea5e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateGroupScreen.kt @@ -55,11 +55,9 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CoordinatorConfig import com.vitorpamplona.amethyst.commons.cordn.DiscoveredCoordinator import com.vitorpamplona.amethyst.commons.cordn.GroupExposure @@ -69,6 +67,55 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.back +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_none +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_seen +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_seen_on +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_unheard +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_hide_older +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_relays_more +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_show_all +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_show_fewer +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_show_older +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_stale_note +import com.vitorpamplona.amethyst.commons.resources.cordn_create_action +import com.vitorpamplona.amethyst.commons.resources.cordn_create_action_invite +import com.vitorpamplona.amethyst.commons.resources.cordn_create_admin_count +import com.vitorpamplona.amethyst.commons.resources.cordn_create_admin_only_me_on +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_change +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_discover +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_hide +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_new +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_pubkey +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_relays +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coverage_all +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coverage_partial +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coverage_unknown +import com.vitorpamplona.amethyst.commons.resources.cordn_create_description +import com.vitorpamplona.amethyst.commons.resources.cordn_create_egalitarian +import com.vitorpamplona.amethyst.commons.resources.cordn_create_egalitarian_note +import com.vitorpamplona.amethyst.commons.resources.cordn_create_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_create_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_create_name +import com.vitorpamplona.amethyst.commons.resources.cordn_create_no_coordinator +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_link +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_no_welcome +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_open +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_skipped +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_title +import com.vitorpamplona.amethyst.commons.resources.cordn_create_outcome_waiting +import com.vitorpamplona.amethyst.commons.resources.cordn_create_people_none +import com.vitorpamplona.amethyst.commons.resources.cordn_create_step_admins +import com.vitorpamplona.amethyst.commons.resources.cordn_create_step_name +import com.vitorpamplona.amethyst.commons.resources.cordn_create_step_people +import com.vitorpamplona.amethyst.commons.resources.cordn_create_step_where +import com.vitorpamplona.amethyst.commons.resources.cordn_create_title +import com.vitorpamplona.amethyst.commons.resources.cordn_create_unreachable_count +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail +import com.vitorpamplona.amethyst.commons.resources.cordn_member_count import com.vitorpamplona.amethyst.commons.ui.components.EmptyState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.model.cordn.CordnCoverage @@ -131,7 +178,7 @@ fun CordnCreateGroupScreen( Icon(MaterialSymbols.AutoMirrored.ArrowBack, contentDescription = stringRes(Res.string.back)) } }, - title = { Text(stringRes(R.string.cordn_create_title)) }, + title = { Text(stringRes(Res.string.cordn_create_title)) }, ) }, ) { padding -> @@ -139,8 +186,8 @@ fun CordnCreateGroupScreen( // The app's own empty state, centred and titled, rather than a // sentence stranded in the top-left corner. EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) return@Scaffold @@ -164,14 +211,14 @@ fun CordnCreateGroupScreen( val draft = rememberCordnGroupDraft(accountViewModel) var creation by remember { mutableStateOf<CordnGroupCreation?>(null) } var error by remember { mutableStateOf<String?>(null) } - val failureFallback = stringRes(R.string.cordn_create_failed) + val failureFallback = stringRes(Res.string.cordn_create_failed) var busy by remember { mutableStateOf(false) } // Coordinators this account has never used, from their CEP-6 // announcements. Not added to the account by looking: picking one here // is what commits to it, and `createGroup` opens the session. var discovering by remember { mutableStateOf(false) } - val discoverFailed = stringRes(R.string.cordn_coordinators_discover_failed) + val discoverFailed = stringRes(Res.string.cordn_coordinators_discover_failed) // Offers this account already holds are not offers; they are the choices // above, and listing them twice would let the same coordinator be picked @@ -222,29 +269,29 @@ fun CordnCreateGroupScreen( verticalArrangement = Arrangement.spacedBy(12.dp), ) { Text( - text = stringRes(R.string.cordn_create_explainer), + text = stringRes(Res.string.cordn_create_explainer), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) - StepHeading(1, stringRes(R.string.cordn_create_step_name)) + StepHeading(1, stringRes(Res.string.cordn_create_step_name)) OutlinedTextField( value = draft.name, onValueChange = { draft.name = it }, - label = { Text(stringRes(R.string.cordn_create_name)) }, + label = { Text(stringRes(Res.string.cordn_create_name)) }, singleLine = true, modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( value = draft.description, onValueChange = { draft.description = it }, - label = { Text(stringRes(R.string.cordn_create_description)) }, + label = { Text(stringRes(Res.string.cordn_create_description)) }, singleLine = false, modifier = Modifier.fillMaxWidth(), ) - StepHeading(2, stringRes(R.string.cordn_create_step_people)) + StepHeading(2, stringRes(Res.string.cordn_create_step_people)) RosterSummary( roster = draft.roster, @@ -254,7 +301,7 @@ fun CordnCreateGroupScreen( nav = nav, ) - StepHeading(3, stringRes(R.string.cordn_create_step_where)) + StepHeading(3, stringRes(Res.string.cordn_create_step_where)) // Collapsed to the one coordinator that will be used, because with a // draft.roster in hand there is usually nothing left to decide. The whole @@ -326,9 +373,9 @@ fun CordnCreateGroupScreen( TextButton(onClick = { draft.showAllLive = !draft.showAllLive }) { Text( if (draft.showAllLive) { - stringRes(R.string.cordn_coordinators_show_fewer) + stringRes(Res.string.cordn_coordinators_show_fewer) } else { - stringRes(R.string.cordn_coordinators_show_all, live.size) + stringRes(Res.string.cordn_coordinators_show_all, live.size) }, ) } @@ -338,9 +385,9 @@ fun CordnCreateGroupScreen( TextButton(onClick = { draft.showStale = !draft.showStale }) { Text( if (draft.showStale) { - stringRes(R.string.cordn_coordinators_hide_older) + stringRes(Res.string.cordn_coordinators_hide_older) } else { - stringRes(R.string.cordn_coordinators_show_older, stale.size) + stringRes(Res.string.cordn_coordinators_show_older, stale.size) }, ) } @@ -348,7 +395,7 @@ fun CordnCreateGroupScreen( if (draft.showStale && stale.isNotEmpty()) { Text( - text = stringRes(R.string.cordn_coordinators_stale_note), + text = stringRes(Res.string.cordn_coordinators_stale_note), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -372,7 +419,7 @@ fun CordnCreateGroupScreen( } CoordinatorChoice( - label = stringRes(R.string.cordn_create_coordinator_new), + label = stringRes(Res.string.cordn_create_coordinator_new), pubKey = null, selected = draft.selected == null, onSelect = { @@ -402,20 +449,20 @@ fun CordnCreateGroupScreen( }, enabled = !discovering && !busy, ) { - Text(stringRes(R.string.cordn_create_coordinator_discover)) + Text(stringRes(Res.string.cordn_create_coordinator_discover)) } draft.discovered?.takeIf { offers.isEmpty() }?.let { result -> Text( text = if (result.unreachable.isEmpty()) { - stringRes(R.string.cordn_coordinators_discover_none) + stringRes(Res.string.cordn_coordinators_discover_none) } else { // "Nobody is announcing" and "we were not told" are // different answers and only one of them is final. // Reporting the first for the second sends someone // off to paste a pubkey by hand over a timeout. - stringRes(R.string.cordn_coordinators_discover_unheard, result.unreachable.size) + stringRes(Res.string.cordn_coordinators_discover_unheard, result.unreachable.size) }, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, @@ -433,7 +480,7 @@ fun CordnCreateGroupScreen( draft.userPicked = true error = null }, - label = { Text(stringRes(R.string.cordn_create_coordinator_pubkey)) }, + label = { Text(stringRes(Res.string.cordn_create_coordinator_pubkey)) }, singleLine = true, modifier = Modifier.fillMaxWidth(), ) @@ -444,7 +491,7 @@ fun CordnCreateGroupScreen( draft.userPicked = true error = null }, - label = { Text(stringRes(R.string.cordn_create_coordinator_relays)) }, + label = { Text(stringRes(Res.string.cordn_create_coordinator_relays)) }, // A coordinator has no address beyond its pubkey (§8.5), so // the relays are how it is reached and more than one is // ordinary. One per line rather than comma-separated, @@ -456,7 +503,7 @@ fun CordnCreateGroupScreen( } } - StepHeading(4, stringRes(R.string.cordn_create_step_admins)) + StepHeading(4, stringRes(Res.string.cordn_create_step_admins)) // spec/01.md §5.3: leaving the admin list empty is not "set it up // later", it is choosing draft.egalitarian permanently -- so it is offered @@ -472,15 +519,15 @@ fun CordnCreateGroupScreen( horizontalArrangement = Arrangement.spacedBy(12.dp), ) { Column(Modifier.weight(1f)) { - Text(stringRes(R.string.cordn_create_egalitarian), style = MaterialTheme.typography.bodyMedium) + Text(stringRes(Res.string.cordn_create_egalitarian), style = MaterialTheme.typography.bodyMedium) Text( text = if (draft.egalitarian) { - stringRes(R.string.cordn_create_egalitarian_note) + stringRes(Res.string.cordn_create_egalitarian_note) } else if (draft.coAdmins.isEmpty()) { - stringRes(R.string.cordn_create_admin_only_me_on) + stringRes(Res.string.cordn_create_admin_only_me_on) } else { - pluralStringRes(LocalContext.current, R.plurals.cordn_create_admin_count, draft.coAdmins.size + 1, draft.coAdmins.size + 1) + pluralStringRes(Res.plurals.cordn_create_admin_count, draft.coAdmins.size + 1, draft.coAdmins.size + 1) }, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, @@ -561,9 +608,9 @@ fun CordnCreateGroupScreen( ) { Text( if (draft.roster.isEmpty()) { - stringRes(R.string.cordn_create_action) + stringRes(Res.string.cordn_create_action) } else { - pluralStringRes(LocalContext.current, R.plurals.cordn_create_action_invite, draft.roster.size, draft.roster.size) + pluralStringRes(Res.plurals.cordn_create_action_invite, draft.roster.size, draft.roster.size) }, ) } @@ -691,9 +738,9 @@ private fun resolvedName( @Composable private fun announcedLabel(announcedAt: Long): String = if (TimeUtils.now() - announcedAt > TimeUtils.ONE_MONTH) { - stringRes(R.string.cordn_coordinators_discover_seen_on, timeAgoNoDot(announcedAt).trim()) + stringRes(Res.string.cordn_coordinators_discover_seen_on, timeAgoNoDot(announcedAt).trim()) } else { - stringRes(R.string.cordn_coordinators_discover_seen, timeAgoNoDot(announcedAt).trim()) + stringRes(Res.string.cordn_coordinators_discover_seen, timeAgoNoDot(announcedAt).trim()) } /** The hosts it answers on, the first two and a count of the rest. */ @@ -705,7 +752,7 @@ private fun relayLabel(relays: List<NormalizedRelayUrl>): String? { return if (hosts.size <= 2) { shown } else { - stringRes(R.string.cordn_coordinators_relays_more, shown, hosts.size - 2) + stringRes(Res.string.cordn_coordinators_relays_more, shown, hosts.size - 2) } } @@ -791,7 +838,7 @@ private fun RosterSummary( ) { if (roster.isEmpty()) { Text( - text = stringRes(R.string.cordn_create_people_none), + text = stringRes(Res.string.cordn_create_people_none), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.weight(1f), @@ -804,7 +851,7 @@ private fun RosterSummary( } Column(Modifier.weight(1f)) { Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_member_count, roster.size + 1, roster.size + 1), + text = pluralStringRes(Res.plurals.cordn_member_count, roster.size + 1, roster.size + 1), style = MaterialTheme.typography.bodyMedium, ) // Counted over coordinators that answered, so an unreachable one @@ -812,7 +859,7 @@ private fun RosterSummary( val unreachable = roster.count { member -> coverage.values.none { it.answered && member in it.reachable } } if (unreachable > 0 && coverage.values.any { it.answered }) { Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_create_unreachable_count, unreachable, unreachable), + text = pluralStringRes(Res.plurals.cordn_create_unreachable_count, unreachable, unreachable), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.error, ) @@ -855,7 +902,7 @@ private fun CoordinatorSummary( ) { if (config == null) { Text( - text = stringRes(R.string.cordn_create_no_coordinator), + text = stringRes(Res.string.cordn_create_no_coordinator), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.weight(1f), @@ -879,9 +926,9 @@ private fun CoordinatorSummary( Text( text = when { - coverage == null || !coverage.answered -> stringRes(R.string.cordn_create_coverage_unknown) - reached == rosterSize -> stringRes(R.string.cordn_create_coverage_all, rosterSize) - else -> stringRes(R.string.cordn_create_coverage_partial, reached ?: 0, rosterSize) + coverage == null || !coverage.answered -> stringRes(Res.string.cordn_create_coverage_unknown) + reached == rosterSize -> stringRes(Res.string.cordn_create_coverage_all, rosterSize) + else -> stringRes(Res.string.cordn_create_coverage_partial, reached ?: 0, rosterSize) }, style = MaterialTheme.typography.labelSmall, color = @@ -899,9 +946,9 @@ private fun CoordinatorSummary( TextButton(onClick = onToggle) { Text( if (expanded) { - stringRes(R.string.cordn_create_coordinator_hide) + stringRes(Res.string.cordn_create_coordinator_hide) } else { - stringRes(R.string.cordn_create_coordinator_change) + stringRes(Res.string.cordn_create_coordinator_change) }, ) } @@ -934,11 +981,11 @@ private fun CordnCreationOutcome( AlertDialog( onDismissRequest = onDismiss, - title = { Text(stringRes(R.string.cordn_create_outcome_title)) }, + title = { Text(stringRes(Res.string.cordn_create_outcome_title)) }, text = { Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { Text( - text = stringRes(R.string.cordn_create_outcome_explainer), + text = stringRes(Res.string.cordn_create_outcome_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -960,10 +1007,10 @@ private fun CordnCreationOutcome( Text( text = when { - outcome == null -> stringRes(R.string.cordn_create_outcome_skipped) - outcome.sent -> stringRes(R.string.cordn_create_outcome_waiting) - outcome.joinedWithoutWelcome -> stringRes(R.string.cordn_create_outcome_no_welcome) - else -> outcome.failure?.message ?: stringRes(R.string.cordn_create_outcome_failed) + outcome == null -> stringRes(Res.string.cordn_create_outcome_skipped) + outcome.sent -> stringRes(Res.string.cordn_create_outcome_waiting) + outcome.joinedWithoutWelcome -> stringRes(Res.string.cordn_create_outcome_no_welcome) + else -> outcome.failure?.message ?: stringRes(Res.string.cordn_create_outcome_failed) }, style = MaterialTheme.typography.labelSmall, color = @@ -979,12 +1026,12 @@ private fun CordnCreationOutcome( // open themselves -- which needs the group to exist, // and now it does. if (outcome == null) { - TextButton(onClick = open) { Text(stringRes(R.string.cordn_create_outcome_link)) } + TextButton(onClick = open) { Text(stringRes(Res.string.cordn_create_outcome_link)) } } } } } }, - confirmButton = { TextButton(onClick = open) { Text(stringRes(R.string.cordn_create_outcome_open)) } }, + confirmButton = { TextButton(onClick = open) { Text(stringRes(Res.string.cordn_create_outcome_open)) } }, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateMembersScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateMembersScreen.kt index e80829bf90..1a09a1c890 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateMembersScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnCreateMembersScreen.kt @@ -47,15 +47,31 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.User +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.cordn_create_add_member +import com.vitorpamplona.amethyst.commons.resources.cordn_create_admin +import com.vitorpamplona.amethyst.commons.resources.cordn_create_people_done +import com.vitorpamplona.amethyst.commons.resources.cordn_create_people_empty +import com.vitorpamplona.amethyst.commons.resources.cordn_create_people_note +import com.vitorpamplona.amethyst.commons.resources.cordn_create_reach_count +import com.vitorpamplona.amethyst.commons.resources.cordn_create_reach_none +import com.vitorpamplona.amethyst.commons.resources.cordn_create_reach_unknown +import com.vitorpamplona.amethyst.commons.resources.cordn_create_step_people +import com.vitorpamplona.amethyst.commons.resources.cordn_create_you +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail +import com.vitorpamplona.amethyst.commons.resources.cordn_info_add_member_none +import com.vitorpamplona.amethyst.commons.resources.cordn_info_add_member_placeholder +import com.vitorpamplona.amethyst.commons.resources.cordn_info_has_key_package +import com.vitorpamplona.amethyst.commons.resources.cordn_info_remove_member +import com.vitorpamplona.amethyst.commons.resources.cordn_member_count import com.vitorpamplona.amethyst.commons.ui.components.EmptyState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton @@ -101,12 +117,12 @@ fun CordnCreateMembersScreen( val draft = rememberCordnGroupDraft(accountViewModel) Scaffold( - topBar = { TopBarWithBackButton(stringRes(R.string.cordn_create_step_people), nav) }, + topBar = { TopBarWithBackButton(stringRes(Res.string.cordn_create_step_people), nav) }, ) { padding -> if (runtime == null) { EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) return@Scaffold @@ -137,7 +153,7 @@ fun CordnCreateMembersScreen( verticalArrangement = Arrangement.spacedBy(12.dp), ) { Text( - text = stringRes(R.string.cordn_create_people_note), + text = stringRes(Res.string.cordn_create_people_note), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -148,8 +164,8 @@ fun CordnCreateMembersScreen( search = it if (it.length > 2) userSuggestions.processCurrentWord(it) else userSuggestions.reset() }, - label = { Text(stringRes(R.string.cordn_create_add_member)) }, - placeholder = { Text(stringRes(R.string.cordn_info_add_member_placeholder)) }, + label = { Text(stringRes(Res.string.cordn_create_add_member)) }, + placeholder = { Text(stringRes(Res.string.cordn_info_add_member_placeholder)) }, singleLine = true, modifier = Modifier.fillMaxWidth(), ) @@ -168,7 +184,7 @@ fun CordnCreateMembersScreen( modifier = SuggestionListDefaultHeightChat, onEmpty = { Text( - text = stringRes(R.string.cordn_info_add_member_none), + text = stringRes(Res.string.cordn_info_add_member_none), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), @@ -182,7 +198,7 @@ fun CordnCreateMembersScreen( if (user.pubkeyHex in reachable) { Icon( symbol = MaterialSymbols.Key, - contentDescription = stringRes(R.string.cordn_info_has_key_package), + contentDescription = stringRes(Res.string.cordn_info_has_key_package), modifier = Modifier.size(16.dp), tint = MaterialTheme.colorScheme.primary, ) @@ -194,7 +210,7 @@ fun CordnCreateMembersScreen( }) { Icon( symbol = MaterialSymbols.PersonAdd, - contentDescription = stringRes(R.string.cordn_create_add_member), + contentDescription = stringRes(Res.string.cordn_create_add_member), tint = MaterialTheme.colorScheme.primary, ) } @@ -206,7 +222,7 @@ fun CordnCreateMembersScreen( HorizontalDivider() Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_member_count, draft.roster.size + 1, draft.roster.size + 1), + text = pluralStringRes(Res.plurals.cordn_member_count, draft.roster.size + 1, draft.roster.size + 1), style = MaterialTheme.typography.titleSmall, ) @@ -230,7 +246,7 @@ fun CordnCreateMembersScreen( if (draft.roster.isEmpty()) { Text( - text = stringRes(R.string.cordn_create_people_empty), + text = stringRes(Res.string.cordn_create_people_empty), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -240,7 +256,7 @@ fun CordnCreateMembersScreen( onClick = { nav.popBack() }, modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp), ) { - Text(stringRes(R.string.cordn_create_people_done)) + Text(stringRes(Res.string.cordn_create_people_done)) } } } @@ -263,14 +279,14 @@ private fun CreatorRow( Column(Modifier.weight(1f)) { Text(observeUserNameByHex(me, accountViewModel), style = MaterialTheme.typography.bodyMedium) Text( - text = stringRes(R.string.cordn_create_you), + text = stringRes(Res.string.cordn_create_you), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) } if (!egalitarian) { Text( - text = stringRes(R.string.cordn_create_admin), + text = stringRes(Res.string.cordn_create_admin), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.primary, ) @@ -304,9 +320,9 @@ private fun MemberRow( Text( text = when { - answered == 0 -> stringRes(R.string.cordn_create_reach_unknown) - reaching > 0 -> pluralStringRes(LocalContext.current, R.plurals.cordn_create_reach_count, reaching, reaching) - else -> stringRes(R.string.cordn_create_reach_none) + answered == 0 -> stringRes(Res.string.cordn_create_reach_unknown) + reaching > 0 -> pluralStringRes(Res.plurals.cordn_create_reach_count, reaching, reaching) + else -> stringRes(Res.string.cordn_create_reach_none) }, style = MaterialTheme.typography.labelSmall, color = @@ -323,7 +339,7 @@ private fun MemberRow( if (!egalitarian) { TextButton(onClick = onToggleAdmin) { Text( - text = stringRes(R.string.cordn_create_admin), + text = stringRes(Res.string.cordn_create_admin), style = MaterialTheme.typography.labelMedium, color = if (isAdmin) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -333,7 +349,7 @@ private fun MemberRow( IconButton(onClick = onRemove) { Icon( symbol = MaterialSymbols.PersonRemove, - contentDescription = stringRes(R.string.cordn_info_remove_member), + contentDescription = stringRes(Res.string.cordn_info_remove_member), modifier = Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupChatScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupChatScreen.kt index 7e0e2d7a13..b884f56dbd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupChatScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupChatScreen.kt @@ -69,7 +69,6 @@ import androidx.compose.ui.unit.dp import androidx.core.content.ContextCompat import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.Amethyst -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CordnGroupManager import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols @@ -78,10 +77,33 @@ import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.back import com.vitorpamplona.amethyst.commons.resources.cancel +import com.vitorpamplona.amethyst.commons.resources.cordn_action_editing +import com.vitorpamplona.amethyst.commons.resources.cordn_action_unpin +import com.vitorpamplona.amethyst.commons.resources.cordn_chat_empty_description +import com.vitorpamplona.amethyst.commons.resources.cordn_chat_empty_title +import com.vitorpamplona.amethyst.commons.resources.cordn_group_info +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable import com.vitorpamplona.amethyst.commons.resources.cordn_group_untitled +import com.vitorpamplona.amethyst.commons.resources.cordn_media_download_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_media_no_server +import com.vitorpamplona.amethyst.commons.resources.cordn_media_unreadable +import com.vitorpamplona.amethyst.commons.resources.cordn_media_upload_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_member_count +import com.vitorpamplona.amethyst.commons.resources.cordn_message_deleted +import com.vitorpamplona.amethyst.commons.resources.cordn_pinned_by +import com.vitorpamplona.amethyst.commons.resources.cordn_pinned_count +import com.vitorpamplona.amethyst.commons.resources.cordn_pinned_next +import com.vitorpamplona.amethyst.commons.resources.cordn_pinned_previous +import com.vitorpamplona.amethyst.commons.resources.cordn_pinned_show_all +import com.vitorpamplona.amethyst.commons.resources.cordn_pinned_title +import com.vitorpamplona.amethyst.commons.resources.cordn_send_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_send_no_session +import com.vitorpamplona.amethyst.commons.resources.cordn_voice_record +import com.vitorpamplona.amethyst.commons.resources.cordn_voice_stop import com.vitorpamplona.amethyst.commons.richtext.EncryptedMediaUrlImage import com.vitorpamplona.amethyst.commons.richtext.EncryptedMediaUrlVideo import com.vitorpamplona.amethyst.commons.ui.components.EmptyState +import com.vitorpamplona.amethyst.commons.ui.loadStringRes import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText @@ -152,7 +174,7 @@ fun CordnGroupChatScreen( // (it was forgotten, or never opened) and not an error to throw at the // user as a blank screen. Column(Modifier.fillMaxSize().padding(24.dp), verticalArrangement = Arrangement.Center) { - Text(stringRes(R.string.cordn_group_unavailable), style = MaterialTheme.typography.bodyLarge) + Text(stringRes(Res.string.cordn_group_unavailable), style = MaterialTheme.typography.bodyLarge) } return } @@ -209,9 +231,9 @@ private fun CordnGroupChat( // and simply never arrived. var sendError by remember { mutableStateOf<String?>(null) } val context = LocalContext.current - val uploadFailed = stringRes(R.string.cordn_media_upload_failed) - val sendFailed = stringRes(R.string.cordn_send_failed) - val noSession = stringRes(R.string.cordn_send_no_session) + val uploadFailed = stringRes(Res.string.cordn_media_upload_failed) + val sendFailed = stringRes(Res.string.cordn_send_failed) + val noSession = stringRes(Res.string.cordn_send_no_session) fun manager() = accountViewModel.account.cordnRuntime @@ -359,8 +381,8 @@ private fun CordnGroupChat( // action that actually needed it. if (rows.isEmpty()) { EmptyState( - title = stringRes(R.string.cordn_chat_empty_title), - description = stringRes(R.string.cordn_chat_empty_description), + title = stringRes(Res.string.cordn_chat_empty_title), + description = stringRes(Res.string.cordn_chat_empty_description), modifier = Modifier.weight(1f), ) } @@ -548,7 +570,7 @@ private fun CordnGroupChat( } if (editing != null) { ComposerBanner( - label = stringRes(R.string.cordn_action_editing), + label = stringRes(Res.string.cordn_action_editing), onCancel = { editing = null room.draft.value = "" @@ -712,7 +734,7 @@ private fun PinnedRibbon( IconButton(onClick = { index = (at - 1 + pinned.size) % pinned.size }, modifier = Modifier.size(28.dp)) { Icon( symbol = MaterialSymbols.AutoMirrored.KeyboardArrowLeft, - contentDescription = stringRes(R.string.cordn_pinned_previous), + contentDescription = stringRes(Res.string.cordn_pinned_previous), modifier = Modifier.size(18.dp), ) } @@ -724,7 +746,7 @@ private fun PinnedRibbon( IconButton(onClick = { index = (at + 1) % pinned.size }, modifier = Modifier.size(28.dp)) { Icon( symbol = MaterialSymbols.AutoMirrored.KeyboardArrowRight, - contentDescription = stringRes(R.string.cordn_pinned_next), + contentDescription = stringRes(Res.string.cordn_pinned_next), modifier = Modifier.size(18.dp), ) } @@ -733,7 +755,7 @@ private fun PinnedRibbon( IconButton(onClick = { showingAll = true }, modifier = Modifier.size(28.dp)) { Icon( symbol = MaterialSymbols.AutoMirrored.List, - contentDescription = stringRes(R.string.cordn_pinned_show_all), + contentDescription = stringRes(Res.string.cordn_pinned_show_all), modifier = Modifier.size(18.dp), ) } @@ -786,7 +808,7 @@ private fun PinnedLine( // points at. text = if (annotations.isDeleted(message.envelope.id)) { - stringRes(R.string.cordn_message_deleted) + stringRes(Res.string.cordn_message_deleted) } else { annotations.contentOf(message.envelope.id).orEmpty() }, @@ -822,7 +844,7 @@ private fun AllPinnedDialog( Row(verticalAlignment = Alignment.CenterVertically) { Icon(MaterialSymbols.PushPin, contentDescription = null, modifier = Modifier.size(18.dp)) Text( - text = stringRes(R.string.cordn_pinned_title), + text = stringRes(Res.string.cordn_pinned_title), modifier = Modifier.padding(start = 8.dp), ) } @@ -830,7 +852,7 @@ private fun AllPinnedDialog( text = { Column { Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_pinned_count, pinned.size, pinned.size), + text = pluralStringRes(Res.plurals.cordn_pinned_count, pinned.size, pinned.size), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -861,7 +883,7 @@ private fun AllPinnedDialog( modifier = Modifier.weight(1f).padding(start = 8.dp), ) TextButton(onClick = { onUnpin(message) }) { - Text(stringRes(R.string.cordn_action_unpin), style = MaterialTheme.typography.labelSmall) + Text(stringRes(Res.string.cordn_action_unpin), style = MaterialTheme.typography.labelSmall) } } @@ -869,7 +891,7 @@ private fun AllPinnedDialog( Text( text = stringRes( - R.string.cordn_pinned_by, + Res.string.cordn_pinned_by, observeUserNameByHex(pinnedBy, accountViewModel), ), style = MaterialTheme.typography.labelSmall, @@ -880,7 +902,7 @@ private fun AllPinnedDialog( Text( text = if (annotations.isDeleted(message.envelope.id)) { - stringRes(R.string.cordn_message_deleted) + stringRes(Res.string.cordn_message_deleted) } else { annotations.contentOf(message.envelope.id).orEmpty() }, @@ -944,7 +966,7 @@ private fun CordnChatTopBar( Text(title, maxLines = 1, overflow = TextOverflow.Ellipsis) if (members.isNotEmpty()) { Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_member_count, members.size, members.size), + text = pluralStringRes(Res.plurals.cordn_member_count, members.size, members.size), style = MaterialTheme.typography.bodySmall, ) } @@ -963,7 +985,7 @@ private fun CordnChatTopBar( // GroupAdd rather than Info, as in Marmot: the same screen, and the thing // people come to it for is adding someone. IconButton(onClick = onInfo) { - Icon(MaterialSymbols.GroupAdd, contentDescription = stringRes(R.string.cordn_group_info)) + Icon(MaterialSymbols.GroupAdd, contentDescription = stringRes(Res.string.cordn_group_info)) } }, ) @@ -995,10 +1017,10 @@ private suspend fun sendAttachment( // a reason a person can act on. val session = accountViewModel.account.cordnRuntime?.sessionOrNull(room.coordinatorPubKey) - ?: throw CordnAttachmentException(stringRes(context, R.string.cordn_send_no_session)) + ?: throw CordnAttachmentException(loadStringRes(Res.string.cordn_send_no_session)) val group = session.manager.group(room.gid) - ?: throw CordnAttachmentException(stringRes(context, R.string.cordn_send_no_session)) + ?: throw CordnAttachmentException(loadStringRes(Res.string.cordn_send_no_session)) // The gallery inside the dialog can delete what was picked, which leaves an empty // orchestrator rather than a null one. canPost() now refuses that, but indexing it @@ -1052,14 +1074,14 @@ private suspend fun sendAttachment( val name = withContext(Dispatchers.IO) { resolveDisplayName(context, uri) } val bytes = withContext(Dispatchers.IO) { context.contentResolver.openInputStream(finalUri)?.use { it.readBytes() } } - ?: throw CordnAttachmentException(stringRes(context, R.string.cordn_media_unreadable)) + ?: throw CordnAttachmentException(loadStringRes(Res.string.cordn_media_unreadable)) // Null means the chosen host has no base URL, which is a setting the person can // change — the one failure here that is entirely actionable. val tag = CordnMediaService(accountViewModel.account) .upload(group, bytes, mime, name, context, state.selectedServer.baseUrl) - ?: throw CordnAttachmentException(stringRes(context, R.string.cordn_media_no_server)) + ?: throw CordnAttachmentException(loadStringRes(Res.string.cordn_media_no_server)) // Into the room as well, for the same reason every other send is: an // attachment of your own echoes back as an Echo and would otherwise be @@ -1140,7 +1162,7 @@ internal fun CordnAttachment( if (mediaKey == null) { Text( - text = stringRes(R.string.cordn_media_download_failed), + text = stringRes(Res.string.cordn_media_download_failed), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.error, ) @@ -1254,7 +1276,7 @@ internal fun VoiceNoteButton( ) { Icon( symbol = if (recording) MaterialSymbols.Stop else MaterialSymbols.Mic, - contentDescription = stringRes(if (recording) R.string.cordn_voice_stop else R.string.cordn_voice_record), + contentDescription = stringRes(if (recording) Res.string.cordn_voice_stop else Res.string.cordn_voice_record), // Matches the attach icon beside it; red only while recording, // which is the one state worth pulling the eye. tint = if (recording) MaterialTheme.colorScheme.error else MaterialTheme.colorScheme.placeholderText, @@ -1284,10 +1306,10 @@ private suspend fun sendVoiceNote( // note that goes nowhere and says nothing is the same bug twice. val session = accountViewModel.account.cordnRuntime?.sessionOrNull(room.coordinatorPubKey) - ?: throw CordnAttachmentException(stringRes(context, R.string.cordn_send_no_session)) + ?: throw CordnAttachmentException(loadStringRes(Res.string.cordn_send_no_session)) val group = session.manager.group(room.gid) - ?: throw CordnAttachmentException(stringRes(context, R.string.cordn_send_no_session)) + ?: throw CordnAttachmentException(loadStringRes(Res.string.cordn_send_no_session)) try { val bytes = withContext(Dispatchers.IO) { recording.file.readBytes() } @@ -1304,7 +1326,7 @@ private suspend fun sendVoiceNote( // is what makes the bubble match the preview. waveform = recording.amplitudes, ) - ?: throw CordnAttachmentException(stringRes(context, R.string.cordn_media_no_server)) + ?: throw CordnAttachmentException(loadStringRes(Res.string.cordn_media_no_server)) // Into the room as well, for the same reason every other send is: an // attachment of your own echoes back as an Echo and would otherwise be // invisible to the person who sent it. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt index 25c90c354e..b08e44b341 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt @@ -20,7 +20,6 @@ */ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.cordnGroup -import android.content.Context import android.util.Log import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.clickable @@ -58,12 +57,10 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalClipboardManager -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CordnGroupException import com.vitorpamplona.amethyst.commons.cordn.GroupExposure import com.vitorpamplona.amethyst.commons.cordn.ui.CordnExposureCard @@ -76,8 +73,58 @@ import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.back import com.vitorpamplona.amethyst.commons.resources.cancel import com.vitorpamplona.amethyst.commons.resources.copy_npub_to_clipboard +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_action_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_coordinator_silent +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_no_key_package +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_no_self_remove +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_no_welcome +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_not_a_member +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_someone +import com.vitorpamplona.amethyst.commons.resources.cordn_admin_wrong_key_package +import com.vitorpamplona.amethyst.commons.resources.cordn_create_description +import com.vitorpamplona.amethyst.commons.resources.cordn_create_name +import com.vitorpamplona.amethyst.commons.resources.cordn_exposure_close +import com.vitorpamplona.amethyst.commons.resources.cordn_exposure_open +import com.vitorpamplona.amethyst.commons.resources.cordn_group_info +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail import com.vitorpamplona.amethyst.commons.resources.cordn_group_untitled +import com.vitorpamplona.amethyst.commons.resources.cordn_info_add_member +import com.vitorpamplona.amethyst.commons.resources.cordn_info_add_member_none +import com.vitorpamplona.amethyst.commons.resources.cordn_info_add_member_note +import com.vitorpamplona.amethyst.commons.resources.cordn_info_add_member_placeholder +import com.vitorpamplona.amethyst.commons.resources.cordn_info_admin_badge +import com.vitorpamplona.amethyst.commons.resources.cordn_info_admins_kept +import com.vitorpamplona.amethyst.commons.resources.cordn_info_coordinator +import com.vitorpamplona.amethyst.commons.resources.cordn_info_coordinator_key +import com.vitorpamplona.amethyst.commons.resources.cordn_info_coordinator_nprofile +import com.vitorpamplona.amethyst.commons.resources.cordn_info_copy_nprofile +import com.vitorpamplona.amethyst.commons.resources.cordn_info_edit_details +import com.vitorpamplona.amethyst.commons.resources.cordn_info_egalitarian +import com.vitorpamplona.amethyst.commons.resources.cordn_info_epoch +import com.vitorpamplona.amethyst.commons.resources.cordn_info_gid +import com.vitorpamplona.amethyst.commons.resources.cordn_info_has_key_package +import com.vitorpamplona.amethyst.commons.resources.cordn_info_members +import com.vitorpamplona.amethyst.commons.resources.cordn_info_remove_confirm_body +import com.vitorpamplona.amethyst.commons.resources.cordn_info_remove_confirm_title +import com.vitorpamplona.amethyst.commons.resources.cordn_info_remove_member +import com.vitorpamplona.amethyst.commons.resources.cordn_info_save +import com.vitorpamplona.amethyst.commons.resources.cordn_info_technical +import com.vitorpamplona.amethyst.commons.resources.cordn_member_count +import com.vitorpamplona.amethyst.commons.resources.cordn_requests_accept +import com.vitorpamplona.amethyst.commons.resources.cordn_requests_admin_only +import com.vitorpamplona.amethyst.commons.resources.cordn_requests_check +import com.vitorpamplona.amethyst.commons.resources.cordn_requests_decline +import com.vitorpamplona.amethyst.commons.resources.cordn_requests_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_requests_none +import com.vitorpamplona.amethyst.commons.resources.cordn_requests_title +import com.vitorpamplona.amethyst.commons.resources.cordn_send_no_session +import com.vitorpamplona.amethyst.commons.resources.cordn_share_copied +import com.vitorpamplona.amethyst.commons.resources.cordn_share_copy +import com.vitorpamplona.amethyst.commons.resources.cordn_share_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_share_title import com.vitorpamplona.amethyst.commons.ui.components.EmptyState +import com.vitorpamplona.amethyst.commons.ui.loadStringRes import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.theme.SuggestionListDefaultHeightChat import com.vitorpamplona.amethyst.commons.util.toShortDisplay @@ -124,8 +171,8 @@ fun CordnGroupInfoScreen( // The app's own empty state, centred and titled, rather than a // sentence stranded in the top-left corner. EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) } @@ -151,7 +198,7 @@ private fun InfoTopBar( Icon(MaterialSymbols.AutoMirrored.ArrowBack, contentDescription = stringRes(Res.string.back)) } }, - title = { Text(stringRes(R.string.cordn_group_info)) }, + title = { Text(stringRes(Res.string.cordn_group_info)) }, actions = actions, ) } @@ -208,8 +255,8 @@ private fun CordnGroupInfo( DisposableEffect(Unit) { onDispose { userSuggestions.reset() } } - val failed = stringRes(R.string.cordn_admin_action_failed) - val noSession = stringRes(R.string.cordn_send_no_session) + val failed = stringRes(Res.string.cordn_admin_action_failed) + val noSession = stringRes(Res.string.cordn_send_no_session) // Computed, never asserted: hardcoding these made the card look like a // disclosure while reporting the same four values for every group. @@ -236,7 +283,6 @@ private fun CordnGroupInfo( * roster, and a rename stayed the old name. The runtime's own methods pair * each commit with that refresh. */ - val context = LocalContext.current fun runAdmin( who: String? = null, @@ -257,7 +303,7 @@ private fun CordnGroupInfo( // and gids in full, so the screen that had just shown a face // answered with 64 hex characters. Log.w("CordnGroupInfo", "admin action failed in ${room.gid}: ${e.message}", e) - adminError = adminFailureText(context, e, who, failed) + adminError = adminFailureText(e, who, failed) } finally { busy = false } @@ -274,7 +320,7 @@ private fun CordnGroupInfo( IconButton(onClick = { renaming = true }, enabled = !busy) { Icon( symbol = MaterialSymbols.Edit, - contentDescription = stringRes(R.string.cordn_info_edit_details), + contentDescription = stringRes(Res.string.cordn_info_edit_details), ) } } @@ -303,7 +349,7 @@ private fun CordnGroupInfo( } // A subtitle, not a labelled row above a list that is itself the count. Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_member_count, members.size, members.size), + text = pluralStringRes(Res.plurals.cordn_member_count, members.size, members.size), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(top = 4.dp), @@ -321,7 +367,7 @@ private fun CordnGroupInfo( // ContextVM addresses it with ordinary p-tags, so it has a kind 0 like // anyone else and the app can already resolve it to a name, an avatar // and a profile to tap through to. - Text(stringRes(R.string.cordn_info_coordinator), style = MaterialTheme.typography.titleMedium) + Text(stringRes(Res.string.cordn_info_coordinator), style = MaterialTheme.typography.titleMedium) Row( Modifier.fillMaxWidth().padding(top = 8.dp), @@ -347,7 +393,7 @@ private fun CordnGroupInfo( IconButton(onClick = { showExposure = true }, enabled = exposure != null) { Icon( symbol = MaterialSymbols.Info, - contentDescription = stringRes(R.string.cordn_exposure_open), + contentDescription = stringRes(Res.string.cordn_exposure_open), tint = MaterialTheme.colorScheme.onSurfaceVariant, ) } @@ -355,7 +401,7 @@ private fun CordnGroupInfo( HorizontalDivider(Modifier.padding(vertical = 16.dp)) - Text(stringRes(R.string.cordn_info_members), style = MaterialTheme.typography.titleMedium) + Text(stringRes(Res.string.cordn_info_members), style = MaterialTheme.typography.titleMedium) // Said once, and only when it is true. An empty admin set is not "none // configured" -- spec/01.md makes it permanently egalitarian, so the @@ -364,7 +410,7 @@ private fun CordnGroupInfo( // a count of them adds nothing. if (admins.isEmpty()) { Text( - text = stringRes(R.string.cordn_info_egalitarian), + text = stringRes(Res.string.cordn_info_egalitarian), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(top = 2.dp, bottom = 4.dp), @@ -385,7 +431,7 @@ private fun CordnGroupInfo( ) if (member in admins) { Text( - text = stringRes(R.string.cordn_info_admin_badge), + text = stringRes(Res.string.cordn_info_admin_badge), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.primary, ) @@ -398,7 +444,7 @@ private fun CordnGroupInfo( IconButton(onClick = { removing = member }, enabled = !busy) { Icon( symbol = MaterialSymbols.PersonRemove, - contentDescription = stringRes(R.string.cordn_info_remove_member), + contentDescription = stringRes(Res.string.cordn_info_remove_member), modifier = Modifier.size(20.dp), tint = MaterialTheme.colorScheme.error, ) @@ -476,9 +522,9 @@ private fun CordnGroupInfo( // would be a setting nobody should be nudged into. AlertDialog( onDismissRequest = { removing = null }, - title = { Text(stringRes(R.string.cordn_info_remove_confirm_title)) }, + title = { Text(stringRes(Res.string.cordn_info_remove_confirm_title)) }, text = { - Text(stringRes(R.string.cordn_info_remove_confirm_body, removingName)) + Text(stringRes(Res.string.cordn_info_remove_confirm_body, removingName)) }, confirmButton = { TextButton(onClick = { @@ -486,7 +532,7 @@ private fun CordnGroupInfo( runAdmin(removingName) { it.removeMember(coordinatorPubKey, room.gid, target) } }) { Text( - text = stringRes(R.string.cordn_info_remove_member), + text = stringRes(Res.string.cordn_info_remove_member), color = MaterialTheme.colorScheme.error, ) } @@ -518,7 +564,7 @@ private fun CordnGroupInfo( text = { CordnExposureCard(it) }, confirmButton = { TextButton(onClick = { showExposure = false }) { - Text(stringRes(R.string.cordn_exposure_close)) + Text(stringRes(Res.string.cordn_exposure_close)) } }, ) @@ -577,15 +623,15 @@ private fun CordnAddMember( OutlinedTextField( value = search, onValueChange = onSearchChange, - label = { Text(stringRes(R.string.cordn_info_add_member)) }, - placeholder = { Text(stringRes(R.string.cordn_info_add_member_placeholder)) }, + label = { Text(stringRes(Res.string.cordn_info_add_member)) }, + placeholder = { Text(stringRes(Res.string.cordn_info_add_member_placeholder)) }, singleLine = true, enabled = !busy, modifier = Modifier.fillMaxWidth(), ) Text( - text = stringRes(R.string.cordn_info_add_member_note), + text = stringRes(Res.string.cordn_info_add_member_note), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(top = 4.dp), @@ -601,7 +647,7 @@ private fun CordnAddMember( modifier = SuggestionListDefaultHeightChat, onEmpty = { Text( - text = stringRes(R.string.cordn_info_add_member_none), + text = stringRes(Res.string.cordn_info_add_member_none), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), @@ -612,7 +658,7 @@ private fun CordnAddMember( if (reachable?.contains(user.pubkeyHex) == true) { Icon( symbol = MaterialSymbols.Key, - contentDescription = stringRes(R.string.cordn_info_has_key_package), + contentDescription = stringRes(Res.string.cordn_info_has_key_package), modifier = Modifier.size(16.dp), tint = MaterialTheme.colorScheme.primary, ) @@ -620,7 +666,7 @@ private fun CordnAddMember( IconButton(onClick = { onInvite(user) }) { Icon( symbol = MaterialSymbols.PersonAdd, - contentDescription = stringRes(R.string.cordn_info_add_member), + contentDescription = stringRes(Res.string.cordn_info_add_member), tint = MaterialTheme.colorScheme.primary, ) } @@ -643,20 +689,19 @@ private fun CordnAddMember( * better than silence — and the caller has logged the throwable in full either * way. */ -private fun adminFailureText( - context: Context, +private suspend fun adminFailureText( e: Throwable, who: String?, fallback: String, ): String { - val name = who ?: stringRes(context, R.string.cordn_admin_someone) + val name = who ?: loadStringRes(Res.string.cordn_admin_someone) return when (e) { is CordnGroupException -> when (e.reason) { - CordnGroupException.Reason.NO_KEY_PACKAGE -> stringRes(context, R.string.cordn_admin_no_key_package, name) - CordnGroupException.Reason.WRONG_KEY_PACKAGE_OWNER -> stringRes(context, R.string.cordn_admin_wrong_key_package, name) - CordnGroupException.Reason.NO_WELCOME -> stringRes(context, R.string.cordn_admin_no_welcome, name) - CordnGroupException.Reason.NOT_A_MEMBER -> stringRes(context, R.string.cordn_admin_not_a_member, name) + CordnGroupException.Reason.NO_KEY_PACKAGE -> loadStringRes(Res.string.cordn_admin_no_key_package, name) + CordnGroupException.Reason.WRONG_KEY_PACKAGE_OWNER -> loadStringRes(Res.string.cordn_admin_wrong_key_package, name) + CordnGroupException.Reason.NO_WELCOME -> loadStringRes(Res.string.cordn_admin_no_welcome, name) + CordnGroupException.Reason.NOT_A_MEMBER -> loadStringRes(Res.string.cordn_admin_not_a_member, name) CordnGroupException.Reason.OTHER -> e.message ?: fallback } @@ -664,14 +709,14 @@ private fun adminFailureText( // roster and the button disagreed rather than that anyone tried. is IllegalArgumentException -> if (e.message?.contains("self-removal") == true) { - stringRes(context, R.string.cordn_admin_no_self_remove) + loadStringRes(Res.string.cordn_admin_no_self_remove) } else { e.message ?: fallback } // A coordinator that does not answer is the single commonest failure // here and says nothing useful in its own words. - is TimeoutCancellationException -> stringRes(context, R.string.cordn_admin_coordinator_silent) + is TimeoutCancellationException -> loadStringRes(Res.string.cordn_admin_coordinator_silent) else -> e.message ?: fallback } @@ -701,7 +746,7 @@ private fun TechnicalDetails( verticalAlignment = Alignment.CenterVertically, ) { Text( - text = stringRes(R.string.cordn_info_technical), + text = stringRes(Res.string.cordn_info_technical), style = MaterialTheme.typography.titleMedium, modifier = Modifier.weight(1f), ) @@ -725,22 +770,22 @@ private fun TechnicalDetails( val coordinator = remember(coordinatorPubKey) { LocalCache.getOrCreateUser(coordinatorPubKey) } CopyableKeyRow( - label = stringRes(R.string.cordn_info_coordinator_key), + label = stringRes(Res.string.cordn_info_coordinator_key), shown = coordinator.pubkeyDisplayHex(), copied = coordinator.pubkeyNpub(), copyDescription = stringRes(Res.string.copy_npub_to_clipboard), ) CopyableKeyRow( - label = stringRes(R.string.cordn_info_coordinator_nprofile), + label = stringRes(Res.string.cordn_info_coordinator_nprofile), shown = coordinator.toNProfile().toShortDisplay(6), copied = coordinator.toNProfile(), - copyDescription = stringRes(R.string.cordn_info_copy_nprofile), + copyDescription = stringRes(Res.string.cordn_info_copy_nprofile), ) SelectionContainer { Column { - InfoRow(stringRes(R.string.cordn_info_gid), gid) - InfoRow(stringRes(R.string.cordn_info_epoch), epoch.toString()) + InfoRow(stringRes(Res.string.cordn_info_gid), gid) + InfoRow(stringRes(Res.string.cordn_info_epoch), epoch.toString()) } } } @@ -835,7 +880,7 @@ private fun JoinRequests( ) { val runtime = accountViewModel.account.cordnRuntime ?: return val scope = rememberCoroutineScope() - val failed = stringRes(R.string.cordn_requests_failed) + val failed = stringRes(Res.string.cordn_requests_failed) var requests by remember { mutableStateOf<List<JoinRequest>?>(null) } var busy by remember { mutableStateOf(false) } @@ -853,15 +898,15 @@ private fun JoinRequests( } } - Text(stringRes(R.string.cordn_requests_title), style = MaterialTheme.typography.titleMedium) + Text(stringRes(Res.string.cordn_requests_title), style = MaterialTheme.typography.titleMedium) Text( - text = stringRes(R.string.cordn_requests_admin_only), + text = stringRes(Res.string.cordn_requests_admin_only), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) OutlinedButton(onClick = { scope.launch { reload() } }, enabled = !busy) { - Text(stringRes(R.string.cordn_requests_check)) + Text(stringRes(Res.string.cordn_requests_check)) } error?.let { Text(it, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.error) } @@ -870,7 +915,7 @@ private fun JoinRequests( if (loaded != null && !busy) { if (loaded.isEmpty()) { Text( - text = stringRes(R.string.cordn_requests_none), + text = stringRes(Res.string.cordn_requests_none), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -899,7 +944,7 @@ private fun JoinRequests( reload() } }) { - Text(stringRes(R.string.cordn_requests_accept)) + Text(stringRes(Res.string.cordn_requests_accept)) } TextButton(onClick = { scope.launch { @@ -911,7 +956,7 @@ private fun JoinRequests( reload() } }) { - Text(stringRes(R.string.cordn_requests_decline)) + Text(stringRes(Res.string.cordn_requests_decline)) } } } @@ -949,9 +994,9 @@ private fun ShareGroup( val clipboard = LocalClipboardManager.current var copied by remember { mutableStateOf(false) } - Text(stringRes(R.string.cordn_share_title), style = MaterialTheme.typography.titleMedium) + Text(stringRes(Res.string.cordn_share_title), style = MaterialTheme.typography.titleMedium) Text( - text = stringRes(R.string.cordn_share_explainer), + text = stringRes(Res.string.cordn_share_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -968,7 +1013,7 @@ private fun ShareGroup( }, modifier = Modifier.padding(top = 8.dp), ) { - Text(stringRes(if (copied) R.string.cordn_share_copied else R.string.cordn_share_copy)) + Text(stringRes(if (copied) Res.string.cordn_share_copied else Res.string.cordn_share_copy)) } } @@ -993,26 +1038,26 @@ private fun EditGroupDetailsDialog( AlertDialog( onDismissRequest = onDismiss, - title = { Text(stringRes(R.string.cordn_info_edit_details)) }, + title = { Text(stringRes(Res.string.cordn_info_edit_details)) }, text = { Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { OutlinedTextField( value = draftName, onValueChange = { draftName = it }, - label = { Text(stringRes(R.string.cordn_create_name)) }, + label = { Text(stringRes(Res.string.cordn_create_name)) }, singleLine = true, modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( value = draftDescription, onValueChange = { draftDescription = it }, - label = { Text(stringRes(R.string.cordn_create_description)) }, + label = { Text(stringRes(Res.string.cordn_create_description)) }, singleLine = false, modifier = Modifier.fillMaxWidth(), ) if (admins.isNotEmpty()) { Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_info_admins_kept, admins.size, admins.size), + text = pluralStringRes(Res.plurals.cordn_info_admins_kept, admins.size, admins.size), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -1024,7 +1069,7 @@ private fun EditGroupDetailsDialog( onClick = { onSave(draftName.trim(), draftDescription.trim()) }, enabled = draftName.isNotBlank(), ) { - Text(stringRes(R.string.cordn_info_save)) + Text(stringRes(Res.string.cordn_info_save)) } }, dismissButton = { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupListScreen.kt index e7a5defb33..13876ffbe1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupListScreen.kt @@ -41,10 +41,8 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CoordinatorHealth import com.vitorpamplona.amethyst.commons.cordn.ui.CoordinatorHealthRow import com.vitorpamplona.amethyst.commons.icons.symbols.Icon @@ -52,6 +50,14 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.cordnGroups.CordnGroupChatroom import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail +import com.vitorpamplona.amethyst.commons.resources.cordn_groups_count +import com.vitorpamplona.amethyst.commons.resources.cordn_groups_down_note +import com.vitorpamplona.amethyst.commons.resources.cordn_groups_manage +import com.vitorpamplona.amethyst.commons.resources.cordn_groups_none +import com.vitorpamplona.amethyst.commons.resources.cordn_groups_none_detail +import com.vitorpamplona.amethyst.commons.resources.cordn_groups_start import com.vitorpamplona.amethyst.commons.resources.cordn_groups_title import com.vitorpamplona.amethyst.commons.ui.components.EmptyState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav @@ -106,14 +112,14 @@ fun CordnGroupListScreen( IconButton(onClick = { nav.nav(Route.CordnCoordinators) }) { Icon( symbol = MaterialSymbols.Dns, - contentDescription = stringRes(R.string.cordn_groups_manage), + contentDescription = stringRes(Res.string.cordn_groups_manage), modifier = Modifier.size(22.dp), ) } IconButton(onClick = { nav.nav(Route.CordnCreateGroup) }) { Icon( symbol = MaterialSymbols.Add, - contentDescription = stringRes(R.string.cordn_groups_start), + contentDescription = stringRes(Res.string.cordn_groups_start), modifier = Modifier.size(24.dp), ) } @@ -122,8 +128,8 @@ fun CordnGroupListScreen( ) { padding -> if (runtime == null) { EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) return@Scaffold @@ -148,8 +154,8 @@ fun CordnGroupListScreen( if (sections.isEmpty()) { EmptyState( - title = stringRes(R.string.cordn_groups_none), - description = stringRes(R.string.cordn_groups_none_detail), + title = stringRes(Res.string.cordn_groups_none), + description = stringRes(Res.string.cordn_groups_none_detail), modifier = Modifier.padding(padding), ) return@Scaffold @@ -230,7 +236,7 @@ private fun CoordinatorSection( }, ) Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_groups_count, groupCount, groupCount), + text = pluralStringRes(Res.plurals.cordn_groups_count, groupCount, groupCount), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -248,7 +254,7 @@ private fun CoordinatorSection( verticalAlignment = Alignment.Top, ) { Text( - text = stringRes(R.string.cordn_groups_down_note), + text = stringRes(Res.string.cordn_groups_down_note), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.error, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt index a1292ad0e6..b145042c85 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnInvitationsScreen.kt @@ -48,16 +48,30 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.back +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail import com.vitorpamplona.amethyst.commons.resources.cordn_group_untitled +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_accept +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_decline +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_decline_warning +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_load_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_members +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_members_more +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_no_coordinators +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_none +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_refresh +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_skipped +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_title +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_unreachable +import com.vitorpamplona.amethyst.commons.resources.cordn_invitations_via import com.vitorpamplona.amethyst.commons.ui.components.EmptyState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.model.cordn.CordnInvitation @@ -69,6 +83,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.cordn.CoordinatorI import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.cordn.coordinatorDisplayName import com.vitorpamplona.amethyst.ui.stringRes import kotlinx.coroutines.launch +import org.jetbrains.compose.resources.pluralStringResource /** * Invitations to cordn groups, waiting to be answered. @@ -106,7 +121,7 @@ fun CordnInvitationsScreen( var invitations by remember { mutableStateOf<CordnInvitations?>(null) } var busy by remember { mutableStateOf(false) } var error by remember { mutableStateOf<String?>(null) } - val loadFailed = stringRes(R.string.cordn_invitations_load_failed) + val loadFailed = stringRes(Res.string.cordn_invitations_load_failed) suspend fun reload() { busy = true @@ -130,10 +145,10 @@ fun CordnInvitationsScreen( Icon(MaterialSymbols.AutoMirrored.ArrowBack, contentDescription = stringRes(Res.string.back)) } }, - title = { Text(stringRes(R.string.cordn_invitations_title)) }, + title = { Text(stringRes(Res.string.cordn_invitations_title)) }, actions = { IconButton(onClick = { scope.launch { reload() } }, enabled = !busy) { - Icon(MaterialSymbols.Refresh, contentDescription = stringRes(R.string.cordn_invitations_refresh)) + Icon(MaterialSymbols.Refresh, contentDescription = stringRes(Res.string.cordn_invitations_refresh)) } }, ) @@ -150,8 +165,8 @@ fun CordnInvitationsScreen( ) { if (runtime == null) { EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), ) return@Column } @@ -163,7 +178,7 @@ fun CordnInvitationsScreen( val coordinators by runtime.coordinators.collectAsStateWithLifecycle() Text( - text = stringRes(R.string.cordn_invitations_explainer), + text = stringRes(Res.string.cordn_invitations_explainer), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -212,7 +227,7 @@ fun CordnInvitationsScreen( NoticeCard( title = stringRes( - R.string.cordn_invitations_unreachable, + Res.string.cordn_invitations_unreachable, coordinatorDisplayName(it.coordinator.pubKey, it.coordinator.label, accountViewModel), ), detail = it.reason, @@ -225,7 +240,7 @@ fun CordnInvitationsScreen( // friend swears they sent simply does not exist here. loaded.skipped.forEach { NoticeCard( - title = stringRes(R.string.cordn_invitations_skipped), + title = stringRes(Res.string.cordn_invitations_skipped), detail = it.reason, isError = false, ) @@ -235,9 +250,9 @@ fun CordnInvitationsScreen( Text( text = if (coordinators.isEmpty()) { - stringRes(R.string.cordn_invitations_no_coordinators) + stringRes(Res.string.cordn_invitations_no_coordinators) } else { - stringRes(R.string.cordn_invitations_none) + stringRes(Res.string.cordn_invitations_none) }, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, @@ -276,7 +291,7 @@ private fun InvitationCard( // "Already in it", never "invited you" — see the screen KDoc. Text( - text = pluralStringResource(R.plurals.cordn_invitations_members, welcome.members.size, welcome.members.size), + text = pluralStringResource(Res.plurals.cordn_invitations_members, welcome.members.size, welcome.members.size), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -300,7 +315,7 @@ private fun InvitationCard( } if (welcome.members.size > MEMBER_FACES) { Text( - text = stringRes(R.string.cordn_invitations_members_more, welcome.members.size - MEMBER_FACES), + text = stringRes(Res.string.cordn_invitations_members_more, welcome.members.size - MEMBER_FACES), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -329,7 +344,7 @@ private fun InvitationCard( size = 20.dp, ) { name -> Text( - text = stringRes(R.string.cordn_invitations_via, name), + text = stringRes(Res.string.cordn_invitations_via, name), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -340,11 +355,11 @@ private fun InvitationCard( horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, ) { - Button(onClick = onAccept) { Text(stringRes(R.string.cordn_invitations_accept)) } - TextButton(onClick = onDecline) { Text(stringRes(R.string.cordn_invitations_decline)) } + Button(onClick = onAccept) { Text(stringRes(Res.string.cordn_invitations_accept)) } + TextButton(onClick = onDecline) { Text(stringRes(Res.string.cordn_invitations_decline)) } } Text( - text = stringRes(R.string.cordn_invitations_decline_warning), + text = stringRes(Res.string.cordn_invitations_decline_warning), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnMessageRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnMessageRow.kt index 189fca42a9..031512faea 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnMessageRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnMessageRow.kt @@ -55,7 +55,6 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.chats.ui.ChatDivisor import com.vitorpamplona.amethyst.commons.chats.ui.UserDisplayNameLayout import com.vitorpamplona.amethyst.commons.cordn.CordnMentions @@ -67,6 +66,24 @@ import com.vitorpamplona.amethyst.commons.model.navigation.Route import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.copied_to_clipboard import com.vitorpamplona.amethyst.commons.resources.copy_text +import com.vitorpamplona.amethyst.commons.resources.cordn_action_delete +import com.vitorpamplona.amethyst.commons.resources.cordn_action_edit +import com.vitorpamplona.amethyst.commons.resources.cordn_action_go_to_message +import com.vitorpamplona.amethyst.commons.resources.cordn_action_pin +import com.vitorpamplona.amethyst.commons.resources.cordn_action_reply +import com.vitorpamplona.amethyst.commons.resources.cordn_action_unpin +import com.vitorpamplona.amethyst.commons.resources.cordn_chat_unread_divider +import com.vitorpamplona.amethyst.commons.resources.cordn_chat_yesterday +import com.vitorpamplona.amethyst.commons.resources.cordn_delete_confirm_body +import com.vitorpamplona.amethyst.commons.resources.cordn_delete_confirm_title +import com.vitorpamplona.amethyst.commons.resources.cordn_delivery_accepted +import com.vitorpamplona.amethyst.commons.resources.cordn_message_deleted +import com.vitorpamplona.amethyst.commons.resources.cordn_message_details_coordinator +import com.vitorpamplona.amethyst.commons.resources.cordn_message_details_cursor +import com.vitorpamplona.amethyst.commons.resources.cordn_message_details_sent_at +import com.vitorpamplona.amethyst.commons.resources.cordn_message_details_title +import com.vitorpamplona.amethyst.commons.resources.cordn_message_edited +import com.vitorpamplona.amethyst.commons.resources.cordn_reactions_title import com.vitorpamplona.amethyst.commons.resources.quick_action_share import com.vitorpamplona.amethyst.commons.resources.today import com.vitorpamplona.amethyst.commons.ui.components.ClickableBox @@ -292,7 +309,7 @@ private fun CordnBubbleContents( when { text == null -> Text( - text = stringRes(R.string.cordn_message_deleted), + text = stringRes(Res.string.cordn_message_deleted), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -448,7 +465,7 @@ private fun CordnReactionDetailSheet( ) { Column(Modifier.fillMaxWidth().verticalScroll(rememberScrollState()).padding(bottom = 24.dp)) { Text( - text = stringRes(R.string.cordn_reactions_title), + text = stringRes(Res.string.cordn_reactions_title), style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(horizontal = 20.dp, vertical = 12.dp), ) @@ -519,7 +536,7 @@ internal fun CordnQuotedMessage( val body = if (annotations.isDeleted(parent.envelope.id)) { - stringRes(R.string.cordn_message_deleted) + stringRes(Res.string.cordn_message_deleted) } else { annotations.contentOf(parent.envelope.id).orEmpty() } @@ -575,7 +592,7 @@ private fun CordnQuoteActionSheet( Column(Modifier.padding(bottom = 24.dp)) { TileRow { if (onGoToMessage != null) { - ActionTile(MaterialSymbols.ArrowUpward, stringRes(R.string.cordn_action_go_to_message)) { + ActionTile(MaterialSymbols.ArrowUpward, stringRes(Res.string.cordn_action_go_to_message)) { onGoToMessage() onDismiss() } @@ -594,7 +611,7 @@ private fun CordnQuoteActionSheet( */ @Composable internal fun UnreadDivider() { - ChatDivisor(stringRes(R.string.cordn_chat_unread_divider), MaterialTheme.colorScheme.primary) + ChatDivisor(stringRes(Res.string.cordn_chat_unread_divider), MaterialTheme.colorScheme.primary) } /** @@ -618,7 +635,7 @@ private fun CordnMessageFooter( if (isPinned) { Icon( symbol = MaterialSymbols.PushPin, - contentDescription = stringRes(R.string.cordn_action_pin), + contentDescription = stringRes(Res.string.cordn_action_pin), modifier = Modifier.size(12.dp), tint = MaterialTheme.colorScheme.primary, ) @@ -627,7 +644,7 @@ private fun CordnMessageFooter( if (isEdited) { Text( - text = stringRes(R.string.cordn_message_edited), + text = stringRes(Res.string.cordn_message_edited), fontSize = Font12SP, color = MaterialTheme.colorScheme.placeholderText, maxLines = 1, @@ -658,7 +675,7 @@ private fun CordnMessageFooter( Spacer(StdHorzSpacer) Icon( symbol = MaterialSymbols.Done, - contentDescription = stringRes(R.string.cordn_delivery_accepted), + contentDescription = stringRes(Res.string.cordn_delivery_accepted), modifier = Modifier.size(12.dp), tint = MaterialTheme.colorScheme.allGoodColor, ) @@ -711,18 +728,18 @@ private fun CordnMessageDetailsSheet( verticalArrangement = Arrangement.spacedBy(6.dp), ) { Text( - text = stringRes(R.string.cordn_message_details_title), + text = stringRes(Res.string.cordn_message_details_title), style = MaterialTheme.typography.titleSmall, ) - DetailLine(stringRes(R.string.cordn_message_details_sent_at), sentAt) - DetailLine(stringRes(R.string.cordn_message_details_cursor), message.cursor.toString()) + DetailLine(stringRes(Res.string.cordn_message_details_sent_at), sentAt) + DetailLine(stringRes(Res.string.cordn_message_details_cursor), message.cursor.toString()) DetailLine( - stringRes(R.string.cordn_message_details_coordinator), + stringRes(Res.string.cordn_message_details_coordinator), coordinatorDisplayName(coordinatorPubKey, label = null, accountViewModel = accountViewModel), ) if (isMine) { Text( - text = stringRes(R.string.cordn_delivery_accepted), + text = stringRes(Res.string.cordn_delivery_accepted), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.allGoodColor, ) @@ -797,10 +814,10 @@ private fun CordnMessageActionSheet( if (confirmingDelete) { QuickActionAlertDialog( - title = stringRes(R.string.cordn_delete_confirm_title), - textContent = stringRes(R.string.cordn_delete_confirm_body), + title = stringRes(Res.string.cordn_delete_confirm_title), + textContent = stringRes(Res.string.cordn_delete_confirm_body), buttonIcon = MaterialSymbols.Delete, - buttonText = stringRes(R.string.cordn_action_delete), + buttonText = stringRes(Res.string.cordn_action_delete), onClickDoOnce = performDelete, onClickDontShowAgain = { accountViewModel.account.settings.setHideDeleteRequestDialog() @@ -843,7 +860,7 @@ private fun CordnMessageActionSheet( TileRow { if (isLive) { - ActionTile(MaterialSymbols.AutoMirrored.Chat, stringRes(R.string.cordn_action_reply)) { + ActionTile(MaterialSymbols.AutoMirrored.Chat, stringRes(Res.string.cordn_action_reply)) { onReply() onDismiss() } @@ -853,7 +870,7 @@ private fun CordnMessageActionSheet( // message rather than only on your own. ActionTile( MaterialSymbols.PushPin, - stringRes(if (isPinned) R.string.cordn_action_unpin else R.string.cordn_action_pin), + stringRes(if (isPinned) Res.string.cordn_action_unpin else Res.string.cordn_action_pin), ) { onTogglePin() onDismiss() @@ -863,11 +880,11 @@ private fun CordnMessageActionSheet( // anyone else. Hiding them here is the same rule, stated where it stops // being a surprise. if (isMine && isLive) { - ActionTile(MaterialSymbols.Edit, stringRes(R.string.cordn_action_edit)) { + ActionTile(MaterialSymbols.Edit, stringRes(Res.string.cordn_action_edit)) { onEdit() onDismiss() } - ActionTile(MaterialSymbols.Delete, stringRes(R.string.cordn_action_delete), isDestructive = true) { + ActionTile(MaterialSymbols.Delete, stringRes(Res.string.cordn_action_delete), isDestructive = true) { // A withdrawal cannot be taken back and the coordinator keeps // the ciphertext either way, so it is worth one question — // unless the account has already opted out of being asked. @@ -989,7 +1006,7 @@ internal fun DaySeparator( val label = when (day) { today -> stringRes(Res.string.today) - today.minusDays(1) -> stringRes(R.string.cordn_chat_yesterday) + today.minusDays(1) -> stringRes(Res.string.cordn_chat_yesterday) // Year included only when it is not this one: printing 2026 on every // divider all year is noise. else -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnBackupScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnBackupScreen.kt index 3560b60be6..0876d4cf5d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnBackupScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnBackupScreen.kt @@ -52,13 +52,26 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.unit.dp -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.cancel +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_contents_body +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_contents_title +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_export +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_exported +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_passphrase +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_restore +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_restore_body +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_restore_confirm_body +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_restore_confirm_title +import com.vitorpamplona.amethyst.commons.resources.cordn_backup_restored import com.vitorpamplona.amethyst.commons.resources.cordn_backup_section_export import com.vitorpamplona.amethyst.commons.resources.cordn_backup_section_passphrase import com.vitorpamplona.amethyst.commons.resources.cordn_backup_section_restore import com.vitorpamplona.amethyst.commons.resources.cordn_backup_title +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail import com.vitorpamplona.amethyst.commons.ui.components.EmptyState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton @@ -113,9 +126,9 @@ fun CordnBackupScreen( var error by remember { mutableStateOf<String?>(null) } var pendingRestore by remember { mutableStateOf<Uri?>(null) } - val exported = stringRes(R.string.cordn_backup_exported) - val restored = stringRes(R.string.cordn_backup_restored) - val failed = stringRes(R.string.cordn_backup_failed) + val exported = stringRes(Res.string.cordn_backup_exported) + val restored = stringRes(Res.string.cordn_backup_restored) + val failed = stringRes(Res.string.cordn_backup_failed) val saver = rememberLauncherForActivityResult(ActivityResultContracts.CreateDocument("application/octet-stream")) { uri -> @@ -179,8 +192,8 @@ fun CordnBackupScreen( // The app's own empty state, centred and titled, rather than a // sentence stranded in the top-left corner. EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) return@Scaffold @@ -196,7 +209,7 @@ fun CordnBackupScreen( verticalArrangement = Arrangement.spacedBy(20.dp), ) { Text( - text = stringRes(R.string.cordn_backup_explainer), + text = stringRes(Res.string.cordn_backup_explainer), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -212,7 +225,7 @@ fun CordnBackupScreen( passphrase = it error = null }, - label = { Text(stringRes(R.string.cordn_backup_passphrase)) }, + label = { Text(stringRes(Res.string.cordn_backup_passphrase)) }, visualTransformation = PasswordVisualTransformation(), // The dots are only half of it. Without the password // keyboard type the IME treats this as ordinary prose: @@ -230,9 +243,9 @@ fun CordnBackupScreen( SettingsSection(Res.string.cordn_backup_section_export) { SettingsFormBlock { - Text(stringRes(R.string.cordn_backup_contents_title), style = MaterialTheme.typography.titleSmall) + Text(stringRes(Res.string.cordn_backup_contents_title), style = MaterialTheme.typography.titleSmall) Text( - text = stringRes(R.string.cordn_backup_contents_body), + text = stringRes(Res.string.cordn_backup_contents_body), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -248,7 +261,7 @@ fun CordnBackupScreen( // Key derivation here is scrypt, which is slow on // purpose, so a greyed-out button was the only sign // anything was happening for several seconds. - BusyLabel(busy, stringRes(R.string.cordn_backup_export)) + BusyLabel(busy, stringRes(Res.string.cordn_backup_export)) } } } @@ -256,7 +269,7 @@ fun CordnBackupScreen( SettingsSection(Res.string.cordn_backup_section_restore) { SettingsFormBlock { Text( - text = stringRes(R.string.cordn_backup_restore_body), + text = stringRes(Res.string.cordn_backup_restore_body), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -266,7 +279,7 @@ fun CordnBackupScreen( enabled = !busy && passphrase.isNotBlank(), modifier = Modifier.fillMaxWidth(), ) { - BusyLabel(busy, stringRes(R.string.cordn_backup_restore)) + BusyLabel(busy, stringRes(Res.string.cordn_backup_restore)) } } } @@ -276,8 +289,8 @@ fun CordnBackupScreen( pendingRestore?.let { uri -> AlertDialog( onDismissRequest = { pendingRestore = null }, - title = { Text(stringRes(R.string.cordn_backup_restore_confirm_title)) }, - text = { Text(stringRes(R.string.cordn_backup_restore_confirm_body)) }, + title = { Text(stringRes(Res.string.cordn_backup_restore_confirm_title)) }, + text = { Text(stringRes(Res.string.cordn_backup_restore_confirm_body)) }, confirmButton = { TextButton(onClick = { pendingRestore = null @@ -302,7 +315,7 @@ fun CordnBackupScreen( } } }) { - Text(stringRes(R.string.cordn_backup_restore), color = MaterialTheme.colorScheme.error) + Text(stringRes(Res.string.cordn_backup_restore), color = MaterialTheme.colorScheme.error) } }, dismissButton = { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnCoordinatorsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnCoordinatorsScreen.kt index 01b0a3c93f..3459eec409 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnCoordinatorsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnCoordinatorsScreen.kt @@ -58,7 +58,6 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CoordinatorConfig import com.vitorpamplona.amethyst.commons.cordn.CoordinatorHealth import com.vitorpamplona.amethyst.commons.cordn.CordnCoordinatorDiscovery @@ -68,10 +67,45 @@ import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.cancel +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_add_action +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_add_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_copy_key +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_action +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_add +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_none +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_seen +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_discover_unheard +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_health_down +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_health_ok +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_health_retrying +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_health_unknown +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_identify +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_key +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_label +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_label_note +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_more +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_none +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_purge +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_purge_body +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_purge_title +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_relays_label +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_remove +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_rename import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_section_discover import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_section_manual import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_section_yours +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_server +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_server_claim +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_server_silent import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_title +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_pubkey +import com.vitorpamplona.amethyst.commons.resources.cordn_create_coordinator_relays +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail +import com.vitorpamplona.amethyst.commons.resources.cordn_info_save import com.vitorpamplona.amethyst.commons.ui.components.CrossfadeIfEnabled import com.vitorpamplona.amethyst.commons.ui.components.EmptyState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav @@ -127,8 +161,8 @@ fun CordnCoordinatorsScreen( // The app's own empty state, centred and titled, rather than a // sentence stranded in the top-left corner. EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) return@Scaffold @@ -146,7 +180,7 @@ fun CordnCoordinatorsScreen( verticalArrangement = Arrangement.spacedBy(20.dp), ) { Text( - text = stringRes(R.string.cordn_coordinators_explainer), + text = stringRes(Res.string.cordn_coordinators_explainer), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -165,7 +199,7 @@ fun CordnCoordinatorsScreen( if (coordinators.isEmpty()) { Text( - text = stringRes(R.string.cordn_coordinators_none), + text = stringRes(Res.string.cordn_coordinators_none), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -225,7 +259,7 @@ private fun CoordinatorCard( IconButton(onClick = { renaming = true }) { Icon( symbol = MaterialSymbols.Edit, - contentDescription = stringRes(R.string.cordn_coordinators_rename), + contentDescription = stringRes(Res.string.cordn_coordinators_rename), modifier = Modifier.size(18.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -264,10 +298,10 @@ private fun CoordinatorCard( // away on the clipboard, which is how a comparison is actually done. val coordinator = remember(config.pubKey) { LocalCache.getOrCreateUser(config.pubKey) } CopyableKeyRow( - label = stringRes(R.string.cordn_coordinators_key), + label = stringRes(Res.string.cordn_coordinators_key), shown = coordinator.pubkeyDisplayHex(), copied = coordinator.pubkeyNpub(), - copyDescription = stringRes(R.string.cordn_coordinators_copy_key), + copyDescription = stringRes(Res.string.cordn_coordinators_copy_key), ) // Every relay, not the first two and a count: this is the management @@ -275,7 +309,7 @@ private fun CoordinatorCard( // came here to check or to rule out. Column(verticalArrangement = Arrangement.spacedBy(2.dp)) { Text( - text = stringRes(R.string.cordn_coordinators_relays_label), + text = stringRes(Res.string.cordn_coordinators_relays_label), style = MaterialTheme.typography.labelMedium, fontWeight = FontWeight.SemiBold, ) @@ -304,10 +338,10 @@ private fun CoordinatorCard( text = info?.let { stringRes( - R.string.cordn_coordinators_server, + Res.string.cordn_coordinators_server, listOfNotNull(it.name, it.version, it.protocolVersion).joinToString(" \u00b7 "), ) - } ?: stringRes(R.string.cordn_coordinators_server_silent), + } ?: stringRes(Res.string.cordn_coordinators_server_silent), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -315,7 +349,7 @@ private fun CoordinatorCard( // Said next to it, every time, because a name on a settings // screen reads as verified and this one is not: §8.5 makes // the pubkey the identity and nothing else. - text = stringRes(R.string.cordn_coordinators_server_claim), + text = stringRes(Res.string.cordn_coordinators_server_claim), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -333,7 +367,7 @@ private fun CoordinatorCard( infoChecked = true } }) { - Text(stringRes(R.string.cordn_coordinators_identify)) + Text(stringRes(Res.string.cordn_coordinators_identify)) } Spacer(Modifier.weight(1f)) @@ -345,14 +379,14 @@ private fun CoordinatorCard( IconButton(onClick = { menuOpen = true }) { Icon( symbol = MaterialSymbols.MoreVert, - contentDescription = stringRes(R.string.cordn_coordinators_more), + contentDescription = stringRes(Res.string.cordn_coordinators_more), modifier = Modifier.size(20.dp), tint = MaterialTheme.colorScheme.onSurfaceVariant, ) } DropdownMenu(expanded = menuOpen, onDismissRequest = { menuOpen = false }) { DropdownMenuItem( - text = { Text(stringRes(R.string.cordn_coordinators_remove)) }, + text = { Text(stringRes(Res.string.cordn_coordinators_remove)) }, onClick = { menuOpen = false scope.launch { runtime.forget(config.pubKey) } @@ -361,7 +395,7 @@ private fun CoordinatorCard( DropdownMenuItem( text = { Text( - text = stringRes(R.string.cordn_coordinators_purge), + text = stringRes(Res.string.cordn_coordinators_purge), color = MaterialTheme.colorScheme.error, ) }, @@ -378,14 +412,14 @@ private fun CoordinatorCard( if (confirmingPurge) { AlertDialog( onDismissRequest = { confirmingPurge = false }, - title = { Text(stringRes(R.string.cordn_coordinators_purge_title)) }, - text = { Text(stringRes(R.string.cordn_coordinators_purge_body)) }, + title = { Text(stringRes(Res.string.cordn_coordinators_purge_title)) }, + text = { Text(stringRes(Res.string.cordn_coordinators_purge_body)) }, confirmButton = { TextButton(onClick = { confirmingPurge = false scope.launch { runtime.purge(config.pubKey) } }) { - Text(stringRes(R.string.cordn_coordinators_purge), color = MaterialTheme.colorScheme.error) + Text(stringRes(Res.string.cordn_coordinators_purge), color = MaterialTheme.colorScheme.error) } }, dismissButton = { @@ -409,10 +443,10 @@ private fun CoordinatorCard( private fun HealthLine(state: CoordinatorHealth.State) { val text = when { - state.isUnknown -> stringRes(R.string.cordn_coordinators_health_unknown) - state.isDown -> stringRes(R.string.cordn_coordinators_health_down, state.consecutiveFailures) - state.consecutiveFailures > 0 -> stringRes(R.string.cordn_coordinators_health_retrying) - else -> stringRes(R.string.cordn_coordinators_health_ok) + state.isUnknown -> stringRes(Res.string.cordn_coordinators_health_unknown) + state.isDown -> stringRes(Res.string.cordn_coordinators_health_down, state.consecutiveFailures) + state.consecutiveFailures > 0 -> stringRes(Res.string.cordn_coordinators_health_retrying) + else -> stringRes(Res.string.cordn_coordinators_health_ok) } Text( @@ -447,10 +481,10 @@ private fun DiscoverCoordinators( var result by remember { mutableStateOf<CordnCoordinatorDiscovery.Result?>(null) } var busy by remember { mutableStateOf(false) } var error by remember { mutableStateOf<String?>(null) } - val failed = stringRes(R.string.cordn_coordinators_discover_failed) + val failed = stringRes(Res.string.cordn_coordinators_discover_failed) Text( - text = stringRes(R.string.cordn_coordinators_discover_explainer), + text = stringRes(Res.string.cordn_coordinators_discover_explainer), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -475,7 +509,7 @@ private fun DiscoverCoordinators( CircularProgressIndicator(Modifier.size(16.dp), strokeWidth = 2.dp) Spacer(Modifier.width(8.dp)) } - Text(stringRes(R.string.cordn_coordinators_discover_action)) + Text(stringRes(Res.string.cordn_coordinators_discover_action)) } error?.let { Text(it, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.error) } @@ -497,11 +531,11 @@ private fun DiscoverCoordinators( Text( text = if (found.unreachable.isEmpty()) { - stringRes(R.string.cordn_coordinators_discover_none) + stringRes(Res.string.cordn_coordinators_discover_none) } else { // "Nobody is announcing" and "we were not told" are // different answers and only one of them is final. - stringRes(R.string.cordn_coordinators_discover_unheard, found.unreachable.size) + stringRes(Res.string.cordn_coordinators_discover_unheard, found.unreachable.size) }, style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, @@ -529,19 +563,19 @@ private fun RenameCoordinatorDialog( AlertDialog( onDismissRequest = onDismiss, - title = { Text(stringRes(R.string.cordn_coordinators_rename)) }, + title = { Text(stringRes(Res.string.cordn_coordinators_rename)) }, text = { Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { OutlinedTextField( value = input, onValueChange = { input = it }, - label = { Text(stringRes(R.string.cordn_coordinators_label)) }, + label = { Text(stringRes(Res.string.cordn_coordinators_label)) }, singleLine = true, modifier = Modifier.fillMaxWidth(), ) Text( // The same caution the add form gives, for the same reason. - text = stringRes(R.string.cordn_coordinators_label_note), + text = stringRes(Res.string.cordn_coordinators_label_note), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -549,7 +583,7 @@ private fun RenameCoordinatorDialog( }, confirmButton = { TextButton(onClick = { onSave(input.trim().ifEmpty { null }) }) { - Text(stringRes(R.string.cordn_info_save)) + Text(stringRes(Res.string.cordn_info_save)) } }, dismissButton = { @@ -601,7 +635,7 @@ private fun DiscoveredCard( Text( // Staleness matters more here than anywhere: the last live // survey found most announcements were months-dead demos. - text = stringRes(R.string.cordn_coordinators_discover_seen, timeAgoNoDot(offer.announcedAt).trim()), + text = stringRes(Res.string.cordn_coordinators_discover_seen, timeAgoNoDot(offer.announcedAt).trim()), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -619,7 +653,7 @@ private fun DiscoveredCard( enabled = !busy, modifier = Modifier.padding(top = 4.dp), ) { - Text(stringRes(R.string.cordn_coordinators_discover_add)) + Text(stringRes(Res.string.cordn_coordinators_discover_add)) } } } @@ -633,7 +667,7 @@ private fun AddCoordinator(runtime: CordnRuntime) { var labelInput by remember { mutableStateOf("") } var error by remember { mutableStateOf<String?>(null) } var busy by remember { mutableStateOf(false) } - val failed = stringRes(R.string.cordn_coordinators_add_failed) + val failed = stringRes(Res.string.cordn_coordinators_add_failed) val config = remember(pubKeyInput, relaysInput, labelInput) { @@ -652,7 +686,7 @@ private fun AddCoordinator(runtime: CordnRuntime) { pubKeyInput = it error = null }, - label = { Text(stringRes(R.string.cordn_create_coordinator_pubkey)) }, + label = { Text(stringRes(Res.string.cordn_create_coordinator_pubkey)) }, singleLine = true, modifier = Modifier.fillMaxWidth(), ) @@ -662,14 +696,14 @@ private fun AddCoordinator(runtime: CordnRuntime) { relaysInput = it error = null }, - label = { Text(stringRes(R.string.cordn_create_coordinator_relays)) }, + label = { Text(stringRes(Res.string.cordn_create_coordinator_relays)) }, singleLine = false, modifier = Modifier.fillMaxWidth(), ) OutlinedTextField( value = labelInput, onValueChange = { labelInput = it }, - label = { Text(stringRes(R.string.cordn_coordinators_label)) }, + label = { Text(stringRes(Res.string.cordn_coordinators_label)) }, singleLine = true, modifier = Modifier.fillMaxWidth(), ) @@ -677,7 +711,7 @@ private fun AddCoordinator(runtime: CordnRuntime) { Text( // A label is ours, never theirs. A coordinator cannot prove a name and // this one is not asked for one. - text = stringRes(R.string.cordn_coordinators_label_note), + text = stringRes(Res.string.cordn_coordinators_label_note), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -705,6 +739,6 @@ private fun AddCoordinator(runtime: CordnRuntime) { enabled = !busy && config != null, modifier = Modifier.fillMaxWidth(), ) { - Text(stringRes(R.string.cordn_coordinators_add_action)) + Text(stringRes(Res.string.cordn_coordinators_add_action)) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnKeyPackagesScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnKeyPackagesScreen.kt index 5f33e13b24..b3ebf82863 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnKeyPackagesScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnKeyPackagesScreen.kt @@ -47,14 +47,28 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CoordinatorConfig import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.cordn_coordinators_none +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_disclosure +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_explainer +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_last_resort_no +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_last_resort_yes +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_orphans +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_orphans_body +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_publish +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_publish_last_resort import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_section +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_summary import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_title +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_topup_note +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_withdraw_all +import com.vitorpamplona.amethyst.commons.resources.cordn_keypackages_withdraw_orphans import com.vitorpamplona.amethyst.commons.ui.components.EmptyState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.TopBarWithBackButton @@ -106,8 +120,8 @@ fun CordnKeyPackagesScreen( ) { padding -> if (runtime == null) { EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) return@Scaffold @@ -125,7 +139,7 @@ fun CordnKeyPackagesScreen( verticalArrangement = Arrangement.spacedBy(20.dp), ) { Text( - text = stringRes(R.string.cordn_keypackages_explainer), + text = stringRes(Res.string.cordn_keypackages_explainer), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -140,7 +154,7 @@ fun CordnKeyPackagesScreen( SettingsFormBlock { if (coordinators.isEmpty()) { Text( - text = stringRes(R.string.cordn_coordinators_none), + text = stringRes(Res.string.cordn_coordinators_none), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -169,7 +183,7 @@ private fun CoordinatorKeyPackages( var rows by remember(config.pubKey) { mutableStateOf<List<CordnKeyPackageRow>?>(null) } var busy by remember(config.pubKey) { mutableStateOf(false) } var error by remember(config.pubKey) { mutableStateOf<String?>(null) } - val failed = stringRes(R.string.cordn_keypackages_failed) + val failed = stringRes(Res.string.cordn_keypackages_failed) suspend fun reload() { busy = true @@ -204,15 +218,15 @@ private fun CoordinatorKeyPackages( val hasLastResort = loaded.any { it.lastResort } Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_keypackages_summary, single, single), + text = pluralStringRes(Res.plurals.cordn_keypackages_summary, single, single), style = MaterialTheme.typography.bodyMedium, ) Text( text = if (hasLastResort) { - stringRes(R.string.cordn_keypackages_last_resort_yes) + stringRes(Res.string.cordn_keypackages_last_resort_yes) } else { - stringRes(R.string.cordn_keypackages_last_resort_no) + stringRes(Res.string.cordn_keypackages_last_resort_no) }, style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, @@ -225,11 +239,11 @@ private fun CoordinatorKeyPackages( ) { Column(Modifier.padding(12.dp)) { Text( - text = pluralStringRes(LocalContext.current, R.plurals.cordn_keypackages_orphans, orphans.size, orphans.size), + text = pluralStringRes(Res.plurals.cordn_keypackages_orphans, orphans.size, orphans.size), style = MaterialTheme.typography.titleSmall, ) Text( - text = stringRes(R.string.cordn_keypackages_orphans_body), + text = stringRes(Res.string.cordn_keypackages_orphans_body), style = MaterialTheme.typography.bodySmall, ) TextButton(onClick = { @@ -242,7 +256,7 @@ private fun CoordinatorKeyPackages( reload() } }) { - Text(stringRes(R.string.cordn_keypackages_withdraw_orphans)) + Text(stringRes(Res.string.cordn_keypackages_withdraw_orphans)) } } } @@ -251,7 +265,7 @@ private fun CoordinatorKeyPackages( Text( // Above the buttons, because it is the part that cannot be taken // back: §8.4 makes publishing an attributable, permanent record. - text = stringRes(R.string.cordn_keypackages_disclosure), + text = stringRes(Res.string.cordn_keypackages_disclosure), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) @@ -274,7 +288,7 @@ private fun CoordinatorKeyPackages( }, enabled = !busy, ) { - Text(stringRes(R.string.cordn_keypackages_publish)) + Text(stringRes(Res.string.cordn_keypackages_publish)) } OutlinedButton( onClick = { @@ -289,7 +303,7 @@ private fun CoordinatorKeyPackages( }, enabled = !busy && !hasLastResort, ) { - Text(stringRes(R.string.cordn_keypackages_publish_last_resort)) + Text(stringRes(Res.string.cordn_keypackages_publish_last_resort)) } if (loaded.isNotEmpty()) { TextButton( @@ -305,7 +319,7 @@ private fun CoordinatorKeyPackages( }, enabled = !busy, ) { - Text(stringRes(R.string.cordn_keypackages_withdraw_all), color = MaterialTheme.colorScheme.error) + Text(stringRes(Res.string.cordn_keypackages_withdraw_all), color = MaterialTheme.colorScheme.error) } } } @@ -313,7 +327,7 @@ private fun CoordinatorKeyPackages( Text( // The rule CordnRuntime.maintainKeyPackages implements, said where // someone can see that it applies to them. - text = stringRes(R.string.cordn_keypackages_topup_note), + text = stringRes(Res.string.cordn_keypackages_topup_note), style = MaterialTheme.typography.labelSmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnLinkScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnLinkScreen.kt index 86aab6c17c..f4ac911967 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnLinkScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnLinkScreen.kt @@ -45,7 +45,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.unit.dp -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CordnLinkInspection import com.vitorpamplona.amethyst.commons.cordn.ui.CordnExposureCard import com.vitorpamplona.amethyst.commons.resources.Res @@ -60,6 +59,11 @@ import com.vitorpamplona.amethyst.commons.resources.cordn_link_no_coordinator import com.vitorpamplona.amethyst.commons.resources.cordn_link_not_joinable import com.vitorpamplona.amethyst.commons.resources.cordn_link_paste import com.vitorpamplona.amethyst.commons.resources.cordn_link_relays +import com.vitorpamplona.amethyst.commons.resources.cordn_link_request +import com.vitorpamplona.amethyst.commons.resources.cordn_link_request_disclosure +import com.vitorpamplona.amethyst.commons.resources.cordn_link_request_failed +import com.vitorpamplona.amethyst.commons.resources.cordn_link_request_sent +import com.vitorpamplona.amethyst.commons.resources.cordn_link_scan import com.vitorpamplona.amethyst.commons.resources.cordn_link_section_input import com.vitorpamplona.amethyst.commons.resources.cordn_link_title import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav @@ -102,8 +106,8 @@ fun CordnLinkScreen( var requesting by remember { mutableStateOf(false) } val runtime = accountViewModel.account.cordnRuntime val scope = rememberCoroutineScope() - val requestFailed = stringRes(R.string.cordn_link_request_failed) - val asked = stringRes(R.string.cordn_link_request_sent) + val requestFailed = stringRes(Res.string.cordn_link_request_failed) + val asked = stringRes(Res.string.cordn_link_request_sent) var scanning by remember { mutableStateOf(false) } val clipboard = LocalClipboardManager.current @@ -163,7 +167,7 @@ fun CordnLinkScreen( Text(stringResource(Res.string.cordn_link_paste)) } OutlinedButton(onClick = { scanning = true }) { - Text(stringRes(R.string.cordn_link_scan)) + Text(stringRes(Res.string.cordn_link_scan)) } if (input.isNotEmpty()) { OutlinedButton( @@ -265,7 +269,7 @@ fun CordnLinkScreen( enabled = !requesting, modifier = Modifier.fillMaxWidth(), ) { - Text(stringRes(R.string.cordn_link_request)) + Text(stringRes(Res.string.cordn_link_request)) } Text( @@ -274,7 +278,7 @@ fun CordnLinkScreen( // KeyPackage under this account's own key and tells // the coordinator this account wants into this // group, whether or not anyone ever answers (§8.4). - text = stringRes(R.string.cordn_link_request_disclosure), + text = stringRes(Res.string.cordn_link_request_disclosure), style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnMigrateScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnMigrateScreen.kt index db9b3d4d4e..6c55c2bbb0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnMigrateScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/cordn/CordnMigrateScreen.kt @@ -47,9 +47,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.cordn.CordnMigration import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable +import com.vitorpamplona.amethyst.commons.resources.cordn_group_unavailable_detail import com.vitorpamplona.amethyst.commons.resources.cordn_migrate_cancel import com.vitorpamplona.amethyst.commons.resources.cordn_migrate_cancel_desc import com.vitorpamplona.amethyst.commons.resources.cordn_migrate_code_note @@ -119,8 +120,8 @@ fun CordnMigrateScreen( ) { padding -> if (runtime == null) { EmptyState( - title = stringRes(R.string.cordn_group_unavailable), - description = stringRes(R.string.cordn_group_unavailable_detail), + title = stringRes(Res.string.cordn_group_unavailable), + description = stringRes(Res.string.cordn_group_unavailable_detail), modifier = Modifier.padding(padding), ) return@Scaffold diff --git a/amethyst/src/main/res/values-hi-rIN/strings.xml b/amethyst/src/main/res/values-hi-rIN/strings.xml index 60879f7b96..8343082ebf 100644 --- a/amethyst/src/main/res/values-hi-rIN/strings.xml +++ b/amethyst/src/main/res/values-hi-rIN/strings.xml @@ -353,322 +353,4 @@ <string name="mute_button">ध्वनि सक्रिय। मौन करने के लिए टाँकें</string> <string name="play">चलाएँ</string> <string name="pause">विराम</string> - <string name="backup_conflict_title">आपने अपना %1$s अन्य क्रमक में परिवर्तित किया</string> - <string name="backup_conflict_removed">हटाए गए (%1$s)</string> - <string name="backup_conflict_added">जोडे गए (%1$s)</string> - <string name="backup_conflict_changed">परिवर्तित (%1$s)</string> - <string name="backup_conflict_private_cleared">आपने सभी निजी (रहस्यीकृत) वस्तुओं को हटा दिया।</string> - <string name="backup_conflict_private_changed">आपने निजी (रहस्यीकृत) वस्तुओं का परिवर्तन भी किया। उनकी तुलना यहाँ नहीं की जा सकती।</string> - <string name="backup_conflict_private_added">आपने निजी (रहस्यीकृत) वस्तुओं को जोडा।</string> - <string name="backup_conflict_restore_mine">सुरक्षित संस्करण पुनःस्थापन</string> - <string name="backup_review_saved">इस यन्त्र पर</string> - <string name="backup_review_new">नया संस्करण</string> - <string name="backup_review_not_set">स्थापित नहीं</string> - <string name="backup_conflict_count_removed">%1$s हटाए गए</string> - <string name="backup_conflict_count_added">%1$s जोडे गए</string> - <string name="backup_conflict_count_changed">%1$s परिवर्तित</string> - <plurals name="backup_card_follows_dropped"> - <item quantity="one">आपने %1$d व्यक्ति का अनुगमन हटाया</item> - <item quantity="other">आपने %1$d व्यक्तियों का अनुगमन हटाए</item> - </plurals> - <string name="backup_card_accept">स्वीकार</string> - <string name="backup_review_title_updated">%1$s अद्यतनकृत</string> - <string name="backup_review_title_cleared">%1$s पारित</string> - <string name="backup_review_changed_by_other_app">अन्य क्रमक में परिवर्तित। %1$s</string> - <string name="backup_action_keep_count">रखें %1$s</string> - <string name="backup_action_restore_count">पुनःस्थापन %1$s</string> - <string name="backup_action_remute">पुनःमौन %1$s</string> - <string name="backup_action_rejoin">पुनःजुडें %1$s</string> - <string name="backup_action_restore_profile">परिचय पुनःस्थापध</string> - <string name="backup_action_restore_relays">पुनःप्रसारक पुनःस्थापन</string> - <string name="backup_review_kept_count">%1$s रखे गए</string> - <string name="backup_review_dropped_count">%1$s परित्यक्त</string> - <string name="backup_review_new_count">%1$s नए</string> - <string name="backup_review_tab_dropped">परित्यक्त। %1$s</string> - <string name="backup_review_tab_new">नए। %1$s</string> - <string name="backup_review_tab_edited">सम्पादित। %1$s</string> - <string name="backup_review_search_people">%1$s लोग खोजें</string> - <string name="backup_review_nothing_here">यहाँ कुछ नहीं</string> - <string name="backup_review_unmuted">%1$s मौनावस्था हटाए गए</string> - <string name="backup_review_unmuted_explainer">ये पुनः आपके सूचनावलियों तक अभिगम्य</string> - <string name="backup_review_newly_muted">%1$s नए मौनकृत</string> - <string name="backup_review_words_and_hashtags">शब्द तथा विषयसूचक</string> - <string name="backup_review_names_and_more">%1$s तथा %2$s अधिक</string> - <string name="backup_review_private_wiped_title">आपने सभी निजी वस्तुओं को हटा दिया</string> - <string name="backup_review_private_wiped_body">वे रहस्यीकृत हैं। इसलिए केवल आप देख सकते हैं कि वे क्या थे। पुनःस्थापन से सब लौटके आ जाएँगे।</string> - <string name="backup_review_private_added_title">आपने वस्तुओं को निजी किया</string> - <string name="backup_review_private_added_body">वे अब रहस्यीकृत हैं। जो कि सम्भाव्यतः ऊपर के सार्वजनिक वस्तुओं का गन्तव्य था।</string> - <string name="backup_review_private_changed_title">आपने निजी वस्तुओं का परिवर्तन किया</string> - <string name="backup_review_private_changed_body">वे रहस्यीकृत हैं। इसलिए उनकी तुलना यहाँ नहीं की जा सकती।</string> - <string name="backup_review_gone">चला गया</string> - <string name="backup_review_new_tag">नव्य</string> - <string name="backup_review_dropped_tag">परित्यक्त</string> - <string name="backup_review_demoted_tag">स्थानान्तरित</string> - <string name="backup_review_units_tag">इकाई</string> - <string name="backup_review_left_tag">शेष</string> - <string name="backup_review_renamed_tag">पुनःनामकृत</string> - <string name="backup_review_outbox">निर्गतपेटिका</string> - <string name="backup_review_outbox_explainer">आप जहाँ प्रकाशित करते हैं</string> - <string name="backup_review_inbox">आगतपेटिका</string> - <string name="backup_review_inbox_explainer">जहाँ अन्य आप तक अभिगमन करते हैं</string> - <string name="backup_review_key_replaced">ग्राहक कुंचिका प्रतिस्थापित</string> - <string name="backup_review_key_removed">ग्राहक कुंचिका हटाया गया</string> - <string name="backup_review_key_warning">नटज्साप आगे से इस कुंचिका से बद्ध होंगे। यदि इस यन्त्र में वह नहीं है तो आप सम्भाव्यतः उनको यहाँ नहीं चुका सकते।</string> - <string name="backup_review_left">शेष</string> - <string name="backup_review_joined">जुड गए</string> - <string name="backup_review_renamed">पुनःनामकृत</string> - <string name="backup_review_was_named">पूर्वतः %1$s था</string> - <string name="backup_action_block_again">पुनःबाधित करें %1$s को</string> - <string name="backup_action_restore_feeds">सूचनावलियाँ पुनःस्थापन</string> - <string name="backup_action_restore_topics">विषय पुनःस्थापन</string> - <string name="backup_action_restore_places">स्थल पुनःस्थापन</string> - <string name="backup_action_restore_providers">प्रदाता पुनःस्थापन</string> - <string name="backup_action_restore_wallet">धनकोष पुनःस्थापन</string> - <string name="backup_review_kept">रखे गए</string> - <string name="backup_review_receiving_tag">ग्रहण मध्य</string> - <string name="backup_review_listed_tag">सूचीबद्ध</string> - <string name="backup_review_searching_tag">खोज मध्य</string> - <string name="backup_review_storing_tag">अभिलेखन मध्य</string> - <string name="backup_review_trusted_tag">विश्वसनीय</string> - <string name="backup_review_untrusted_tag">अविश्वसनीय</string> - <string name="backup_review_unblocked">%1$s अबाधित</string> - <string name="backup_review_unblocked_explainer">अमेथिस्ट पुनः उनसे जुडेगा</string> - <string name="backup_review_no_longer_blocked">अब से बाधित नहीं</string> - <string name="backup_review_newly_blocked">नव्यतः बाधित</string> - <string name="backup_review_still_blocked">अभी भी बाधित</string> - <string name="backup_review_allowed_tag">अनुमत</string> - <string name="backup_review_moved_tag">स्थानान्तरित</string> - <string name="backup_review_feed">सूचनावली</string> - <string name="backup_review_topics_gone">विषय हटाए गए</string> - <string name="backup_review_places_gone">स्थल हटाए गए</string> - <string name="backup_review_new_count_caption">नव्य</string> - <string name="backup_review_hashtags_you_follow">विषयसूचक जिनका आप अनुगमन करते हैं</string> - <string name="backup_review_places_you_follow">स्थल जिनका आप अनुगमन करते हैं</string> - <string name="backup_review_services_changed">%2$s में से %1$s सेवाएँ परिवर्तित</string> - <string name="backup_review_services_changed_explainer">वे अब अन्य व्यक्ति से आते है। अथवा किसी से नहीं</string> - <string name="backup_review_service">सेवा</string> - <string name="backup_review_service_rank">श्रेणी</string> - <string name="backup_review_service_followers">अनुचर</string> - <string name="backup_review_service_topics">विषयसूची</string> - <string name="backup_review_trust_warning">श्रेणीयाँ तथा अनुचर गिनती तथा कचरालेख छालन जो आप देखते हैं इन प्रदाताओं से आते हैं।</string> - <plurals name="backup_review_payment_targets_gone"> - <item quantity="one">आपको भुगतान करने की %1$d विधि हटाया गया</item> - <item quantity="other">आपको भुगतान करने की %1$d विधियाँ हटाए गए</item> - </plurals> - <plurals name="backup_review_offers_gone"> - <item quantity="one">%1$d प्रस्ताव हटाया गया</item> - <item quantity="other">%1$d प्रस्ताव हटाए गए</item> - </plurals> - <string name="backup_review_payments_explainer">लोग जो आपको भुगतान करते हैं उसी को देखते हैं जो इस सूची में है।</string> - <string name="backup_review_offer">बोल्ट॰बारह प्रस्ताव</string> - <string name="backup_review_encrypted_cleared">आपने उसे रिक्त किया</string> - <string name="backup_review_encrypted_added">आपने उसे बनाया</string> - <string name="backup_review_encrypted_changed">आपने उसे परिवर्तित किया</string> - <string name="backup_review_wallet_body">आपके धनकोष के टकसाल तथा कुंचिकाएँ आपके लिए रहस्यीकृत हैं। इसलिए उनकी तुलना वस्तु प्रति वस्तु यहाँ नहीं की जा सकती। पुनःस्थापन उन्हीं को लौट डालेगा जिनका अभिलेखन इस यन्त्र ने किया।</string> - <string name="backup_review_concord_body">आपके कोंकोर्ड समुदाय आपके लिए रहस्यीकृत हैं। इसलिए उनकी तुलना यहाँ नहीं की जा सकती। पुनःस्थापन उन्हीं को लौट डालेगा जिनका अभिलेखन इस यन्त्र ने किया।</string> - <plurals name="backup_card_mutes_visible"> - <item quantity="one">आपने %1$d की मौनावस्था हटाया</item> - <item quantity="other">आपने %1$d की मौनावस्था हटाए</item> - </plurals> - <plurals name="backup_card_profile_lost_fields"> - <item quantity="one">आपने %1$d परिचय प्रपत्रस्थान हटाया</item> - <item quantity="other">आपने %1$d परिचय प्रपत्रस्थान हटाए</item> - </plurals> - <plurals name="backup_card_nip65_lost"> - <item quantity="one">आपने %1$d सार्वजनिक पुनःप्रसारक हटाया</item> - <item quantity="other">आपने %1$d सार्वजनिक पुनःप्रसारकों को हटाए</item> - </plurals> - <plurals name="backup_card_dm_relays_lost"> - <item quantity="one">आपने %1$d सीधासन्देश पुनःप्रसारक हटाया</item> - <item quantity="other">आपने %1$d सीधासन्देश पुनःप्रसारकों को हटाए</item> - </plurals> - <plurals name="backup_card_key_package_relays_lost"> - <item quantity="one">आपने %1$d समूहचर्चा कुंचिका पुनःप्रसारक हटाया</item> - <item quantity="other">आपने %1$d समूहचर्चा कुंचिका पुनःप्रसारकों को हटाए</item> - </plurals> - <plurals name="backup_card_search_relays_lost"> - <item quantity="one">आपने %1$d खोज पुनःप्रसारक हटाया</item> - <item quantity="other">आपने %1$d खोज पुनःप्रसारकों को हटाए</item> - </plurals> - <plurals name="backup_card_indexer_relays_lost"> - <item quantity="one">आपने %1$d अनुक्रमणीकार पुनःप्रसारक हटाया</item> - <item quantity="other">आपने %1$d अनुक्रमणीकार पुनःप्रसारकों को हटाए</item> - </plurals> - <plurals name="backup_card_relay_feeds_lost"> - <item quantity="one">आपने %1$d पुनःप्रसारक सूचनावली हटाया</item> - <item quantity="other">आपने %1$d पुनःप्रसारक सूचनावलियाँ हटाए</item> - </plurals> - <plurals name="backup_card_private_outbox_lost"> - <item quantity="one">आपने %1$d निजी पुनःप्रसारक हटाया</item> - <item quantity="other">आपने %1$d निजी पुनःप्रसारकों को हटाए</item> - </plurals> - <plurals name="backup_card_trusted_lost"> - <item quantity="one">आपने %1$d पुनःप्रसारक पर विश्वास करना रोक दिया</item> - <item quantity="other">आपने %1$d पुनःप्रसारकों पर विश्वास करना रोक दिए</item> - </plurals> - <plurals name="backup_card_unblocked"> - <item quantity="one">आपने %1$d पुनःप्रसारक अबाधित किया</item> - <item quantity="other">आपने %1$d पुनःप्रसारकों को अबाधित किए</item> - </plurals> - <plurals name="backup_card_leave_chats"> - <item quantity="one">आपने %1$d सार्वजनिक चर्चा छोड दिया</item> - <item quantity="other">आपने %1$d सार्वजनिक चर्चाओं को छोड दिए</item> - </plurals> - <plurals name="backup_card_leave_communities"> - <item quantity="one">आपने %1$d समुदाय छोड दिया</item> - <item quantity="other">आपने %1$d समुदायों को छोड दिए</item> - </plurals> - <plurals name="backup_card_leave_rooms"> - <item quantity="one">आपने %1$d चर्चाशाला छोड दिया</item> - <item quantity="other">आपने %1$d चर्चाशालाओं को छोड दिए</item> - </plurals> - <plurals name="backup_card_leave_groups"> - <item quantity="one">आपने %1$d समूह छोड दिया</item> - <item quantity="other">आपने %1$d समूहों को छोड दिए</item> - </plurals> - <plurals name="backup_card_feeds_removed"> - <item quantity="one">आपने %1$d इष्ट सूचनावली हटाया</item> - <item quantity="other">आपने %1$d इष्ट सूचनावलियों को हटाए</item> - </plurals> - <plurals name="backup_card_hashtags_unfollowed"> - <item quantity="one">आपने %1$d विषयसूचक का अनुगमन हटाया</item> - <item quantity="other">आपने %1$d विषयसूचकों का अनुगमन हटाए</item> - </plurals> - <plurals name="backup_card_places_unfollowed"> - <item quantity="one">आपने %1$d स्थल का अनुगमन हटाया</item> - <item quantity="other">आपने %1$d स्थलों का अनुगमन हटाए</item> - </plurals> - <plurals name="backup_card_trust_services_changed"> - <item quantity="one">आपने %1$d विश्वाससेवा प्रदाता परिवर्तित किया</item> - <item quantity="other">आपने %1$d विश्वाससेवाओं के प्रदाता को परिवर्तित किया</item> - </plurals> - <plurals name="backup_card_nutzap_mints_removed"> - <item quantity="one">आपने %1$d नटज्साप टकसाल हटाया</item> - <item quantity="other">आपने %1$d नटज्साप टकसालों को हटाए</item> - </plurals> - <plurals name="backup_card_payment_targets_removed"> - <item quantity="one">आपने %1$d भुगतान प्राप्त करने की विधि हटाया</item> - <item quantity="other">आपने %1$d भुगतान प्राप्त करने के विधियों को हटाए</item> - </plurals> - <plurals name="backup_card_offers_removed"> - <item quantity="one">आपने %1$d बोल्ट॰बारह प्रस्ताव हटाया</item> - <item quantity="other">आपने %1$d बोल्ट॰बारह प्रस्तावों को हटाए</item> - </plurals> - <plurals name="backup_card_and_added"> - <item quantity="one">%1$s तथा %2$d जोडा</item> - <item quantity="other">%1$s तथा %2$d जोडे</item> - </plurals> - <plurals name="backup_card_and_followed"> - <item quantity="one">%1$s तथा %2$d का अनुगमन किया</item> - <item quantity="other">%1$s तथा %2$d का अनुगमन किए</item> - </plurals> - <plurals name="backup_card_and_muted"> - <item quantity="one">%1$s तथा %2$d को मौनकृत किया</item> - <item quantity="other">%1$s तथा %2$d को मौनकृत किए</item> - </plurals> - <plurals name="backup_card_and_joined"> - <item quantity="one">%1$s तथा %2$d से जुडे</item> - <item quantity="other">%1$s तथा %2$d से जुडे</item> - </plurals> - <plurals name="backup_card_and_blocked"> - <item quantity="one">%1$s तथा %2$d बाधित किया</item> - <item quantity="other">%1$s तथा %2$d को बाधित किए</item> - </plurals> - <string name="backup_card_app_settings">आपके अमेथिस्ट समचरणीकृत क्रमक स्थापना विकल्पों को परिवर्तित किया गया एक अन्य क्रमक में और वह अमेथिस्ट नहीं था। इससे समस्याएँ उत्पन्न हो सकते हैं।</string> - <string name="backup_card_nutzap_key_replaced">आपने अपनी नटज्साप कुंचिका का प्रतिस्थापन किया</string> - <string name="backup_card_nutzap_key_removed">आपने अपनी नटज्साप कुंचिका को हटाया</string> - <string name="backup_card_wallet_emptied">आपने अपना काशयू धनकोष रिक्त किया</string> - <string name="backup_card_wallet_rewritten">आपने अपने काशयू धनकोष को परिवर्तित किया</string> - <string name="backup_card_concord_emptied">आपने अपनी कोंकोर्ड सूची रिक्त की</string> - <string name="backup_card_concord_rewritten">आपने अपनी कोंकोर्ड सूची का परिवर्तन किया</string> - <string name="backup_conflict_keep_new">नया संस्करण का उपयोग करें</string> - <string name="backup_conflict_relay_read_only">पठनेवशक्य</string> - <string name="backup_conflict_relay_write_only">लेखनेवशक्य</string> - <string name="backup_conflict_relay_read_write">पठन तथा लेखन</string> - <string name="backup_type_profile">परिचय</string> - <string name="backup_type_profile_explainer">आपका नाम चित्र चरित तथा भुगतान पते। जैसे सब को दिखते हैं वैसे।</string> - <string name="backup_type_follow_list">अनुचरण सूची</string> - <string name="backup_type_follow_list_explainer">निर्णय करता है किसके पत्र आपकी मुख्य सूचनावली में प्रकट होंगे।</string> - <string name="backup_type_mute_list">मौन सूची</string> - <string name="backup_type_mute_list_explainer">छिपाता है लोग शब्द विषयसूचक तथा सूत्र उन सब में से जो आप देखते हैं।</string> - <string name="backup_type_outbox_inbox_relays">सार्वजनिक पुनःप्रसारक सूची</string> - <string name="backup_type_outbox_inbox_relays_explainer">सबको बताता है आपके पत्र कहाँ प्राप्त करें तथा आपको उत्तर तथा उल्लेखों को कहाँ भेजें।</string> - <string name="backup_type_dm_relays">सीधासन्देश पुनःप्रसारक सूची</string> - <string name="backup_type_dm_relays_explainer">जहाँ अन्य आपके निजी सन्देश भेजते हैं।</string> - <string name="backup_type_key_package_relays">समूहचर्चा कुंचिका पुनःप्रसारक</string> - <string name="backup_type_key_package_relays_explainer">जहाँ अन्य उन कुंचिकाओं को प्राप्त करते हैं आपको रहस्यीकृत समूहचर्चाओं में जोडने के लिए।</string> - <string name="backup_type_search_relays">खोज पुनःप्रसारक सूची</string> - <string name="backup_type_search_relays_explainer">उपयुक्त पुनःप्रसारक जब आप खोजते हैं।</string> - <string name="backup_type_indexer_relays">अनुक्रमणीकार पुनःप्रसारक सूची</string> - <string name="backup_type_indexer_relays_explainer">पुनःप्रसारक उपयुक्त अन्य लोगों के परिचय तथा पुनःप्रसारक सूचियों को प्राप्त करने के लिए।</string> - <string name="backup_type_relay_feeds">इष्ट पुनःप्रसारक सूचनावलियाँ</string> - <string name="backup_type_relay_feeds_explainer">पुनःप्रसारक जिनका आप वीक्षण करते हैं सूचनावलियों के रूप में।</string> - <string name="backup_type_blocked_relays">बाधित पुनःप्रसारक सूची</string> - <string name="backup_type_blocked_relays_explainer">पुनःप्रसारक जिनसे यह क्रमक कभी भी संयोजन नहीं करता।</string> - <string name="backup_type_trusted_relays">विश्वसनीय पुनःप्रसारक सूची</string> - <string name="backup_type_trusted_relays_explainer">पुनःप्रसारक जिनपर आप पर्याप्त विश्वास करते हैं बिना पूछे उनसे संयोजन करने के लिए।</string> - <string name="backup_type_private_outbox_relays">निजी पुनःप्रसारक सूची</string> - <string name="backup_type_private_outbox_relays_explainer">जहाँ आपके पाण्डुलिपियाँ तथा निजी जानकारी रखे जाते हैं।</string> - <string name="backup_type_app_settings">समचरणीकृत क्रमक स्थापना विकल्प</string> - <string name="backup_type_app_settings_explainer">अमेथिस्ट स्थापना विकल्प समचरणीकृत आपके यन्त्रों में। वे रहस्यीकृत हैं। इसलिए केवल उनकी उपस्थिति की तुलना की जा सकती है।</string> - <string name="backup_type_public_chats">सार्वजनिक चर्चा सूची</string> - <string name="backup_type_public_chats_explainer">सार्वजनिक चर्चाएँ जिनसे आप जुडे।</string> - <string name="backup_type_communities">समुदाय सूची</string> - <string name="backup_type_communities_explainer">समुदाय जिनसे आप जुडे।</string> - <string name="backup_type_hashtags">अनुचरित विषयसूचक</string> - <string name="backup_type_hashtags_explainer">विषयसूचक जिससे युक्त पत्र आपकी मुख्य सूचनावली में प्रकट होंगे।</string> - <string name="backup_type_geohashes">अनुचरित स्थान</string> - <string name="backup_type_geohashes_explainer">स्थान जहाँ से पत्र आपकी मुख्य सूचनावली में प्रकट होंगे।</string> - <string name="backup_type_favorite_algo_feeds">इष्ट सूचनावली सूची</string> - <string name="backup_type_favorite_algo_feeds_explainer">कलनविध्यात्मक सूचनावलियाँ जिनको आपने अभिलेखित किया।</string> - <string name="backup_type_ephemeral_chats">अस्थायी चर्चा सूची</string> - <string name="backup_type_ephemeral_chats_explainer">अस्थायी चर्चा शालाएँ जिनसे आप जुडे।</string> - <string name="backup_type_relay_groups">समूह सूची</string> - <string name="backup_type_relay_groups_explainer">पुनःप्रसारक आधारित समूह जिनसे आप जुडे।</string> - <string name="backup_type_concord_communities">कोंकोर्ड समुदाय सूची</string> - <string name="backup_type_concord_communities_explainer">कोंकोर्ड समुदाय जिनसे आप जुडे। वे रहस्यीकृत हैं। इसलिए केवल उनकी उपस्थिति की तुलना की जा सकती है।</string> - <string name="backup_type_trust_providers">विश्वाससेवा प्रदाता सूची</string> - <string name="backup_type_trust_providers_explainer">सेवाएँ जिनपर आप विश्वास करते है आपके लिए लोगों का सत्यापन तथा श्रेणीकरण करने के लिए।</string> - <string name="backup_type_cashu_wallet">काशयू धनकोष</string> - <string name="backup_type_cashu_wallet_explainer">आपके ईकाश धनकोष स्थापना विकल्प तथा टकसाल। वे रहस्यीकृत हैं। इसलिए केवल उनकी उपस्थिति की तुलना की जा सकती है।</string> - <string name="backup_type_nutzap_info">नटज्साप प्राप्ती स्थापना विकल्प</string> - <string name="backup_type_nutzap_info_explainer">टकसाल तथा कुंचिका जिनका उपयोग अन्य करते हैं आपको नटज्साप भेजने के लिए।</string> - <string name="backup_type_payment_targets">भुगतान पते</string> - <string name="backup_type_payment_targets_explainer">विधियाँ जिनसे अन्य लोग आपको भुगतान कर सके।</string> - <string name="backup_type_bolt12_offers">बोल्ट॰बारह प्रस्ताव</string> - <string name="backup_type_bolt12_offers_explainer">लैटनिंग प्रस्ताव जिनका उपयोग करके अन्य लोग आपको भुगतान करते हैं।</string> - <string name="backup_type_other">सूची</string> - <string name="backup_type_other_explainer">इस यन्त्र पर अभिलेखित सूची।</string> - <string name="backup_entry_profile_field">परिचय प्रपत्रस्थान</string> - <string name="backup_entry_person">लोग</string> - <string name="backup_entry_hashtag">विषयसूचक</string> - <string name="backup_entry_word">शब्द</string> - <string name="backup_entry_thread">सूत्र</string> - <string name="backup_entry_public_chat">सार्वजनिक चर्चाएँ</string> - <string name="backup_entry_community">समुदाय</string> - <string name="backup_entry_algo_feed">सूचनावलियाँ</string> - <string name="backup_entry_location">स्थान</string> - <string name="backup_entry_relay">पुनःप्रसारक</string> - <string name="backup_entry_relay_group">समूह</string> - <string name="backup_entry_chat_room">चर्चा शालाएँ</string> - <string name="backup_entry_trust_provider">विश्वाससेवा प्रदाता</string> - <string name="backup_entry_mint">टकसाल</string> - <string name="backup_entry_nutzap_key">नटज्साप कुंचिकाएँ</string> - <string name="backup_entry_payment_target">भुगतान पते</string> - <string name="backup_entry_offer">प्रस्ताव</string> - <string name="backup_entry_identity_claim">सम्बन्धित व्यक्तिगण</string> - <string name="backup_entry_other">अन्य प्रविष्टियाँ</string> - <string name="backup_profile_field_name">प्रयोक्तानाम</string> - <string name="backup_profile_field_display_name">प्रदर्शन नाम</string> - <string name="backup_profile_field_about">जानकारी</string> - <string name="backup_profile_field_picture">चित्र</string> - <string name="backup_profile_field_banner">ध्वज</string> - <string name="backup_profile_field_website">जालस्थान</string> - <string name="backup_profile_field_nip05">नोस्टर पता</string> - <string name="backup_profile_field_lud16">लैटनिंग पता</string> - <string name="backup_profile_field_lud06">लैटनिंग जालपता</string> - <string name="backup_profile_field_pronouns">सर्वनाम</string> - <string name="backup_profile_field_birthday">जन्मदिन</string> - <string name="backup_profile_field_clink_offer">क्लिंक॰ प्रस्ताव</string> - <string name="backup_profile_field_bot">क्रमचर चिह्न</string> </resources> diff --git a/amethyst/src/main/res/values-hu-rHU/strings.xml b/amethyst/src/main/res/values-hu-rHU/strings.xml index e7a9da119d..37bd743202 100644 --- a/amethyst/src/main/res/values-hu-rHU/strings.xml +++ b/amethyst/src/main/res/values-hu-rHU/strings.xml @@ -353,322 +353,4 @@ <string name="mute_button">Hang bekapcsolva. Koppintson a némításhoz</string> <string name="play">Lejátszás</string> <string name="pause">Szüneteltetés</string> - <string name="backup_conflict_title">Ön módosította a következőt: %1$s, egy másik alkalmazásban</string> - <string name="backup_conflict_removed">Eltávolítva (%1$s)</string> - <string name="backup_conflict_added">Hozzáadva (%1$s)</string> - <string name="backup_conflict_changed">Módosítva (%1$s)</string> - <string name="backup_conflict_private_cleared">Ön eltávolította az összes privát (titkosított) elemet.</string> - <string name="backup_conflict_private_changed">Ön privát (titkosított) elemeket is módosított. Ezek itt nem hasonlíthatók össze.</string> - <string name="backup_conflict_private_added">Ön privát (titkosított) elemeket adott hozzá.</string> - <string name="backup_conflict_restore_mine">Mentett verzió visszaállítása</string> - <string name="backup_review_saved">Ezen az eszközön</string> - <string name="backup_review_new">Új verzió</string> - <string name="backup_review_not_set">Nincs beállítva</string> - <string name="backup_conflict_count_removed">%1$s eltávolítva</string> - <string name="backup_conflict_count_added">%1$s hozzáadva</string> - <string name="backup_conflict_count_changed">%1$s módosítva</string> - <plurals name="backup_card_follows_dropped"> - <item quantity="one">%1$d személyt nem követ többé</item> - <item quantity="other">%1$d személyt nem követ többé</item> - </plurals> - <string name="backup_card_accept">Elfogadás</string> - <string name="backup_review_title_updated">%1$s frissítve</string> - <string name="backup_review_title_cleared">%1$s törölve</string> - <string name="backup_review_changed_by_other_app">Módosítva egy másik alkalmazásban · %1$s</string> - <string name="backup_action_keep_count">%1$s megtartása</string> - <string name="backup_action_restore_count">%1$s visszaállítása</string> - <string name="backup_action_remute">%1$s újbóli némítása</string> - <string name="backup_action_rejoin">Újbóli csatlakozás ehhez: %1$s</string> - <string name="backup_action_restore_profile">Profil visszaállítása</string> - <string name="backup_action_restore_relays">Átjátszók visszaállítása</string> - <string name="backup_review_kept_count">%1$s megtartva</string> - <string name="backup_review_dropped_count">%1$s elvetve</string> - <string name="backup_review_new_count">%1$s új</string> - <string name="backup_review_tab_dropped">Elvetve · %1$s</string> - <string name="backup_review_tab_new">Új · %1$s</string> - <string name="backup_review_tab_edited">Szerkesztve · %1$s</string> - <string name="backup_review_search_people">%1$s személy keresése</string> - <string name="backup_review_nothing_here">Itt nincs semmi</string> - <string name="backup_review_unmuted">%1$s némítása feloldva</string> - <string name="backup_review_unmuted_explainer">Ezek újra megjelenhetnek a hírfolyamaiban</string> - <string name="backup_review_newly_muted">%1$s újonnan némítva</string> - <string name="backup_review_words_and_hashtags">Szavak és kulcsszavak</string> - <string name="backup_review_names_and_more">%1$s és %2$s további</string> - <string name="backup_review_private_wiped_title">Ön eltávolította az összes privát elemet</string> - <string name="backup_review_private_wiped_body">Titkosítva vannak, így csak Ön láthatja, mik voltak. A visszaállítás mindet visszahozza.</string> - <string name="backup_review_private_added_title">Ön priváttá tette az elemeket</string> - <string name="backup_review_private_added_body">Most már titkosítva vannak, valószínűleg ide kerültek a fenti nyilvános elemek.</string> - <string name="backup_review_private_changed_title">Ön módosította a privát elemeket</string> - <string name="backup_review_private_changed_body">Titkosítva vannak, így itt nem hasonlíthatók össze.</string> - <string name="backup_review_gone">Eltűnt</string> - <string name="backup_review_new_tag">Új</string> - <string name="backup_review_dropped_tag">Elvetve</string> - <string name="backup_review_demoted_tag">Áthelyezve</string> - <string name="backup_review_units_tag">Egységek</string> - <string name="backup_review_left_tag">Elhagyva</string> - <string name="backup_review_renamed_tag">Átnevezve</string> - <string name="backup_review_outbox">Kimenő</string> - <string name="backup_review_outbox_explainer">ahol közzétesz</string> - <string name="backup_review_inbox">Bejövő</string> - <string name="backup_review_inbox_explainer">ahol mások elérik Önt</string> - <string name="backup_review_key_replaced">Fogadási kulcs lecserélve</string> - <string name="backup_review_key_removed">Fogadási kulcs eltávolítva</string> - <string name="backup_review_key_warning">A nutzapok ehhez az új kulcshoz lesznek kötve. Ha ez az eszköz nem rendelkezik vele, lehet, hogy itt nem tudja beváltani őket.</string> - <string name="backup_review_left">elhagyta a csoportot</string> - <string name="backup_review_joined">csatlakozott</string> - <string name="backup_review_renamed">átnevezte</string> - <string name="backup_review_was_named">„%1$s” volt</string> - <string name="backup_action_block_again">%1$s újbóli letiltása</string> - <string name="backup_action_restore_feeds">Hírfolyamok visszaállítása</string> - <string name="backup_action_restore_topics">Témák visszaállítása</string> - <string name="backup_action_restore_places">Helyek visszaállítása</string> - <string name="backup_action_restore_providers">Szolgáltatók visszaállítása</string> - <string name="backup_action_restore_wallet">Pénztárca visszaállítása</string> - <string name="backup_review_kept">megtartva</string> - <string name="backup_review_receiving_tag">Fogadás</string> - <string name="backup_review_listed_tag">Listázva</string> - <string name="backup_review_searching_tag">Keresés</string> - <string name="backup_review_storing_tag">Tárolás</string> - <string name="backup_review_trusted_tag">Megbízható</string> - <string name="backup_review_untrusted_tag">Nem megbízható</string> - <string name="backup_review_unblocked">%1$s letiltása feloldva</string> - <string name="backup_review_unblocked_explainer">Az Amethyst újra kapcsolódni fog hozzájuk</string> - <string name="backup_review_no_longer_blocked">Már nincs letiltva</string> - <string name="backup_review_newly_blocked">Újonnan letiltva</string> - <string name="backup_review_still_blocked">Továbbra is le van tiltva</string> - <string name="backup_review_allowed_tag">Engedélyezve</string> - <string name="backup_review_moved_tag">Áthelyezve</string> - <string name="backup_review_feed">Hírfolyam</string> - <string name="backup_review_topics_gone">eltűnt témák</string> - <string name="backup_review_places_gone">eltűnt helyek</string> - <string name="backup_review_new_count_caption">új</string> - <string name="backup_review_hashtags_you_follow">Ön által követett kulcsszavak</string> - <string name="backup_review_places_you_follow">Ön által követett helyek</string> - <string name="backup_review_services_changed">%2$s szolgáltatásból %1$s módosult</string> - <string name="backup_review_services_changed_explainer">Most már valaki mástól vagy senkitől sem származnak</string> - <string name="backup_review_service">Szolgáltatás</string> - <string name="backup_review_service_rank">Rang</string> - <string name="backup_review_service_followers">Követők</string> - <string name="backup_review_service_topics">Témák</string> - <string name="backup_review_trust_warning">A látott rangok, követőszámok és a kéretlen tartalomszűrés ezektől a szolgáltatóktól származnak.</string> - <plurals name="backup_review_payment_targets_gone"> - <item quantity="one">%1$d fizetési mód eltávolítva</item> - <item quantity="other">%1$d fizetési mód eltávolítva</item> - </plurals> - <plurals name="backup_review_offers_gone"> - <item quantity="one">%1$d ajánlat eltávolítva</item> - <item quantity="other">%1$d ajánlat eltávolítva</item> - </plurals> - <string name="backup_review_payments_explainer">A fizető emberek csak azt látják, ami ebben a listában van.</string> - <string name="backup_review_offer">BOLT12 ajánlat</string> - <string name="backup_review_encrypted_cleared">Ön kiürítette</string> - <string name="backup_review_encrypted_added">Ön hozta létre</string> - <string name="backup_review_encrypted_changed">Ön módosította</string> - <string name="backup_review_wallet_body">A saját pénztárca pénzverdéi és kulcsai Önhöz vannak titkosítva, így itt nem hasonlíthatók össze tételesen. A visszaállítás pontosan azt hozza vissza, amit ez az eszköz mentett.</string> - <string name="backup_review_concord_body">A Concord közösségei Önhöz vannak titkosítva, így itt nem hasonlíthatók össze. A visszaállítás pontosan azt hozza vissza, amit ez az eszköz mentett.</string> - <plurals name="backup_card_mutes_visible"> - <item quantity="one">Ön %1$d dolog némítását oldotta fel</item> - <item quantity="other">%1$d dolog némítását oldotta fel</item> - </plurals> - <plurals name="backup_card_profile_lost_fields"> - <item quantity="one">Ön %1$d profilmezőt távolított el</item> - <item quantity="other">%1$d profilmezőt távolított el</item> - </plurals> - <plurals name="backup_card_nip65_lost"> - <item quantity="one">Ön %1$d nyilvános átjátszót távolított el</item> - <item quantity="other">%1$d nyilvános átjátszót távolított el</item> - </plurals> - <plurals name="backup_card_dm_relays_lost"> - <item quantity="one">Ön %1$d privát üzenetátjátszót távolított el</item> - <item quantity="other">%1$d privát üzenet átjátszót távolított el</item> - </plurals> - <plurals name="backup_card_key_package_relays_lost"> - <item quantity="one">Ön %1$d csoportos csevegési kulcsátjátszót távolított el</item> - <item quantity="other">%1$d csoportcsevegés kulcs átjátszót távolított el</item> - </plurals> - <plurals name="backup_card_search_relays_lost"> - <item quantity="one">Ön %1$d kereső átjátszót távolított el</item> - <item quantity="other">%1$d kereső átjátszót távolított el</item> - </plurals> - <plurals name="backup_card_indexer_relays_lost"> - <item quantity="one">Ön %1$d indexelő átjátszót távolított el</item> - <item quantity="other">%1$d indexelő átjátszót távolított el</item> - </plurals> - <plurals name="backup_card_relay_feeds_lost"> - <item quantity="one">Ön %1$d átjátszó-hírfolyamot távolított el</item> - <item quantity="other">%1$d átjátszó hírfolyamot távolított el</item> - </plurals> - <plurals name="backup_card_private_outbox_lost"> - <item quantity="one">Ön %1$d privát átjátszót távolított el</item> - <item quantity="other">%1$d privát átjátszót távolított el</item> - </plurals> - <plurals name="backup_card_trusted_lost"> - <item quantity="one">Ön %1$d átjátszóban nem bízik többé</item> - <item quantity="other">%1$d átjátszóban nem bízik többé</item> - </plurals> - <plurals name="backup_card_unblocked"> - <item quantity="one">Ön %1$d átjátszó letiltását oldotta fel</item> - <item quantity="other">%1$d átjátszó blokkolását oldotta fel</item> - </plurals> - <plurals name="backup_card_leave_chats"> - <item quantity="one">Ön %1$d nyilvános csevegést hagyott el</item> - <item quantity="other">%1$d nyilvános csevegést hagyott el</item> - </plurals> - <plurals name="backup_card_leave_communities"> - <item quantity="one">Ön %1$d közösséget hagyott el</item> - <item quantity="other">%1$d közösséget hagyott el</item> - </plurals> - <plurals name="backup_card_leave_rooms"> - <item quantity="one">Ön %1$d csevegőszobát hagyott el</item> - <item quantity="other">%1$d csevegőszobát hagyott el</item> - </plurals> - <plurals name="backup_card_leave_groups"> - <item quantity="one">Ön %1$d csoportot hagyott el</item> - <item quantity="other">%1$d csoportot hagyott el</item> - </plurals> - <plurals name="backup_card_feeds_removed"> - <item quantity="one">Ön %1$d kedvenc hírfolyamot távolított el</item> - <item quantity="other">%1$d kedvenc hírfolyamot távolított el</item> - </plurals> - <plurals name="backup_card_hashtags_unfollowed"> - <item quantity="one">Ön %1$d kulcsszót nem követ többé</item> - <item quantity="other">%1$d hashtaget nem követ többé</item> - </plurals> - <plurals name="backup_card_places_unfollowed"> - <item quantity="one">Ön %1$d helyet nem követ többé</item> - <item quantity="other">%1$d helyet nem követ többé</item> - </plurals> - <plurals name="backup_card_trust_services_changed"> - <item quantity="one">Ön %1$d bizalmi szolgáltatás szolgáltatóját módosította</item> - <item quantity="other">%1$d bizalmi szolgáltatás szolgáltatóját változtatta meg</item> - </plurals> - <plurals name="backup_card_nutzap_mints_removed"> - <item quantity="one">Ön %1$d nutzap pénzverdét távolított el</item> - <item quantity="other">%1$d nutzap pénzverdét távolított el</item> - </plurals> - <plurals name="backup_card_payment_targets_removed"> - <item quantity="one">Ön %1$d fizetési módot távolított el</item> - <item quantity="other">%1$d fizetési módot távolított el</item> - </plurals> - <plurals name="backup_card_offers_removed"> - <item quantity="one">Ön %1$d BOLT12 ajánlatot távolított el</item> - <item quantity="other">%1$d BOLT12 ajánlatot távolított el</item> - </plurals> - <plurals name="backup_card_and_added"> - <item quantity="one">%1$s és %2$d hozzáadva</item> - <item quantity="other">%1$s és %2$d hozzáadva</item> - </plurals> - <plurals name="backup_card_and_followed"> - <item quantity="one">%1$s és %2$d követve</item> - <item quantity="other">%1$s és %2$d követve</item> - </plurals> - <plurals name="backup_card_and_muted"> - <item quantity="one">%1$s és %2$d némítva</item> - <item quantity="other">%1$s és %2$d némítva</item> - </plurals> - <plurals name="backup_card_and_joined"> - <item quantity="one">%1$s és %2$d csatlakozva</item> - <item quantity="other">%1$s és %2$d csatlakozva</item> - </plurals> - <plurals name="backup_card_and_blocked"> - <item quantity="one">%1$s és %2$d letiltva</item> - <item quantity="other">%1$s és %2$d letiltva</item> - </plurals> - <string name="backup_card_app_settings">A szinkronizált Amethyst alkalmazásbeállításai egy másik, nem Amethyst alkalmazásban módosultak. Ez problémákat okozhat.</string> - <string name="backup_card_nutzap_key_replaced">Ön lecserélte a nutzap kulcsát</string> - <string name="backup_card_nutzap_key_removed">Ön eltávolította a nutzap kulcsát</string> - <string name="backup_card_wallet_emptied">Ön kiürítette a Cashu pénztárcáját</string> - <string name="backup_card_wallet_rewritten">Ön módosította a Cashu pénztárcáját</string> - <string name="backup_card_concord_emptied">Ön kiürítette a Concord listáját</string> - <string name="backup_card_concord_rewritten">Ön módosította a Concord listáját</string> - <string name="backup_conflict_keep_new">Új verzió használata</string> - <string name="backup_conflict_relay_read_only">csak olvasható</string> - <string name="backup_conflict_relay_write_only">csak írható</string> - <string name="backup_conflict_relay_read_write">olvasás és írás</string> - <string name="backup_type_profile">profil</string> - <string name="backup_type_profile_explainer">Az Ön neve, képe, bemutatkozása és fizetési címei, ahogy mindenki látja őket.</string> - <string name="backup_type_follow_list">követési lista</string> - <string name="backup_type_follow_list_explainer">Meghatározza, kinek a bejegyzései jelenjenek meg a kezdőlapon.</string> - <string name="backup_type_mute_list">némítási lista</string> - <string name="backup_type_mute_list_explainer">Elrejti a személyeket, szavakat, kulcsszavakat és beszélgetéseket mindenből, amit lát.</string> - <string name="backup_type_outbox_inbox_relays">nyilvános átjátszólista</string> - <string name="backup_type_outbox_inbox_relays_explainer">Megmondja mindenkinek, hol találhatók a bejegyzései, és hová küldjék a válaszokat és említéseket.</string> - <string name="backup_type_dm_relays">privát üzenet átjátszólista</string> - <string name="backup_type_dm_relays_explainer">Ahová mások kézbesítik a privát üzeneteit.</string> - <string name="backup_type_key_package_relays">csoportos csevegési kulcsátjátszók</string> - <string name="backup_type_key_package_relays_explainer">Ahol mások megtalálják a kulcsokat, hogy titkosított csoportos csevegésekhez adhassák Önt.</string> - <string name="backup_type_search_relays">kereső átjátszólista</string> - <string name="backup_type_search_relays_explainer">Kereséskor használt átjátszók.</string> - <string name="backup_type_indexer_relays">indexelő átjátszólista</string> - <string name="backup_type_indexer_relays_explainer">Azok az átjátszók, amelyeket mások profiljainak és átjátszólistáinak megtalálásához használnak.</string> - <string name="backup_type_relay_feeds">kedvenc átjátszóhírfolyamok</string> - <string name="backup_type_relay_feeds_explainer">Olyan átjátszók, amelyeket hírfolyamként böngész.</string> - <string name="backup_type_blocked_relays">letiltott átjátszólista</string> - <string name="backup_type_blocked_relays_explainer">Átjátszók, amelyekhez ez az alkalmazás soha nem kapcsolódik.</string> - <string name="backup_type_trusted_relays">megbízható átjátszólista</string> - <string name="backup_type_trusted_relays_explainer">Átjátszók, amelyekhez kérdezés nélkül kapcsolódhat.</string> - <string name="backup_type_private_outbox_relays">privát átjátszólista</string> - <string name="backup_type_private_outbox_relays_explainer">Ahol a piszkozatai és privát adatai tárolódnak.</string> - <string name="backup_type_app_settings">szinkronizált alkalmazásbeállítások</string> - <string name="backup_type_app_settings_explainer">Az eszközök között szinkronizált Amethyst-beállítások. Titkosítva vannak, így csak a jelenlétük hasonlítható össze.</string> - <string name="backup_type_public_chats">nyilvános csevegési lista</string> - <string name="backup_type_public_chats_explainer">Nyilvános csevegések, amelyekhez csatlakozott.</string> - <string name="backup_type_communities">közösséglista</string> - <string name="backup_type_communities_explainer">Közösségek, amelyekhez csatlakozott.</string> - <string name="backup_type_hashtags">követett kulcsszavak</string> - <string name="backup_type_hashtags_explainer">Kulcsszavak, amelyek bejegyzései megjelennek a hírfolyamban.</string> - <string name="backup_type_geohashes">követett helyek</string> - <string name="backup_type_geohashes_explainer">Helyek, amelyek bejegyzései megjelennek a hírfolyamaiban.</string> - <string name="backup_type_favorite_algo_feeds">kedvenc hírfolyamlista</string> - <string name="backup_type_favorite_algo_feeds_explainer">Mentett algoritmus-hírfolyamok.</string> - <string name="backup_type_ephemeral_chats">rövid életű csevegési lista</string> - <string name="backup_type_ephemeral_chats_explainer">Rövid életű csevegőszobák, amelyekhez csatlakozott.</string> - <string name="backup_type_relay_groups">csoportlista</string> - <string name="backup_type_relay_groups_explainer">Átjátszó-alapú csoportok, amelyekhez csatlakozott.</string> - <string name="backup_type_concord_communities">Concord közösséglista</string> - <string name="backup_type_concord_communities_explainer">A Concord közösségek, amelyekhez csatlakozott. Titkosítva vannak, így csak a jelenlétük hasonlítható össze.</string> - <string name="backup_type_trust_providers">bizalmi szolgáltatólista</string> - <string name="backup_type_trust_providers_explainer">A szolgáltatások, amelyekben megbízik, hogy rangsorolják és ellenőrizzék Önnek az embereket.</string> - <string name="backup_type_cashu_wallet">Cashu pénztárca</string> - <string name="backup_type_cashu_wallet_explainer">Az ecash pénztárca beállításai és pénzverdéi. Titkosítva vannak, így csak a jelenlétük hasonlítható össze.</string> - <string name="backup_type_nutzap_info">nutzap fogadási beállítások</string> - <string name="backup_type_nutzap_info_explainer">A pénzverdék és a kulcs, amelyeket mások a nutzapok küldéséhez használnak az Ön számára.</string> - <string name="backup_type_payment_targets">fizetési címek</string> - <string name="backup_type_payment_targets_explainer">A módok, ahogy mások fizethetnek Önnek.</string> - <string name="backup_type_bolt12_offers">BOLT12 ajánlatok</string> - <string name="backup_type_bolt12_offers_explainer">A lightning ajánlatok, amelyeket mások a fizetéshez használnak az Ön számára.</string> - <string name="backup_type_other">lista</string> - <string name="backup_type_other_explainer">Egy listaelem ezen az eszközön mentve.</string> - <string name="backup_entry_profile_field">Profilmezők</string> - <string name="backup_entry_person">Személyek</string> - <string name="backup_entry_hashtag">Kulcsszavak</string> - <string name="backup_entry_word">Szavak</string> - <string name="backup_entry_thread">Beszélgetések</string> - <string name="backup_entry_public_chat">Nyilvános csevegések</string> - <string name="backup_entry_community">Közösségek</string> - <string name="backup_entry_algo_feed">Hírfolyamok</string> - <string name="backup_entry_location">Helyek</string> - <string name="backup_entry_relay">Átjátszók</string> - <string name="backup_entry_relay_group">Csoportok</string> - <string name="backup_entry_chat_room">Csevegőszobák</string> - <string name="backup_entry_trust_provider">Bizalmi szolgáltatók</string> - <string name="backup_entry_mint">Pénzverdék</string> - <string name="backup_entry_nutzap_key">Nutzap kulcsok</string> - <string name="backup_entry_payment_target">Fizetési címek</string> - <string name="backup_entry_offer">Ajánlatok</string> - <string name="backup_entry_identity_claim">Kapcsolt identitások</string> - <string name="backup_entry_other">Egyéb bejegyzések</string> - <string name="backup_profile_field_name">Felhasználónév</string> - <string name="backup_profile_field_display_name">Megjelenített név</string> - <string name="backup_profile_field_about">Névjegy</string> - <string name="backup_profile_field_picture">Kép</string> - <string name="backup_profile_field_banner">Borító</string> - <string name="backup_profile_field_website">Weboldal</string> - <string name="backup_profile_field_nip05">Nostr-cím</string> - <string name="backup_profile_field_lud16">Lightning-cím</string> - <string name="backup_profile_field_lud06">LNURL</string> - <string name="backup_profile_field_pronouns">Névmások</string> - <string name="backup_profile_field_birthday">Születésnap</string> - <string name="backup_profile_field_clink_offer">CLINK-ajánlat</string> - <string name="backup_profile_field_bot">Bot jelölő</string> </resources> diff --git a/amethyst/src/main/res/values-pl-rPL/strings.xml b/amethyst/src/main/res/values-pl-rPL/strings.xml index 601165a320..eda8c8fe1a 100644 --- a/amethyst/src/main/res/values-pl-rPL/strings.xml +++ b/amethyst/src/main/res/values-pl-rPL/strings.xml @@ -381,382 +381,4 @@ <string name="mute_button">Dźwięk włączony. Kliknij, aby wyciszyć</string> <string name="play">Odtwórz</string> <string name="pause">Pauza</string> - <string name="backup_conflict_title">Zmieniłeś %1$s w innej aplikacji</string> - <string name="backup_conflict_removed">Usunięto (%1$s)</string> - <string name="backup_conflict_added">Dodano (%1$s)</string> - <string name="backup_conflict_changed">Zmieniono (%1$s)</string> - <string name="backup_conflict_private_cleared">Usunąłeś wszystkie prywatne (zaszyfrowane) elementy.</string> - <string name="backup_conflict_private_changed">Zmieniłeś również elementy prywatne (zaszyfrowane). Nie można ich tutaj porównać.</string> - <string name="backup_conflict_private_added">Dodano prywatne (zaszyfrowane) pozycje.</string> - <string name="backup_conflict_restore_mine">Przywróć zapisaną wersję</string> - <string name="backup_review_saved">Na tym urządzeniu</string> - <string name="backup_review_new">Nowa wersja</string> - <string name="backup_review_not_set">Nie ustawiono</string> - <string name="backup_conflict_count_removed">Usunięto %1$s</string> - <string name="backup_conflict_count_added">Dodano %1$s</string> - <string name="backup_conflict_count_changed">%1$s zmieniono</string> - <plurals name="backup_card_follows_dropped"> - <item quantity="one">Przestałeś obserwować %1$d osobę</item> - <item quantity="few">Przestałeś obserwować %1$d osób</item> - <item quantity="many">Przestałeś obserwować %1$d osób</item> - <item quantity="other">Przestałeś obserwować %1$d osoby</item> - </plurals> - <string name="backup_card_accept">Zaakceptuj</string> - <string name="backup_review_title_updated">%1$s zaktualizowano</string> - <string name="backup_review_title_cleared">%1$s wyczyszczono</string> - <string name="backup_review_changed_by_other_app">Zmieniono w innej aplikacji · %1$s</string> - <string name="backup_action_keep_count">Zachowaj %1$s</string> - <string name="backup_action_restore_count">Przywróć %1$s</string> - <string name="backup_action_remute">Ponownie wycisz %1$s</string> - <string name="backup_action_rejoin">Ponów %1$s</string> - <string name="backup_action_restore_profile">Przywróć profil</string> - <string name="backup_action_restore_relays">Przywróć transmitery</string> - <string name="backup_review_kept_count">Zachowano %1$s</string> - <string name="backup_review_dropped_count">%1$s odrzuconych</string> - <string name="backup_review_new_count">%1$s nowych</string> - <string name="backup_review_tab_dropped">Usunięte · %1$s</string> - <string name="backup_review_tab_new">Nowe · %1$s</string> - <string name="backup_review_tab_edited">Edytowane · %1$s</string> - <string name="backup_review_search_people">Szukaj %1$s osób</string> - <string name="backup_review_nothing_here">Nic tu nie ma!</string> - <string name="backup_review_unmuted">%1$s odblokowanych</string> - <string name="backup_review_unmuted_explainer">Mogą one ponownie pojawić się w Twoich informacjach</string> - <string name="backup_review_newly_muted">%1$s nowo wyciszonych</string> - <string name="backup_review_words_and_hashtags">Wyrazy & hasztagi</string> - <string name="backup_review_names_and_more">%1$s i %2$s więcej</string> - <string name="backup_review_private_wiped_title">Usunąłeś wszystkie prywatne elementy</string> - <string name="backup_review_private_wiped_body">Są zaszyfrowane, więc tylko Ty możesz zobaczyć, co to było. Odtworzenie przywróci je wszystkie.</string> - <string name="backup_review_private_added_title">Ustawiłeś te pozycje jako prywatne</string> - <string name="backup_review_private_added_body">Są teraz zaszyfrowane, co prawdopodobnie wyjaśnia, gdzie podziały się powyższe elementy publiczne.</string> - <string name="backup_review_private_changed_title">Zmieniłeś prywatne elementy</string> - <string name="backup_review_private_changed_body">Są zaszyfrowane, więc nie można ich tu porównać.</string> - <string name="backup_review_gone">Zniknęła</string> - <string name="backup_review_new_tag">Nowa</string> - <string name="backup_review_dropped_tag">Usunięta</string> - <string name="backup_review_demoted_tag">Przeniesiona</string> - <string name="backup_review_units_tag">Jednostek</string> - <string name="backup_review_left_tag">Zostało</string> - <string name="backup_review_renamed_tag">Zmieniono nazwę</string> - <string name="backup_review_outbox">Skrzynka nadawcza</string> - <string name="backup_review_outbox_explainer">gdzie publikujesz</string> - <string name="backup_review_inbox">Skrzynka odbiorcza</string> - <string name="backup_review_inbox_explainer">gdzie inni docierają do Ciebie</string> - <string name="backup_review_key_replaced">Wymieniono klucz odbierający</string> - <string name="backup_review_key_removed">Usunięto klucz odbierający</string> - <string name="backup_review_key_warning">Nutzapy zostaną przypisane do tego nowego klucza. Jeśli urządzenie nie posiada tego klucza, może się okazać, że nie będzie można ich tutaj zrealizować.</string> - <string name="backup_review_left">zostało</string> - <string name="backup_review_joined">dołączył(a)</string> - <string name="backup_review_renamed">zmieniono nazwę</string> - <string name="backup_review_was_named">było „%1$s”</string> - <string name="backup_action_block_again">Zablokuj %1$s ponownie</string> - <string name="backup_action_restore_feeds">Przywróć kanały</string> - <string name="backup_action_restore_topics">Przywróć tematy</string> - <string name="backup_action_restore_places">Przywróć miejsca</string> - <string name="backup_action_restore_providers">Przywróć dostawców</string> - <string name="backup_action_restore_wallet">Przywróć portfel</string> - <string name="backup_review_kept">zachowane</string> - <string name="backup_review_receiving_tag">Pobieranie</string> - <string name="backup_review_listed_tag">Na Liście</string> - <string name="backup_review_searching_tag">Szukam</string> - <string name="backup_review_storing_tag">Przechowywanie</string> - <string name="backup_review_trusted_tag">Zaufane</string> - <string name="backup_review_untrusted_tag">Niezaufane</string> - <string name="backup_review_unblocked">%1$s odblokowane</string> - <string name="backup_review_unblocked_explainer">Ametyst ponownie połączy się z nimi</string> - <string name="backup_review_no_longer_blocked">Nie jest już zablokowana</string> - <string name="backup_review_newly_blocked">Nowo zablokowana</string> - <string name="backup_review_still_blocked">Nadal zablokowana</string> - <string name="backup_review_allowed_tag">Dozwolona</string> - <string name="backup_review_moved_tag">Przeniesiona</string> - <string name="backup_review_feed">Kanał</string> - <string name="backup_review_topics_gone">tematy zniknęły</string> - <string name="backup_review_places_gone"> miejsca zniknęły</string> - <string name="backup_review_new_count_caption">nowe</string> - <string name="backup_review_hashtags_you_follow">Hashtagi, które obserwujesz</string> - <string name="backup_review_places_you_follow">Miejsca które obserwujesz</string> - <string name="backup_review_services_changed">Zmieniono %1$s z %2$s serwisów</string> - <string name="backup_review_services_changed_explainer">Teraz pochodzą od kogoś innego albo od nikogo</string> - <string name="backup_review_service">Serwis</string> - <string name="backup_review_service_rank">Ranking</string> - <string name="backup_review_service_followers">Obserwujący</string> - <string name="backup_review_service_topics">Tematy</string> - <string name="backup_review_trust_warning">Rankingi, liczba obserwujących i filtrowanie spamu, które widzisz, pochodzą od tych dostawców.</string> - <plurals name="backup_review_payment_targets_gone"> - <item quantity="one">%1$d sposób płatności został usunięty</item> - <item quantity="few">%1$d sposobów płatności zostało usuniętych</item> - <item quantity="many">%1$d sposobów płatności zostało usuniętych</item> - <item quantity="other">%1$d sposoby płatności zostały usunięte</item> - </plurals> - <plurals name="backup_review_offers_gone"> - <item quantity="one">%1$d oferta usunięta</item> - <item quantity="few">%1$d ofert usunięto</item> - <item quantity="many">%1$d ofert usunięto</item> - <item quantity="other">%1$d oferty usunięte</item> - </plurals> - <string name="backup_review_payments_explainer">Osoby, które Ci płacą, widzą tylko to, co znajduje się na tej liście.</string> - <string name="backup_review_offer">Oferta BOLT12</string> - <string name="backup_review_encrypted_cleared">Opróżniłeś to</string> - <string name="backup_review_encrypted_added">Utworzyłeś to</string> - <string name="backup_review_encrypted_changed">Zmieniłeś to</string> - <string name="backup_review_wallet_body">Minty i klucze w Twoim portfelu są zaszyfrowane dla Ciebie, więc nie można ich tutaj porównać pozycja po pozycji. Przywrócenie danych powoduje przywrócenie dokładnie tego, co zostało zapisane na tym urządzeniu.</string> - <string name="backup_review_concord_body">Twoje społeczności w Concord są dla Ciebie zaszyfrowane, więc nie można ich tutaj porównać. Przywrócenie danych powoduje przywrócenie dokładnie tego, co zostało zapisane na tym urządzeniu.</string> - <plurals name="backup_card_mutes_visible"> - <item quantity="one">Włączyłeś dźwięk dla %1$d elementu</item> - <item quantity="few">Włączyłeś dźwięk dla %1$d elementów</item> - <item quantity="many">Włączyłeś dźwięk dla %1$d elementów</item> - <item quantity="other">%1$d elementy mają włączony dźwięk</item> - </plurals> - <plurals name="backup_card_profile_lost_fields"> - <item quantity="one">Usunąłeś %1$d pole profilu</item> - <item quantity="few">Usunąłeś %1$d pól profilowych</item> - <item quantity="many">Usunąłeś %1$d pól profilowych</item> - <item quantity="other">Usunąłeś %1$d pola profilowe</item> - </plurals> - <plurals name="backup_card_nip65_lost"> - <item quantity="one">Usunąłeś %1$d publiczny transmiter</item> - <item quantity="few">Usunąłeś %1$d publicznych transmiterów</item> - <item quantity="many">Usunąłeś %1$d publicznych transmiterów</item> - <item quantity="other">Usunąłeś %1$d publiczne transmitery</item> - </plurals> - <plurals name="backup_card_dm_relays_lost"> - <item quantity="one">Usunąłeś %1$d transmiter DM</item> - <item quantity="few">Usunąłeś %1$d transmiterów DM</item> - <item quantity="many">Usunąłeś %1$d transmiterów DM</item> - <item quantity="other">Usunąłeś %1$d transmitery DM</item> - </plurals> - <plurals name="backup_card_key_package_relays_lost"> - <item quantity="one">Usunięto %1$d transmiter klucza grupowego czatu</item> - <item quantity="few">Usunięto %1$d transmiterów klucza grupowego czatu</item> - <item quantity="many">Usunięto %1$d transmiterów klucza grupowego czatu</item> - <item quantity="other">Usunięto %1$d transmitery klucza grupowego czatu</item> - </plurals> - <plurals name="backup_card_search_relays_lost"> - <item quantity="one">Usunięto %1$d transmiter wyszukiwania</item> - <item quantity="few">Usunięto %1$d transmiterów wyszukiwania</item> - <item quantity="many">Usunięto %1$d transmiterów wyszukiwania</item> - <item quantity="other">Usunięto %1$d transmitery wyszukiwania</item> - </plurals> - <plurals name="backup_card_indexer_relays_lost"> - <item quantity="one">Usunięto %1$d transmiter indeksujący</item> - <item quantity="few">Usunięto %1$d transmiterów indeksujących</item> - <item quantity="many">Usunięto %1$d transmiterów indeksujących</item> - <item quantity="other">Usunięto %1$d transmitery indeksujące</item> - </plurals> - <plurals name="backup_card_relay_feeds_lost"> - <item quantity="one">Usunięto %1$d kanał transmitera</item> - <item quantity="few">Usunięto %1$d kanałów transmitera</item> - <item quantity="many">Usunięto %1$d kanałów transmitera</item> - <item quantity="other">Usunięto %1$d kanały transmitera</item> - </plurals> - <plurals name="backup_card_private_outbox_lost"> - <item quantity="one">Usunięto %1$d prywatny transmiter</item> - <item quantity="few">Usunięto %1$d prywatnych transmiterów</item> - <item quantity="many">Usunięto %1$d prywatnych transmiterów</item> - <item quantity="other">Usunięto %1$d prywatne transmitery</item> - </plurals> - <plurals name="backup_card_trusted_lost"> - <item quantity="one">Przestałeś ufać %1$d transmiterowi</item> - <item quantity="few">Przestałeś ufać %1$d transmiterom</item> - <item quantity="many">Przestałeś ufać %1$d transmiterom</item> - <item quantity="other">Przestałeś ufać %1$d transmiterom</item> - </plurals> - <plurals name="backup_card_unblocked"> - <item quantity="one">Odblokowałeś %1$d transmiter</item> - <item quantity="few">Odblokowałeś %1$d transmiterów</item> - <item quantity="many">Odblokowałeś %1$d transmiterów</item> - <item quantity="other">Odblokowałeś %1$d transmitery</item> - </plurals> - <plurals name="backup_card_leave_chats"> - <item quantity="one">Opuściłeś %1$d czat publiczny</item> - <item quantity="few">Opuściłeś %1$d czatów publicznych</item> - <item quantity="many">Opuściłeś %1$d czatów publicznych</item> - <item quantity="other">Opuściłeś %1$d czaty publiczne</item> - </plurals> - <plurals name="backup_card_leave_communities"> - <item quantity="one">Opuściłeś %1$d społeczność</item> - <item quantity="few">Opuściłeś %1$d społeczności</item> - <item quantity="many">Opuściłeś %1$d społeczności</item> - <item quantity="other">Opuściłeś %1$d społeczności</item> - </plurals> - <plurals name="backup_card_leave_rooms"> - <item quantity="one">Opuściłeś %1$d pokój czatu</item> - <item quantity="few">Opuściłeś %1$d pokoi czatu</item> - <item quantity="many">Opuściłeś %1$d pokoi czatu</item> - <item quantity="other">Opuściłeś %1$d pokoje czatu</item> - </plurals> - <plurals name="backup_card_leave_groups"> - <item quantity="one">Opuściłeś %1$d grupę</item> - <item quantity="few">Opuściłeś %1$d grup</item> - <item quantity="many">Opuściłeś %1$d grup</item> - <item quantity="other">Opuszczono %1$d grupy</item> - </plurals> - <plurals name="backup_card_feeds_removed"> - <item quantity="one">Usunąłeś %1$d ulubiony kanał</item> - <item quantity="few">Usunąłeś %1$d ulubionych kanałów</item> - <item quantity="many">Usunąłeś %1$d ulubionych kanałów</item> - <item quantity="other">Usunięto %1$d ulubione kanały</item> - </plurals> - <plurals name="backup_card_hashtags_unfollowed"> - <item quantity="one">Przestałeś obserwować %1$d hashtag</item> - <item quantity="few">Przestałeś obserwować %1$d hashtagów</item> - <item quantity="many">Przestałeś obserwować %1$d hashtagów</item> - <item quantity="other">Przestałeś obserwować %1$d hashtagi</item> - </plurals> - <plurals name="backup_card_places_unfollowed"> - <item quantity="one">Przestałeś obserwować %1$d miejsce</item> - <item quantity="few">Przestałeś obserwować %1$d miejsc</item> - <item quantity="many">Przestałeś obserwować %1$d miejsc</item> - <item quantity="other">Przestałeś obserwować %1$d miejsca</item> - </plurals> - <plurals name="backup_card_trust_services_changed"> - <item quantity="one">Zmieniłeś dostawcę %1$d zaufanego serwisu</item> - <item quantity="few">Zmieniłeś dostawcę %1$d zaufanych serwisów</item> - <item quantity="many">Zmieniłeś dostawcę %1$d zaufanych serwisów</item> - <item quantity="other">Zmieniłeś dostawcę %1$d zaufanych serwisów</item> - </plurals> - <plurals name="backup_card_nutzap_mints_removed"> - <item quantity="one">Usunięto %1$d nutzap mint</item> - <item quantity="few">Usunięto %1$d nutzap mintów</item> - <item quantity="many">Usunięto %1$d nutzap mintów</item> - <item quantity="other">Usunięto %1$d nutzap minty</item> - </plurals> - <plurals name="backup_card_payment_targets_removed"> - <item quantity="one">Usunięto %1$d sposób na otrzymanie zapłaty</item> - <item quantity="few">Usunięto %1$d sposobów otrzymywania zapłaty</item> - <item quantity="many">Usunięto %1$d sposobów otrzymywania zapłaty</item> - <item quantity="other">Usunięto %1$d sposoby otrzymywania zapłaty</item> - </plurals> - <plurals name="backup_card_offers_removed"> - <item quantity="one">Usunięto %1$d ofertę BOLT12</item> - <item quantity="few">Usunięto %1$d ofert BOLT12</item> - <item quantity="many">Usunięto %1$d ofert BOLT12</item> - <item quantity="other">Usunięto %1$d oferty BOLT12</item> - </plurals> - <plurals name="backup_card_and_added"> - <item quantity="one">%1$s i dodano %2$d</item> - <item quantity="few">%1$s i dodano %2$d</item> - <item quantity="many">%1$s i dodano %2$d</item> - <item quantity="other">%1$s i dodano %2$d</item> - </plurals> - <plurals name="backup_card_and_followed"> - <item quantity="one">%1$s i obserwowany %2$d</item> - <item quantity="few">%1$s i obserwowanych %2$d</item> - <item quantity="many">%1$s i obserwowanych %2$d</item> - <item quantity="other">%1$s i obserwowane %2$d</item> - </plurals> - <plurals name="backup_card_and_muted"> - <item quantity="one">%1$s i wyciszony %2$d</item> - <item quantity="few">%1$s i wyciszono %2$d</item> - <item quantity="many">%1$s i wyciszono %2$d</item> - <item quantity="other">%1$s i wyciszone %2$d</item> - </plurals> - <plurals name="backup_card_and_joined"> - <item quantity="one">%1$s i dołączono do %2$d</item> - <item quantity="few">%1$s i dołączono do %2$d</item> - <item quantity="many">%1$s i dołączono do %2$d</item> - <item quantity="other">%1$s i dołączono do %2$d</item> - </plurals> - <plurals name="backup_card_and_blocked"> - <item quantity="one">%1$s i zablokowano %2$d</item> - <item quantity="few">%1$s i zablokowano %2$d</item> - <item quantity="many">%1$s i zablokowano %2$d</item> - <item quantity="other">%1$s i zablokowano %2$d</item> - </plurals> - <string name="backup_card_app_settings">Twoje zsynchronizowane ustawienia aplikacji Amethyst zostały zmienione w innej aplikacji, która nie jest Amethystem. To może powodować problemy.</string> - <string name="backup_card_nutzap_key_replaced">Wymieniłeś swój klucz Nutzap</string> - <string name="backup_card_nutzap_key_removed">Usunąłeś swój klucz nutzap</string> - <string name="backup_card_wallet_emptied">Opróżniłeś swój portfel Cashu</string> - <string name="backup_card_wallet_rewritten">Zmieniłeś swój portfel Cashu</string> - <string name="backup_card_concord_emptied">Opróżniłeś swoją listę Concorda</string> - <string name="backup_card_concord_rewritten">Zmieniłeś swoją listę Concorda</string> - <string name="backup_conflict_keep_new">Użyj nowej wersji</string> - <string name="backup_conflict_relay_read_only">tylko do odczytu</string> - <string name="backup_conflict_relay_write_only">tylko do zapisu</string> - <string name="backup_conflict_relay_read_write">odczyt i zapis</string> - <string name="backup_type_profile">profil</string> - <string name="backup_type_profile_explainer">Twoje imię i nazwisko, zdjęcie, biografia oraz adresy do płatności – tak, jak widzą je wszyscy.</string> - <string name="backup_type_follow_list">lista obserwowanych</string> - <string name="backup_type_follow_list_explainer">Określa, czyje posty pojawiają się w Twoim kanale głównym.</string> - <string name="backup_type_mute_list">lista zablokowanych</string> - <string name="backup_type_mute_list_explainer">Ukrywa osoby, słowa, hashtagi i wątki we wszystkich wyświetlanych treściach.</string> - <string name="backup_type_outbox_inbox_relays">lista publicznych transmiterów</string> - <string name="backup_type_outbox_inbox_relays_explainer">Informuje wszystkich, gdzie mogą znaleźć Twoje posty oraz gdzie mają wysyłać Ci odpowiedzi i wzmianki.</string> - <string name="backup_type_dm_relays">Lista transmiterów DM</string> - <string name="backup_type_dm_relays_explainer">Gdzie inni dostarczają Twoje prywatne wiadomości.</string> - <string name="backup_type_key_package_relays">transmitery kluczy czatu grupowego</string> - <string name="backup_type_key_package_relays_explainer">Gdzie inni znajdą klucze do dodawania cię do zaszyfrowanych czatów grupowych.</string> - <string name="backup_type_search_relays">lista transmiterów wyszukiwania</string> - <string name="backup_type_search_relays_explainer">Transmitery używane podczas wyszukiwania.</string> - <string name="backup_type_indexer_relays">lista transmiterów indeksujących</string> - <string name="backup_type_indexer_relays_explainer">Transmitery służące do wyszukiwania profili innych osób oraz list transmiterów.</string> - <string name="backup_type_relay_feeds">ulubione kanały transmitera</string> - <string name="backup_type_relay_feeds_explainer">Transmitery, które przeglądasz jako kanały informacyjne.</string> - <string name="backup_type_blocked_relays">lista zablokowanych przekaźników</string> - <string name="backup_type_blocked_relays_explainer">Transmitery, z którymi ta aplikacja nigdy się nie łączy.</string> - <string name="backup_type_trusted_relays">lista zaufanych transmiterów</string> - <string name="backup_type_trusted_relays_explainer">Zaufane transmitery, z którymi bez wahania nawiązujesz połączenie.</string> - <string name="backup_type_private_outbox_relays">lista prywatnych transmiterów</string> - <string name="backup_type_private_outbox_relays_explainer">Gdzie przechowywane są Twoje projekty i prywatne dane.</string> - <string name="backup_type_app_settings">zsynchronizowane ustawienia aplikacji</string> - <string name="backup_type_app_settings_explainer">Ustawienia Amethyst są synchronizowane na wszystkich Twoich urządzeniach. Są one zaszyfrowane, więc można porównać jedynie sam fakt ich obecności.</string> - <string name="backup_type_public_chats">lista czatów publicznych</string> - <string name="backup_type_public_chats_explainer">Publiczne czaty, do których dołączyłeś.</string> - <string name="backup_type_communities">lista społeczności</string> - <string name="backup_type_communities_explainer">Społeczności, do których dołączyłeś.</string> - <string name="backup_type_hashtags">obserwowane hashtagi</string> - <string name="backup_type_hashtags_explainer">Hashtagi, z których pochodzą posty wyświetlane w Twoich kanałach.</string> - <string name="backup_type_geohashes">obserwowane lokalizacje</string> - <string name="backup_type_geohashes_explainer">Miejsca, z których posty pojawiają się na Twoich kanałach.</string> - <string name="backup_type_favorite_algo_feeds">lista ulubionych kanałów</string> - <string name="backup_type_favorite_algo_feeds_explainer">Zapisane przez Ciebie kanały algorytmiczne.</string> - <string name="backup_type_ephemeral_chats">lista czatów efemerycznych</string> - <string name="backup_type_ephemeral_chats_explainer">Tymczasowe czaty, do których dołączyłeś.</string> - <string name="backup_type_relay_groups">lista grup</string> - <string name="backup_type_relay_groups_explainer">Grupy oparte na transmiterach, do których dołączyłeś.</string> - <string name="backup_type_concord_communities">Lista społeczności Concord</string> - <string name="backup_type_concord_communities_explainer">Społeczności Concord, do których dołączyłeś. Są one zaszyfrowane, więc można porównać jedynie fakt ich istnienia.</string> - <string name="backup_type_trust_providers">lista zaufanych dostawców</string> - <string name="backup_type_trust_providers_explainer">Serwisy, którym ufasz, a które zajmują się klasyfikowaniem i weryfikacją osób w Twoim imieniu.</string> - <string name="backup_type_cashu_wallet">Portfel Cashu</string> - <string name="backup_type_cashu_wallet_explainer">Ustawienia portfela ecash oraz minty. Są one zaszyfrowane, więc można porównać jedynie sam fakt ich istnienia.</string> - <string name="backup_type_nutzap_info">ustawienia odbioru nutzap</string> - <string name="backup_type_nutzap_info_explainer">Minty i klucz, które inni używają do wysyłania ci „nutzapów”.</string> - <string name="backup_type_payment_targets">adresy płatności</string> - <string name="backup_type_payment_targets_explainer">Sposoby, w jakie inni mogą Ci zapłacić.</string> - <string name="backup_type_bolt12_offers">Oferta BOLT12</string> - <string name="backup_type_bolt12_offers_explainer">Ta możliwość pozwala innym płacić Ci za pomocą Lightning.</string> - <string name="backup_type_other">lista</string> - <string name="backup_type_other_explainer">Lista zapisana na tym urządzeniu.</string> - <string name="backup_entry_profile_field">Pola profilu</string> - <string name="backup_entry_person">Osoby</string> - <string name="backup_entry_hashtag">Hashtagi</string> - <string name="backup_entry_word">Słowa</string> - <string name="backup_entry_thread">Wątki</string> - <string name="backup_entry_public_chat">Czaty publiczne</string> - <string name="backup_entry_community">Społeczności</string> - <string name="backup_entry_algo_feed">Kanały</string> - <string name="backup_entry_location">Lokalizacje</string> - <string name="backup_entry_relay">Transmitery</string> - <string name="backup_entry_relay_group">Grupy</string> - <string name="backup_entry_chat_room">Czat pokoje</string> - <string name="backup_entry_trust_provider">Zaufani dostawcy</string> - <string name="backup_entry_mint">Minty</string> - <string name="backup_entry_nutzap_key">Klucze Nutzap</string> - <string name="backup_entry_payment_target">Adresy płatności</string> - <string name="backup_entry_offer">Oferty</string> - <string name="backup_entry_identity_claim">Powiązane tożsamości</string> - <string name="backup_entry_other">Inne wpisy</string> - <string name="backup_profile_field_name">Nazwa użytkownika</string> - <string name="backup_profile_field_display_name">Nazwa wyświetlana</string> - <string name="backup_profile_field_about">O profilu</string> - <string name="backup_profile_field_picture">Zdjęcie</string> - <string name="backup_profile_field_banner">Baner</string> - <string name="backup_profile_field_website">Strona www</string> - <string name="backup_profile_field_nip05">Adres Nostr</string> - <string name="backup_profile_field_lud16">Lightning Adres</string> - <string name="backup_profile_field_lud06">LNURL</string> - <string name="backup_profile_field_pronouns">Zaimki</string> - <string name="backup_profile_field_birthday">Data urodzin</string> - <string name="backup_profile_field_clink_offer">Oferta CLINK</string> - <string name="backup_profile_field_bot">Flaga bota</string> </resources> diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index 2da4657d8d..3803e00f8a 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -305,250 +305,6 @@ - <string name="cordn_groups_manage">Coordinators</string> - <string name="cordn_groups_down_note">Nothing is arriving from these groups. Amethyst keeps retrying.</string> - <string name="cordn_groups_none">No cordn groups yet</string> - <string name="cordn_groups_none_detail">A cordn group lives on one coordinator that holds its membership and passes messages along, without ever seeing what anyone writes.</string> - <string name="cordn_groups_start">Start one</string> - <string name="cordn_group_unavailable">This group is not available. Its coordinator may have been removed.</string> - <string name="cordn_group_info">Group info</string> - <string name="cordn_message_deleted">Message deleted</string> - <string name="cordn_message_edited">edited</string> - <string name="cordn_action_go_to_message">Go to message</string> - <string name="cordn_delete_confirm_title">Withdraw message</string> - <string name="cordn_delete_confirm_body">Everyone in the group will see this message as withdrawn, and Amethyst will stop showing its text. The coordinator still holds the encrypted copy it was sent as, and anyone who already read it has already read it.</string> - <string name="cordn_delivery_accepted">Accepted by the coordinator</string> - <string name="cordn_message_details_title">Message details</string> - <string name="cordn_message_details_sent_at">Sent</string> - <string name="cordn_message_details_cursor">Cursor</string> - <string name="cordn_message_details_coordinator">Coordinator</string> - <string name="cordn_composer_hint">Message</string> - <string name="cordn_action_reply">Reply</string> - <string name="cordn_action_edit">Edit</string> - <string name="cordn_action_delete">Delete</string> - <string name="cordn_action_pin">Pin</string> - <string name="cordn_pinned_previous">Previous pinned message</string> - <string name="cordn_pinned_next">Next pinned message</string> - <string name="cordn_pinned_show_all">Show all pinned messages</string> - <string name="cordn_pinned_title">Pinned messages</string> - <string name="cordn_pinned_by">Pinned by %1$s</string> - <plurals name="cordn_pinned_count"> - <item quantity="one">%1$d pinned message in this group</item> - <item quantity="other">%1$d pinned messages in this group</item> - </plurals> - <string name="cordn_action_unpin">Unpin</string> - <string name="cordn_action_editing">Editing your message</string> - <string name="cordn_media_upload_failed">Could not send that file.</string> - <string name="cordn_send_failed">That did not send.</string> - <string name="cordn_send_no_session">This group\'s coordinator is not open, so nothing can be sent yet.</string> - <string name="cordn_media_download_failed">Could not open that file.</string> - <string name="cordn_media_no_server">No media server is set for this account, so there is nowhere to put the file. Pick one in Settings.</string> - <string name="cordn_media_unreadable">That file could not be read.</string> - <string name="cordn_voice_record">Record a voice note</string> - <string name="cordn_voice_stop">Stop and send</string> - <string name="cordn_voice_play">Play voice note</string> - <string name="cordn_backup_explainer">Your nsec cannot bring cordn groups back. A cordn group lives as encryption state on this device and an ordered stream on a coordinator that cannot read it — lose the device without a backup and the group is gone, including everything already said in it.</string> - <string name="cordn_backup_passphrase">Passphrase</string> - <string name="cordn_backup_contents_title">What is in the file</string> - <string name="cordn_backup_contents_body">Your group encryption keys, your key packages, and every message in those groups. Anyone who opens it can read the conversations. The passphrase is the only thing protecting it once it leaves Amethyst.</string> - <string name="cordn_backup_export">Export</string> - <string name="cordn_backup_exported">Backup saved.</string> - <string name="cordn_backup_restore_title">Restore</string> - <string name="cordn_backup_restore_body">Restoring replaces the cordn groups on this device with the ones in the file. It is for a phone that has taken over from another — not a way to use the same groups on two devices at once.</string> - <string name="cordn_backup_restore">Restore</string> - <string name="cordn_backup_restore_confirm_title">Replace this device\'s cordn groups?</string> - <string name="cordn_backup_restore_confirm_body">Every cordn group now on this device will be removed and replaced by the ones in the file.\n\nDo not restore onto a second phone while the first is still in use. Both would hold the same group keys, and once both have sent a message the group breaks for everyone — silently, and with no way back.</string> - <string name="cordn_backup_restored">Restored.</string> - <string name="cordn_backup_failed">That did not work. Check the passphrase and the file.</string> - <string name="cordn_send">Send</string> - <string name="cordn_info_coordinator">Coordinator</string> - <string name="cordn_info_coordinator_key">Coordinator key</string> - <string name="cordn_info_coordinator_nprofile">Coordinator link</string> - <string name="cordn_info_copy_nprofile">Copy the coordinator\'s nprofile</string> - <string name="cordn_info_gid">Group id</string> - <string name="cordn_info_epoch">Epoch</string> - <string name="cordn_info_members">Members</string> - <string name="cordn_info_egalitarian">This group has no admins: everyone can add, remove and rename, permanently.</string> - <string name="cordn_info_technical">Technical details</string> - <string name="cordn_create_title">New Cordn group</string> - <string name="cordn_create_explainer">A cordn group is ordered by one coordinator you choose. Creating the group happens on this device — the coordinator only learns the group exists once you invite someone or send a message.</string> - <string name="cordn_create_people_none">Nobody yet — tap to add people</string> - <string name="cordn_create_people_empty">Nobody added yet. A group can be created empty and invitations sent later, but naming people now is what shows which coordinator can reach them.</string> - <string name="cordn_create_people_done">Done</string> - <string name="cordn_create_you">You, always an admin</string> - <string name="cordn_create_step_name">Name it</string> - <string name="cordn_create_step_people">Who is in it</string> - <string name="cordn_create_step_where">Where it lives</string> - <string name="cordn_create_step_admins">Who can add and remove</string> - <string name="cordn_create_add_member">Add someone</string> - <string name="cordn_create_people_note">Naming people now is what tells us which coordinator can reach them. Each one gets a Welcome left on that coordinator, which they pick up next time they open their app.</string> - <string name="cordn_create_reach_unknown">Not checked yet</string> - <string name="cordn_create_reach_none">No key on any coordinator you use</string> - <string name="cordn_create_egalitarian">Everyone can add and remove</string> - <string name="cordn_create_admin">Admin</string> - <string name="cordn_create_no_coordinator">No coordinator chosen</string> - <string name="cordn_create_coordinator_change">Change</string> - <string name="cordn_create_coordinator_hide">Done</string> - <string name="cordn_create_coverage_unknown">Not checked — picking it will ask</string> - <string name="cordn_create_coverage_all">Reaches all %1$d of your people</string> - <string name="cordn_create_coverage_partial">Reaches %1$d of %2$d — the rest would be left out</string> - <string name="cordn_create_outcome_title">The group exists</string> - <string name="cordn_create_outcome_explainer">Each invitation is a Welcome left on the coordinator, so they can fail one at a time. Nobody has been notified: they see it next time they open their app.</string> - <string name="cordn_create_outcome_no_welcome">Added to the group, but the invitation did not reach them — try again from the group screen</string> - <string name="cordn_create_outcome_waiting">Waiting for them</string> - <string name="cordn_create_outcome_failed">The coordinator refused the invitation</string> - <string name="cordn_create_outcome_skipped">No key here, so no Welcome could be left</string> - <string name="cordn_create_outcome_link">Send a link</string> - <string name="cordn_create_outcome_open">Open the chat</string> - <string name="cordn_create_coordinator">Coordinator</string> - <string name="cordn_create_coordinator_discover">Find coordinators</string> - <string name="cordn_create_coordinator_new">Another coordinator</string> - <string name="cordn_create_coordinator_pubkey">Coordinator public key (hex or npub)</string> - <string name="cordn_create_coordinator_relays">Relays it answers on, one per line</string> - <string name="cordn_create_name">Group name</string> - <string name="cordn_create_description">Description (optional)</string> - <string name="cordn_create_egalitarian_note">Everyone in the group can invite, remove members and change its details. Any member can name admins later, which ends that.</string> - <string name="cordn_create_admin_only_me">Only I manage this group</string> - <string name="cordn_admin_action_failed">That change could not be made.</string> - <string name="cordn_info_remove_member">Remove</string> - <string name="cordn_info_remove_confirm_title">Remove from group?</string> - <string name="cordn_info_remove_confirm_body">%1$s stops receiving messages from here. They keep what they have already read, and this cannot be undone — they would have to be invited again.</string> - <string name="cordn_info_edit_details">Edit details</string> - <string name="cordn_info_save">Save</string> - <string name="cordn_create_admin_only_me_on">Only you can invite, remove members or change the group\'s details. You can hand that to someone else later.</string> - <string name="cordn_create_action">Create group</string> - <string name="cordn_create_failed">The group could not be created.</string> - <string name="cordn_invitations_title">Cordn invitations</string> - <string name="cordn_invitations_explainer">Checked when you open this screen, and at no other time — asking a coordinator whether anyone invited you tells it you are here, so Amethyst does not do it in the background.</string> - <string name="cordn_invitations_refresh">Check again</string> - <string name="cordn_invitations_accept">Join</string> - <string name="cordn_invitations_decline">Decline</string> - <string name="cordn_invitations_decline_warning">Declining is permanent. Getting back in means being invited again.</string> - <string name="cordn_chat_yesterday">Yesterday</string> - <string name="cordn_chat_unread_divider">New messages</string> - <string name="cordn_chat_empty_title">No messages yet</string> - <string name="cordn_chat_empty_description">Anything sent here is encrypted for this group. The coordinator relays it without being able to read it.</string> - <string name="cordn_reactions_title">Reactions</string> - <string name="cordn_group_unavailable_detail">Add a coordinator in Settings to start using cordn groups.</string> - <string name="cordn_coordinators_discover_explainer">Reads announcements your relays already carry. No coordinator is contacted, so none of them learns you looked.</string> - <string name="cordn_coordinators_discover_action">Look for coordinators</string> - <string name="cordn_coordinators_discover_add">Add</string> - <string name="cordn_coordinators_discover_failed">Could not read announcements</string> - <string name="cordn_coordinators_discover_none">Nobody is announcing on your relays.</string> - <string name="cordn_coordinators_discover_unheard">Nothing found, and %1$d of your relays did not answer.</string> - <string name="cordn_coordinators_discover_seen">Announced %1$s ago</string> - <string name="cordn_coordinators_discover_seen_on">Last announced %1$s</string> - <string name="cordn_coordinators_relays">%1$s</string> - <string name="cordn_coordinators_relays_more">%1$s +%2$d more</string> - <string name="cordn_coordinators_show_all">Show all %1$d</string> - <string name="cordn_coordinators_show_fewer">Show fewer</string> - <string name="cordn_coordinators_show_older">Show %1$d that stopped announcing</string> - <string name="cordn_coordinators_hide_older">Hide the ones that stopped announcing</string> - <string name="cordn_coordinators_stale_note">These have not announced in over a month. Creating a group on one that has gone away will fail.</string> - <string name="cordn_info_add_member">Add someone</string> - <string name="cordn_info_add_member_placeholder">Name, npub or name@domain</string> - <string name="cordn_info_has_key_package">Can be added on this coordinator</string> - <string name="cordn_info_add_member_note">They can only be added if they published a key package to this coordinator.</string> - <string name="cordn_exposure_open">What this coordinator can see</string> - <string name="cordn_exposure_close">Got it</string> - <string name="cordn_admin_someone">That person</string> - <string name="cordn_admin_no_key_package">%1$s has not published a key package to this coordinator, so they cannot be added yet. Ask them to open cordn on this coordinator first.</string> - <string name="cordn_admin_wrong_key_package">This coordinator served a key package that belongs to someone else, so %1$s was not added. Nothing was changed.</string> - <string name="cordn_admin_no_welcome">%1$s could not be given a way into the group, so the add was abandoned.</string> - <string name="cordn_admin_not_a_member">%1$s is not in this group.</string> - <string name="cordn_admin_no_self_remove">You cannot remove yourself from a cordn group.</string> - <string name="cordn_admin_coordinator_silent">The coordinator did not answer, so nothing was changed. Try again in a moment.</string> - <string name="cordn_info_add_member_none">Nobody found by that name.</string> - <string name="cordn_info_admin_badge">Admin</string> - <string name="cordn_invitations_members_more">+%1$d more</string> - <string name="cordn_invitations_via">Through %1$s</string> - <string name="cordn_invitations_none">No invitations waiting.</string> - <string name="cordn_invitations_no_coordinators">You have no coordinator open. cordn invitations arrive through a coordinator, so there is nowhere to look yet.</string> - <string name="cordn_invitations_unreachable">%1$s did not answer</string> - <string name="cordn_invitations_skipped">An invitation was left for another device</string> - <string name="cordn_invitations_load_failed">Could not read invitations.</string> - <string name="cordn_link_request">Ask to join this group</string> - <string name="cordn_link_request_disclosure">This publishes a key package under your own account key and tells the coordinator you want into this group — whether or not anyone answers.</string> - <string name="cordn_link_request_sent">Asked. A member of the group has to add you; the invitation will show up under cordn invitations.</string> - <string name="cordn_link_request_failed">Could not ask to join.</string> - <string name="cordn_requests_title">Requests to join</string> - <string name="cordn_requests_check">Check for requests</string> - <string name="cordn_requests_none">Nobody is waiting to join.</string> - <string name="cordn_requests_accept">Add</string> - <string name="cordn_requests_decline">Dismiss</string> - <string name="cordn_requests_admin_only">Only an admin can accept. In a group with no admins, that is everyone.</string> - <string name="cordn_requests_failed">Could not read the requests.</string> - <string name="cordn_link_scan">Scan</string> - <string name="cordn_share_title">Share this group</string> - <string name="cordn_share_explainer">Anyone with this link can ask to join. An admin still has to let them in.</string> - <string name="cordn_share_copy">Copy link</string> - <string name="cordn_share_copied">Copied</string> - <string name="cordn_coordinators_explainer">A coordinator orders one group\'s messages and is the only thing that can. Losing it loses the ordering, and a second one does not mirror the first — so these are named things you choose, not interchangeable relays.</string> - <string name="cordn_coordinators_none">No coordinators yet.</string> - <string name="cordn_coordinators_add_action">Add</string> - <string name="cordn_coordinators_add_failed">Could not open that coordinator.</string> - <string name="cordn_coordinators_label">A name for it (yours, optional)</string> - <string name="cordn_coordinators_relays_label">Answers on</string> - <string name="cordn_coordinators_key">Coordinator key</string> - <string name="cordn_coordinators_copy_key">Copy the coordinator\'s npub</string> - <string name="cordn_coordinators_more">More actions</string> - <string name="cordn_coordinators_rename">Rename</string> - <string name="cordn_coordinators_label_note">This name is yours and stays on this device. A coordinator cannot prove a name, so it is never asked for one.</string> - <string name="cordn_coordinators_identify">Ask who it is</string> - <string name="cordn_coordinators_server">Says it is: %1$s</string> - <string name="cordn_coordinators_server_silent">Answered, but named nothing.</string> - <string name="cordn_coordinators_server_claim">A coordinator\'s name and version are strings it chose. Its public key is the only thing that identifies it.</string> - <string name="cordn_coordinators_health_ok">Answering.</string> - <string name="cordn_coordinators_health_retrying">A call failed; retrying.</string> - <string name="cordn_coordinators_health_down">Not answering — %1$d calls in a row have failed. Groups on it are not syncing.</string> - <string name="cordn_coordinators_health_unknown">Nothing asked of it yet.</string> - <string name="cordn_coordinators_remove">Remove</string> - <string name="cordn_coordinators_purge">Purge</string> - <string name="cordn_coordinators_purge_title">Purge this coordinator?</string> - <string name="cordn_coordinators_purge_body">Removing keeps the groups on this device, so adding the coordinator back brings them with it. Purging deletes them: the group keys, the read positions and your key packages all go, and those groups can only be re-entered by a fresh invitation.\n\nThe coordinator is not told and keeps whatever it already had.</string> - <string name="cordn_keypackages_explainer">Others can only add you to a cordn group by taking a key package you published to that coordinator. cordn has no other place to keep one, so with none published nobody can invite you — and nothing tells them why.</string> - <plurals name="cordn_create_unreachable_count"> - <item quantity="one">%1$d person cannot be reached by any coordinator you use</item> - <item quantity="other">%1$d people cannot be reached by any coordinator you use</item> - </plurals> - <plurals name="cordn_groups_count"> - <item quantity="one">%1$d group</item> - <item quantity="other">%1$d groups</item> - </plurals> - <plurals name="cordn_create_reach_count"> - <item quantity="one">Reachable on %1$d coordinator</item> - <item quantity="other">Reachable on %1$d coordinators</item> - </plurals> - <plurals name="cordn_create_admin_count"> - <item quantity="one">%1$d person can add and remove</item> - <item quantity="other">%1$d people can add and remove</item> - </plurals> - <plurals name="cordn_create_action_invite"> - <item quantity="one">Create and invite %1$d person</item> - <item quantity="other">Create and invite %1$d people</item> - </plurals> - <plurals name="cordn_member_count"> - <item quantity="one">%1$d member</item> - <item quantity="other">%1$d members</item> - </plurals> - <plurals name="cordn_keypackages_summary"> - <item quantity="one">%1$d single-use package available.</item> - <item quantity="other">%1$d single-use packages available.</item> - </plurals> - <string name="cordn_keypackages_last_resort_yes">A last-resort package is published, so an invitation can still be made once the single-use ones run out.</string> - <string name="cordn_keypackages_last_resort_no">No last-resort package. Once the single-use ones run out, invitations fail.</string> - <plurals name="cordn_keypackages_orphans"> - <item quantity="one">%1$d package this device cannot open</item> - <item quantity="other">%1$d packages this device cannot open</item> - </plurals> - <string name="cordn_keypackages_orphans_body">The coordinator will hand these to anyone inviting you, but the private half is not on this device — it belongs to another install. If that install is gone, an invitation using one of these produces a welcome nobody can ever open.</string> - <string name="cordn_keypackages_withdraw_orphans">Withdraw those</string> - <string name="cordn_keypackages_disclosure">Publishing signs a record under your own account key. That coordinator then knows this account exists and is invitable — permanently, and whether or not anyone invites you.</string> - <string name="cordn_keypackages_publish">Publish one</string> - <string name="cordn_keypackages_publish_last_resort">Publish last-resort</string> - <string name="cordn_keypackages_withdraw_all">Withdraw all</string> - <string name="cordn_keypackages_topup_note">Once you have published here, Amethyst quietly replaces packages as they are used up. It never publishes the first one for you.</string> - <string name="cordn_keypackages_failed">Could not read the key packages.</string> <!-- Buzz calls its groups channels, and a Buzz relay is one workspace rather than a directory of groups. --> <string name="buzz_channel_flag_forum">Forum channel</string> <string name="buzz_channel_flag_forum_desc">Threaded posts instead of a chat timeline. This cannot be changed later.</string> @@ -899,10 +655,6 @@ <!-- My Fitness: the signed-in user's own training summary. Android resource because NavBarItemDef labels are R.string ids. --> - <plurals name="cordn_invitations_members"> - <item quantity="one">%1$d person is already in this group</item> - <item quantity="other">%1$d people are already in this group</item> - </plurals> <string name="private_message">Private Message</string> <string name="pow_kind_chat_message">Chat message</string> <string name="nest_notification_broadcasting">Nest — Live</string> @@ -931,326 +683,4 @@ <string name="mute_button">Sound on. Click to mute</string> <string name="play">Play</string> <string name="pause">Pause</string> - <string name="backup_conflict_title">You changed your %1$s in another app</string> - <string name="backup_conflict_removed">Removed (%1$s)</string> - <string name="backup_conflict_added">Added (%1$s)</string> - <string name="backup_conflict_changed">Changed (%1$s)</string> - <string name="backup_conflict_private_cleared">You removed all private (encrypted) items.</string> - <string name="backup_conflict_private_changed">You also changed private (encrypted) items. They can\'t be compared here.</string> - <string name="backup_conflict_private_added">You added private (encrypted) items.</string> - <string name="backup_conflict_restore_mine">Restore saved version</string> - <string name="backup_review_saved">On this device</string> - <string name="backup_review_new">New version</string> - <string name="backup_review_not_set">Not set</string> - <string name="backup_conflict_count_removed">%1$s removed</string> - <string name="backup_conflict_count_added">%1$s added</string> - <string name="backup_conflict_count_changed">%1$s changed</string> - <plurals name="backup_card_follows_dropped"> - <item quantity="one">You unfollowed %1$d person</item> - <item quantity="other">You unfollowed %1$d people</item> - </plurals> - <string name="backup_card_accept">Accept</string> - <string name="backup_review_title_updated">%1$s updated</string> - <string name="backup_review_title_cleared">%1$s cleared</string> - <string name="backup_review_changed_by_other_app">Changed in another app · %1$s</string> - <string name="backup_action_keep_count">Keep %1$s</string> - <string name="backup_action_restore_count">Restore %1$s</string> - <string name="backup_action_remute">Re-mute %1$s</string> - <string name="backup_action_rejoin">Rejoin %1$s</string> - <string name="backup_action_restore_profile">Restore profile</string> - <string name="backup_action_restore_relays">Restore relays</string> - <string name="backup_review_kept_count">%1$s kept</string> - <string name="backup_review_dropped_count">%1$s dropped</string> - <string name="backup_review_new_count">%1$s new</string> - <string name="backup_review_tab_dropped">Dropped · %1$s</string> - <string name="backup_review_tab_new">New · %1$s</string> - <string name="backup_review_tab_edited">Edited · %1$s</string> - <string name="backup_review_search_people">Search %1$s people</string> - <string name="backup_review_nothing_here">Nothing here</string> - <string name="backup_review_unmuted">%1$s unmuted</string> - <string name="backup_review_unmuted_explainer">These can reach your feeds again</string> - <string name="backup_review_newly_muted">%1$s newly muted</string> - <string name="backup_review_words_and_hashtags">Words & hashtags</string> - <string name="backup_review_names_and_more">%1$s and %2$s more</string> - <string name="backup_review_private_wiped_title">You removed all private items</string> - <string name="backup_review_private_wiped_body">They\'re encrypted, so only you can see what they were. Restoring brings them all back.</string> - <string name="backup_review_private_added_title">You made items private</string> - <string name="backup_review_private_added_body">They\'re encrypted now, which is likely where the public items above went.</string> - <string name="backup_review_private_changed_title">You changed private items</string> - <string name="backup_review_private_changed_body">They\'re encrypted, so they can\'t be compared here.</string> - <string name="backup_review_gone">Gone</string> - <string name="backup_review_new_tag">New</string> - <string name="backup_review_dropped_tag">Dropped</string> - <string name="backup_review_demoted_tag">Moved</string> - <string name="backup_review_units_tag">Units</string> - <string name="backup_review_left_tag">Left</string> - <string name="backup_review_renamed_tag">Renamed</string> - <string name="backup_review_outbox">Outbox</string> - <string name="backup_review_outbox_explainer">where you publish</string> - <string name="backup_review_inbox">Inbox</string> - <string name="backup_review_inbox_explainer">where others reach you</string> - <string name="backup_review_key_replaced">Receiving key replaced</string> - <string name="backup_review_key_removed">Receiving key removed</string> - <string name="backup_review_key_warning">Nutzaps will be locked to this new key. If this device doesn\'t have it, you may not be able to redeem them here.</string> - <string name="backup_review_left">left</string> - <string name="backup_review_joined">joined</string> - <string name="backup_review_renamed">renamed</string> - <string name="backup_review_was_named">was “%1$s”</string> - <string name="backup_action_block_again">Block %1$s again</string> - <string name="backup_action_restore_feeds">Restore feeds</string> - <string name="backup_action_restore_topics">Restore topics</string> - <string name="backup_action_restore_places">Restore places</string> - <string name="backup_action_restore_providers">Restore providers</string> - <string name="backup_action_restore_wallet">Restore wallet</string> - <string name="backup_review_kept">kept</string> - <string name="backup_review_receiving_tag">Receiving</string> - <string name="backup_review_listed_tag">Listed</string> - <string name="backup_review_searching_tag">Searching</string> - <string name="backup_review_storing_tag">Storing</string> - <string name="backup_review_trusted_tag">Trusted</string> - <string name="backup_review_untrusted_tag">Untrusted</string> - <string name="backup_review_unblocked">%1$s unblocked</string> - <string name="backup_review_unblocked_explainer">Amethyst will connect to them again</string> - <string name="backup_review_no_longer_blocked">No longer blocked</string> - <string name="backup_review_newly_blocked">Newly blocked</string> - <string name="backup_review_still_blocked">Still blocked</string> - <string name="backup_review_allowed_tag">Allowed</string> - <string name="backup_review_moved_tag">Moved</string> - <string name="backup_review_feed">Feed</string> - <string name="backup_review_topics_gone">topics gone</string> - <string name="backup_review_places_gone">places gone</string> - <string name="backup_review_new_count_caption">new</string> - <string name="backup_review_hashtags_you_follow">Hashtags you follow</string> - <string name="backup_review_places_you_follow">Places you follow</string> - <string name="backup_review_services_changed">%1$s of %2$s services changed</string> - <string name="backup_review_services_changed_explainer">They now come from someone else, or no one</string> - <string name="backup_review_service">Service</string> - <string name="backup_review_service_rank">Rank</string> - <string name="backup_review_service_followers">Followers</string> - <string name="backup_review_service_topics">Topics</string> - <string name="backup_review_trust_warning">Ranks, follower counts and spam filtering you see come from these providers.</string> - <plurals name="backup_review_payment_targets_gone"> - <item quantity="one">%1$d way to pay you removed</item> - <item quantity="other">%1$d ways to pay you removed</item> - </plurals> - <plurals name="backup_review_offers_gone"> - <item quantity="one">%1$d offer removed</item> - <item quantity="other">%1$d offers removed</item> - </plurals> - <string name="backup_review_payments_explainer">People paying you only see what\'s in this list.</string> - <string name="backup_review_offer">BOLT12 offer</string> - <string name="backup_review_encrypted_cleared">You emptied it</string> - <string name="backup_review_encrypted_added">You created it</string> - <string name="backup_review_encrypted_changed">You changed it</string> - <string name="backup_review_wallet_body">Your wallet\'s mints and keys are encrypted to you, so they can\'t be compared item by item here. Restoring puts back exactly what this device saved.</string> - <string name="backup_review_concord_body">Your Concord communities are encrypted to you, so they can\'t be compared here. Restoring puts back exactly what this device saved.</string> - <plurals name="backup_card_mutes_visible"> - <item quantity="one">You unmuted %1$d thing</item> - <item quantity="other">You unmuted %1$d things</item> - </plurals> - <plurals name="backup_card_profile_lost_fields"> - <item quantity="one">You removed %1$d profile field</item> - <item quantity="other">You removed %1$d profile fields</item> - </plurals> - <plurals name="backup_card_nip65_lost"> - <item quantity="one">You removed %1$d public relay</item> - <item quantity="other">You removed %1$d public relays</item> - </plurals> - <plurals name="backup_card_dm_relays_lost"> - <item quantity="one">You removed %1$d DM relay</item> - <item quantity="other">You removed %1$d DM relays</item> - </plurals> - <plurals name="backup_card_key_package_relays_lost"> - <item quantity="one">You removed %1$d group-chat key relay</item> - <item quantity="other">You removed %1$d group-chat key relays</item> - </plurals> - <plurals name="backup_card_search_relays_lost"> - <item quantity="one">You removed %1$d search relay</item> - <item quantity="other">You removed %1$d search relays</item> - </plurals> - <plurals name="backup_card_indexer_relays_lost"> - <item quantity="one">You removed %1$d indexer relay</item> - <item quantity="other">You removed %1$d indexer relays</item> - </plurals> - <plurals name="backup_card_relay_feeds_lost"> - <item quantity="one">You removed %1$d relay feed</item> - <item quantity="other">You removed %1$d relay feeds</item> - </plurals> - <plurals name="backup_card_private_outbox_lost"> - <item quantity="one">You removed %1$d private relay</item> - <item quantity="other">You removed %1$d private relays</item> - </plurals> - <plurals name="backup_card_trusted_lost"> - <item quantity="one">You stopped trusting %1$d relay</item> - <item quantity="other">You stopped trusting %1$d relays</item> - </plurals> - <plurals name="backup_card_unblocked"> - <item quantity="one">You unblocked %1$d relay</item> - <item quantity="other">You unblocked %1$d relays</item> - </plurals> - <plurals name="backup_card_leave_chats"> - <item quantity="one">You left %1$d public chat</item> - <item quantity="other">You left %1$d public chats</item> - </plurals> - <plurals name="backup_card_leave_communities"> - <item quantity="one">You left %1$d community</item> - <item quantity="other">You left %1$d communities</item> - </plurals> - <plurals name="backup_card_leave_rooms"> - <item quantity="one">You left %1$d chat room</item> - <item quantity="other">You left %1$d chat rooms</item> - </plurals> - <plurals name="backup_card_leave_groups"> - <item quantity="one">You left %1$d group</item> - <item quantity="other">You left %1$d groups</item> - </plurals> - <plurals name="backup_card_feeds_removed"> - <item quantity="one">You removed %1$d favorite feed</item> - <item quantity="other">You removed %1$d favorite feeds</item> - </plurals> - <plurals name="backup_card_hashtags_unfollowed"> - <item quantity="one">You unfollowed %1$d hashtag</item> - <item quantity="other">You unfollowed %1$d hashtags</item> - </plurals> - <plurals name="backup_card_places_unfollowed"> - <item quantity="one">You unfollowed %1$d place</item> - <item quantity="other">You unfollowed %1$d places</item> - </plurals> - <plurals name="backup_card_trust_services_changed"> - <item quantity="one">You changed the provider of %1$d trust service</item> - <item quantity="other">You changed the provider of %1$d trust services</item> - </plurals> - <plurals name="backup_card_nutzap_mints_removed"> - <item quantity="one">You removed %1$d nutzap mint</item> - <item quantity="other">You removed %1$d nutzap mints</item> - </plurals> - <plurals name="backup_card_payment_targets_removed"> - <item quantity="one">You removed %1$d way to get paid</item> - <item quantity="other">You removed %1$d ways to get paid</item> - </plurals> - <plurals name="backup_card_offers_removed"> - <item quantity="one">You removed %1$d BOLT12 offer</item> - <item quantity="other">You removed %1$d BOLT12 offers</item> - </plurals> - <plurals name="backup_card_and_added"> - <item quantity="one">%1$s and added %2$d</item> - <item quantity="other">%1$s and added %2$d</item> - </plurals> - <plurals name="backup_card_and_followed"> - <item quantity="one">%1$s and followed %2$d</item> - <item quantity="other">%1$s and followed %2$d</item> - </plurals> - <plurals name="backup_card_and_muted"> - <item quantity="one">%1$s and muted %2$d</item> - <item quantity="other">%1$s and muted %2$d</item> - </plurals> - <plurals name="backup_card_and_joined"> - <item quantity="one">%1$s and joined %2$d</item> - <item quantity="other">%1$s and joined %2$d</item> - </plurals> - <plurals name="backup_card_and_blocked"> - <item quantity="one">%1$s and blocked %2$d</item> - <item quantity="other">%1$s and blocked %2$d</item> - </plurals> - <string name="backup_card_app_settings">Your Amethyst synced app settings changed in another app that is not Amethyst. This can create problems.</string> - <string name="backup_card_nutzap_key_replaced">You replaced your nutzap key</string> - <string name="backup_card_nutzap_key_removed">You removed your nutzap key</string> - <string name="backup_card_wallet_emptied">You emptied your Cashu wallet</string> - <string name="backup_card_wallet_rewritten">You changed your Cashu wallet</string> - <string name="backup_card_concord_emptied">You emptied your Concord list</string> - <string name="backup_card_concord_rewritten">You changed your Concord list</string> - <string name="backup_conflict_keep_new">Use new version</string> - <string name="backup_conflict_relay_read_only">read only</string> - <string name="backup_conflict_relay_write_only">write only</string> - <string name="backup_conflict_relay_read_write">read and write</string> - <string name="backup_type_profile">profile</string> - <string name="backup_type_profile_explainer">Your name, picture, bio and payment addresses, as everyone sees them.</string> - <string name="backup_type_follow_list">follow list</string> - <string name="backup_type_follow_list_explainer">Decides whose posts appear in your home feed.</string> - <string name="backup_type_mute_list">mute list</string> - <string name="backup_type_mute_list_explainer">Hides people, words, hashtags and threads from everything you see.</string> - <string name="backup_type_outbox_inbox_relays">public relay list</string> - <string name="backup_type_outbox_inbox_relays_explainer">Tells everyone where to find your posts and where to send you replies and mentions.</string> - <string name="backup_type_dm_relays">DM relay list</string> - <string name="backup_type_dm_relays_explainer">Where others deliver your private messages.</string> - <string name="backup_type_key_package_relays">group-chat key relays</string> - <string name="backup_type_key_package_relays_explainer">Where others find the keys to add you to encrypted group chats.</string> - <string name="backup_type_search_relays">search relay list</string> - <string name="backup_type_search_relays_explainer">The relays used when you search.</string> - <string name="backup_type_indexer_relays">indexer relay list</string> - <string name="backup_type_indexer_relays_explainer">The relays used to find other people\'s profiles and relay lists.</string> - <string name="backup_type_relay_feeds">favorite relay feeds</string> - <string name="backup_type_relay_feeds_explainer">The relays you browse as feeds.</string> - <string name="backup_type_blocked_relays">blocked relay list</string> - <string name="backup_type_blocked_relays_explainer">Relays this app never connects to.</string> - <string name="backup_type_trusted_relays">trusted relay list</string> - <string name="backup_type_trusted_relays_explainer">Relays you trust to connect to without asking.</string> - <string name="backup_type_private_outbox_relays">private relay list</string> - <string name="backup_type_private_outbox_relays_explainer">Where your drafts and private data are stored.</string> - <string name="backup_type_app_settings">synced app settings</string> - <string name="backup_type_app_settings_explainer">Amethyst settings synced across your devices. They are encrypted, so only their presence can be compared.</string> - <string name="backup_type_public_chats">public chat list</string> - <string name="backup_type_public_chats_explainer">The public chats you joined.</string> - <string name="backup_type_communities">community list</string> - <string name="backup_type_communities_explainer">The communities you joined.</string> - <string name="backup_type_hashtags">followed hashtags</string> - <string name="backup_type_hashtags_explainer">Hashtags whose posts appear in your feeds.</string> - <string name="backup_type_geohashes">followed locations</string> - <string name="backup_type_geohashes_explainer">Locations whose posts appear in your feeds.</string> - <string name="backup_type_favorite_algo_feeds">favorite feeds list</string> - <string name="backup_type_favorite_algo_feeds_explainer">The algorithmic feeds you saved.</string> - <string name="backup_type_ephemeral_chats">ephemeral chat list</string> - <string name="backup_type_ephemeral_chats_explainer">The ephemeral chat rooms you joined.</string> - <string name="backup_type_relay_groups">group list</string> - <string name="backup_type_relay_groups_explainer">The relay-based groups you joined.</string> - <string name="backup_type_concord_communities">Concord community list</string> - <string name="backup_type_concord_communities_explainer">The Concord communities you joined. They are encrypted, so only their presence can be compared.</string> - <string name="backup_type_trust_providers">trust provider list</string> - <string name="backup_type_trust_providers_explainer">The services you trust to rank and verify people for you.</string> - <string name="backup_type_cashu_wallet">Cashu wallet</string> - <string name="backup_type_cashu_wallet_explainer">Your ecash wallet settings and mints. They are encrypted, so only their presence can be compared.</string> - <string name="backup_type_nutzap_info">nutzap receiving settings</string> - <string name="backup_type_nutzap_info_explainer">The mints and key others use to send you nutzaps.</string> - <string name="backup_type_payment_targets">payment addresses</string> - <string name="backup_type_payment_targets_explainer">The ways other people can pay you.</string> - <string name="backup_type_bolt12_offers">BOLT12 offers</string> - <string name="backup_type_bolt12_offers_explainer">The lightning offers others use to pay you.</string> - <string name="backup_type_other">list</string> - <string name="backup_type_other_explainer">A list saved on this device.</string> - <string name="backup_entry_profile_field">Profile fields</string> - <string name="backup_entry_person">People</string> - <string name="backup_entry_hashtag">Hashtags</string> - <string name="backup_entry_word">Words</string> - <string name="backup_entry_thread">Threads</string> - <string name="backup_entry_public_chat">Public chats</string> - <string name="backup_entry_community">Communities</string> - <string name="backup_entry_algo_feed">Feeds</string> - <string name="backup_entry_location">Locations</string> - <string name="backup_entry_relay">Relays</string> - <string name="backup_entry_relay_group">Groups</string> - <string name="backup_entry_chat_room">Chat rooms</string> - <string name="backup_entry_trust_provider">Trust providers</string> - <string name="backup_entry_mint">Mints</string> - <string name="backup_entry_nutzap_key">Nutzap keys</string> - <string name="backup_entry_payment_target">Payment addresses</string> - <string name="backup_entry_offer">Offers</string> - <string name="backup_entry_identity_claim">Linked identities</string> - <string name="backup_entry_other">Other entries</string> - <string name="backup_profile_field_name">Username</string> - <string name="backup_profile_field_display_name">Display name</string> - <string name="backup_profile_field_about">About</string> - <string name="backup_profile_field_picture">Picture</string> - <string name="backup_profile_field_banner">Banner</string> - <string name="backup_profile_field_website">Website</string> - <string name="backup_profile_field_nip05">Nostr address</string> - <string name="backup_profile_field_lud16">Lightning address</string> - <string name="backup_profile_field_lud06">LNURL</string> - <string name="backup_profile_field_pronouns">Pronouns</string> - <string name="backup_profile_field_birthday">Birthday</string> - <string name="backup_profile_field_clink_offer">CLINK offer</string> - <string name="backup_profile_field_bot">Bot flag</string> - <plurals name="cordn_info_admins_kept"> - <item quantity="one">The group\'s %1$d admin stays as it is.</item> - <item quantity="other">The group\'s %1$d admins stay as they are.</item> - </plurals> </resources> diff --git a/commonsUI/ARCHITECTURE.md b/commonsUI/ARCHITECTURE.md index b693e06a2b..8a091c05f7 100644 --- a/commonsUI/ARCHITECTURE.md +++ b/commonsUI/ARCHITECTURE.md @@ -58,7 +58,10 @@ is specific to the UI module. `tools/icon-font/build_icon_font.py` read `icons/` and write `composeResources/font/` in this module (see root `.claude/CLAUDE.md`, "Icons"). - Translations: `crowdin.yml` and `tools/strings-migrate/` target - `commonsUI/src/commonMain/composeResources/`. + `commonsUI/src/commonMain/composeResources/`. This is where **every new + user-visible string** goes, Android-only screens included; the app's own + `res/values/strings.xml` holds only the synchronous-platform tier (see root + `.claude/CLAUDE.md`, "Strings"). - CI: `.github/workflows/build.yml` runs `:commonsUI:jvmTest`, `:commonsUI:verifyKmpPurity` and the iOS compile/test tasks next to the `:commons` ones. diff --git a/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml b/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml index 3a1f286d3d..2d16c9c513 100644 --- a/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml @@ -5286,4 +5286,322 @@ <string name="cyberspace_bag_unsigned">हस्ताक्षररहित। इसलिए यह कर्ता केवल एक कथन है</string> <string name="cyberspace_bag_unknown_kind">प्रकार %1$d का वस्तु। जिसे यह ग्राहक चित्रित नहीं करता</string> <string name="cyberspace_bag_opaque">%1$d अष्टकों का अमुक जिसे यह ग्राहक पढता नहीं</string> + <string name="backup_action_block_again">पुनःबाधित करें %1$s को</string> + <string name="backup_action_keep_count">रखें %1$s</string> + <string name="backup_action_rejoin">पुनःजुडें %1$s</string> + <string name="backup_action_remute">पुनःमौन %1$s</string> + <string name="backup_action_restore_count">पुनःस्थापन %1$s</string> + <string name="backup_action_restore_feeds">सूचनावलियाँ पुनःस्थापन</string> + <string name="backup_action_restore_places">स्थल पुनःस्थापन</string> + <string name="backup_action_restore_profile">परिचय पुनःस्थापध</string> + <string name="backup_action_restore_providers">प्रदाता पुनःस्थापन</string> + <string name="backup_action_restore_relays">पुनःप्रसारक पुनःस्थापन</string> + <string name="backup_action_restore_topics">विषय पुनःस्थापन</string> + <string name="backup_action_restore_wallet">धनकोष पुनःस्थापन</string> + <string name="backup_card_accept">स्वीकार</string> + <plurals name="backup_card_and_added"> + <item quantity="one">%1$s तथा %2$d जोडा</item> + <item quantity="other">%1$s तथा %2$d जोडे</item> + </plurals> + <plurals name="backup_card_and_blocked"> + <item quantity="one">%1$s तथा %2$d बाधित किया</item> + <item quantity="other">%1$s तथा %2$d को बाधित किए</item> + </plurals> + <plurals name="backup_card_and_followed"> + <item quantity="one">%1$s तथा %2$d का अनुगमन किया</item> + <item quantity="other">%1$s तथा %2$d का अनुगमन किए</item> + </plurals> + <plurals name="backup_card_and_joined"> + <item quantity="one">%1$s तथा %2$d से जुडे</item> + <item quantity="other">%1$s तथा %2$d से जुडे</item> + </plurals> + <plurals name="backup_card_and_muted"> + <item quantity="one">%1$s तथा %2$d को मौनकृत किया</item> + <item quantity="other">%1$s तथा %2$d को मौनकृत किए</item> + </plurals> + <string name="backup_card_app_settings">आपके अमेथिस्ट समचरणीकृत क्रमक स्थापना विकल्पों को परिवर्तित किया गया एक अन्य क्रमक में और वह अमेथिस्ट नहीं था। इससे समस्याएँ उत्पन्न हो सकते हैं।</string> + <string name="backup_card_concord_emptied">आपने अपनी कोंकोर्ड सूची रिक्त की</string> + <string name="backup_card_concord_rewritten">आपने अपनी कोंकोर्ड सूची का परिवर्तन किया</string> + <plurals name="backup_card_dm_relays_lost"> + <item quantity="one">आपने %1$d सीधासन्देश पुनःप्रसारक हटाया</item> + <item quantity="other">आपने %1$d सीधासन्देश पुनःप्रसारकों को हटाए</item> + </plurals> + <plurals name="backup_card_feeds_removed"> + <item quantity="one">आपने %1$d इष्ट सूचनावली हटाया</item> + <item quantity="other">आपने %1$d इष्ट सूचनावलियों को हटाए</item> + </plurals> + <plurals name="backup_card_follows_dropped"> + <item quantity="one">आपने %1$d व्यक्ति का अनुगमन हटाया</item> + <item quantity="other">आपने %1$d व्यक्तियों का अनुगमन हटाए</item> + </plurals> + <plurals name="backup_card_hashtags_unfollowed"> + <item quantity="one">आपने %1$d विषयसूचक का अनुगमन हटाया</item> + <item quantity="other">आपने %1$d विषयसूचकों का अनुगमन हटाए</item> + </plurals> + <plurals name="backup_card_indexer_relays_lost"> + <item quantity="one">आपने %1$d अनुक्रमणीकार पुनःप्रसारक हटाया</item> + <item quantity="other">आपने %1$d अनुक्रमणीकार पुनःप्रसारकों को हटाए</item> + </plurals> + <plurals name="backup_card_key_package_relays_lost"> + <item quantity="one">आपने %1$d समूहचर्चा कुंचिका पुनःप्रसारक हटाया</item> + <item quantity="other">आपने %1$d समूहचर्चा कुंचिका पुनःप्रसारकों को हटाए</item> + </plurals> + <plurals name="backup_card_leave_chats"> + <item quantity="one">आपने %1$d सार्वजनिक चर्चा छोड दिया</item> + <item quantity="other">आपने %1$d सार्वजनिक चर्चाओं को छोड दिए</item> + </plurals> + <plurals name="backup_card_leave_communities"> + <item quantity="one">आपने %1$d समुदाय छोड दिया</item> + <item quantity="other">आपने %1$d समुदायों को छोड दिए</item> + </plurals> + <plurals name="backup_card_leave_groups"> + <item quantity="one">आपने %1$d समूह छोड दिया</item> + <item quantity="other">आपने %1$d समूहों को छोड दिए</item> + </plurals> + <plurals name="backup_card_leave_rooms"> + <item quantity="one">आपने %1$d चर्चाशाला छोड दिया</item> + <item quantity="other">आपने %1$d चर्चाशालाओं को छोड दिए</item> + </plurals> + <plurals name="backup_card_mutes_visible"> + <item quantity="one">आपने %1$d की मौनावस्था हटाया</item> + <item quantity="other">आपने %1$d की मौनावस्था हटाए</item> + </plurals> + <plurals name="backup_card_nip65_lost"> + <item quantity="one">आपने %1$d सार्वजनिक पुनःप्रसारक हटाया</item> + <item quantity="other">आपने %1$d सार्वजनिक पुनःप्रसारकों को हटाए</item> + </plurals> + <string name="backup_card_nutzap_key_removed">आपने अपनी नटज्साप कुंचिका को हटाया</string> + <string name="backup_card_nutzap_key_replaced">आपने अपनी नटज्साप कुंचिका का प्रतिस्थापन किया</string> + <plurals name="backup_card_nutzap_mints_removed"> + <item quantity="one">आपने %1$d नटज्साप टकसाल हटाया</item> + <item quantity="other">आपने %1$d नटज्साप टकसालों को हटाए</item> + </plurals> + <plurals name="backup_card_offers_removed"> + <item quantity="one">आपने %1$d बोल्ट॰बारह प्रस्ताव हटाया</item> + <item quantity="other">आपने %1$d बोल्ट॰बारह प्रस्तावों को हटाए</item> + </plurals> + <plurals name="backup_card_payment_targets_removed"> + <item quantity="one">आपने %1$d भुगतान प्राप्त करने की विधि हटाया</item> + <item quantity="other">आपने %1$d भुगतान प्राप्त करने के विधियों को हटाए</item> + </plurals> + <plurals name="backup_card_places_unfollowed"> + <item quantity="one">आपने %1$d स्थल का अनुगमन हटाया</item> + <item quantity="other">आपने %1$d स्थलों का अनुगमन हटाए</item> + </plurals> + <plurals name="backup_card_private_outbox_lost"> + <item quantity="one">आपने %1$d निजी पुनःप्रसारक हटाया</item> + <item quantity="other">आपने %1$d निजी पुनःप्रसारकों को हटाए</item> + </plurals> + <plurals name="backup_card_profile_lost_fields"> + <item quantity="one">आपने %1$d परिचय प्रपत्रस्थान हटाया</item> + <item quantity="other">आपने %1$d परिचय प्रपत्रस्थान हटाए</item> + </plurals> + <plurals name="backup_card_relay_feeds_lost"> + <item quantity="one">आपने %1$d पुनःप्रसारक सूचनावली हटाया</item> + <item quantity="other">आपने %1$d पुनःप्रसारक सूचनावलियाँ हटाए</item> + </plurals> + <plurals name="backup_card_search_relays_lost"> + <item quantity="one">आपने %1$d खोज पुनःप्रसारक हटाया</item> + <item quantity="other">आपने %1$d खोज पुनःप्रसारकों को हटाए</item> + </plurals> + <plurals name="backup_card_trust_services_changed"> + <item quantity="one">आपने %1$d विश्वाससेवा प्रदाता परिवर्तित किया</item> + <item quantity="other">आपने %1$d विश्वाससेवाओं के प्रदाता को परिवर्तित किया</item> + </plurals> + <plurals name="backup_card_trusted_lost"> + <item quantity="one">आपने %1$d पुनःप्रसारक पर विश्वास करना रोक दिया</item> + <item quantity="other">आपने %1$d पुनःप्रसारकों पर विश्वास करना रोक दिए</item> + </plurals> + <plurals name="backup_card_unblocked"> + <item quantity="one">आपने %1$d पुनःप्रसारक अबाधित किया</item> + <item quantity="other">आपने %1$d पुनःप्रसारकों को अबाधित किए</item> + </plurals> + <string name="backup_card_wallet_emptied">आपने अपना काशयू धनकोष रिक्त किया</string> + <string name="backup_card_wallet_rewritten">आपने अपने काशयू धनकोष को परिवर्तित किया</string> + <string name="backup_conflict_added">जोडे गए (%1$s)</string> + <string name="backup_conflict_changed">परिवर्तित (%1$s)</string> + <string name="backup_conflict_count_added">%1$s जोडे गए</string> + <string name="backup_conflict_count_changed">%1$s परिवर्तित</string> + <string name="backup_conflict_count_removed">%1$s हटाए गए</string> + <string name="backup_conflict_keep_new">नया संस्करण का उपयोग करें</string> + <string name="backup_conflict_private_added">आपने निजी (रहस्यीकृत) वस्तुओं को जोडा।</string> + <string name="backup_conflict_private_changed">आपने निजी (रहस्यीकृत) वस्तुओं का परिवर्तन भी किया। उनकी तुलना यहाँ नहीं की जा सकती।</string> + <string name="backup_conflict_private_cleared">आपने सभी निजी (रहस्यीकृत) वस्तुओं को हटा दिया।</string> + <string name="backup_conflict_relay_read_only">पठनेवशक्य</string> + <string name="backup_conflict_relay_read_write">पठन तथा लेखन</string> + <string name="backup_conflict_relay_write_only">लेखनेवशक्य</string> + <string name="backup_conflict_removed">हटाए गए (%1$s)</string> + <string name="backup_conflict_restore_mine">सुरक्षित संस्करण पुनःस्थापन</string> + <string name="backup_conflict_title">आपने अपना %1$s अन्य क्रमक में परिवर्तित किया</string> + <string name="backup_entry_algo_feed">सूचनावलियाँ</string> + <string name="backup_entry_chat_room">चर्चा शालाएँ</string> + <string name="backup_entry_community">समुदाय</string> + <string name="backup_entry_hashtag">विषयसूचक</string> + <string name="backup_entry_identity_claim">सम्बन्धित व्यक्तिगण</string> + <string name="backup_entry_location">स्थान</string> + <string name="backup_entry_mint">टकसाल</string> + <string name="backup_entry_nutzap_key">नटज्साप कुंचिकाएँ</string> + <string name="backup_entry_offer">प्रस्ताव</string> + <string name="backup_entry_other">अन्य प्रविष्टियाँ</string> + <string name="backup_entry_payment_target">भुगतान पते</string> + <string name="backup_entry_person">लोग</string> + <string name="backup_entry_profile_field">परिचय प्रपत्रस्थान</string> + <string name="backup_entry_public_chat">सार्वजनिक चर्चाएँ</string> + <string name="backup_entry_relay">पुनःप्रसारक</string> + <string name="backup_entry_relay_group">समूह</string> + <string name="backup_entry_thread">सूत्र</string> + <string name="backup_entry_trust_provider">विश्वाससेवा प्रदाता</string> + <string name="backup_entry_word">शब्द</string> + <string name="backup_profile_field_about">जानकारी</string> + <string name="backup_profile_field_banner">ध्वज</string> + <string name="backup_profile_field_birthday">जन्मदिन</string> + <string name="backup_profile_field_bot">क्रमचर चिह्न</string> + <string name="backup_profile_field_clink_offer">क्लिंक॰ प्रस्ताव</string> + <string name="backup_profile_field_display_name">प्रदर्शन नाम</string> + <string name="backup_profile_field_lud06">लैटनिंग जालपता</string> + <string name="backup_profile_field_lud16">लैटनिंग पता</string> + <string name="backup_profile_field_name">प्रयोक्तानाम</string> + <string name="backup_profile_field_nip05">नोस्टर पता</string> + <string name="backup_profile_field_picture">चित्र</string> + <string name="backup_profile_field_pronouns">सर्वनाम</string> + <string name="backup_profile_field_website">जालस्थान</string> + <string name="backup_review_allowed_tag">अनुमत</string> + <string name="backup_review_changed_by_other_app">अन्य क्रमक में परिवर्तित। %1$s</string> + <string name="backup_review_concord_body">आपके कोंकोर्ड समुदाय आपके लिए रहस्यीकृत हैं। इसलिए उनकी तुलना यहाँ नहीं की जा सकती। पुनःस्थापन उन्हीं को लौट डालेगा जिनका अभिलेखन इस यन्त्र ने किया।</string> + <string name="backup_review_demoted_tag">स्थानान्तरित</string> + <string name="backup_review_dropped_count">%1$s परित्यक्त</string> + <string name="backup_review_dropped_tag">परित्यक्त</string> + <string name="backup_review_encrypted_added">आपने उसे बनाया</string> + <string name="backup_review_encrypted_changed">आपने उसे परिवर्तित किया</string> + <string name="backup_review_encrypted_cleared">आपने उसे रिक्त किया</string> + <string name="backup_review_feed">सूचनावली</string> + <string name="backup_review_gone">चला गया</string> + <string name="backup_review_hashtags_you_follow">विषयसूचक जिनका आप अनुगमन करते हैं</string> + <string name="backup_review_inbox">आगतपेटिका</string> + <string name="backup_review_inbox_explainer">जहाँ अन्य आप तक अभिगमन करते हैं</string> + <string name="backup_review_joined">जुड गए</string> + <string name="backup_review_kept">रखे गए</string> + <string name="backup_review_kept_count">%1$s रखे गए</string> + <string name="backup_review_key_removed">ग्राहक कुंचिका हटाया गया</string> + <string name="backup_review_key_replaced">ग्राहक कुंचिका प्रतिस्थापित</string> + <string name="backup_review_key_warning">नटज्साप आगे से इस कुंचिका से बद्ध होंगे। यदि इस यन्त्र में वह नहीं है तो आप सम्भाव्यतः उनको यहाँ नहीं चुका सकते।</string> + <string name="backup_review_left">शेष</string> + <string name="backup_review_left_tag">शेष</string> + <string name="backup_review_listed_tag">सूचीबद्ध</string> + <string name="backup_review_moved_tag">स्थानान्तरित</string> + <string name="backup_review_names_and_more">%1$s तथा %2$s अधिक</string> + <string name="backup_review_new">नया संस्करण</string> + <string name="backup_review_new_count">%1$s नए</string> + <string name="backup_review_new_count_caption">नव्य</string> + <string name="backup_review_new_tag">नव्य</string> + <string name="backup_review_newly_blocked">नव्यतः बाधित</string> + <string name="backup_review_newly_muted">%1$s नए मौनकृत</string> + <string name="backup_review_no_longer_blocked">अब से बाधित नहीं</string> + <string name="backup_review_not_set">स्थापित नहीं</string> + <string name="backup_review_nothing_here">यहाँ कुछ नहीं</string> + <string name="backup_review_offer">बोल्ट॰बारह प्रस्ताव</string> + <plurals name="backup_review_offers_gone"> + <item quantity="one">%1$d प्रस्ताव हटाया गया</item> + <item quantity="other">%1$d प्रस्ताव हटाए गए</item> + </plurals> + <string name="backup_review_outbox">निर्गतपेटिका</string> + <string name="backup_review_outbox_explainer">आप जहाँ प्रकाशित करते हैं</string> + <plurals name="backup_review_payment_targets_gone"> + <item quantity="one">आपको भुगतान करने की %1$d विधि हटाया गया</item> + <item quantity="other">आपको भुगतान करने की %1$d विधियाँ हटाए गए</item> + </plurals> + <string name="backup_review_payments_explainer">लोग जो आपको भुगतान करते हैं उसी को देखते हैं जो इस सूची में है।</string> + <string name="backup_review_places_gone">स्थल हटाए गए</string> + <string name="backup_review_places_you_follow">स्थल जिनका आप अनुगमन करते हैं</string> + <string name="backup_review_private_added_body">वे अब रहस्यीकृत हैं। जो कि सम्भाव्यतः ऊपर के सार्वजनिक वस्तुओं का गन्तव्य था।</string> + <string name="backup_review_private_added_title">आपने वस्तुओं को निजी किया</string> + <string name="backup_review_private_changed_body">वे रहस्यीकृत हैं। इसलिए उनकी तुलना यहाँ नहीं की जा सकती।</string> + <string name="backup_review_private_changed_title">आपने निजी वस्तुओं का परिवर्तन किया</string> + <string name="backup_review_private_wiped_body">वे रहस्यीकृत हैं। इसलिए केवल आप देख सकते हैं कि वे क्या थे। पुनःस्थापन से सब लौटके आ जाएँगे।</string> + <string name="backup_review_private_wiped_title">आपने सभी निजी वस्तुओं को हटा दिया</string> + <string name="backup_review_receiving_tag">ग्रहण मध्य</string> + <string name="backup_review_renamed">पुनःनामकृत</string> + <string name="backup_review_renamed_tag">पुनःनामकृत</string> + <string name="backup_review_saved">इस यन्त्र पर</string> + <string name="backup_review_search_people">%1$s लोग खोजें</string> + <string name="backup_review_searching_tag">खोज मध्य</string> + <string name="backup_review_service">सेवा</string> + <string name="backup_review_service_followers">अनुचर</string> + <string name="backup_review_service_rank">श्रेणी</string> + <string name="backup_review_service_topics">विषयसूची</string> + <string name="backup_review_services_changed">%2$s में से %1$s सेवाएँ परिवर्तित</string> + <string name="backup_review_services_changed_explainer">वे अब अन्य व्यक्ति से आते है। अथवा किसी से नहीं</string> + <string name="backup_review_still_blocked">अभी भी बाधित</string> + <string name="backup_review_storing_tag">अभिलेखन मध्य</string> + <string name="backup_review_tab_dropped">परित्यक्त। %1$s</string> + <string name="backup_review_tab_edited">सम्पादित। %1$s</string> + <string name="backup_review_tab_new">नए। %1$s</string> + <string name="backup_review_title_cleared">%1$s पारित</string> + <string name="backup_review_title_updated">%1$s अद्यतनकृत</string> + <string name="backup_review_topics_gone">विषय हटाए गए</string> + <string name="backup_review_trust_warning">श्रेणीयाँ तथा अनुचर गिनती तथा कचरालेख छालन जो आप देखते हैं इन प्रदाताओं से आते हैं।</string> + <string name="backup_review_trusted_tag">विश्वसनीय</string> + <string name="backup_review_unblocked">%1$s अबाधित</string> + <string name="backup_review_unblocked_explainer">अमेथिस्ट पुनः उनसे जुडेगा</string> + <string name="backup_review_units_tag">इकाई</string> + <string name="backup_review_unmuted">%1$s मौनावस्था हटाए गए</string> + <string name="backup_review_unmuted_explainer">ये पुनः आपके सूचनावलियों तक अभिगम्य</string> + <string name="backup_review_untrusted_tag">अविश्वसनीय</string> + <string name="backup_review_wallet_body">आपके धनकोष के टकसाल तथा कुंचिकाएँ आपके लिए रहस्यीकृत हैं। इसलिए उनकी तुलना वस्तु प्रति वस्तु यहाँ नहीं की जा सकती। पुनःस्थापन उन्हीं को लौट डालेगा जिनका अभिलेखन इस यन्त्र ने किया।</string> + <string name="backup_review_was_named">पूर्वतः %1$s था</string> + <string name="backup_review_words_and_hashtags">शब्द तथा विषयसूचक</string> + <string name="backup_type_app_settings">समचरणीकृत क्रमक स्थापना विकल्प</string> + <string name="backup_type_app_settings_explainer">अमेथिस्ट स्थापना विकल्प समचरणीकृत आपके यन्त्रों में। वे रहस्यीकृत हैं। इसलिए केवल उनकी उपस्थिति की तुलना की जा सकती है।</string> + <string name="backup_type_blocked_relays">बाधित पुनःप्रसारक सूची</string> + <string name="backup_type_blocked_relays_explainer">पुनःप्रसारक जिनसे यह क्रमक कभी भी संयोजन नहीं करता।</string> + <string name="backup_type_bolt12_offers">बोल्ट॰बारह प्रस्ताव</string> + <string name="backup_type_bolt12_offers_explainer">लैटनिंग प्रस्ताव जिनका उपयोग करके अन्य लोग आपको भुगतान करते हैं।</string> + <string name="backup_type_cashu_wallet">काशयू धनकोष</string> + <string name="backup_type_cashu_wallet_explainer">आपके ईकाश धनकोष स्थापना विकल्प तथा टकसाल। वे रहस्यीकृत हैं। इसलिए केवल उनकी उपस्थिति की तुलना की जा सकती है।</string> + <string name="backup_type_communities">समुदाय सूची</string> + <string name="backup_type_communities_explainer">समुदाय जिनसे आप जुडे।</string> + <string name="backup_type_concord_communities">कोंकोर्ड समुदाय सूची</string> + <string name="backup_type_concord_communities_explainer">कोंकोर्ड समुदाय जिनसे आप जुडे। वे रहस्यीकृत हैं। इसलिए केवल उनकी उपस्थिति की तुलना की जा सकती है।</string> + <string name="backup_type_dm_relays">सीधासन्देश पुनःप्रसारक सूची</string> + <string name="backup_type_dm_relays_explainer">जहाँ अन्य आपके निजी सन्देश भेजते हैं।</string> + <string name="backup_type_ephemeral_chats">अस्थायी चर्चा सूची</string> + <string name="backup_type_ephemeral_chats_explainer">अस्थायी चर्चा शालाएँ जिनसे आप जुडे।</string> + <string name="backup_type_favorite_algo_feeds">इष्ट सूचनावली सूची</string> + <string name="backup_type_favorite_algo_feeds_explainer">कलनविध्यात्मक सूचनावलियाँ जिनको आपने अभिलेखित किया।</string> + <string name="backup_type_follow_list">अनुचरण सूची</string> + <string name="backup_type_follow_list_explainer">निर्णय करता है किसके पत्र आपकी मुख्य सूचनावली में प्रकट होंगे।</string> + <string name="backup_type_geohashes">अनुचरित स्थान</string> + <string name="backup_type_geohashes_explainer">स्थान जहाँ से पत्र आपकी मुख्य सूचनावली में प्रकट होंगे।</string> + <string name="backup_type_hashtags">अनुचरित विषयसूचक</string> + <string name="backup_type_hashtags_explainer">विषयसूचक जिससे युक्त पत्र आपकी मुख्य सूचनावली में प्रकट होंगे।</string> + <string name="backup_type_indexer_relays">अनुक्रमणीकार पुनःप्रसारक सूची</string> + <string name="backup_type_indexer_relays_explainer">पुनःप्रसारक उपयुक्त अन्य लोगों के परिचय तथा पुनःप्रसारक सूचियों को प्राप्त करने के लिए।</string> + <string name="backup_type_key_package_relays">समूहचर्चा कुंचिका पुनःप्रसारक</string> + <string name="backup_type_key_package_relays_explainer">जहाँ अन्य उन कुंचिकाओं को प्राप्त करते हैं आपको रहस्यीकृत समूहचर्चाओं में जोडने के लिए।</string> + <string name="backup_type_mute_list">मौन सूची</string> + <string name="backup_type_mute_list_explainer">छिपाता है लोग शब्द विषयसूचक तथा सूत्र उन सब में से जो आप देखते हैं।</string> + <string name="backup_type_nutzap_info">नटज्साप प्राप्ती स्थापना विकल्प</string> + <string name="backup_type_nutzap_info_explainer">टकसाल तथा कुंचिका जिनका उपयोग अन्य करते हैं आपको नटज्साप भेजने के लिए।</string> + <string name="backup_type_other">सूची</string> + <string name="backup_type_other_explainer">इस यन्त्र पर अभिलेखित सूची।</string> + <string name="backup_type_outbox_inbox_relays">सार्वजनिक पुनःप्रसारक सूची</string> + <string name="backup_type_outbox_inbox_relays_explainer">सबको बताता है आपके पत्र कहाँ प्राप्त करें तथा आपको उत्तर तथा उल्लेखों को कहाँ भेजें।</string> + <string name="backup_type_payment_targets">भुगतान पते</string> + <string name="backup_type_payment_targets_explainer">विधियाँ जिनसे अन्य लोग आपको भुगतान कर सके।</string> + <string name="backup_type_private_outbox_relays">निजी पुनःप्रसारक सूची</string> + <string name="backup_type_private_outbox_relays_explainer">जहाँ आपके पाण्डुलिपियाँ तथा निजी जानकारी रखे जाते हैं।</string> + <string name="backup_type_profile">परिचय</string> + <string name="backup_type_profile_explainer">आपका नाम चित्र चरित तथा भुगतान पते। जैसे सब को दिखते हैं वैसे।</string> + <string name="backup_type_public_chats">सार्वजनिक चर्चा सूची</string> + <string name="backup_type_public_chats_explainer">सार्वजनिक चर्चाएँ जिनसे आप जुडे।</string> + <string name="backup_type_relay_feeds">इष्ट पुनःप्रसारक सूचनावलियाँ</string> + <string name="backup_type_relay_feeds_explainer">पुनःप्रसारक जिनका आप वीक्षण करते हैं सूचनावलियों के रूप में।</string> + <string name="backup_type_relay_groups">समूह सूची</string> + <string name="backup_type_relay_groups_explainer">पुनःप्रसारक आधारित समूह जिनसे आप जुडे।</string> + <string name="backup_type_search_relays">खोज पुनःप्रसारक सूची</string> + <string name="backup_type_search_relays_explainer">उपयुक्त पुनःप्रसारक जब आप खोजते हैं।</string> + <string name="backup_type_trust_providers">विश्वाससेवा प्रदाता सूची</string> + <string name="backup_type_trust_providers_explainer">सेवाएँ जिनपर आप विश्वास करते है आपके लिए लोगों का सत्यापन तथा श्रेणीकरण करने के लिए।</string> + <string name="backup_type_trusted_relays">विश्वसनीय पुनःप्रसारक सूची</string> + <string name="backup_type_trusted_relays_explainer">पुनःप्रसारक जिनपर आप पर्याप्त विश्वास करते हैं बिना पूछे उनसे संयोजन करने के लिए।</string> </resources> diff --git a/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml b/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml index 950cdfa8b9..4931f70f61 100644 --- a/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml @@ -5287,4 +5287,322 @@ <string name="cyberspace_bag_unsigned">Aláírás nélküli, így ez a szerző csak állítás</string> <string name="cyberspace_bag_unknown_kind">Egy %1$d típusú elem, amelyet ez a kliens nem jelenít meg</string> <string name="cyberspace_bag_opaque">%1$d bájt valamiből, amit ez a kliens nem olvas</string> + <string name="backup_action_block_again">%1$s újbóli letiltása</string> + <string name="backup_action_keep_count">%1$s megtartása</string> + <string name="backup_action_rejoin">Újbóli csatlakozás ehhez: %1$s</string> + <string name="backup_action_remute">%1$s újbóli némítása</string> + <string name="backup_action_restore_count">%1$s visszaállítása</string> + <string name="backup_action_restore_feeds">Hírfolyamok visszaállítása</string> + <string name="backup_action_restore_places">Helyek visszaállítása</string> + <string name="backup_action_restore_profile">Profil visszaállítása</string> + <string name="backup_action_restore_providers">Szolgáltatók visszaállítása</string> + <string name="backup_action_restore_relays">Átjátszók visszaállítása</string> + <string name="backup_action_restore_topics">Témák visszaállítása</string> + <string name="backup_action_restore_wallet">Pénztárca visszaállítása</string> + <string name="backup_card_accept">Elfogadás</string> + <plurals name="backup_card_and_added"> + <item quantity="one">%1$s és %2$d hozzáadva</item> + <item quantity="other">%1$s és %2$d hozzáadva</item> + </plurals> + <plurals name="backup_card_and_blocked"> + <item quantity="one">%1$s és %2$d letiltva</item> + <item quantity="other">%1$s és %2$d letiltva</item> + </plurals> + <plurals name="backup_card_and_followed"> + <item quantity="one">%1$s és %2$d követve</item> + <item quantity="other">%1$s és %2$d követve</item> + </plurals> + <plurals name="backup_card_and_joined"> + <item quantity="one">%1$s és %2$d csatlakozva</item> + <item quantity="other">%1$s és %2$d csatlakozva</item> + </plurals> + <plurals name="backup_card_and_muted"> + <item quantity="one">%1$s és %2$d némítva</item> + <item quantity="other">%1$s és %2$d némítva</item> + </plurals> + <string name="backup_card_app_settings">A szinkronizált Amethyst alkalmazásbeállításai egy másik, nem Amethyst alkalmazásban módosultak. Ez problémákat okozhat.</string> + <string name="backup_card_concord_emptied">Ön kiürítette a Concord listáját</string> + <string name="backup_card_concord_rewritten">Ön módosította a Concord listáját</string> + <plurals name="backup_card_dm_relays_lost"> + <item quantity="one">Ön %1$d privát üzenetátjátszót távolított el</item> + <item quantity="other">%1$d privát üzenet átjátszót távolított el</item> + </plurals> + <plurals name="backup_card_feeds_removed"> + <item quantity="one">Ön %1$d kedvenc hírfolyamot távolított el</item> + <item quantity="other">%1$d kedvenc hírfolyamot távolított el</item> + </plurals> + <plurals name="backup_card_follows_dropped"> + <item quantity="one">%1$d személyt nem követ többé</item> + <item quantity="other">%1$d személyt nem követ többé</item> + </plurals> + <plurals name="backup_card_hashtags_unfollowed"> + <item quantity="one">Ön %1$d kulcsszót nem követ többé</item> + <item quantity="other">%1$d hashtaget nem követ többé</item> + </plurals> + <plurals name="backup_card_indexer_relays_lost"> + <item quantity="one">Ön %1$d indexelő átjátszót távolított el</item> + <item quantity="other">%1$d indexelő átjátszót távolított el</item> + </plurals> + <plurals name="backup_card_key_package_relays_lost"> + <item quantity="one">Ön %1$d csoportos csevegési kulcsátjátszót távolított el</item> + <item quantity="other">%1$d csoportcsevegés kulcs átjátszót távolított el</item> + </plurals> + <plurals name="backup_card_leave_chats"> + <item quantity="one">Ön %1$d nyilvános csevegést hagyott el</item> + <item quantity="other">%1$d nyilvános csevegést hagyott el</item> + </plurals> + <plurals name="backup_card_leave_communities"> + <item quantity="one">Ön %1$d közösséget hagyott el</item> + <item quantity="other">%1$d közösséget hagyott el</item> + </plurals> + <plurals name="backup_card_leave_groups"> + <item quantity="one">Ön %1$d csoportot hagyott el</item> + <item quantity="other">%1$d csoportot hagyott el</item> + </plurals> + <plurals name="backup_card_leave_rooms"> + <item quantity="one">Ön %1$d csevegőszobát hagyott el</item> + <item quantity="other">%1$d csevegőszobát hagyott el</item> + </plurals> + <plurals name="backup_card_mutes_visible"> + <item quantity="one">Ön %1$d dolog némítását oldotta fel</item> + <item quantity="other">%1$d dolog némítását oldotta fel</item> + </plurals> + <plurals name="backup_card_nip65_lost"> + <item quantity="one">Ön %1$d nyilvános átjátszót távolított el</item> + <item quantity="other">%1$d nyilvános átjátszót távolított el</item> + </plurals> + <string name="backup_card_nutzap_key_removed">Ön eltávolította a nutzap kulcsát</string> + <string name="backup_card_nutzap_key_replaced">Ön lecserélte a nutzap kulcsát</string> + <plurals name="backup_card_nutzap_mints_removed"> + <item quantity="one">Ön %1$d nutzap pénzverdét távolított el</item> + <item quantity="other">%1$d nutzap pénzverdét távolított el</item> + </plurals> + <plurals name="backup_card_offers_removed"> + <item quantity="one">Ön %1$d BOLT12 ajánlatot távolított el</item> + <item quantity="other">%1$d BOLT12 ajánlatot távolított el</item> + </plurals> + <plurals name="backup_card_payment_targets_removed"> + <item quantity="one">Ön %1$d fizetési módot távolított el</item> + <item quantity="other">%1$d fizetési módot távolított el</item> + </plurals> + <plurals name="backup_card_places_unfollowed"> + <item quantity="one">Ön %1$d helyet nem követ többé</item> + <item quantity="other">%1$d helyet nem követ többé</item> + </plurals> + <plurals name="backup_card_private_outbox_lost"> + <item quantity="one">Ön %1$d privát átjátszót távolított el</item> + <item quantity="other">%1$d privát átjátszót távolított el</item> + </plurals> + <plurals name="backup_card_profile_lost_fields"> + <item quantity="one">Ön %1$d profilmezőt távolított el</item> + <item quantity="other">%1$d profilmezőt távolított el</item> + </plurals> + <plurals name="backup_card_relay_feeds_lost"> + <item quantity="one">Ön %1$d átjátszó-hírfolyamot távolított el</item> + <item quantity="other">%1$d átjátszó hírfolyamot távolított el</item> + </plurals> + <plurals name="backup_card_search_relays_lost"> + <item quantity="one">Ön %1$d kereső átjátszót távolított el</item> + <item quantity="other">%1$d kereső átjátszót távolított el</item> + </plurals> + <plurals name="backup_card_trust_services_changed"> + <item quantity="one">Ön %1$d bizalmi szolgáltatás szolgáltatóját módosította</item> + <item quantity="other">%1$d bizalmi szolgáltatás szolgáltatóját változtatta meg</item> + </plurals> + <plurals name="backup_card_trusted_lost"> + <item quantity="one">Ön %1$d átjátszóban nem bízik többé</item> + <item quantity="other">%1$d átjátszóban nem bízik többé</item> + </plurals> + <plurals name="backup_card_unblocked"> + <item quantity="one">Ön %1$d átjátszó letiltását oldotta fel</item> + <item quantity="other">%1$d átjátszó blokkolását oldotta fel</item> + </plurals> + <string name="backup_card_wallet_emptied">Ön kiürítette a Cashu pénztárcáját</string> + <string name="backup_card_wallet_rewritten">Ön módosította a Cashu pénztárcáját</string> + <string name="backup_conflict_added">Hozzáadva (%1$s)</string> + <string name="backup_conflict_changed">Módosítva (%1$s)</string> + <string name="backup_conflict_count_added">%1$s hozzáadva</string> + <string name="backup_conflict_count_changed">%1$s módosítva</string> + <string name="backup_conflict_count_removed">%1$s eltávolítva</string> + <string name="backup_conflict_keep_new">Új verzió használata</string> + <string name="backup_conflict_private_added">Ön privát (titkosított) elemeket adott hozzá.</string> + <string name="backup_conflict_private_changed">Ön privát (titkosított) elemeket is módosított. Ezek itt nem hasonlíthatók össze.</string> + <string name="backup_conflict_private_cleared">Ön eltávolította az összes privát (titkosított) elemet.</string> + <string name="backup_conflict_relay_read_only">csak olvasható</string> + <string name="backup_conflict_relay_read_write">olvasás és írás</string> + <string name="backup_conflict_relay_write_only">csak írható</string> + <string name="backup_conflict_removed">Eltávolítva (%1$s)</string> + <string name="backup_conflict_restore_mine">Mentett verzió visszaállítása</string> + <string name="backup_conflict_title">Ön módosította a következőt: %1$s, egy másik alkalmazásban</string> + <string name="backup_entry_algo_feed">Hírfolyamok</string> + <string name="backup_entry_chat_room">Csevegőszobák</string> + <string name="backup_entry_community">Közösségek</string> + <string name="backup_entry_hashtag">Kulcsszavak</string> + <string name="backup_entry_identity_claim">Kapcsolt identitások</string> + <string name="backup_entry_location">Helyek</string> + <string name="backup_entry_mint">Pénzverdék</string> + <string name="backup_entry_nutzap_key">Nutzap kulcsok</string> + <string name="backup_entry_offer">Ajánlatok</string> + <string name="backup_entry_other">Egyéb bejegyzések</string> + <string name="backup_entry_payment_target">Fizetési címek</string> + <string name="backup_entry_person">Személyek</string> + <string name="backup_entry_profile_field">Profilmezők</string> + <string name="backup_entry_public_chat">Nyilvános csevegések</string> + <string name="backup_entry_relay">Átjátszók</string> + <string name="backup_entry_relay_group">Csoportok</string> + <string name="backup_entry_thread">Beszélgetések</string> + <string name="backup_entry_trust_provider">Bizalmi szolgáltatók</string> + <string name="backup_entry_word">Szavak</string> + <string name="backup_profile_field_about">Névjegy</string> + <string name="backup_profile_field_banner">Borító</string> + <string name="backup_profile_field_birthday">Születésnap</string> + <string name="backup_profile_field_bot">Bot jelölő</string> + <string name="backup_profile_field_clink_offer">CLINK-ajánlat</string> + <string name="backup_profile_field_display_name">Megjelenített név</string> + <string name="backup_profile_field_lud06">LNURL</string> + <string name="backup_profile_field_lud16">Lightning-cím</string> + <string name="backup_profile_field_name">Felhasználónév</string> + <string name="backup_profile_field_nip05">Nostr-cím</string> + <string name="backup_profile_field_picture">Kép</string> + <string name="backup_profile_field_pronouns">Névmások</string> + <string name="backup_profile_field_website">Weboldal</string> + <string name="backup_review_allowed_tag">Engedélyezve</string> + <string name="backup_review_changed_by_other_app">Módosítva egy másik alkalmazásban · %1$s</string> + <string name="backup_review_concord_body">A Concord közösségei Önhöz vannak titkosítva, így itt nem hasonlíthatók össze. A visszaállítás pontosan azt hozza vissza, amit ez az eszköz mentett.</string> + <string name="backup_review_demoted_tag">Áthelyezve</string> + <string name="backup_review_dropped_count">%1$s elvetve</string> + <string name="backup_review_dropped_tag">Elvetve</string> + <string name="backup_review_encrypted_added">Ön hozta létre</string> + <string name="backup_review_encrypted_changed">Ön módosította</string> + <string name="backup_review_encrypted_cleared">Ön kiürítette</string> + <string name="backup_review_feed">Hírfolyam</string> + <string name="backup_review_gone">Eltűnt</string> + <string name="backup_review_hashtags_you_follow">Ön által követett kulcsszavak</string> + <string name="backup_review_inbox">Bejövő</string> + <string name="backup_review_inbox_explainer">ahol mások elérik Önt</string> + <string name="backup_review_joined">csatlakozott</string> + <string name="backup_review_kept">megtartva</string> + <string name="backup_review_kept_count">%1$s megtartva</string> + <string name="backup_review_key_removed">Fogadási kulcs eltávolítva</string> + <string name="backup_review_key_replaced">Fogadási kulcs lecserélve</string> + <string name="backup_review_key_warning">A nutzapok ehhez az új kulcshoz lesznek kötve. Ha ez az eszköz nem rendelkezik vele, lehet, hogy itt nem tudja beváltani őket.</string> + <string name="backup_review_left">elhagyta a csoportot</string> + <string name="backup_review_left_tag">Elhagyva</string> + <string name="backup_review_listed_tag">Listázva</string> + <string name="backup_review_moved_tag">Áthelyezve</string> + <string name="backup_review_names_and_more">%1$s és %2$s további</string> + <string name="backup_review_new">Új verzió</string> + <string name="backup_review_new_count">%1$s új</string> + <string name="backup_review_new_count_caption">új</string> + <string name="backup_review_new_tag">Új</string> + <string name="backup_review_newly_blocked">Újonnan letiltva</string> + <string name="backup_review_newly_muted">%1$s újonnan némítva</string> + <string name="backup_review_no_longer_blocked">Már nincs letiltva</string> + <string name="backup_review_not_set">Nincs beállítva</string> + <string name="backup_review_nothing_here">Itt nincs semmi</string> + <string name="backup_review_offer">BOLT12 ajánlat</string> + <plurals name="backup_review_offers_gone"> + <item quantity="one">%1$d ajánlat eltávolítva</item> + <item quantity="other">%1$d ajánlat eltávolítva</item> + </plurals> + <string name="backup_review_outbox">Kimenő</string> + <string name="backup_review_outbox_explainer">ahol közzétesz</string> + <plurals name="backup_review_payment_targets_gone"> + <item quantity="one">%1$d fizetési mód eltávolítva</item> + <item quantity="other">%1$d fizetési mód eltávolítva</item> + </plurals> + <string name="backup_review_payments_explainer">A fizető emberek csak azt látják, ami ebben a listában van.</string> + <string name="backup_review_places_gone">eltűnt helyek</string> + <string name="backup_review_places_you_follow">Ön által követett helyek</string> + <string name="backup_review_private_added_body">Most már titkosítva vannak, valószínűleg ide kerültek a fenti nyilvános elemek.</string> + <string name="backup_review_private_added_title">Ön priváttá tette az elemeket</string> + <string name="backup_review_private_changed_body">Titkosítva vannak, így itt nem hasonlíthatók össze.</string> + <string name="backup_review_private_changed_title">Ön módosította a privát elemeket</string> + <string name="backup_review_private_wiped_body">Titkosítva vannak, így csak Ön láthatja, mik voltak. A visszaállítás mindet visszahozza.</string> + <string name="backup_review_private_wiped_title">Ön eltávolította az összes privát elemet</string> + <string name="backup_review_receiving_tag">Fogadás</string> + <string name="backup_review_renamed">átnevezte</string> + <string name="backup_review_renamed_tag">Átnevezve</string> + <string name="backup_review_saved">Ezen az eszközön</string> + <string name="backup_review_search_people">%1$s személy keresése</string> + <string name="backup_review_searching_tag">Keresés</string> + <string name="backup_review_service">Szolgáltatás</string> + <string name="backup_review_service_followers">Követők</string> + <string name="backup_review_service_rank">Rang</string> + <string name="backup_review_service_topics">Témák</string> + <string name="backup_review_services_changed">%2$s szolgáltatásból %1$s módosult</string> + <string name="backup_review_services_changed_explainer">Most már valaki mástól vagy senkitől sem származnak</string> + <string name="backup_review_still_blocked">Továbbra is le van tiltva</string> + <string name="backup_review_storing_tag">Tárolás</string> + <string name="backup_review_tab_dropped">Elvetve · %1$s</string> + <string name="backup_review_tab_edited">Szerkesztve · %1$s</string> + <string name="backup_review_tab_new">Új · %1$s</string> + <string name="backup_review_title_cleared">%1$s törölve</string> + <string name="backup_review_title_updated">%1$s frissítve</string> + <string name="backup_review_topics_gone">eltűnt témák</string> + <string name="backup_review_trust_warning">A látott rangok, követőszámok és a kéretlen tartalomszűrés ezektől a szolgáltatóktól származnak.</string> + <string name="backup_review_trusted_tag">Megbízható</string> + <string name="backup_review_unblocked">%1$s letiltása feloldva</string> + <string name="backup_review_unblocked_explainer">Az Amethyst újra kapcsolódni fog hozzájuk</string> + <string name="backup_review_units_tag">Egységek</string> + <string name="backup_review_unmuted">%1$s némítása feloldva</string> + <string name="backup_review_unmuted_explainer">Ezek újra megjelenhetnek a hírfolyamaiban</string> + <string name="backup_review_untrusted_tag">Nem megbízható</string> + <string name="backup_review_wallet_body">A saját pénztárca pénzverdéi és kulcsai Önhöz vannak titkosítva, így itt nem hasonlíthatók össze tételesen. A visszaállítás pontosan azt hozza vissza, amit ez az eszköz mentett.</string> + <string name="backup_review_was_named">„%1$s” volt</string> + <string name="backup_review_words_and_hashtags">Szavak és kulcsszavak</string> + <string name="backup_type_app_settings">szinkronizált alkalmazásbeállítások</string> + <string name="backup_type_app_settings_explainer">Az eszközök között szinkronizált Amethyst-beállítások. Titkosítva vannak, így csak a jelenlétük hasonlítható össze.</string> + <string name="backup_type_blocked_relays">letiltott átjátszólista</string> + <string name="backup_type_blocked_relays_explainer">Átjátszók, amelyekhez ez az alkalmazás soha nem kapcsolódik.</string> + <string name="backup_type_bolt12_offers">BOLT12 ajánlatok</string> + <string name="backup_type_bolt12_offers_explainer">A lightning ajánlatok, amelyeket mások a fizetéshez használnak az Ön számára.</string> + <string name="backup_type_cashu_wallet">Cashu pénztárca</string> + <string name="backup_type_cashu_wallet_explainer">Az ecash pénztárca beállításai és pénzverdéi. Titkosítva vannak, így csak a jelenlétük hasonlítható össze.</string> + <string name="backup_type_communities">közösséglista</string> + <string name="backup_type_communities_explainer">Közösségek, amelyekhez csatlakozott.</string> + <string name="backup_type_concord_communities">Concord közösséglista</string> + <string name="backup_type_concord_communities_explainer">A Concord közösségek, amelyekhez csatlakozott. Titkosítva vannak, így csak a jelenlétük hasonlítható össze.</string> + <string name="backup_type_dm_relays">privát üzenet átjátszólista</string> + <string name="backup_type_dm_relays_explainer">Ahová mások kézbesítik a privát üzeneteit.</string> + <string name="backup_type_ephemeral_chats">rövid életű csevegési lista</string> + <string name="backup_type_ephemeral_chats_explainer">Rövid életű csevegőszobák, amelyekhez csatlakozott.</string> + <string name="backup_type_favorite_algo_feeds">kedvenc hírfolyamlista</string> + <string name="backup_type_favorite_algo_feeds_explainer">Mentett algoritmus-hírfolyamok.</string> + <string name="backup_type_follow_list">követési lista</string> + <string name="backup_type_follow_list_explainer">Meghatározza, kinek a bejegyzései jelenjenek meg a kezdőlapon.</string> + <string name="backup_type_geohashes">követett helyek</string> + <string name="backup_type_geohashes_explainer">Helyek, amelyek bejegyzései megjelennek a hírfolyamaiban.</string> + <string name="backup_type_hashtags">követett kulcsszavak</string> + <string name="backup_type_hashtags_explainer">Kulcsszavak, amelyek bejegyzései megjelennek a hírfolyamban.</string> + <string name="backup_type_indexer_relays">indexelő átjátszólista</string> + <string name="backup_type_indexer_relays_explainer">Azok az átjátszók, amelyeket mások profiljainak és átjátszólistáinak megtalálásához használnak.</string> + <string name="backup_type_key_package_relays">csoportos csevegési kulcsátjátszók</string> + <string name="backup_type_key_package_relays_explainer">Ahol mások megtalálják a kulcsokat, hogy titkosított csoportos csevegésekhez adhassák Önt.</string> + <string name="backup_type_mute_list">némítási lista</string> + <string name="backup_type_mute_list_explainer">Elrejti a személyeket, szavakat, kulcsszavakat és beszélgetéseket mindenből, amit lát.</string> + <string name="backup_type_nutzap_info">nutzap fogadási beállítások</string> + <string name="backup_type_nutzap_info_explainer">A pénzverdék és a kulcs, amelyeket mások a nutzapok küldéséhez használnak az Ön számára.</string> + <string name="backup_type_other">lista</string> + <string name="backup_type_other_explainer">Egy listaelem ezen az eszközön mentve.</string> + <string name="backup_type_outbox_inbox_relays">nyilvános átjátszólista</string> + <string name="backup_type_outbox_inbox_relays_explainer">Megmondja mindenkinek, hol találhatók a bejegyzései, és hová küldjék a válaszokat és említéseket.</string> + <string name="backup_type_payment_targets">fizetési címek</string> + <string name="backup_type_payment_targets_explainer">A módok, ahogy mások fizethetnek Önnek.</string> + <string name="backup_type_private_outbox_relays">privát átjátszólista</string> + <string name="backup_type_private_outbox_relays_explainer">Ahol a piszkozatai és privát adatai tárolódnak.</string> + <string name="backup_type_profile">profil</string> + <string name="backup_type_profile_explainer">Az Ön neve, képe, bemutatkozása és fizetési címei, ahogy mindenki látja őket.</string> + <string name="backup_type_public_chats">nyilvános csevegési lista</string> + <string name="backup_type_public_chats_explainer">Nyilvános csevegések, amelyekhez csatlakozott.</string> + <string name="backup_type_relay_feeds">kedvenc átjátszóhírfolyamok</string> + <string name="backup_type_relay_feeds_explainer">Olyan átjátszók, amelyeket hírfolyamként böngész.</string> + <string name="backup_type_relay_groups">csoportlista</string> + <string name="backup_type_relay_groups_explainer">Átjátszó-alapú csoportok, amelyekhez csatlakozott.</string> + <string name="backup_type_search_relays">kereső átjátszólista</string> + <string name="backup_type_search_relays_explainer">Kereséskor használt átjátszók.</string> + <string name="backup_type_trust_providers">bizalmi szolgáltatólista</string> + <string name="backup_type_trust_providers_explainer">A szolgáltatások, amelyekben megbízik, hogy rangsorolják és ellenőrizzék Önnek az embereket.</string> + <string name="backup_type_trusted_relays">megbízható átjátszólista</string> + <string name="backup_type_trusted_relays_explainer">Átjátszók, amelyekhez kérdezés nélkül kapcsolódhat.</string> </resources> diff --git a/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml b/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml index 55a0998df3..6b3fd3bf9a 100644 --- a/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml @@ -5507,4 +5507,382 @@ Zaplanowane posty z innych kont nie zostaną opublikowane, dopóki to konto jest <string name="cyberspace_bag_unsigned">Brak podpisu, więc autor to tylko domysł</string> <string name="cyberspace_bag_unknown_kind">Element typu %1$d, którego ten klient nie wyświetla</string> <string name="cyberspace_bag_opaque">%1$d bajtów danych, których ten klient nie odczytuje</string> + <string name="backup_action_block_again">Zablokuj %1$s ponownie</string> + <string name="backup_action_keep_count">Zachowaj %1$s</string> + <string name="backup_action_rejoin">Ponów %1$s</string> + <string name="backup_action_remute">Ponownie wycisz %1$s</string> + <string name="backup_action_restore_count">Przywróć %1$s</string> + <string name="backup_action_restore_feeds">Przywróć kanały</string> + <string name="backup_action_restore_places">Przywróć miejsca</string> + <string name="backup_action_restore_profile">Przywróć profil</string> + <string name="backup_action_restore_providers">Przywróć dostawców</string> + <string name="backup_action_restore_relays">Przywróć transmitery</string> + <string name="backup_action_restore_topics">Przywróć tematy</string> + <string name="backup_action_restore_wallet">Przywróć portfel</string> + <string name="backup_card_accept">Zaakceptuj</string> + <plurals name="backup_card_and_added"> + <item quantity="one">%1$s i dodano %2$d</item> + <item quantity="few">%1$s i dodano %2$d</item> + <item quantity="many">%1$s i dodano %2$d</item> + <item quantity="other">%1$s i dodano %2$d</item> + </plurals> + <plurals name="backup_card_and_blocked"> + <item quantity="one">%1$s i zablokowano %2$d</item> + <item quantity="few">%1$s i zablokowano %2$d</item> + <item quantity="many">%1$s i zablokowano %2$d</item> + <item quantity="other">%1$s i zablokowano %2$d</item> + </plurals> + <plurals name="backup_card_and_followed"> + <item quantity="one">%1$s i obserwowany %2$d</item> + <item quantity="few">%1$s i obserwowanych %2$d</item> + <item quantity="many">%1$s i obserwowanych %2$d</item> + <item quantity="other">%1$s i obserwowane %2$d</item> + </plurals> + <plurals name="backup_card_and_joined"> + <item quantity="one">%1$s i dołączono do %2$d</item> + <item quantity="few">%1$s i dołączono do %2$d</item> + <item quantity="many">%1$s i dołączono do %2$d</item> + <item quantity="other">%1$s i dołączono do %2$d</item> + </plurals> + <plurals name="backup_card_and_muted"> + <item quantity="one">%1$s i wyciszony %2$d</item> + <item quantity="few">%1$s i wyciszono %2$d</item> + <item quantity="many">%1$s i wyciszono %2$d</item> + <item quantity="other">%1$s i wyciszone %2$d</item> + </plurals> + <string name="backup_card_app_settings">Twoje zsynchronizowane ustawienia aplikacji Amethyst zostały zmienione w innej aplikacji, która nie jest Amethystem. To może powodować problemy.</string> + <string name="backup_card_concord_emptied">Opróżniłeś swoją listę Concorda</string> + <string name="backup_card_concord_rewritten">Zmieniłeś swoją listę Concorda</string> + <plurals name="backup_card_dm_relays_lost"> + <item quantity="one">Usunąłeś %1$d transmiter DM</item> + <item quantity="few">Usunąłeś %1$d transmiterów DM</item> + <item quantity="many">Usunąłeś %1$d transmiterów DM</item> + <item quantity="other">Usunąłeś %1$d transmitery DM</item> + </plurals> + <plurals name="backup_card_feeds_removed"> + <item quantity="one">Usunąłeś %1$d ulubiony kanał</item> + <item quantity="few">Usunąłeś %1$d ulubionych kanałów</item> + <item quantity="many">Usunąłeś %1$d ulubionych kanałów</item> + <item quantity="other">Usunięto %1$d ulubione kanały</item> + </plurals> + <plurals name="backup_card_follows_dropped"> + <item quantity="one">Przestałeś obserwować %1$d osobę</item> + <item quantity="few">Przestałeś obserwować %1$d osób</item> + <item quantity="many">Przestałeś obserwować %1$d osób</item> + <item quantity="other">Przestałeś obserwować %1$d osoby</item> + </plurals> + <plurals name="backup_card_hashtags_unfollowed"> + <item quantity="one">Przestałeś obserwować %1$d hashtag</item> + <item quantity="few">Przestałeś obserwować %1$d hashtagów</item> + <item quantity="many">Przestałeś obserwować %1$d hashtagów</item> + <item quantity="other">Przestałeś obserwować %1$d hashtagi</item> + </plurals> + <plurals name="backup_card_indexer_relays_lost"> + <item quantity="one">Usunięto %1$d transmiter indeksujący</item> + <item quantity="few">Usunięto %1$d transmiterów indeksujących</item> + <item quantity="many">Usunięto %1$d transmiterów indeksujących</item> + <item quantity="other">Usunięto %1$d transmitery indeksujące</item> + </plurals> + <plurals name="backup_card_key_package_relays_lost"> + <item quantity="one">Usunięto %1$d transmiter klucza grupowego czatu</item> + <item quantity="few">Usunięto %1$d transmiterów klucza grupowego czatu</item> + <item quantity="many">Usunięto %1$d transmiterów klucza grupowego czatu</item> + <item quantity="other">Usunięto %1$d transmitery klucza grupowego czatu</item> + </plurals> + <plurals name="backup_card_leave_chats"> + <item quantity="one">Opuściłeś %1$d czat publiczny</item> + <item quantity="few">Opuściłeś %1$d czatów publicznych</item> + <item quantity="many">Opuściłeś %1$d czatów publicznych</item> + <item quantity="other">Opuściłeś %1$d czaty publiczne</item> + </plurals> + <plurals name="backup_card_leave_communities"> + <item quantity="one">Opuściłeś %1$d społeczność</item> + <item quantity="few">Opuściłeś %1$d społeczności</item> + <item quantity="many">Opuściłeś %1$d społeczności</item> + <item quantity="other">Opuściłeś %1$d społeczności</item> + </plurals> + <plurals name="backup_card_leave_groups"> + <item quantity="one">Opuściłeś %1$d grupę</item> + <item quantity="few">Opuściłeś %1$d grup</item> + <item quantity="many">Opuściłeś %1$d grup</item> + <item quantity="other">Opuszczono %1$d grupy</item> + </plurals> + <plurals name="backup_card_leave_rooms"> + <item quantity="one">Opuściłeś %1$d pokój czatu</item> + <item quantity="few">Opuściłeś %1$d pokoi czatu</item> + <item quantity="many">Opuściłeś %1$d pokoi czatu</item> + <item quantity="other">Opuściłeś %1$d pokoje czatu</item> + </plurals> + <plurals name="backup_card_mutes_visible"> + <item quantity="one">Włączyłeś dźwięk dla %1$d elementu</item> + <item quantity="few">Włączyłeś dźwięk dla %1$d elementów</item> + <item quantity="many">Włączyłeś dźwięk dla %1$d elementów</item> + <item quantity="other">%1$d elementy mają włączony dźwięk</item> + </plurals> + <plurals name="backup_card_nip65_lost"> + <item quantity="one">Usunąłeś %1$d publiczny transmiter</item> + <item quantity="few">Usunąłeś %1$d publicznych transmiterów</item> + <item quantity="many">Usunąłeś %1$d publicznych transmiterów</item> + <item quantity="other">Usunąłeś %1$d publiczne transmitery</item> + </plurals> + <string name="backup_card_nutzap_key_removed">Usunąłeś swój klucz nutzap</string> + <string name="backup_card_nutzap_key_replaced">Wymieniłeś swój klucz Nutzap</string> + <plurals name="backup_card_nutzap_mints_removed"> + <item quantity="one">Usunięto %1$d nutzap mint</item> + <item quantity="few">Usunięto %1$d nutzap mintów</item> + <item quantity="many">Usunięto %1$d nutzap mintów</item> + <item quantity="other">Usunięto %1$d nutzap minty</item> + </plurals> + <plurals name="backup_card_offers_removed"> + <item quantity="one">Usunięto %1$d ofertę BOLT12</item> + <item quantity="few">Usunięto %1$d ofert BOLT12</item> + <item quantity="many">Usunięto %1$d ofert BOLT12</item> + <item quantity="other">Usunięto %1$d oferty BOLT12</item> + </plurals> + <plurals name="backup_card_payment_targets_removed"> + <item quantity="one">Usunięto %1$d sposób na otrzymanie zapłaty</item> + <item quantity="few">Usunięto %1$d sposobów otrzymywania zapłaty</item> + <item quantity="many">Usunięto %1$d sposobów otrzymywania zapłaty</item> + <item quantity="other">Usunięto %1$d sposoby otrzymywania zapłaty</item> + </plurals> + <plurals name="backup_card_places_unfollowed"> + <item quantity="one">Przestałeś obserwować %1$d miejsce</item> + <item quantity="few">Przestałeś obserwować %1$d miejsc</item> + <item quantity="many">Przestałeś obserwować %1$d miejsc</item> + <item quantity="other">Przestałeś obserwować %1$d miejsca</item> + </plurals> + <plurals name="backup_card_private_outbox_lost"> + <item quantity="one">Usunięto %1$d prywatny transmiter</item> + <item quantity="few">Usunięto %1$d prywatnych transmiterów</item> + <item quantity="many">Usunięto %1$d prywatnych transmiterów</item> + <item quantity="other">Usunięto %1$d prywatne transmitery</item> + </plurals> + <plurals name="backup_card_profile_lost_fields"> + <item quantity="one">Usunąłeś %1$d pole profilu</item> + <item quantity="few">Usunąłeś %1$d pól profilowych</item> + <item quantity="many">Usunąłeś %1$d pól profilowych</item> + <item quantity="other">Usunąłeś %1$d pola profilowe</item> + </plurals> + <plurals name="backup_card_relay_feeds_lost"> + <item quantity="one">Usunięto %1$d kanał transmitera</item> + <item quantity="few">Usunięto %1$d kanałów transmitera</item> + <item quantity="many">Usunięto %1$d kanałów transmitera</item> + <item quantity="other">Usunięto %1$d kanały transmitera</item> + </plurals> + <plurals name="backup_card_search_relays_lost"> + <item quantity="one">Usunięto %1$d transmiter wyszukiwania</item> + <item quantity="few">Usunięto %1$d transmiterów wyszukiwania</item> + <item quantity="many">Usunięto %1$d transmiterów wyszukiwania</item> + <item quantity="other">Usunięto %1$d transmitery wyszukiwania</item> + </plurals> + <plurals name="backup_card_trust_services_changed"> + <item quantity="one">Zmieniłeś dostawcę %1$d zaufanego serwisu</item> + <item quantity="few">Zmieniłeś dostawcę %1$d zaufanych serwisów</item> + <item quantity="many">Zmieniłeś dostawcę %1$d zaufanych serwisów</item> + <item quantity="other">Zmieniłeś dostawcę %1$d zaufanych serwisów</item> + </plurals> + <plurals name="backup_card_trusted_lost"> + <item quantity="one">Przestałeś ufać %1$d transmiterowi</item> + <item quantity="few">Przestałeś ufać %1$d transmiterom</item> + <item quantity="many">Przestałeś ufać %1$d transmiterom</item> + <item quantity="other">Przestałeś ufać %1$d transmiterom</item> + </plurals> + <plurals name="backup_card_unblocked"> + <item quantity="one">Odblokowałeś %1$d transmiter</item> + <item quantity="few">Odblokowałeś %1$d transmiterów</item> + <item quantity="many">Odblokowałeś %1$d transmiterów</item> + <item quantity="other">Odblokowałeś %1$d transmitery</item> + </plurals> + <string name="backup_card_wallet_emptied">Opróżniłeś swój portfel Cashu</string> + <string name="backup_card_wallet_rewritten">Zmieniłeś swój portfel Cashu</string> + <string name="backup_conflict_added">Dodano (%1$s)</string> + <string name="backup_conflict_changed">Zmieniono (%1$s)</string> + <string name="backup_conflict_count_added">Dodano %1$s</string> + <string name="backup_conflict_count_changed">%1$s zmieniono</string> + <string name="backup_conflict_count_removed">Usunięto %1$s</string> + <string name="backup_conflict_keep_new">Użyj nowej wersji</string> + <string name="backup_conflict_private_added">Dodano prywatne (zaszyfrowane) pozycje.</string> + <string name="backup_conflict_private_changed">Zmieniłeś również elementy prywatne (zaszyfrowane). Nie można ich tutaj porównać.</string> + <string name="backup_conflict_private_cleared">Usunąłeś wszystkie prywatne (zaszyfrowane) elementy.</string> + <string name="backup_conflict_relay_read_only">tylko do odczytu</string> + <string name="backup_conflict_relay_read_write">odczyt i zapis</string> + <string name="backup_conflict_relay_write_only">tylko do zapisu</string> + <string name="backup_conflict_removed">Usunięto (%1$s)</string> + <string name="backup_conflict_restore_mine">Przywróć zapisaną wersję</string> + <string name="backup_conflict_title">Zmieniłeś %1$s w innej aplikacji</string> + <string name="backup_entry_algo_feed">Kanały</string> + <string name="backup_entry_chat_room">Czat pokoje</string> + <string name="backup_entry_community">Społeczności</string> + <string name="backup_entry_hashtag">Hashtagi</string> + <string name="backup_entry_identity_claim">Powiązane tożsamości</string> + <string name="backup_entry_location">Lokalizacje</string> + <string name="backup_entry_mint">Minty</string> + <string name="backup_entry_nutzap_key">Klucze Nutzap</string> + <string name="backup_entry_offer">Oferty</string> + <string name="backup_entry_other">Inne wpisy</string> + <string name="backup_entry_payment_target">Adresy płatności</string> + <string name="backup_entry_person">Osoby</string> + <string name="backup_entry_profile_field">Pola profilu</string> + <string name="backup_entry_public_chat">Czaty publiczne</string> + <string name="backup_entry_relay">Transmitery</string> + <string name="backup_entry_relay_group">Grupy</string> + <string name="backup_entry_thread">Wątki</string> + <string name="backup_entry_trust_provider">Zaufani dostawcy</string> + <string name="backup_entry_word">Słowa</string> + <string name="backup_profile_field_about">O profilu</string> + <string name="backup_profile_field_banner">Baner</string> + <string name="backup_profile_field_birthday">Data urodzin</string> + <string name="backup_profile_field_bot">Flaga bota</string> + <string name="backup_profile_field_clink_offer">Oferta CLINK</string> + <string name="backup_profile_field_display_name">Nazwa wyświetlana</string> + <string name="backup_profile_field_lud06">LNURL</string> + <string name="backup_profile_field_lud16">Lightning Adres</string> + <string name="backup_profile_field_name">Nazwa użytkownika</string> + <string name="backup_profile_field_nip05">Adres Nostr</string> + <string name="backup_profile_field_picture">Zdjęcie</string> + <string name="backup_profile_field_pronouns">Zaimki</string> + <string name="backup_profile_field_website">Strona www</string> + <string name="backup_review_allowed_tag">Dozwolona</string> + <string name="backup_review_changed_by_other_app">Zmieniono w innej aplikacji · %1$s</string> + <string name="backup_review_concord_body">Twoje społeczności w Concord są dla Ciebie zaszyfrowane, więc nie można ich tutaj porównać. Przywrócenie danych powoduje przywrócenie dokładnie tego, co zostało zapisane na tym urządzeniu.</string> + <string name="backup_review_demoted_tag">Przeniesiona</string> + <string name="backup_review_dropped_count">%1$s odrzuconych</string> + <string name="backup_review_dropped_tag">Usunięta</string> + <string name="backup_review_encrypted_added">Utworzyłeś to</string> + <string name="backup_review_encrypted_changed">Zmieniłeś to</string> + <string name="backup_review_encrypted_cleared">Opróżniłeś to</string> + <string name="backup_review_feed">Kanał</string> + <string name="backup_review_gone">Zniknęła</string> + <string name="backup_review_hashtags_you_follow">Hashtagi, które obserwujesz</string> + <string name="backup_review_inbox">Skrzynka odbiorcza</string> + <string name="backup_review_inbox_explainer">gdzie inni docierają do Ciebie</string> + <string name="backup_review_joined">dołączył(a)</string> + <string name="backup_review_kept">zachowane</string> + <string name="backup_review_kept_count">Zachowano %1$s</string> + <string name="backup_review_key_removed">Usunięto klucz odbierający</string> + <string name="backup_review_key_replaced">Wymieniono klucz odbierający</string> + <string name="backup_review_key_warning">Nutzapy zostaną przypisane do tego nowego klucza. Jeśli urządzenie nie posiada tego klucza, może się okazać, że nie będzie można ich tutaj zrealizować.</string> + <string name="backup_review_left">zostało</string> + <string name="backup_review_left_tag">Zostało</string> + <string name="backup_review_listed_tag">Na Liście</string> + <string name="backup_review_moved_tag">Przeniesiona</string> + <string name="backup_review_names_and_more">%1$s i %2$s więcej</string> + <string name="backup_review_new">Nowa wersja</string> + <string name="backup_review_new_count">%1$s nowych</string> + <string name="backup_review_new_count_caption">nowe</string> + <string name="backup_review_new_tag">Nowa</string> + <string name="backup_review_newly_blocked">Nowo zablokowana</string> + <string name="backup_review_newly_muted">%1$s nowo wyciszonych</string> + <string name="backup_review_no_longer_blocked">Nie jest już zablokowana</string> + <string name="backup_review_not_set">Nie ustawiono</string> + <string name="backup_review_nothing_here">Nic tu nie ma!</string> + <string name="backup_review_offer">Oferta BOLT12</string> + <plurals name="backup_review_offers_gone"> + <item quantity="one">%1$d oferta usunięta</item> + <item quantity="few">%1$d ofert usunięto</item> + <item quantity="many">%1$d ofert usunięto</item> + <item quantity="other">%1$d oferty usunięte</item> + </plurals> + <string name="backup_review_outbox">Skrzynka nadawcza</string> + <string name="backup_review_outbox_explainer">gdzie publikujesz</string> + <plurals name="backup_review_payment_targets_gone"> + <item quantity="one">%1$d sposób płatności został usunięty</item> + <item quantity="few">%1$d sposobów płatności zostało usuniętych</item> + <item quantity="many">%1$d sposobów płatności zostało usuniętych</item> + <item quantity="other">%1$d sposoby płatności zostały usunięte</item> + </plurals> + <string name="backup_review_payments_explainer">Osoby, które Ci płacą, widzą tylko to, co znajduje się na tej liście.</string> + <string name="backup_review_places_gone"> miejsca zniknęły</string> + <string name="backup_review_places_you_follow">Miejsca które obserwujesz</string> + <string name="backup_review_private_added_body">Są teraz zaszyfrowane, co prawdopodobnie wyjaśnia, gdzie podziały się powyższe elementy publiczne.</string> + <string name="backup_review_private_added_title">Ustawiłeś te pozycje jako prywatne</string> + <string name="backup_review_private_changed_body">Są zaszyfrowane, więc nie można ich tu porównać.</string> + <string name="backup_review_private_changed_title">Zmieniłeś prywatne elementy</string> + <string name="backup_review_private_wiped_body">Są zaszyfrowane, więc tylko Ty możesz zobaczyć, co to było. Odtworzenie przywróci je wszystkie.</string> + <string name="backup_review_private_wiped_title">Usunąłeś wszystkie prywatne elementy</string> + <string name="backup_review_receiving_tag">Pobieranie</string> + <string name="backup_review_renamed">zmieniono nazwę</string> + <string name="backup_review_renamed_tag">Zmieniono nazwę</string> + <string name="backup_review_saved">Na tym urządzeniu</string> + <string name="backup_review_search_people">Szukaj %1$s osób</string> + <string name="backup_review_searching_tag">Szukam</string> + <string name="backup_review_service">Serwis</string> + <string name="backup_review_service_followers">Obserwujący</string> + <string name="backup_review_service_rank">Ranking</string> + <string name="backup_review_service_topics">Tematy</string> + <string name="backup_review_services_changed">Zmieniono %1$s z %2$s serwisów</string> + <string name="backup_review_services_changed_explainer">Teraz pochodzą od kogoś innego albo od nikogo</string> + <string name="backup_review_still_blocked">Nadal zablokowana</string> + <string name="backup_review_storing_tag">Przechowywanie</string> + <string name="backup_review_tab_dropped">Usunięte · %1$s</string> + <string name="backup_review_tab_edited">Edytowane · %1$s</string> + <string name="backup_review_tab_new">Nowe · %1$s</string> + <string name="backup_review_title_cleared">%1$s wyczyszczono</string> + <string name="backup_review_title_updated">%1$s zaktualizowano</string> + <string name="backup_review_topics_gone">tematy zniknęły</string> + <string name="backup_review_trust_warning">Rankingi, liczba obserwujących i filtrowanie spamu, które widzisz, pochodzą od tych dostawców.</string> + <string name="backup_review_trusted_tag">Zaufane</string> + <string name="backup_review_unblocked">%1$s odblokowane</string> + <string name="backup_review_unblocked_explainer">Ametyst ponownie połączy się z nimi</string> + <string name="backup_review_units_tag">Jednostek</string> + <string name="backup_review_unmuted">%1$s odblokowanych</string> + <string name="backup_review_unmuted_explainer">Mogą one ponownie pojawić się w Twoich informacjach</string> + <string name="backup_review_untrusted_tag">Niezaufane</string> + <string name="backup_review_wallet_body">Minty i klucze w Twoim portfelu są zaszyfrowane dla Ciebie, więc nie można ich tutaj porównać pozycja po pozycji. Przywrócenie danych powoduje przywrócenie dokładnie tego, co zostało zapisane na tym urządzeniu.</string> + <string name="backup_review_was_named">było „%1$s”</string> + <string name="backup_review_words_and_hashtags">Wyrazy & hasztagi</string> + <string name="backup_type_app_settings">zsynchronizowane ustawienia aplikacji</string> + <string name="backup_type_app_settings_explainer">Ustawienia Amethyst są synchronizowane na wszystkich Twoich urządzeniach. Są one zaszyfrowane, więc można porównać jedynie sam fakt ich obecności.</string> + <string name="backup_type_blocked_relays">lista zablokowanych przekaźników</string> + <string name="backup_type_blocked_relays_explainer">Transmitery, z którymi ta aplikacja nigdy się nie łączy.</string> + <string name="backup_type_bolt12_offers">Oferta BOLT12</string> + <string name="backup_type_bolt12_offers_explainer">Ta możliwość pozwala innym płacić Ci za pomocą Lightning.</string> + <string name="backup_type_cashu_wallet">Portfel Cashu</string> + <string name="backup_type_cashu_wallet_explainer">Ustawienia portfela ecash oraz minty. Są one zaszyfrowane, więc można porównać jedynie sam fakt ich istnienia.</string> + <string name="backup_type_communities">lista społeczności</string> + <string name="backup_type_communities_explainer">Społeczności, do których dołączyłeś.</string> + <string name="backup_type_concord_communities">Lista społeczności Concord</string> + <string name="backup_type_concord_communities_explainer">Społeczności Concord, do których dołączyłeś. Są one zaszyfrowane, więc można porównać jedynie fakt ich istnienia.</string> + <string name="backup_type_dm_relays">Lista transmiterów DM</string> + <string name="backup_type_dm_relays_explainer">Gdzie inni dostarczają Twoje prywatne wiadomości.</string> + <string name="backup_type_ephemeral_chats">lista czatów efemerycznych</string> + <string name="backup_type_ephemeral_chats_explainer">Tymczasowe czaty, do których dołączyłeś.</string> + <string name="backup_type_favorite_algo_feeds">lista ulubionych kanałów</string> + <string name="backup_type_favorite_algo_feeds_explainer">Zapisane przez Ciebie kanały algorytmiczne.</string> + <string name="backup_type_follow_list">lista obserwowanych</string> + <string name="backup_type_follow_list_explainer">Określa, czyje posty pojawiają się w Twoim kanale głównym.</string> + <string name="backup_type_geohashes">obserwowane lokalizacje</string> + <string name="backup_type_geohashes_explainer">Miejsca, z których posty pojawiają się na Twoich kanałach.</string> + <string name="backup_type_hashtags">obserwowane hashtagi</string> + <string name="backup_type_hashtags_explainer">Hashtagi, z których pochodzą posty wyświetlane w Twoich kanałach.</string> + <string name="backup_type_indexer_relays">lista transmiterów indeksujących</string> + <string name="backup_type_indexer_relays_explainer">Transmitery służące do wyszukiwania profili innych osób oraz list transmiterów.</string> + <string name="backup_type_key_package_relays">transmitery kluczy czatu grupowego</string> + <string name="backup_type_key_package_relays_explainer">Gdzie inni znajdą klucze do dodawania cię do zaszyfrowanych czatów grupowych.</string> + <string name="backup_type_mute_list">lista zablokowanych</string> + <string name="backup_type_mute_list_explainer">Ukrywa osoby, słowa, hashtagi i wątki we wszystkich wyświetlanych treściach.</string> + <string name="backup_type_nutzap_info">ustawienia odbioru nutzap</string> + <string name="backup_type_nutzap_info_explainer">Minty i klucz, które inni używają do wysyłania ci „nutzapów”.</string> + <string name="backup_type_other">lista</string> + <string name="backup_type_other_explainer">Lista zapisana na tym urządzeniu.</string> + <string name="backup_type_outbox_inbox_relays">lista publicznych transmiterów</string> + <string name="backup_type_outbox_inbox_relays_explainer">Informuje wszystkich, gdzie mogą znaleźć Twoje posty oraz gdzie mają wysyłać Ci odpowiedzi i wzmianki.</string> + <string name="backup_type_payment_targets">adresy płatności</string> + <string name="backup_type_payment_targets_explainer">Sposoby, w jakie inni mogą Ci zapłacić.</string> + <string name="backup_type_private_outbox_relays">lista prywatnych transmiterów</string> + <string name="backup_type_private_outbox_relays_explainer">Gdzie przechowywane są Twoje projekty i prywatne dane.</string> + <string name="backup_type_profile">profil</string> + <string name="backup_type_profile_explainer">Twoje imię i nazwisko, zdjęcie, biografia oraz adresy do płatności – tak, jak widzą je wszyscy.</string> + <string name="backup_type_public_chats">lista czatów publicznych</string> + <string name="backup_type_public_chats_explainer">Publiczne czaty, do których dołączyłeś.</string> + <string name="backup_type_relay_feeds">ulubione kanały transmitera</string> + <string name="backup_type_relay_feeds_explainer">Transmitery, które przeglądasz jako kanały informacyjne.</string> + <string name="backup_type_relay_groups">lista grup</string> + <string name="backup_type_relay_groups_explainer">Grupy oparte na transmiterach, do których dołączyłeś.</string> + <string name="backup_type_search_relays">lista transmiterów wyszukiwania</string> + <string name="backup_type_search_relays_explainer">Transmitery używane podczas wyszukiwania.</string> + <string name="backup_type_trust_providers">lista zaufanych dostawców</string> + <string name="backup_type_trust_providers_explainer">Serwisy, którym ufasz, a które zajmują się klasyfikowaniem i weryfikacją osób w Twoim imieniu.</string> + <string name="backup_type_trusted_relays">lista zaufanych transmiterów</string> + <string name="backup_type_trusted_relays_explainer">Zaufane transmitery, z którymi bez wahania nawiązujesz połączenie.</string> </resources> diff --git a/commonsUI/src/commonMain/composeResources/values/strings.xml b/commonsUI/src/commonMain/composeResources/values/strings.xml index a0b587b986..f8a7c986c4 100644 --- a/commonsUI/src/commonMain/composeResources/values/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values/strings.xml @@ -5482,4 +5482,574 @@ <string name="cyberspace_bag_unsigned">Unsigned, so this author is a claim</string> <string name="cyberspace_bag_unknown_kind">An item of kind %1$d, which this client does not draw</string> <string name="cyberspace_bag_opaque">%1$d bytes of something this client does not read</string> + <string name="backup_action_block_again">Block %1$s again</string> + <string name="backup_action_keep_count">Keep %1$s</string> + <string name="backup_action_rejoin">Rejoin %1$s</string> + <string name="backup_action_remute">Re-mute %1$s</string> + <string name="backup_action_restore_count">Restore %1$s</string> + <string name="backup_action_restore_feeds">Restore feeds</string> + <string name="backup_action_restore_places">Restore places</string> + <string name="backup_action_restore_profile">Restore profile</string> + <string name="backup_action_restore_providers">Restore providers</string> + <string name="backup_action_restore_relays">Restore relays</string> + <string name="backup_action_restore_topics">Restore topics</string> + <string name="backup_action_restore_wallet">Restore wallet</string> + <string name="backup_card_accept">Accept</string> + <plurals name="backup_card_and_added"> + <item quantity="one">%1$s and added %2$d</item> + <item quantity="other">%1$s and added %2$d</item> + </plurals> + <plurals name="backup_card_and_blocked"> + <item quantity="one">%1$s and blocked %2$d</item> + <item quantity="other">%1$s and blocked %2$d</item> + </plurals> + <plurals name="backup_card_and_followed"> + <item quantity="one">%1$s and followed %2$d</item> + <item quantity="other">%1$s and followed %2$d</item> + </plurals> + <plurals name="backup_card_and_joined"> + <item quantity="one">%1$s and joined %2$d</item> + <item quantity="other">%1$s and joined %2$d</item> + </plurals> + <plurals name="backup_card_and_muted"> + <item quantity="one">%1$s and muted %2$d</item> + <item quantity="other">%1$s and muted %2$d</item> + </plurals> + <string name="backup_card_app_settings">Your Amethyst synced app settings changed in another app that is not Amethyst. This can create problems.</string> + <string name="backup_card_concord_emptied">You emptied your Concord list</string> + <string name="backup_card_concord_rewritten">You changed your Concord list</string> + <plurals name="backup_card_dm_relays_lost"> + <item quantity="one">You removed %1$d DM relay</item> + <item quantity="other">You removed %1$d DM relays</item> + </plurals> + <plurals name="backup_card_feeds_removed"> + <item quantity="one">You removed %1$d favorite feed</item> + <item quantity="other">You removed %1$d favorite feeds</item> + </plurals> + <plurals name="backup_card_follows_dropped"> + <item quantity="one">You unfollowed %1$d person</item> + <item quantity="other">You unfollowed %1$d people</item> + </plurals> + <plurals name="backup_card_hashtags_unfollowed"> + <item quantity="one">You unfollowed %1$d hashtag</item> + <item quantity="other">You unfollowed %1$d hashtags</item> + </plurals> + <plurals name="backup_card_indexer_relays_lost"> + <item quantity="one">You removed %1$d indexer relay</item> + <item quantity="other">You removed %1$d indexer relays</item> + </plurals> + <plurals name="backup_card_key_package_relays_lost"> + <item quantity="one">You removed %1$d group-chat key relay</item> + <item quantity="other">You removed %1$d group-chat key relays</item> + </plurals> + <plurals name="backup_card_leave_chats"> + <item quantity="one">You left %1$d public chat</item> + <item quantity="other">You left %1$d public chats</item> + </plurals> + <plurals name="backup_card_leave_communities"> + <item quantity="one">You left %1$d community</item> + <item quantity="other">You left %1$d communities</item> + </plurals> + <plurals name="backup_card_leave_groups"> + <item quantity="one">You left %1$d group</item> + <item quantity="other">You left %1$d groups</item> + </plurals> + <plurals name="backup_card_leave_rooms"> + <item quantity="one">You left %1$d chat room</item> + <item quantity="other">You left %1$d chat rooms</item> + </plurals> + <plurals name="backup_card_mutes_visible"> + <item quantity="one">You unmuted %1$d thing</item> + <item quantity="other">You unmuted %1$d things</item> + </plurals> + <plurals name="backup_card_nip65_lost"> + <item quantity="one">You removed %1$d public relay</item> + <item quantity="other">You removed %1$d public relays</item> + </plurals> + <string name="backup_card_nutzap_key_removed">You removed your nutzap key</string> + <string name="backup_card_nutzap_key_replaced">You replaced your nutzap key</string> + <plurals name="backup_card_nutzap_mints_removed"> + <item quantity="one">You removed %1$d nutzap mint</item> + <item quantity="other">You removed %1$d nutzap mints</item> + </plurals> + <plurals name="backup_card_offers_removed"> + <item quantity="one">You removed %1$d BOLT12 offer</item> + <item quantity="other">You removed %1$d BOLT12 offers</item> + </plurals> + <plurals name="backup_card_payment_targets_removed"> + <item quantity="one">You removed %1$d way to get paid</item> + <item quantity="other">You removed %1$d ways to get paid</item> + </plurals> + <plurals name="backup_card_places_unfollowed"> + <item quantity="one">You unfollowed %1$d place</item> + <item quantity="other">You unfollowed %1$d places</item> + </plurals> + <plurals name="backup_card_private_outbox_lost"> + <item quantity="one">You removed %1$d private relay</item> + <item quantity="other">You removed %1$d private relays</item> + </plurals> + <plurals name="backup_card_profile_lost_fields"> + <item quantity="one">You removed %1$d profile field</item> + <item quantity="other">You removed %1$d profile fields</item> + </plurals> + <plurals name="backup_card_relay_feeds_lost"> + <item quantity="one">You removed %1$d relay feed</item> + <item quantity="other">You removed %1$d relay feeds</item> + </plurals> + <plurals name="backup_card_search_relays_lost"> + <item quantity="one">You removed %1$d search relay</item> + <item quantity="other">You removed %1$d search relays</item> + </plurals> + <plurals name="backup_card_trust_services_changed"> + <item quantity="one">You changed the provider of %1$d trust service</item> + <item quantity="other">You changed the provider of %1$d trust services</item> + </plurals> + <plurals name="backup_card_trusted_lost"> + <item quantity="one">You stopped trusting %1$d relay</item> + <item quantity="other">You stopped trusting %1$d relays</item> + </plurals> + <plurals name="backup_card_unblocked"> + <item quantity="one">You unblocked %1$d relay</item> + <item quantity="other">You unblocked %1$d relays</item> + </plurals> + <string name="backup_card_wallet_emptied">You emptied your Cashu wallet</string> + <string name="backup_card_wallet_rewritten">You changed your Cashu wallet</string> + <string name="backup_conflict_added">Added (%1$s)</string> + <string name="backup_conflict_changed">Changed (%1$s)</string> + <string name="backup_conflict_count_added">%1$s added</string> + <string name="backup_conflict_count_changed">%1$s changed</string> + <string name="backup_conflict_count_removed">%1$s removed</string> + <string name="backup_conflict_keep_new">Use new version</string> + <string name="backup_conflict_private_added">You added private (encrypted) items.</string> + <string name="backup_conflict_private_changed">You also changed private (encrypted) items. They can't be compared here.</string> + <string name="backup_conflict_private_cleared">You removed all private (encrypted) items.</string> + <string name="backup_conflict_relay_read_only">read only</string> + <string name="backup_conflict_relay_read_write">read and write</string> + <string name="backup_conflict_relay_write_only">write only</string> + <string name="backup_conflict_removed">Removed (%1$s)</string> + <string name="backup_conflict_restore_mine">Restore saved version</string> + <string name="backup_conflict_title">You changed your %1$s in another app</string> + <string name="backup_entry_algo_feed">Feeds</string> + <string name="backup_entry_chat_room">Chat rooms</string> + <string name="backup_entry_community">Communities</string> + <string name="backup_entry_hashtag">Hashtags</string> + <string name="backup_entry_identity_claim">Linked identities</string> + <string name="backup_entry_location">Locations</string> + <string name="backup_entry_mint">Mints</string> + <string name="backup_entry_nutzap_key">Nutzap keys</string> + <string name="backup_entry_offer">Offers</string> + <string name="backup_entry_other">Other entries</string> + <string name="backup_entry_payment_target">Payment addresses</string> + <string name="backup_entry_person">People</string> + <string name="backup_entry_profile_field">Profile fields</string> + <string name="backup_entry_public_chat">Public chats</string> + <string name="backup_entry_relay">Relays</string> + <string name="backup_entry_relay_group">Groups</string> + <string name="backup_entry_thread">Threads</string> + <string name="backup_entry_trust_provider">Trust providers</string> + <string name="backup_entry_word">Words</string> + <string name="backup_profile_field_about">About</string> + <string name="backup_profile_field_banner">Banner</string> + <string name="backup_profile_field_birthday">Birthday</string> + <string name="backup_profile_field_bot">Bot flag</string> + <string name="backup_profile_field_clink_offer">CLINK offer</string> + <string name="backup_profile_field_display_name">Display name</string> + <string name="backup_profile_field_lud06">LNURL</string> + <string name="backup_profile_field_lud16">Lightning address</string> + <string name="backup_profile_field_name">Username</string> + <string name="backup_profile_field_nip05">Nostr address</string> + <string name="backup_profile_field_picture">Picture</string> + <string name="backup_profile_field_pronouns">Pronouns</string> + <string name="backup_profile_field_website">Website</string> + <string name="backup_review_allowed_tag">Allowed</string> + <string name="backup_review_changed_by_other_app">Changed in another app · %1$s</string> + <string name="backup_review_concord_body">Your Concord communities are encrypted to you, so they can't be compared here. Restoring puts back exactly what this device saved.</string> + <string name="backup_review_demoted_tag">Moved</string> + <string name="backup_review_dropped_count">%1$s dropped</string> + <string name="backup_review_dropped_tag">Dropped</string> + <string name="backup_review_encrypted_added">You created it</string> + <string name="backup_review_encrypted_changed">You changed it</string> + <string name="backup_review_encrypted_cleared">You emptied it</string> + <string name="backup_review_feed">Feed</string> + <string name="backup_review_gone">Gone</string> + <string name="backup_review_hashtags_you_follow">Hashtags you follow</string> + <string name="backup_review_inbox">Inbox</string> + <string name="backup_review_inbox_explainer">where others reach you</string> + <string name="backup_review_joined">joined</string> + <string name="backup_review_kept">kept</string> + <string name="backup_review_kept_count">%1$s kept</string> + <string name="backup_review_key_removed">Receiving key removed</string> + <string name="backup_review_key_replaced">Receiving key replaced</string> + <string name="backup_review_key_warning">Nutzaps will be locked to this new key. If this device doesn't have it, you may not be able to redeem them here.</string> + <string name="backup_review_left">left</string> + <string name="backup_review_left_tag">Left</string> + <string name="backup_review_listed_tag">Listed</string> + <string name="backup_review_moved_tag">Moved</string> + <string name="backup_review_names_and_more">%1$s and %2$s more</string> + <string name="backup_review_new">New version</string> + <string name="backup_review_new_count">%1$s new</string> + <string name="backup_review_new_count_caption">new</string> + <string name="backup_review_new_tag">New</string> + <string name="backup_review_newly_blocked">Newly blocked</string> + <string name="backup_review_newly_muted">%1$s newly muted</string> + <string name="backup_review_no_longer_blocked">No longer blocked</string> + <string name="backup_review_not_set">Not set</string> + <string name="backup_review_nothing_here">Nothing here</string> + <string name="backup_review_offer">BOLT12 offer</string> + <plurals name="backup_review_offers_gone"> + <item quantity="one">%1$d offer removed</item> + <item quantity="other">%1$d offers removed</item> + </plurals> + <string name="backup_review_outbox">Outbox</string> + <string name="backup_review_outbox_explainer">where you publish</string> + <plurals name="backup_review_payment_targets_gone"> + <item quantity="one">%1$d way to pay you removed</item> + <item quantity="other">%1$d ways to pay you removed</item> + </plurals> + <string name="backup_review_payments_explainer">People paying you only see what's in this list.</string> + <string name="backup_review_places_gone">places gone</string> + <string name="backup_review_places_you_follow">Places you follow</string> + <string name="backup_review_private_added_body">They're encrypted now, which is likely where the public items above went.</string> + <string name="backup_review_private_added_title">You made items private</string> + <string name="backup_review_private_changed_body">They're encrypted, so they can't be compared here.</string> + <string name="backup_review_private_changed_title">You changed private items</string> + <string name="backup_review_private_wiped_body">They're encrypted, so only you can see what they were. Restoring brings them all back.</string> + <string name="backup_review_private_wiped_title">You removed all private items</string> + <string name="backup_review_receiving_tag">Receiving</string> + <string name="backup_review_renamed">renamed</string> + <string name="backup_review_renamed_tag">Renamed</string> + <string name="backup_review_saved">On this device</string> + <string name="backup_review_search_people">Search %1$s people</string> + <string name="backup_review_searching_tag">Searching</string> + <string name="backup_review_service">Service</string> + <string name="backup_review_service_followers">Followers</string> + <string name="backup_review_service_rank">Rank</string> + <string name="backup_review_service_topics">Topics</string> + <string name="backup_review_services_changed">%1$s of %2$s services changed</string> + <string name="backup_review_services_changed_explainer">They now come from someone else, or no one</string> + <string name="backup_review_still_blocked">Still blocked</string> + <string name="backup_review_storing_tag">Storing</string> + <string name="backup_review_tab_dropped">Dropped · %1$s</string> + <string name="backup_review_tab_edited">Edited · %1$s</string> + <string name="backup_review_tab_new">New · %1$s</string> + <string name="backup_review_title_cleared">%1$s cleared</string> + <string name="backup_review_title_updated">%1$s updated</string> + <string name="backup_review_topics_gone">topics gone</string> + <string name="backup_review_trust_warning">Ranks, follower counts and spam filtering you see come from these providers.</string> + <string name="backup_review_trusted_tag">Trusted</string> + <string name="backup_review_unblocked">%1$s unblocked</string> + <string name="backup_review_unblocked_explainer">Amethyst will connect to them again</string> + <string name="backup_review_units_tag">Units</string> + <string name="backup_review_unmuted">%1$s unmuted</string> + <string name="backup_review_unmuted_explainer">These can reach your feeds again</string> + <string name="backup_review_untrusted_tag">Untrusted</string> + <string name="backup_review_wallet_body">Your wallet's mints and keys are encrypted to you, so they can't be compared item by item here. Restoring puts back exactly what this device saved.</string> + <string name="backup_review_was_named">was “%1$s”</string> + <string name="backup_review_words_and_hashtags">Words & hashtags</string> + <string name="backup_type_app_settings">synced app settings</string> + <string name="backup_type_app_settings_explainer">Amethyst settings synced across your devices. They are encrypted, so only their presence can be compared.</string> + <string name="backup_type_blocked_relays">blocked relay list</string> + <string name="backup_type_blocked_relays_explainer">Relays this app never connects to.</string> + <string name="backup_type_bolt12_offers">BOLT12 offers</string> + <string name="backup_type_bolt12_offers_explainer">The lightning offers others use to pay you.</string> + <string name="backup_type_cashu_wallet">Cashu wallet</string> + <string name="backup_type_cashu_wallet_explainer">Your ecash wallet settings and mints. They are encrypted, so only their presence can be compared.</string> + <string name="backup_type_communities">community list</string> + <string name="backup_type_communities_explainer">The communities you joined.</string> + <string name="backup_type_concord_communities">Concord community list</string> + <string name="backup_type_concord_communities_explainer">The Concord communities you joined. They are encrypted, so only their presence can be compared.</string> + <string name="backup_type_dm_relays">DM relay list</string> + <string name="backup_type_dm_relays_explainer">Where others deliver your private messages.</string> + <string name="backup_type_ephemeral_chats">ephemeral chat list</string> + <string name="backup_type_ephemeral_chats_explainer">The ephemeral chat rooms you joined.</string> + <string name="backup_type_favorite_algo_feeds">favorite feeds list</string> + <string name="backup_type_favorite_algo_feeds_explainer">The algorithmic feeds you saved.</string> + <string name="backup_type_follow_list">follow list</string> + <string name="backup_type_follow_list_explainer">Decides whose posts appear in your home feed.</string> + <string name="backup_type_geohashes">followed locations</string> + <string name="backup_type_geohashes_explainer">Locations whose posts appear in your feeds.</string> + <string name="backup_type_hashtags">followed hashtags</string> + <string name="backup_type_hashtags_explainer">Hashtags whose posts appear in your feeds.</string> + <string name="backup_type_indexer_relays">indexer relay list</string> + <string name="backup_type_indexer_relays_explainer">The relays used to find other people's profiles and relay lists.</string> + <string name="backup_type_key_package_relays">group-chat key relays</string> + <string name="backup_type_key_package_relays_explainer">Where others find the keys to add you to encrypted group chats.</string> + <string name="backup_type_mute_list">mute list</string> + <string name="backup_type_mute_list_explainer">Hides people, words, hashtags and threads from everything you see.</string> + <string name="backup_type_nutzap_info">nutzap receiving settings</string> + <string name="backup_type_nutzap_info_explainer">The mints and key others use to send you nutzaps.</string> + <string name="backup_type_other">list</string> + <string name="backup_type_other_explainer">A list saved on this device.</string> + <string name="backup_type_outbox_inbox_relays">public relay list</string> + <string name="backup_type_outbox_inbox_relays_explainer">Tells everyone where to find your posts and where to send you replies and mentions.</string> + <string name="backup_type_payment_targets">payment addresses</string> + <string name="backup_type_payment_targets_explainer">The ways other people can pay you.</string> + <string name="backup_type_private_outbox_relays">private relay list</string> + <string name="backup_type_private_outbox_relays_explainer">Where your drafts and private data are stored.</string> + <string name="backup_type_profile">profile</string> + <string name="backup_type_profile_explainer">Your name, picture, bio and payment addresses, as everyone sees them.</string> + <string name="backup_type_public_chats">public chat list</string> + <string name="backup_type_public_chats_explainer">The public chats you joined.</string> + <string name="backup_type_relay_feeds">favorite relay feeds</string> + <string name="backup_type_relay_feeds_explainer">The relays you browse as feeds.</string> + <string name="backup_type_relay_groups">group list</string> + <string name="backup_type_relay_groups_explainer">The relay-based groups you joined.</string> + <string name="backup_type_search_relays">search relay list</string> + <string name="backup_type_search_relays_explainer">The relays used when you search.</string> + <string name="backup_type_trust_providers">trust provider list</string> + <string name="backup_type_trust_providers_explainer">The services you trust to rank and verify people for you.</string> + <string name="backup_type_trusted_relays">trusted relay list</string> + <string name="backup_type_trusted_relays_explainer">Relays you trust to connect to without asking.</string> + <string name="cordn_action_delete">Delete</string> + <string name="cordn_action_edit">Edit</string> + <string name="cordn_action_editing">Editing your message</string> + <string name="cordn_action_go_to_message">Go to message</string> + <string name="cordn_action_pin">Pin</string> + <string name="cordn_action_reply">Reply</string> + <string name="cordn_action_unpin">Unpin</string> + <string name="cordn_admin_action_failed">That change could not be made.</string> + <string name="cordn_admin_coordinator_silent">The coordinator did not answer, so nothing was changed. Try again in a moment.</string> + <string name="cordn_admin_no_key_package">%1$s has not published a key package to this coordinator, so they cannot be added yet. Ask them to open cordn on this coordinator first.</string> + <string name="cordn_admin_no_self_remove">You cannot remove yourself from a cordn group.</string> + <string name="cordn_admin_no_welcome">%1$s could not be given a way into the group, so the add was abandoned.</string> + <string name="cordn_admin_not_a_member">%1$s is not in this group.</string> + <string name="cordn_admin_someone">That person</string> + <string name="cordn_admin_wrong_key_package">This coordinator served a key package that belongs to someone else, so %1$s was not added. Nothing was changed.</string> + <string name="cordn_backup_contents_body">Your group encryption keys, your key packages, and every message in those groups. Anyone who opens it can read the conversations. The passphrase is the only thing protecting it once it leaves Amethyst.</string> + <string name="cordn_backup_contents_title">What is in the file</string> + <string name="cordn_backup_explainer">Your nsec cannot bring cordn groups back. A cordn group lives as encryption state on this device and an ordered stream on a coordinator that cannot read it — lose the device without a backup and the group is gone, including everything already said in it.</string> + <string name="cordn_backup_export">Export</string> + <string name="cordn_backup_exported">Backup saved.</string> + <string name="cordn_backup_failed">That did not work. Check the passphrase and the file.</string> + <string name="cordn_backup_passphrase">Passphrase</string> + <string name="cordn_backup_restore">Restore</string> + <string name="cordn_backup_restore_body">Restoring replaces the cordn groups on this device with the ones in the file. It is for a phone that has taken over from another — not a way to use the same groups on two devices at once.</string> + <string name="cordn_backup_restore_confirm_body">Every cordn group now on this device will be removed and replaced by the ones in the file.\n\nDo not restore onto a second phone while the first is still in use. Both would hold the same group keys, and once both have sent a message the group breaks for everyone — silently, and with no way back.</string> + <string name="cordn_backup_restore_confirm_title">Replace this device's cordn groups?</string> + <string name="cordn_backup_restore_title">Restore</string> + <string name="cordn_backup_restored">Restored.</string> + <string name="cordn_chat_empty_description">Anything sent here is encrypted for this group. The coordinator relays it without being able to read it.</string> + <string name="cordn_chat_empty_title">No messages yet</string> + <string name="cordn_chat_unread_divider">New messages</string> + <string name="cordn_chat_yesterday">Yesterday</string> + <string name="cordn_composer_hint">Message</string> + <string name="cordn_coordinators_add_action">Add</string> + <string name="cordn_coordinators_add_failed">Could not open that coordinator.</string> + <string name="cordn_coordinators_copy_key">Copy the coordinator's npub</string> + <string name="cordn_coordinators_discover_action">Look for coordinators</string> + <string name="cordn_coordinators_discover_add">Add</string> + <string name="cordn_coordinators_discover_explainer">Reads announcements your relays already carry. No coordinator is contacted, so none of them learns you looked.</string> + <string name="cordn_coordinators_discover_failed">Could not read announcements</string> + <string name="cordn_coordinators_discover_none">Nobody is announcing on your relays.</string> + <string name="cordn_coordinators_discover_seen">Announced %1$s ago</string> + <string name="cordn_coordinators_discover_seen_on">Last announced %1$s</string> + <string name="cordn_coordinators_discover_unheard">Nothing found, and %1$d of your relays did not answer.</string> + <string name="cordn_coordinators_explainer">A coordinator orders one group's messages and is the only thing that can. Losing it loses the ordering, and a second one does not mirror the first — so these are named things you choose, not interchangeable relays.</string> + <string name="cordn_coordinators_health_down">Not answering — %1$d calls in a row have failed. Groups on it are not syncing.</string> + <string name="cordn_coordinators_health_ok">Answering.</string> + <string name="cordn_coordinators_health_retrying">A call failed; retrying.</string> + <string name="cordn_coordinators_health_unknown">Nothing asked of it yet.</string> + <string name="cordn_coordinators_hide_older">Hide the ones that stopped announcing</string> + <string name="cordn_coordinators_identify">Ask who it is</string> + <string name="cordn_coordinators_key">Coordinator key</string> + <string name="cordn_coordinators_label">A name for it (yours, optional)</string> + <string name="cordn_coordinators_label_note">This name is yours and stays on this device. A coordinator cannot prove a name, so it is never asked for one.</string> + <string name="cordn_coordinators_more">More actions</string> + <string name="cordn_coordinators_none">No coordinators yet.</string> + <string name="cordn_coordinators_purge">Purge</string> + <string name="cordn_coordinators_purge_body">Removing keeps the groups on this device, so adding the coordinator back brings them with it. Purging deletes them: the group keys, the read positions and your key packages all go, and those groups can only be re-entered by a fresh invitation.\n\nThe coordinator is not told and keeps whatever it already had.</string> + <string name="cordn_coordinators_purge_title">Purge this coordinator?</string> + <string name="cordn_coordinators_relays">%1$s</string> + <string name="cordn_coordinators_relays_label">Answers on</string> + <string name="cordn_coordinators_relays_more">%1$s +%2$d more</string> + <string name="cordn_coordinators_remove">Remove</string> + <string name="cordn_coordinators_rename">Rename</string> + <string name="cordn_coordinators_server">Says it is: %1$s</string> + <string name="cordn_coordinators_server_claim">A coordinator's name and version are strings it chose. Its public key is the only thing that identifies it.</string> + <string name="cordn_coordinators_server_silent">Answered, but named nothing.</string> + <string name="cordn_coordinators_show_all">Show all %1$d</string> + <string name="cordn_coordinators_show_fewer">Show fewer</string> + <string name="cordn_coordinators_show_older">Show %1$d that stopped announcing</string> + <string name="cordn_coordinators_stale_note">These have not announced in over a month. Creating a group on one that has gone away will fail.</string> + <string name="cordn_create_action">Create group</string> + <plurals name="cordn_create_action_invite"> + <item quantity="one">Create and invite %1$d person</item> + <item quantity="other">Create and invite %1$d people</item> + </plurals> + <string name="cordn_create_add_member">Add someone</string> + <string name="cordn_create_admin">Admin</string> + <plurals name="cordn_create_admin_count"> + <item quantity="one">%1$d person can add and remove</item> + <item quantity="other">%1$d people can add and remove</item> + </plurals> + <string name="cordn_create_admin_only_me">Only I manage this group</string> + <string name="cordn_create_admin_only_me_on">Only you can invite, remove members or change the group's details. You can hand that to someone else later.</string> + <string name="cordn_create_coordinator">Coordinator</string> + <string name="cordn_create_coordinator_change">Change</string> + <string name="cordn_create_coordinator_discover">Find coordinators</string> + <string name="cordn_create_coordinator_hide">Done</string> + <string name="cordn_create_coordinator_new">Another coordinator</string> + <string name="cordn_create_coordinator_pubkey">Coordinator public key (hex or npub)</string> + <string name="cordn_create_coordinator_relays">Relays it answers on, one per line</string> + <string name="cordn_create_coverage_all">Reaches all %1$d of your people</string> + <string name="cordn_create_coverage_partial">Reaches %1$d of %2$d — the rest would be left out</string> + <string name="cordn_create_coverage_unknown">Not checked — picking it will ask</string> + <string name="cordn_create_description">Description (optional)</string> + <string name="cordn_create_egalitarian">Everyone can add and remove</string> + <string name="cordn_create_egalitarian_note">Everyone in the group can invite, remove members and change its details. Any member can name admins later, which ends that.</string> + <string name="cordn_create_explainer">A cordn group is ordered by one coordinator you choose. Creating the group happens on this device — the coordinator only learns the group exists once you invite someone or send a message.</string> + <string name="cordn_create_failed">The group could not be created.</string> + <string name="cordn_create_name">Group name</string> + <string name="cordn_create_no_coordinator">No coordinator chosen</string> + <string name="cordn_create_outcome_explainer">Each invitation is a Welcome left on the coordinator, so they can fail one at a time. Nobody has been notified: they see it next time they open their app.</string> + <string name="cordn_create_outcome_failed">The coordinator refused the invitation</string> + <string name="cordn_create_outcome_link">Send a link</string> + <string name="cordn_create_outcome_no_welcome">Added to the group, but the invitation did not reach them — try again from the group screen</string> + <string name="cordn_create_outcome_open">Open the chat</string> + <string name="cordn_create_outcome_skipped">No key here, so no Welcome could be left</string> + <string name="cordn_create_outcome_title">The group exists</string> + <string name="cordn_create_outcome_waiting">Waiting for them</string> + <string name="cordn_create_people_done">Done</string> + <string name="cordn_create_people_empty">Nobody added yet. A group can be created empty and invitations sent later, but naming people now is what shows which coordinator can reach them.</string> + <string name="cordn_create_people_none">Nobody yet — tap to add people</string> + <string name="cordn_create_people_note">Naming people now is what tells us which coordinator can reach them. Each one gets a Welcome left on that coordinator, which they pick up next time they open their app.</string> + <plurals name="cordn_create_reach_count"> + <item quantity="one">Reachable on %1$d coordinator</item> + <item quantity="other">Reachable on %1$d coordinators</item> + </plurals> + <string name="cordn_create_reach_none">No key on any coordinator you use</string> + <string name="cordn_create_reach_unknown">Not checked yet</string> + <string name="cordn_create_step_admins">Who can add and remove</string> + <string name="cordn_create_step_name">Name it</string> + <string name="cordn_create_step_people">Who is in it</string> + <string name="cordn_create_step_where">Where it lives</string> + <string name="cordn_create_title">New Cordn group</string> + <plurals name="cordn_create_unreachable_count"> + <item quantity="one">%1$d person cannot be reached by any coordinator you use</item> + <item quantity="other">%1$d people cannot be reached by any coordinator you use</item> + </plurals> + <string name="cordn_create_you">You, always an admin</string> + <string name="cordn_delete_confirm_body">Everyone in the group will see this message as withdrawn, and Amethyst will stop showing its text. The coordinator still holds the encrypted copy it was sent as, and anyone who already read it has already read it.</string> + <string name="cordn_delete_confirm_title">Withdraw message</string> + <string name="cordn_delivery_accepted">Accepted by the coordinator</string> + <string name="cordn_exposure_close">Got it</string> + <string name="cordn_exposure_open">What this coordinator can see</string> + <string name="cordn_group_info">Group info</string> + <string name="cordn_group_unavailable">This group is not available. Its coordinator may have been removed.</string> + <string name="cordn_group_unavailable_detail">Add a coordinator in Settings to start using cordn groups.</string> + <plurals name="cordn_groups_count"> + <item quantity="one">%1$d group</item> + <item quantity="other">%1$d groups</item> + </plurals> + <string name="cordn_groups_down_note">Nothing is arriving from these groups. Amethyst keeps retrying.</string> + <string name="cordn_groups_manage">Coordinators</string> + <string name="cordn_groups_none">No cordn groups yet</string> + <string name="cordn_groups_none_detail">A cordn group lives on one coordinator that holds its membership and passes messages along, without ever seeing what anyone writes.</string> + <string name="cordn_groups_start">Start one</string> + <string name="cordn_info_add_member">Add someone</string> + <string name="cordn_info_add_member_none">Nobody found by that name.</string> + <string name="cordn_info_add_member_note">They can only be added if they published a key package to this coordinator.</string> + <string name="cordn_info_add_member_placeholder">Name, npub or name@domain</string> + <string name="cordn_info_admin_badge">Admin</string> + <plurals name="cordn_info_admins_kept"> + <item quantity="one">The group's %1$d admin stays as it is.</item> + <item quantity="other">The group's %1$d admins stay as they are.</item> + </plurals> + <string name="cordn_info_coordinator">Coordinator</string> + <string name="cordn_info_coordinator_key">Coordinator key</string> + <string name="cordn_info_coordinator_nprofile">Coordinator link</string> + <string name="cordn_info_copy_nprofile">Copy the coordinator's nprofile</string> + <string name="cordn_info_edit_details">Edit details</string> + <string name="cordn_info_egalitarian">This group has no admins: everyone can add, remove and rename, permanently.</string> + <string name="cordn_info_epoch">Epoch</string> + <string name="cordn_info_gid">Group id</string> + <string name="cordn_info_has_key_package">Can be added on this coordinator</string> + <string name="cordn_info_members">Members</string> + <string name="cordn_info_remove_confirm_body">%1$s stops receiving messages from here. They keep what they have already read, and this cannot be undone — they would have to be invited again.</string> + <string name="cordn_info_remove_confirm_title">Remove from group?</string> + <string name="cordn_info_remove_member">Remove</string> + <string name="cordn_info_save">Save</string> + <string name="cordn_info_technical">Technical details</string> + <string name="cordn_invitations_accept">Join</string> + <string name="cordn_invitations_decline">Decline</string> + <string name="cordn_invitations_decline_warning">Declining is permanent. Getting back in means being invited again.</string> + <string name="cordn_invitations_explainer">Checked when you open this screen, and at no other time — asking a coordinator whether anyone invited you tells it you are here, so Amethyst does not do it in the background.</string> + <string name="cordn_invitations_load_failed">Could not read invitations.</string> + <plurals name="cordn_invitations_members"> + <item quantity="one">%1$d person is already in this group</item> + <item quantity="other">%1$d people are already in this group</item> + </plurals> + <string name="cordn_invitations_members_more">+%1$d more</string> + <string name="cordn_invitations_no_coordinators">You have no coordinator open. cordn invitations arrive through a coordinator, so there is nowhere to look yet.</string> + <string name="cordn_invitations_none">No invitations waiting.</string> + <string name="cordn_invitations_refresh">Check again</string> + <string name="cordn_invitations_skipped">An invitation was left for another device</string> + <string name="cordn_invitations_title">Cordn invitations</string> + <string name="cordn_invitations_unreachable">%1$s did not answer</string> + <string name="cordn_invitations_via">Through %1$s</string> + <string name="cordn_keypackages_disclosure">Publishing signs a record under your own account key. That coordinator then knows this account exists and is invitable — permanently, and whether or not anyone invites you.</string> + <string name="cordn_keypackages_explainer">Others can only add you to a cordn group by taking a key package you published to that coordinator. cordn has no other place to keep one, so with none published nobody can invite you — and nothing tells them why.</string> + <string name="cordn_keypackages_failed">Could not read the key packages.</string> + <string name="cordn_keypackages_last_resort_no">No last-resort package. Once the single-use ones run out, invitations fail.</string> + <string name="cordn_keypackages_last_resort_yes">A last-resort package is published, so an invitation can still be made once the single-use ones run out.</string> + <plurals name="cordn_keypackages_orphans"> + <item quantity="one">%1$d package this device cannot open</item> + <item quantity="other">%1$d packages this device cannot open</item> + </plurals> + <string name="cordn_keypackages_orphans_body">The coordinator will hand these to anyone inviting you, but the private half is not on this device — it belongs to another install. If that install is gone, an invitation using one of these produces a welcome nobody can ever open.</string> + <string name="cordn_keypackages_publish">Publish one</string> + <string name="cordn_keypackages_publish_last_resort">Publish last-resort</string> + <plurals name="cordn_keypackages_summary"> + <item quantity="one">%1$d single-use package available.</item> + <item quantity="other">%1$d single-use packages available.</item> + </plurals> + <string name="cordn_keypackages_topup_note">Once you have published here, Amethyst quietly replaces packages as they are used up. It never publishes the first one for you.</string> + <string name="cordn_keypackages_withdraw_all">Withdraw all</string> + <string name="cordn_keypackages_withdraw_orphans">Withdraw those</string> + <string name="cordn_link_request">Ask to join this group</string> + <string name="cordn_link_request_disclosure">This publishes a key package under your own account key and tells the coordinator you want into this group — whether or not anyone answers.</string> + <string name="cordn_link_request_failed">Could not ask to join.</string> + <string name="cordn_link_request_sent">Asked. A member of the group has to add you; the invitation will show up under cordn invitations.</string> + <string name="cordn_link_scan">Scan</string> + <string name="cordn_media_download_failed">Could not open that file.</string> + <string name="cordn_media_no_server">No media server is set for this account, so there is nowhere to put the file. Pick one in Settings.</string> + <string name="cordn_media_unreadable">That file could not be read.</string> + <string name="cordn_media_upload_failed">Could not send that file.</string> + <plurals name="cordn_member_count"> + <item quantity="one">%1$d member</item> + <item quantity="other">%1$d members</item> + </plurals> + <string name="cordn_message_deleted">Message deleted</string> + <string name="cordn_message_details_coordinator">Coordinator</string> + <string name="cordn_message_details_cursor">Cursor</string> + <string name="cordn_message_details_sent_at">Sent</string> + <string name="cordn_message_details_title">Message details</string> + <string name="cordn_message_edited">edited</string> + <string name="cordn_pinned_by">Pinned by %1$s</string> + <plurals name="cordn_pinned_count"> + <item quantity="one">%1$d pinned message in this group</item> + <item quantity="other">%1$d pinned messages in this group</item> + </plurals> + <string name="cordn_pinned_next">Next pinned message</string> + <string name="cordn_pinned_previous">Previous pinned message</string> + <string name="cordn_pinned_show_all">Show all pinned messages</string> + <string name="cordn_pinned_title">Pinned messages</string> + <string name="cordn_reactions_title">Reactions</string> + <string name="cordn_requests_accept">Add</string> + <string name="cordn_requests_admin_only">Only an admin can accept. In a group with no admins, that is everyone.</string> + <string name="cordn_requests_check">Check for requests</string> + <string name="cordn_requests_decline">Dismiss</string> + <string name="cordn_requests_failed">Could not read the requests.</string> + <string name="cordn_requests_none">Nobody is waiting to join.</string> + <string name="cordn_requests_title">Requests to join</string> + <string name="cordn_send">Send</string> + <string name="cordn_send_failed">That did not send.</string> + <string name="cordn_send_no_session">This group's coordinator is not open, so nothing can be sent yet.</string> + <string name="cordn_share_copied">Copied</string> + <string name="cordn_share_copy">Copy link</string> + <string name="cordn_share_explainer">Anyone with this link can ask to join. An admin still has to let them in.</string> + <string name="cordn_share_title">Share this group</string> + <string name="cordn_voice_play">Play voice note</string> + <string name="cordn_voice_record">Record a voice note</string> + <string name="cordn_voice_stop">Stop and send</string> </resources> From 9b26de4515fab797300d7ee84d26a09613cbf992 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 21:13:14 +0000 Subject: [PATCH 52/57] refactor(commonsUI): move the remaining movable layouts, feed helpers and link components Most of the sweep's "Batch 4" had already landed in other PRs; this moves what was left that had no real blocker. - NewItemsBubble -> commonsUI components. - ChatHeaderLayout, LeftPictureLayout, listItem/SlimListItemLayout -> commonsUI layouts. Their @Previews use app drawables, TimeAgo and TextCount, so the previews stay in the app as *Preview.kt files. - WatchScrollToTop (list/grid/pager) -> commonsUI feeds; the CardFeedContentState overload stays in the app. The app's StickToTopOnPrepend was a copy of the commons one and is deleted; the commons one now collects with collectAsStateWithLifecycle, as the app copy did. - ChannelFeedState, ChannelFeedContentState -> commons feeds (headless). checkNotInMainThread() becomes LocalCache.appHost.assertNotMainThread(), which Android wires to the same check. - ClickableBuzzInviteLink, ClickableConcordInviteLink, ClickableRelayGroupLink, ClickableRelayUrl, OutlinedThinPaddingTextField -> commonsUI components. - The app's ClickableEmail/ClickablePhone are deleted in favour of the commons ones, which open mailto:/tel: through LocalUriHandler rather than ACTION_SEND/ACTION_DIAL intents. The commons ClickablePhone is new. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjQQN9CgWHVtNCSWqnKoqY --- .../amethyst/ui/actions/EditPostView.kt | 2 +- .../ui/components/AmethystRichText.kt | 6 + .../amethyst/ui/components/ClickableEmail.kt | 60 ------ .../ui/components/ConcordInviteCard.kt | 1 + .../amethyst/ui/components/RelayGroupCard.kt | 1 + .../amethyst/ui/components/RichTextViewer.kt | 6 + .../amethyst/ui/feeds/FeedContentStateView.kt | 2 + .../amethyst/ui/feeds/WatchScrollToTop.kt | 204 ------------------ ...erLayout.kt => ChatHeaderLayoutPreview.kt} | 53 +---- ...eLayout.kt => LeftPictureLayoutPreview.kt} | 53 +---- .../layouts/listItem/SlimListItemPreview.kt | 132 ++++++++++++ .../amethyst/ui/note/UserCompose.kt | 2 +- .../ui/note/creators/notify/AudienceSheet.kt | 2 +- .../userSuggestions/ShowUserSuggestionList.kt | 2 +- .../note/creators/zapsplits/ForwardZapTo.kt | 2 +- .../amethyst/ui/screen/FeedView.kt | 4 +- .../amethyst/ui/screen/UserFeedView.kt | 2 +- .../loggedIn/AccountFeedContentStates.kt | 2 +- .../calendars/CalendarCollectionsView.kt | 2 +- .../loggedIn/calendars/CalendarFeedView.kt | 2 +- .../chats/rooms/ChatroomHeaderCompose.kt | 9 +- .../RenderPublicChatChannelThumb.kt | 2 +- .../nip72Communities/CommunityCard.kt | 2 +- .../loggedIn/discover/nip90DVMs/DVMCard.kt | 2 +- .../browse/BrowseEmojiSetsScreen.kt | 4 +- .../ui/screen/loggedIn/home/HomeScreen.kt | 4 +- .../loggedIn/notifications/CardFeedView.kt | 2 +- .../notifications/NotificationScreen.kt | 1 + .../profile/newthreads/TabNotesNewThreads.kt | 4 +- .../loggedIn/profile/zaps/ZapNoteCompose.kt | 2 +- .../relays/nip86/RelayManagementScreen.kt | 2 +- .../commons}/feeds/ChannelFeedContentState.kt | 14 +- .../commons}/feeds/ChannelFeedState.kt | 3 +- .../ui/components/ClickableBuzzInviteLink.kt | 2 +- .../components/ClickableConcordInviteLink.kt | 2 +- .../commons/ui/components/ClickableLinks.kt | 24 +++ .../ui/components/ClickableRelayGroupLink.kt | 2 +- .../ui/components/ClickableRelayUrl.kt | 2 +- .../commons/ui/components/NewItemsBubble.kt | 29 +-- .../OutlinedThinPaddingTextField.kt | 2 +- .../commons/ui/feeds/StickToTopOnPrepend.kt | 17 +- .../commons/ui/feeds/WatchScrollToTop.kt | 75 +++++++ .../commons/ui/layouts/ChatHeaderLayout.kt | 78 +++++++ .../commons/ui/layouts/LeftPictureLayout.kt | 77 +++++++ .../ui/layouts/listItem/SlimListItemLayout.kt | 126 +---------- 45 files changed, 471 insertions(+), 556 deletions(-) delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/{ChatHeaderLayout.kt => ChatHeaderLayoutPreview.kt} (77%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/{LeftPictureLayout.kt => LeftPictureLayoutPreview.kt} (72%) create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemPreview.kt rename {amethyst/src/main/java/com/vitorpamplona/amethyst/ui => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/feeds/ChannelFeedContentState.kt (92%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst/ui => commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/feeds/ChannelFeedState.kt (93%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/ui/components/ClickableBuzzInviteLink.kt (98%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/ui/components/ClickableConcordInviteLink.kt (98%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/ui/components/ClickableRelayGroupLink.kt (98%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/ui/components/ClickableRelayUrl.kt (97%) rename amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/NewItemsBubble.kt (63%) rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/ui/components/OutlinedThinPaddingTextField.kt (99%) create mode 100644 commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/WatchScrollToTop.kt create mode 100644 commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/ChatHeaderLayout.kt create mode 100644 commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/LeftPictureLayout.kt rename {amethyst/src/main/java/com/vitorpamplona/amethyst => commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons}/ui/layouts/listItem/SlimListItemLayout.kt (81%) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt index 5db9dcbbd4..f7f574dbd6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt @@ -78,6 +78,7 @@ import com.vitorpamplona.amethyst.commons.resources.lightning_create_and_add_inv import com.vitorpamplona.amethyst.commons.resources.lightning_invoice import com.vitorpamplona.amethyst.commons.resources.what_s_on_your_mind import com.vitorpamplona.amethyst.commons.richtext.RichTextParser +import com.vitorpamplona.amethyst.commons.ui.components.OutlinedThinPaddingTextField import com.vitorpamplona.amethyst.commons.ui.insets.imePaddingSafe import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.navigation.topbars.PostingTopBar @@ -98,7 +99,6 @@ import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromFiles import com.vitorpamplona.amethyst.ui.actions.uploads.SelectFromGallery import com.vitorpamplona.amethyst.ui.components.BechLink import com.vitorpamplona.amethyst.ui.components.LoadUrlPreview -import com.vitorpamplona.amethyst.ui.components.OutlinedThinPaddingTextField import com.vitorpamplona.amethyst.ui.note.NoteCompose import com.vitorpamplona.amethyst.ui.note.creators.invoice.InvoiceRequest import com.vitorpamplona.amethyst.ui.note.creators.uploads.ImageVideoDescription diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/AmethystRichText.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/AmethystRichText.kt index 2f8261e466..176ba467b5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/AmethystRichText.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/AmethystRichText.kt @@ -52,6 +52,12 @@ import com.vitorpamplona.amethyst.commons.richtext.RichTextViewerState import com.vitorpamplona.amethyst.commons.richtext.SecretEmoji import com.vitorpamplona.amethyst.commons.richtext.Segment import com.vitorpamplona.amethyst.commons.richtext.WithdrawSegment +import com.vitorpamplona.amethyst.commons.ui.components.ClickableBuzzInviteLink +import com.vitorpamplona.amethyst.commons.ui.components.ClickableConcordInviteLink +import com.vitorpamplona.amethyst.commons.ui.components.ClickableEmail +import com.vitorpamplona.amethyst.commons.ui.components.ClickablePhone +import com.vitorpamplona.amethyst.commons.ui.components.ClickableRelayGroupLink +import com.vitorpamplona.amethyst.commons.ui.components.ClickableRelayUrl import com.vitorpamplona.amethyst.commons.ui.components.NowhereLinkCard import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.richtext.LocalRichTextInteractions diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt deleted file mode 100644 index 6e25f4be6b..0000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableEmail.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.components - -import android.content.ActivityNotFoundException -import android.content.Context -import android.content.Intent -import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalContext -import com.vitorpamplona.amethyst.commons.ui.components.ClickableTextPrimary -import kotlinx.coroutines.CancellationException - -@Composable -fun ClickableEmail(email: String) { - val stripped = email.replaceFirst("mailto:", "") - val context = LocalContext.current - - ClickableTextPrimary( - text = stripped, - onClick = { runCatching { context.sendMail(stripped) } }, - ) -} - -fun Context.sendMail( - to: String, - subject: String? = null, -) { - try { - val intent = Intent(Intent.ACTION_SEND) - intent.type = "vnd.android.cursor.item/email" // or "message/rfc822" - intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(to)) - if (subject != null) { - intent.putExtra(Intent.EXTRA_SUBJECT, subject) - } - startActivity(intent) - } catch (e: ActivityNotFoundException) { - // TODO: Handle case where no email app is available - } catch (t: Throwable) { - if (t is CancellationException) throw t - // TODO: Handle potential other type of exceptions - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ConcordInviteCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ConcordInviteCard.kt index 8935486076..714fc0af02 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ConcordInviteCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ConcordInviteCard.kt @@ -49,6 +49,7 @@ import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.concord_home_title import com.vitorpamplona.amethyst.commons.resources.concord_invite_card_join import com.vitorpamplona.amethyst.commons.resources.concord_invite_card_subtitle +import com.vitorpamplona.amethyst.commons.ui.components.ClickableConcordInviteLink import com.vitorpamplona.amethyst.commons.ui.components.RobohashFallbackAsyncImage import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RelayGroupCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RelayGroupCard.kt index cda380757e..e2a636f8c7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RelayGroupCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RelayGroupCard.kt @@ -53,6 +53,7 @@ import com.vitorpamplona.amethyst.commons.resources.relay_group_badge_invite_onl import com.vitorpamplona.amethyst.commons.resources.relay_group_badge_private import com.vitorpamplona.amethyst.commons.resources.relay_group_member_count import com.vitorpamplona.amethyst.commons.resources.relay_group_open +import com.vitorpamplona.amethyst.commons.ui.components.ClickableRelayGroupLink import com.vitorpamplona.amethyst.commons.ui.components.RobohashFallbackAsyncImage import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.pluralStringRes diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt index ede5174be2..bfa2899272 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/RichTextViewer.kt @@ -102,6 +102,12 @@ import com.vitorpamplona.amethyst.commons.richtext.Segment import com.vitorpamplona.amethyst.commons.richtext.VideoSegment import com.vitorpamplona.amethyst.commons.richtext.WithdrawSegment import com.vitorpamplona.amethyst.commons.ui.components.AnimatedBorderTextCornerRadius +import com.vitorpamplona.amethyst.commons.ui.components.ClickableBuzzInviteLink +import com.vitorpamplona.amethyst.commons.ui.components.ClickableConcordInviteLink +import com.vitorpamplona.amethyst.commons.ui.components.ClickableEmail +import com.vitorpamplona.amethyst.commons.ui.components.ClickablePhone +import com.vitorpamplona.amethyst.commons.ui.components.ClickableRelayGroupLink +import com.vitorpamplona.amethyst.commons.ui.components.ClickableRelayUrl import com.vitorpamplona.amethyst.commons.ui.components.ClickableTextPrimary import com.vitorpamplona.amethyst.commons.ui.components.CrossfadeIfEnabled import com.vitorpamplona.amethyst.commons.ui.components.NowhereLinkCard diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentStateView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentStateView.kt index ce29dc0daf..85dc9c6610 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentStateView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/FeedContentStateView.kt @@ -35,6 +35,8 @@ import com.vitorpamplona.amethyst.commons.ui.feeds.FeedEmpty import com.vitorpamplona.amethyst.commons.ui.feeds.FeedError import com.vitorpamplona.amethyst.commons.ui.feeds.LoadingFeed import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox +import com.vitorpamplona.amethyst.commons.ui.feeds.StickToTopOnPrepend +import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyGridState import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyListState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/WatchScrollToTop.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/WatchScrollToTop.kt index b9580ea8ba..d0d7daa8c5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/WatchScrollToTop.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/WatchScrollToTop.kt @@ -21,52 +21,11 @@ package com.vitorpamplona.amethyst.ui.feeds import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.lazy.grid.LazyGridState -import androidx.compose.foundation.pager.PagerState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.runtime.snapshotFlow import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.vitorpamplona.amethyst.commons.feeds.FeedContentState -import com.vitorpamplona.amethyst.commons.feeds.FeedState import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.CardFeedContentState -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flatMapLatest -import kotlinx.coroutines.flow.flowOf -import kotlinx.coroutines.flow.map - -@Composable -fun WatchScrollToTop( - feedContentState: FeedContentState, - listState: LazyListState, -) { - val scrollToTop by feedContentState.scrollToTop.collectAsStateWithLifecycle() - - LaunchedEffect(scrollToTop) { - if (scrollToTop > 0 && feedContentState.scrollToTopPending) { - listState.scrollToItem(index = 0) - feedContentState.sentToTop() - } - } -} - -@Composable -fun WatchScrollToTop( - feedContentState: FeedContentState, - listState: LazyGridState, -) { - val scrollToTop by feedContentState.scrollToTop.collectAsStateWithLifecycle() - - LaunchedEffect(scrollToTop) { - if (scrollToTop > 0 && feedContentState.scrollToTopPending) { - listState.scrollToItem(index = 0) - feedContentState.sentToTop() - } - } -} @Composable fun WatchScrollToTop( @@ -82,166 +41,3 @@ fun WatchScrollToTop( } } } - -@Composable -fun WatchScrollToTop( - videoFeedContentState: FeedContentState, - pagerState: PagerState, -) { - val scrollToTop by videoFeedContentState.scrollToTop.collectAsStateWithLifecycle() - - LaunchedEffect(scrollToTop) { - if (scrollToTop > 0 && videoFeedContentState.scrollToTopPending) { - pagerState.scrollToPage(page = 0) - videoFeedContentState.sentToTop() - } - } -} - -/** - * Keeps the user pinned to index 0 when new items prepend to a feed, but - * only if they were already at the very top right before the update. - * - * Why this is non-trivial: every feed uses stable `key = item.idHex` in - * its lazy list, which makes Compose preserve the visual anchor across - * data changes. When N items prepend, the user's previously-visible - * top item is still on screen but its index is now N — so - * `firstVisibleItemIndex` shifts from 0 to N without any user gesture. - * A naive `if (firstVisibleItemIndex <= 1) scrollToItem(0)` check inside - * `LaunchedEffect(items.firstOrNull())` therefore fails as soon as more - * than one item arrives in the same batch. - * - * The trick: track "was at top" continuously via [snapshotFlow], but - * only flip it from true → false when [LazyListState.isScrollInProgress] - * is true (i.e. the user is actively scrolling). Compose's keyed-item - * shift after a data update does not set that flag — only real touch - * gestures and `animate*` calls do — so data-driven index shifts can - * never poison the cached value. When [firstItemKey] changes (head of - * the list moved), if the cached value is still true, snap back to 0 - * with an instant (non-animated) scroll so the prepend appears as - * in-place growth rather than a visible jump-then-scroll. - * - * Most callers should not invoke this directly: [SaveableFeedContentState], - * [SaveableGridFeedContentState], and the analogous wrappers in - * `ui/screen/FeedView.kt` already apply auto-stick to every feed they - * own. Invoke the explicit overload only when the listState is - * constructed outside one of those wrappers, or when the key that - * should trigger the snap is not the default `items.list[0].idHex` - * (e.g. notifications, chats, or feeds keyed on something other than a - * Note's hex id). - */ -@Composable -fun StickToTopOnPrepend( - listState: LazyListState, - firstItemKey: Any?, -) { - stickToTopOnPrepend( - stateKey = listState, - firstItemKey = firstItemKey, - initialAtTop = { - listState.firstVisibleItemIndex == 0 && listState.firstVisibleItemScrollOffset == 0 - }, - sampler = { - snapshotFlow { - listState.firstVisibleItemIndex == 0 && listState.firstVisibleItemScrollOffset == 0 - } - }, - isScrollInProgress = { listState.isScrollInProgress }, - firstVisibleItemIndex = { listState.firstVisibleItemIndex }, - scrollToTop = { listState.scrollToItem(0) }, - ) -} - -@Composable -fun StickToTopOnPrepend( - gridState: LazyGridState, - firstItemKey: Any?, -) { - stickToTopOnPrepend( - stateKey = gridState, - firstItemKey = firstItemKey, - initialAtTop = { - gridState.firstVisibleItemIndex == 0 && gridState.firstVisibleItemScrollOffset == 0 - }, - sampler = { - snapshotFlow { - gridState.firstVisibleItemIndex == 0 && gridState.firstVisibleItemScrollOffset == 0 - } - }, - isScrollInProgress = { gridState.isScrollInProgress }, - firstVisibleItemIndex = { gridState.firstVisibleItemIndex }, - scrollToTop = { gridState.scrollToItem(0) }, - ) -} - -/** - * Auto-stick wired straight to a [FeedContentState]: derives the head - * key from `feedContent → Loaded.feed → list.firstOrNull()?.idHex` so - * callers don't have to collect the inner feed flow themselves. Used - * by the Saveable* wrappers; suitable for any Note-keyed feed. - */ -@Composable -fun StickToTopOnPrepend( - feedContentState: FeedContentState, - listState: LazyListState, -) { - StickToTopOnPrepend(listState, rememberFirstItemIdHex(feedContentState)) -} - -@Composable -fun StickToTopOnPrepend( - feedContentState: FeedContentState, - gridState: LazyGridState, -) { - StickToTopOnPrepend(gridState, rememberFirstItemIdHex(feedContentState)) -} - -@OptIn(ExperimentalCoroutinesApi::class) -@Composable -private fun rememberFirstItemIdHex(feedContentState: FeedContentState): String? { - val flow = - remember(feedContentState) { - feedContentState.feedContent.flatMapLatest { state -> - when (state) { - is FeedState.Loaded -> state.feed.map { it.list.firstOrNull()?.idHex } - else -> flowOf(null) - } - } - } - val key by flow.collectAsStateWithLifecycle(initialValue = null) - return key -} - -@Composable -private fun stickToTopOnPrepend( - stateKey: Any, - firstItemKey: Any?, - initialAtTop: () -> Boolean, - sampler: () -> Flow<Boolean>, - isScrollInProgress: () -> Boolean, - firstVisibleItemIndex: () -> Int, - scrollToTop: suspend () -> Unit, -) { - // Plain holder instead of mutableStateOf — we only read this inside - // effects, never in composition, so we don't need snapshot tracking. - // Seed from the actual restored scroll position: when the user returns - // to a feed via rememberForeverLazyListState, the saved offset is - // already in place, and a hardcoded `true` would mis-snap them to 0. - val wasAtTop = remember(stateKey) { booleanArrayOf(initialAtTop()) } - - LaunchedEffect(stateKey) { - sampler().collect { atTop -> - if (atTop) { - wasAtTop[0] = true - } else if (isScrollInProgress()) { - wasAtTop[0] = false - } - } - } - - LaunchedEffect(firstItemKey) { - if (firstItemKey != null && wasAtTop[0] && firstVisibleItemIndex() > 0) { - scrollToTop() - } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayout.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayoutPreview.kt similarity index 77% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayout.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayoutPreview.kt index 5abf8308cf..1f49f5ac52 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayout.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/ChatHeaderLayoutPreview.kt @@ -20,16 +20,10 @@ */ package com.vitorpamplona.amethyst.ui.layouts -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image -import androidx.compose.foundation.combinedClickable -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.ListItem import androidx.compose.material3.Text @@ -38,20 +32,19 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.profile_banner +import com.vitorpamplona.amethyst.commons.ui.components.NewItemsBubble +import com.vitorpamplona.amethyst.commons.ui.layouts.ChatHeaderLayout +import com.vitorpamplona.amethyst.commons.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness -import com.vitorpamplona.amethyst.commons.ui.theme.DoubleHorzSpacer import com.vitorpamplona.amethyst.commons.ui.theme.Height4dpModifier import com.vitorpamplona.amethyst.commons.ui.theme.Size55Modifier import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn -import com.vitorpamplona.amethyst.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo import com.vitorpamplona.amethyst.ui.painterRes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.NewItemsBubble import com.vitorpamplona.quartz.utils.TimeUtils private const val PREVIEW_AUTHOR = "This is my author" @@ -136,43 +129,3 @@ fun ChannelNamePreview() { } } } - -@OptIn(ExperimentalFoundationApi::class) -@Composable -fun ChatHeaderLayout( - channelPicture: @Composable () -> Unit, - firstRow: @Composable RowScope.() -> Unit, - secondRow: @Composable RowScope.() -> Unit, - onClick: () -> Unit, - onLongClick: (() -> Unit)? = null, -) { - Row( - modifier = - Modifier - .combinedClickable(onClick = onClick, onLongClick = onLongClick) - .padding(10.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - Box(Size55Modifier) { channelPicture() } - - Spacer(modifier = DoubleHorzSpacer) - - Column( - modifier = Modifier.fillMaxWidth(), - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - ) { - firstRow() - } - - Spacer(modifier = Height4dpModifier) - - Row( - verticalAlignment = Alignment.CenterVertically, - ) { - secondRow() - } - } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayout.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayoutPreview.kt similarity index 72% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayout.kt rename to amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayoutPreview.kt index 167bbc4a51..2f26c2e73e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayout.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/LeftPictureLayoutPreview.kt @@ -21,18 +21,11 @@ package com.vitorpamplona.amethyst.ui.layouts import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale @@ -43,10 +36,10 @@ import androidx.compose.ui.unit.sp import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.profile_banner +import com.vitorpamplona.amethyst.commons.ui.layouts.LeftPictureLayout import com.vitorpamplona.amethyst.commons.ui.note.LikeIcon import com.vitorpamplona.amethyst.commons.ui.note.ZappedIcon import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.commons.ui.theme.DoubleHorzSpacer import com.vitorpamplona.amethyst.commons.ui.theme.QuoteBorder import com.vitorpamplona.amethyst.commons.ui.theme.Size16Modifier import com.vitorpamplona.amethyst.commons.ui.theme.Size20Modifier @@ -104,47 +97,3 @@ fun LeftPictureLayoutPreviewCard() { onBottomRow = { Text("This is my Moderator List") }, ) } - -@Composable -fun LeftPictureLayout( - onImage: @Composable () -> Unit, - onTitleRow: @Composable RowScope.() -> Unit, - onDescription: @Composable () -> Unit, - onBottomRow: @Composable RowScope.() -> Unit, - imageFraction: Float = 0.25f, -) { - Row(Modifier.aspectRatio(ratio = 1 / imageFraction)) { - Column( - modifier = Modifier.fillMaxWidth(imageFraction).aspectRatio(ratio = 1f), - ) { - onImage() - } - - Spacer(modifier = DoubleHorzSpacer) - - Column( - modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.SpaceBetween, - ) { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - ) { - onTitleRow() - } - - Row( - modifier = Modifier.fillMaxWidth().weight(1f), - ) { - onDescription() - } - - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - ) { - onBottomRow() - } - } - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemPreview.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemPreview.kt new file mode 100644 index 0000000000..f4529fc097 --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemPreview.kt @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.ui.layouts.listItem + +import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.ListItem +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment.Companion.CenterVertically +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.tooling.preview.Preview +import com.vitorpamplona.amethyst.R +import com.vitorpamplona.amethyst.commons.resources.Res +import com.vitorpamplona.amethyst.commons.resources.profile_banner +import com.vitorpamplona.amethyst.commons.ui.components.NewItemsBubble +import com.vitorpamplona.amethyst.commons.ui.layouts.ChatHeaderLayout +import com.vitorpamplona.amethyst.commons.ui.layouts.listItem.SlimListItem +import com.vitorpamplona.amethyst.commons.ui.stringRes +import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness +import com.vitorpamplona.amethyst.commons.ui.theme.Height4dpModifier +import com.vitorpamplona.amethyst.commons.ui.theme.Size55Modifier +import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn +import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo +import com.vitorpamplona.amethyst.ui.painterRes +import com.vitorpamplona.quartz.utils.TimeUtils + +private const val PREVIEW_AUTHOR = "This is my author" +private const val PREVIEW_MESSAGE = "This is a message from this person" + +@Composable +@Preview +fun ChannelNamePreview() { + ThemeComparisonColumn { + Column { + ChatHeaderLayout( + channelPicture = { + Image( + painter = painterRes(R.drawable.github, 1), + contentDescription = stringRes(id = Res.string.profile_banner), + contentScale = ContentScale.FillWidth, + ) + }, + firstRow = { + Text(PREVIEW_AUTHOR, Modifier.weight(1f)) + TimeAgo(TimeUtils.now()) + }, + secondRow = { + Text(PREVIEW_MESSAGE, Modifier.weight(1f)) + NewItemsBubble() + }, + onClick = {}, + ) + + HorizontalDivider(thickness = DividerThickness) + + SlimListItem( + headlineContent = { + Row(verticalAlignment = CenterVertically) { + Text(PREVIEW_AUTHOR, Modifier.weight(1f)) + TimeAgo(TimeUtils.now()) + } + }, + supportingContent = { + Row(verticalAlignment = CenterVertically) { + Text(PREVIEW_MESSAGE, Modifier.weight(1f)) + Spacer(modifier = Height4dpModifier) + NewItemsBubble() + } + }, + leadingContent = { + Image( + painter = painterRes(R.drawable.github, 2), + contentDescription = stringRes(id = Res.string.profile_banner), + contentScale = ContentScale.FillWidth, + modifier = Size55Modifier, + ) + }, + ) + + HorizontalDivider(thickness = DividerThickness) + + ListItem( + headlineContent = { + Row(verticalAlignment = CenterVertically) { + Text(PREVIEW_AUTHOR, Modifier.weight(1f)) + TimeAgo(TimeUtils.now()) + } + }, + supportingContent = { + Row(verticalAlignment = CenterVertically) { + Text(PREVIEW_MESSAGE, Modifier.weight(1f)) + Spacer(modifier = Height4dpModifier) + NewItemsBubble() + } + }, + leadingContent = { + Image( + painter = painterRes(R.drawable.github, 2), + contentDescription = stringRes(id = Res.string.profile_banner), + contentScale = ContentScale.FillWidth, + modifier = Size55Modifier, + ) + }, + ) + + HorizontalDivider(thickness = DividerThickness) + } + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt index 46771e5f29..f002b59bef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserCompose.kt @@ -43,6 +43,7 @@ import com.vitorpamplona.amethyst.commons.resources.follow import com.vitorpamplona.amethyst.commons.resources.login_with_a_private_key_to_be_able_to_follow import com.vitorpamplona.amethyst.commons.resources.login_with_a_private_key_to_be_able_to_unfollow import com.vitorpamplona.amethyst.commons.resources.read_only_user +import com.vitorpamplona.amethyst.commons.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.note.ShowUserButton import com.vitorpamplona.amethyst.commons.ui.theme.Size55dp @@ -51,7 +52,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.service.relayClient.reqCommand.account.observeAccountIsHiddenUser import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserAboutMe import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserIsFollowing -import com.vitorpamplona.amethyst.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt index bb78a2b1b1..e2aedac116 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/notify/AudienceSheet.kt @@ -88,6 +88,7 @@ import com.vitorpamplona.amethyst.commons.resources.discover_follows import com.vitorpamplona.amethyst.commons.resources.follow_sets import com.vitorpamplona.amethyst.commons.resources.num_selected import com.vitorpamplona.amethyst.commons.resources.select_all +import com.vitorpamplona.amethyst.commons.ui.components.OutlinedThinPaddingTextField import com.vitorpamplona.amethyst.commons.ui.pluralStringRes import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness @@ -95,7 +96,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size24dp import com.vitorpamplona.amethyst.commons.ui.theme.grayText import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.commons.ui.theme.warningColor -import com.vitorpamplona.amethyst.ui.components.OutlinedThinPaddingTextField import com.vitorpamplona.amethyst.ui.note.BaseUserPicture import com.vitorpamplona.amethyst.ui.note.UsernameDisplay import com.vitorpamplona.amethyst.ui.note.creators.userSuggestions.ShowUserSuggestionList diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt index b13c5e1386..ee8e180270 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/ShowUserSuggestionList.kt @@ -53,6 +53,7 @@ import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.nip05DnsIdentifiers.Nip05State import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.user_suggestion_in_this_chat +import com.vitorpamplona.amethyst.commons.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.Font14SP @@ -60,7 +61,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.NIP05IconSize import com.vitorpamplona.amethyst.commons.ui.theme.Size55dp import com.vitorpamplona.amethyst.commons.ui.theme.nip05 import com.vitorpamplona.amethyst.service.relayClient.searchCommand.UserSearchDataSourceSubscription -import com.vitorpamplona.amethyst.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture import com.vitorpamplona.amethyst.ui.note.ObserveAndRenderNIP05VerifiedSymbol import com.vitorpamplona.amethyst.ui.note.UsernameDisplay diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/ForwardZapTo.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/ForwardZapTo.kt index 6554cdcabe..ad2b1c3ea5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/ForwardZapTo.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/zapsplits/ForwardZapTo.kt @@ -45,6 +45,7 @@ import com.vitorpamplona.amethyst.commons.resources.zap_split_explainer import com.vitorpamplona.amethyst.commons.resources.zap_split_search_and_add_user import com.vitorpamplona.amethyst.commons.resources.zap_split_search_and_add_user_placeholder import com.vitorpamplona.amethyst.commons.resources.zap_split_title +import com.vitorpamplona.amethyst.commons.ui.components.OutlinedThinPaddingTextField import com.vitorpamplona.amethyst.commons.ui.note.creators.zapsplits.IZapField import com.vitorpamplona.amethyst.commons.ui.note.creators.zapsplits.ZapSplitIcon import com.vitorpamplona.amethyst.commons.ui.stringRes @@ -55,7 +56,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size55dp import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.ui.actions.MentionPreservingInputTransformation import com.vitorpamplona.amethyst.ui.actions.UrlUserTagOutputTransformation -import com.vitorpamplona.amethyst.ui.components.OutlinedThinPaddingTextField import com.vitorpamplona.amethyst.ui.note.BaseUserPicture import com.vitorpamplona.amethyst.ui.note.UsernameDisplay import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt index 421549ffb6..bcb73b461a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt @@ -35,14 +35,14 @@ import com.vitorpamplona.amethyst.commons.ui.feeds.FeedEmpty import com.vitorpamplona.amethyst.commons.ui.feeds.FeedError import com.vitorpamplona.amethyst.commons.ui.feeds.LoadingFeed import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox +import com.vitorpamplona.amethyst.commons.ui.feeds.StickToTopOnPrepend +import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyGridState import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyListState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.viewmodels.FeedViewModel import com.vitorpamplona.amethyst.ui.feeds.FeedLoaded import com.vitorpamplona.amethyst.ui.feeds.PrefetchLoadedFeedMedia -import com.vitorpamplona.amethyst.ui.feeds.StickToTopOnPrepend -import com.vitorpamplona.amethyst.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @Composable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt index 880e12de22..4ed610bed1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt @@ -35,11 +35,11 @@ import com.vitorpamplona.amethyst.commons.ui.feeds.FeedEmpty import com.vitorpamplona.amethyst.commons.ui.feeds.FeedError import com.vitorpamplona.amethyst.commons.ui.feeds.LoadingFeed import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox +import com.vitorpamplona.amethyst.commons.ui.feeds.StickToTopOnPrepend import com.vitorpamplona.amethyst.commons.ui.layouts.rememberFeedContentPadding import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding -import com.vitorpamplona.amethyst.ui.feeds.StickToTopOnPrepend import com.vitorpamplona.amethyst.ui.note.UserCompose import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt index dd46388f4d..a62a265f18 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountFeedContentStates.kt @@ -22,13 +22,13 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn import android.content.ComponentCallbacks2 import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.feeds.ChannelFeedContentState import com.vitorpamplona.amethyst.commons.feeds.FeedContentState import com.vitorpamplona.amethyst.commons.model.Note import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.topNavFeeds.TopFilter import com.vitorpamplona.amethyst.model.Account import com.vitorpamplona.amethyst.service.checkNotInMainThread -import com.vitorpamplona.amethyst.ui.feeds.ChannelFeedContentState import com.vitorpamplona.amethyst.ui.screen.TopNavFilterState import com.vitorpamplona.amethyst.ui.screen.loggedIn.articles.dal.ArticlesFeedFilter import com.vitorpamplona.amethyst.ui.screen.loggedIn.badges.dal.BadgesFeedFilter diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt index 644d10c45e..c84bbfbd80 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarCollectionsView.kt @@ -64,13 +64,13 @@ import com.vitorpamplona.amethyst.commons.resources.calendar_export_event import com.vitorpamplona.amethyst.commons.resources.calendar_export_share_title import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox import com.vitorpamplona.amethyst.commons.ui.feeds.ScrollStateKeys +import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyListState import com.vitorpamplona.amethyst.commons.ui.layouts.rememberFeedContentPadding import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.pluralStringRes import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding -import com.vitorpamplona.amethyst.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.UserCardHeader import com.vitorpamplona.quartz.nip01Core.core.Address diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarFeedView.kt index 443c0b0b0d..0d62fc715b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/CalendarFeedView.kt @@ -47,11 +47,11 @@ import com.vitorpamplona.amethyst.commons.resources.calendar_empty_feed_title import com.vitorpamplona.amethyst.commons.resources.calendar_section_past import com.vitorpamplona.amethyst.commons.resources.calendar_section_upcoming import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox +import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.layouts.rememberFeedContentPadding import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding -import com.vitorpamplona.amethyst.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.utils.TimeUtils diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt index 8b2ba48747..f758b7bdcc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/ChatroomHeaderCompose.kt @@ -106,7 +106,9 @@ import com.vitorpamplona.amethyst.commons.resources.relay_group_server_label import com.vitorpamplona.amethyst.commons.resources.remove_from_messages import com.vitorpamplona.amethyst.commons.resources.unmute_notifications import com.vitorpamplona.amethyst.commons.resources.unpin_conversation +import com.vitorpamplona.amethyst.commons.ui.components.NewItemsBubble import com.vitorpamplona.amethyst.commons.ui.components.RobohashFallbackAsyncImage +import com.vitorpamplona.amethyst.commons.ui.layouts.ChatHeaderLayout import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.note.HeaderPill import com.vitorpamplona.amethyst.commons.ui.screen.LocalDisplaySettings @@ -118,7 +120,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size15Modifier import com.vitorpamplona.amethyst.commons.ui.theme.Size55dp import com.vitorpamplona.amethyst.commons.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.commons.ui.theme.grayText -import com.vitorpamplona.amethyst.commons.ui.theme.newItemBubbleModifier import com.vitorpamplona.amethyst.commons.ui.theme.placeholderText import com.vitorpamplona.amethyst.model.buzz.toMembershipNotice import com.vitorpamplona.amethyst.model.nip11RelayInfo.loadRelayInfo @@ -126,7 +127,6 @@ import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.observe import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteHasEvent import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.UserFinderByParentFilterAssemblerSubscription import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.observeUserName -import com.vitorpamplona.amethyst.ui.layouts.ChatHeaderLayout import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor import com.vitorpamplona.amethyst.ui.note.BlankNote import com.vitorpamplona.amethyst.ui.note.LoadDecryptedContentOrNull @@ -1377,8 +1377,3 @@ private fun TimeAgo(channelLastTime: Long?) { color = MaterialTheme.colorScheme.grayText, ) } - -@Composable -fun NewItemsBubble() { - Box(MaterialTheme.colorScheme.newItemBubbleModifier) -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/RenderPublicChatChannelThumb.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/RenderPublicChatChannelThumb.kt index 4623df34fe..fda82b5723 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/RenderPublicChatChannelThumb.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/RenderPublicChatChannelThumb.kt @@ -53,6 +53,7 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.Mute import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsByProxyTopNavFilter import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.chat_about_topic +import com.vitorpamplona.amethyst.commons.ui.layouts.LeftPictureLayout import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.HalfTopPadding @@ -61,7 +62,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.RowColSpacing import com.vitorpamplona.amethyst.commons.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.commons.ui.theme.grayText import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.observeChannel -import com.vitorpamplona.amethyst.ui.layouts.LeftPictureLayout import com.vitorpamplona.amethyst.ui.note.DisplayAuthorBanner import com.vitorpamplona.amethyst.ui.note.Gallery import com.vitorpamplona.amethyst.ui.note.LikeReaction diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/CommunityCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/CommunityCard.kt index 0a4dc47515..43dfdebcbe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/CommunityCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/CommunityCard.kt @@ -55,6 +55,7 @@ import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.Mute import com.vitorpamplona.amethyst.commons.model.topNavFeeds.noteBased.muted.MutedAuthorsByProxyTopNavFilter import com.vitorpamplona.amethyst.commons.resources.Res import com.vitorpamplona.amethyst.commons.resources.community_about_topic +import com.vitorpamplona.amethyst.commons.ui.layouts.LeftPictureLayout import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.stringRes import com.vitorpamplona.amethyst.commons.ui.theme.HalfTopPadding @@ -63,7 +64,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.RowColSpacing import com.vitorpamplona.amethyst.commons.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.commons.ui.theme.grayText import com.vitorpamplona.amethyst.service.relayClient.reqCommand.event.observeNoteEvent -import com.vitorpamplona.amethyst.ui.layouts.LeftPictureLayout import com.vitorpamplona.amethyst.ui.note.DisplayAuthorBanner import com.vitorpamplona.amethyst.ui.note.Gallery import com.vitorpamplona.amethyst.ui.note.LikeReaction diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt index 64b35607fc..89efcd5e61 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/DVMCard.kt @@ -41,6 +41,7 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.sp import com.vitorpamplona.amethyst.commons.model.AddressableNote import com.vitorpamplona.amethyst.commons.model.Note +import com.vitorpamplona.amethyst.commons.ui.layouts.LeftPictureLayout import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.theme.HalfTopPadding import com.vitorpamplona.amethyst.commons.ui.theme.RowColSpacing5dp @@ -51,7 +52,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.grayText import com.vitorpamplona.amethyst.commons.ui.theme.nip05 import com.vitorpamplona.amethyst.service.relayClient.reqCommand.user.UserFinderFilterAssemblerSubscription import com.vitorpamplona.amethyst.ui.components.MyAsyncImage -import com.vitorpamplona.amethyst.ui.layouts.LeftPictureLayout import com.vitorpamplona.amethyst.ui.note.LikeReaction import com.vitorpamplona.amethyst.ui.note.ZapReaction import com.vitorpamplona.amethyst.ui.note.elements.BannerImage diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/BrowseEmojiSetsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/BrowseEmojiSetsScreen.kt index 4aa7c25131..ddcb0b073f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/BrowseEmojiSetsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/emojipacks/browse/BrowseEmojiSetsScreen.kt @@ -46,12 +46,12 @@ import com.vitorpamplona.amethyst.commons.ui.feeds.FeedError import com.vitorpamplona.amethyst.commons.ui.feeds.LoadingFeed import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox import com.vitorpamplona.amethyst.commons.ui.feeds.ScrollStateKeys +import com.vitorpamplona.amethyst.commons.ui.feeds.StickToTopOnPrepend import com.vitorpamplona.amethyst.commons.ui.feeds.WatchLifecycleAndUpdateModel +import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyGridState import com.vitorpamplona.amethyst.commons.ui.layouts.rememberFeedContentPadding import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav -import com.vitorpamplona.amethyst.ui.feeds.StickToTopOnPrepend -import com.vitorpamplona.amethyst.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold import com.vitorpamplona.amethyst.ui.navigation.bottombars.AppBottomBar import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt index 66ebccef97..14b4ff9783 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt @@ -61,6 +61,8 @@ import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.tooling.preview.Preview import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.Amethyst +import com.vitorpamplona.amethyst.commons.feeds.ChannelFeedContentState +import com.vitorpamplona.amethyst.commons.feeds.ChannelFeedState import com.vitorpamplona.amethyst.commons.feeds.FeedContentState import com.vitorpamplona.amethyst.commons.feeds.FeedState import com.vitorpamplona.amethyst.commons.model.emphChat.EphemeralChatChannel @@ -96,8 +98,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.commons.ui.theme.TabRowHeight import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonRow import com.vitorpamplona.amethyst.service.location.LocationState -import com.vitorpamplona.amethyst.ui.feeds.ChannelFeedContentState -import com.vitorpamplona.amethyst.ui.feeds.ChannelFeedState import com.vitorpamplona.amethyst.ui.feeds.RenderFeedContentState import com.vitorpamplona.amethyst.ui.feeds.SaveableFeedContentState import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt index e471e8f3c7..bec6b7c1fa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedView.kt @@ -60,6 +60,7 @@ import com.vitorpamplona.amethyst.commons.ui.feeds.LoadingFeed import com.vitorpamplona.amethyst.commons.ui.feeds.RelayReachCursor import com.vitorpamplona.amethyst.commons.ui.feeds.RelayReachDetailDialog import com.vitorpamplona.amethyst.commons.ui.feeds.RelayReachMarkers +import com.vitorpamplona.amethyst.commons.ui.feeds.StickToTopOnPrepend import com.vitorpamplona.amethyst.commons.ui.layouts.rememberFeedContentPadding import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.note.CloseIcon @@ -73,7 +74,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.Size10dp import com.vitorpamplona.amethyst.commons.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.commons.ui.theme.imageModifier import com.vitorpamplona.amethyst.logTime -import com.vitorpamplona.amethyst.ui.feeds.StickToTopOnPrepend import com.vitorpamplona.amethyst.ui.note.BadgeCompose import com.vitorpamplona.amethyst.ui.note.MessageSetCompose import com.vitorpamplona.amethyst.ui.note.MultiSetCompose diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt index cd772a90de..208c12bb85 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt @@ -40,6 +40,7 @@ import com.vitorpamplona.amethyst.commons.resources.notification_tab_following import com.vitorpamplona.amethyst.commons.ui.feeds.PagerStateKeys import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox import com.vitorpamplona.amethyst.commons.ui.feeds.ScrollStateKeys +import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyListState import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverPagerState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt index abed0924d7..d600bd16fd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/newthreads/TabNotesNewThreads.kt @@ -40,12 +40,12 @@ import com.vitorpamplona.amethyst.commons.ui.feeds.FeedEmpty import com.vitorpamplona.amethyst.commons.ui.feeds.FeedError import com.vitorpamplona.amethyst.commons.ui.feeds.LoadingFeed import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox +import com.vitorpamplona.amethyst.commons.ui.feeds.StickToTopOnPrepend +import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness import com.vitorpamplona.amethyst.commons.ui.theme.FeedPadding import com.vitorpamplona.amethyst.ui.feeds.PrefetchLoadedFeedMedia -import com.vitorpamplona.amethyst.ui.feeds.StickToTopOnPrepend -import com.vitorpamplona.amethyst.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.ui.note.NoteCompose import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.profile.newthreads.dal.UserProfileNewThreadsFeedViewModel diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/ZapNoteCompose.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/ZapNoteCompose.kt index ed93534498..f3d45d8565 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/ZapNoteCompose.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/zaps/ZapNoteCompose.kt @@ -35,12 +35,12 @@ import androidx.compose.ui.unit.sp import com.vitorpamplona.amethyst.commons.model.User import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.model.navigation.routeFor +import com.vitorpamplona.amethyst.commons.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.commons.ui.navigation.navs.EmptyNav import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.theme.BitcoinOrange import com.vitorpamplona.amethyst.commons.ui.theme.Size55dp import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn -import com.vitorpamplona.amethyst.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.ui.navigation.routes.routeFor import com.vitorpamplona.amethyst.ui.note.UserActionOptions import com.vitorpamplona.amethyst.ui.note.UserPicture diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt index fd0e1f5a7c..0498e1996f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip86/RelayManagementScreen.kt @@ -122,6 +122,7 @@ import com.vitorpamplona.amethyst.commons.resources.relay_management_tab_pubkeys import com.vitorpamplona.amethyst.commons.resources.relay_management_tab_settings import com.vitorpamplona.amethyst.commons.resources.relay_management_title import com.vitorpamplona.amethyst.commons.resources.search_and_add_a_user +import com.vitorpamplona.amethyst.commons.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav import com.vitorpamplona.amethyst.commons.ui.note.ClearTextIcon import com.vitorpamplona.amethyst.commons.ui.stringRes @@ -133,7 +134,6 @@ import com.vitorpamplona.amethyst.commons.ui.theme.SmallBorder import com.vitorpamplona.amethyst.commons.ui.theme.StdHorzSpacer import com.vitorpamplona.amethyst.commons.ui.theme.nip05 import com.vitorpamplona.amethyst.service.relayClient.searchCommand.UserSearchDataSourceSubscription -import com.vitorpamplona.amethyst.ui.layouts.listItem.SlimListItem import com.vitorpamplona.amethyst.ui.note.AboutDisplay import com.vitorpamplona.amethyst.ui.note.ClickableUserPicture import com.vitorpamplona.amethyst.ui.note.ObserveAndRenderNIP05VerifiedSymbol diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/ChannelFeedContentState.kt similarity index 92% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/ChannelFeedContentState.kt index 611d27ff59..296893376c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedContentState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/ChannelFeedContentState.kt @@ -18,26 +18,24 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.feeds +package com.vitorpamplona.amethyst.commons.feeds import androidx.compose.runtime.MutableState import androidx.compose.runtime.Stable import androidx.compose.runtime.mutableStateOf -import com.vitorpamplona.amethyst.commons.feeds.AdditiveComplexFeedFilter -import com.vitorpamplona.amethyst.commons.feeds.InvalidatableContent -import com.vitorpamplona.amethyst.commons.feeds.LoadedFeedState import com.vitorpamplona.amethyst.commons.model.Channel import com.vitorpamplona.amethyst.commons.model.Note +import com.vitorpamplona.amethyst.commons.model.cache.LocalCache import com.vitorpamplona.amethyst.commons.service.BundledInsert import com.vitorpamplona.amethyst.commons.service.BundledUpdate -import com.vitorpamplona.amethyst.service.checkNotInMainThread -import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.equalImmutableLists +import com.vitorpamplona.amethyst.commons.util.equalImmutableLists import com.vitorpamplona.quartz.utils.Log import com.vitorpamplona.quartz.utils.flattenToSet import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.IO import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch @@ -75,7 +73,7 @@ class ChannelFeedContentState( } fun refreshSuspended() { - checkNotInMainThread() + LocalCache.appHost.assertNotMainThread() isRefreshing.value = true try { @@ -178,7 +176,7 @@ class ChannelFeedContentState( } fun destroy() { - Log.d("Init") { "OnCleared: ${this.javaClass.simpleName}" } + Log.d("Init") { "OnCleared: ${this::class.simpleName}" } bundlerInsert.cancel() bundler.cancel() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedState.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/ChannelFeedState.kt similarity index 93% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedState.kt rename to commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/ChannelFeedState.kt index be96af6803..b3cb58b1e9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/feeds/ChannelFeedState.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/feeds/ChannelFeedState.kt @@ -18,10 +18,9 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.feeds +package com.vitorpamplona.amethyst.commons.feeds import androidx.compose.runtime.Stable -import com.vitorpamplona.amethyst.commons.feeds.LoadedFeedState import com.vitorpamplona.amethyst.commons.model.Channel import kotlinx.coroutines.flow.MutableStateFlow diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableBuzzInviteLink.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableBuzzInviteLink.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableBuzzInviteLink.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableBuzzInviteLink.kt index 7779422d4b..089ff137a3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableBuzzInviteLink.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableBuzzInviteLink.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.components +package com.vitorpamplona.amethyst.commons.ui.components import androidx.compose.foundation.combinedClickable import androidx.compose.material3.MaterialTheme diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableConcordInviteLink.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableConcordInviteLink.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableConcordInviteLink.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableConcordInviteLink.kt index 3212e52163..e18ff60ff8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableConcordInviteLink.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableConcordInviteLink.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.components +package com.vitorpamplona.amethyst.commons.ui.components import androidx.compose.foundation.combinedClickable import androidx.compose.material3.MaterialTheme diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt index beedb404fc..8a48da7f7d 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt @@ -91,3 +91,27 @@ fun ClickableEmail( }, ) } + +/** + * A primary-colored clickable phone number that opens the platform dialer via + * [LocalUriHandler] (`tel:`). Strips a leading `tel:` from the display text. + * [underline] + hover cursor are the Desktop mouse-first affordances. + */ +@Composable +fun ClickablePhone( + number: String, + modifier: Modifier = Modifier, + underline: Boolean = false, +) { + val uriHandler = LocalUriHandler.current + val display = remember(number) { number.removePrefix("tel:") } + Text( + text = display, + color = MaterialTheme.colorScheme.primary, + textDecoration = if (underline) TextDecoration.Underline else null, + modifier = + modifier.pointerHoverIcon(PointerIcon.Hand).clickable { + runCatching { uriHandler.openUri("tel:$display") } + }, + ) +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRelayGroupLink.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableRelayGroupLink.kt similarity index 98% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRelayGroupLink.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableRelayGroupLink.kt index d968ab300b..72a1104bed 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRelayGroupLink.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableRelayGroupLink.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.components +package com.vitorpamplona.amethyst.commons.ui.components import androidx.compose.foundation.combinedClickable import androidx.compose.material3.MaterialTheme diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRelayUrl.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableRelayUrl.kt similarity index 97% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRelayUrl.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableRelayUrl.kt index 303fd67251..60e3668e5c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickableRelayUrl.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableRelayUrl.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.components +package com.vitorpamplona.amethyst.commons.ui.components import androidx.compose.foundation.combinedClickable import androidx.compose.material3.MaterialTheme diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/NewItemsBubble.kt similarity index 63% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/NewItemsBubble.kt index 3eb265a4e7..0d7b070240 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ClickablePhone.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/NewItemsBubble.kt @@ -18,30 +18,15 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.components +package com.vitorpamplona.amethyst.commons.ui.components -import android.content.Context -import android.content.Intent -import android.net.Uri +import androidx.compose.foundation.layout.Box +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalContext -import com.vitorpamplona.amethyst.commons.ui.components.ClickableTextPrimary +import com.vitorpamplona.amethyst.commons.ui.theme.newItemBubbleModifier +/** The small dot that marks a row with unread items. */ @Composable -fun ClickablePhone(phone: String) { - val context = LocalContext.current - - ClickableTextPrimary( - text = phone, - onClick = { context.dial(phone) }, - ) -} - -fun Context.dial(phone: String) { - try { - val intent = Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", phone, null)) - startActivity(intent) - } catch (t: Throwable) { - // TODO: Handle potential exceptions - } +fun NewItemsBubble() { + Box(MaterialTheme.colorScheme.newItemBubbleModifier) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/OutlinedThinPaddingTextField.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/OutlinedThinPaddingTextField.kt similarity index 99% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/OutlinedThinPaddingTextField.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/OutlinedThinPaddingTextField.kt index 3ee7f3cc0a..d7e7a537ec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/OutlinedThinPaddingTextField.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/OutlinedThinPaddingTextField.kt @@ -18,7 +18,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.components +package com.vitorpamplona.amethyst.commons.ui.components import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.interaction.MutableInteractionSource diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/StickToTopOnPrepend.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/StickToTopOnPrepend.kt index 9074a494dd..7ba0fb5eed 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/StickToTopOnPrepend.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/StickToTopOnPrepend.kt @@ -24,10 +24,10 @@ import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.grid.LazyGridState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.runtime.snapshotFlow +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vitorpamplona.amethyst.commons.feeds.FeedContentState import com.vitorpamplona.amethyst.commons.feeds.FeedState import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -59,11 +59,14 @@ import kotlinx.coroutines.flow.map * with an instant (non-animated) scroll so the prepend appears as * in-place growth rather than a visible jump-then-scroll. * - * Commons port of `amethyst/.../WatchScrollToTop.kt` so Desktop and any - * other multiplatform front-end can use the same auto-stick behavior. - * Uses plain `collectAsState` instead of the Android-only - * `collectAsStateWithLifecycle` — equivalent here because the effect's - * lifecycle is already bound to composition via `LaunchedEffect`. + * Most callers should not invoke this directly: `SaveableFeedContentState`, + * `SaveableGridFeedContentState`, and the analogous wrappers in the app's + * `ui/screen/FeedView.kt` already apply auto-stick to every feed they + * own. Invoke the explicit overload only when the listState is + * constructed outside one of those wrappers, or when the key that + * should trigger the snap is not the default `items.list[0].idHex` + * (e.g. notifications, chats, or feeds keyed on something other than a + * Note's hex id). */ @Composable fun StickToTopOnPrepend( @@ -142,7 +145,7 @@ private fun rememberFirstItemIdHex(feedContentState: FeedContentState): String? } } } - val key by flow.collectAsState(initial = null) + val key by flow.collectAsStateWithLifecycle(initialValue = null) return key } diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/WatchScrollToTop.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/WatchScrollToTop.kt new file mode 100644 index 0000000000..5bd267e8f5 --- /dev/null +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/feeds/WatchScrollToTop.kt @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.ui.feeds + +import androidx.compose.foundation.lazy.LazyListState +import androidx.compose.foundation.lazy.grid.LazyGridState +import androidx.compose.foundation.pager.PagerState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.commons.feeds.FeedContentState + +@Composable +fun WatchScrollToTop( + feedContentState: FeedContentState, + listState: LazyListState, +) { + val scrollToTop by feedContentState.scrollToTop.collectAsStateWithLifecycle() + + LaunchedEffect(scrollToTop) { + if (scrollToTop > 0 && feedContentState.scrollToTopPending) { + listState.scrollToItem(index = 0) + feedContentState.sentToTop() + } + } +} + +@Composable +fun WatchScrollToTop( + feedContentState: FeedContentState, + listState: LazyGridState, +) { + val scrollToTop by feedContentState.scrollToTop.collectAsStateWithLifecycle() + + LaunchedEffect(scrollToTop) { + if (scrollToTop > 0 && feedContentState.scrollToTopPending) { + listState.scrollToItem(index = 0) + feedContentState.sentToTop() + } + } +} + +@Composable +fun WatchScrollToTop( + videoFeedContentState: FeedContentState, + pagerState: PagerState, +) { + val scrollToTop by videoFeedContentState.scrollToTop.collectAsStateWithLifecycle() + + LaunchedEffect(scrollToTop) { + if (scrollToTop > 0 && videoFeedContentState.scrollToTopPending) { + pagerState.scrollToPage(page = 0) + videoFeedContentState.sentToTop() + } + } +} diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/ChatHeaderLayout.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/ChatHeaderLayout.kt new file mode 100644 index 0000000000..76fc5b6425 --- /dev/null +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/ChatHeaderLayout.kt @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.ui.layouts + +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.combinedClickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.vitorpamplona.amethyst.commons.ui.theme.DoubleHorzSpacer +import com.vitorpamplona.amethyst.commons.ui.theme.Height4dpModifier +import com.vitorpamplona.amethyst.commons.ui.theme.Size55Modifier + +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun ChatHeaderLayout( + channelPicture: @Composable () -> Unit, + firstRow: @Composable RowScope.() -> Unit, + secondRow: @Composable RowScope.() -> Unit, + onClick: () -> Unit, + onLongClick: (() -> Unit)? = null, +) { + Row( + modifier = + Modifier + .combinedClickable(onClick = onClick, onLongClick = onLongClick) + .padding(10.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + Box(Size55Modifier) { channelPicture() } + + Spacer(modifier = DoubleHorzSpacer) + + Column( + modifier = Modifier.fillMaxWidth(), + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + firstRow() + } + + Spacer(modifier = Height4dpModifier) + + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + secondRow() + } + } + } +} diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/LeftPictureLayout.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/LeftPictureLayout.kt new file mode 100644 index 0000000000..2d7102877c --- /dev/null +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/LeftPictureLayout.kt @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.commons.ui.layouts + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import com.vitorpamplona.amethyst.commons.ui.theme.DoubleHorzSpacer + +@Composable +fun LeftPictureLayout( + onImage: @Composable () -> Unit, + onTitleRow: @Composable RowScope.() -> Unit, + onDescription: @Composable () -> Unit, + onBottomRow: @Composable RowScope.() -> Unit, + imageFraction: Float = 0.25f, +) { + Row(Modifier.aspectRatio(ratio = 1 / imageFraction)) { + Column( + modifier = Modifier.fillMaxWidth(imageFraction).aspectRatio(ratio = 1f), + ) { + onImage() + } + + Spacer(modifier = DoubleHorzSpacer) + + Column( + modifier = Modifier.fillMaxWidth(), + verticalArrangement = Arrangement.SpaceBetween, + ) { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + ) { + onTitleRow() + } + + Row( + modifier = Modifier.fillMaxWidth().weight(1f), + ) { + onDescription() + } + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + ) { + onBottomRow() + } + } + } +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemLayout.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/listItem/SlimListItemLayout.kt similarity index 81% rename from amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemLayout.kt rename to commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/listItem/SlimListItemLayout.kt index ed6f0b1a5d..b7ac7505f8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/layouts/listItem/SlimListItemLayout.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/layouts/listItem/SlimListItemLayout.kt @@ -18,31 +18,22 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.vitorpamplona.amethyst.ui.layouts.listItem +package com.vitorpamplona.amethyst.commons.ui.layouts.listItem -import androidx.annotation.VisibleForTesting -import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.ListItem import androidx.compose.material3.ListItemColors import androidx.compose.material3.ListItemDefaults import androidx.compose.material3.LocalContentColor import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember import androidx.compose.ui.Alignment.Companion.CenterVertically import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.FirstBaseline import androidx.compose.ui.layout.IntrinsicMeasurable import androidx.compose.ui.layout.IntrinsicMeasureScope @@ -55,117 +46,20 @@ import androidx.compose.ui.layout.MultiContentMeasurePolicy import androidx.compose.ui.layout.Placeable import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.offset import androidx.compose.ui.unit.sp -import com.vitorpamplona.amethyst.R -import com.vitorpamplona.amethyst.commons.resources.Res -import com.vitorpamplona.amethyst.commons.resources.profile_banner -import com.vitorpamplona.amethyst.commons.ui.stringRes -import com.vitorpamplona.amethyst.commons.ui.theme.DividerThickness -import com.vitorpamplona.amethyst.commons.ui.theme.Height4dpModifier -import com.vitorpamplona.amethyst.commons.ui.theme.Size55Modifier -import com.vitorpamplona.amethyst.commons.ui.theme.ThemeComparisonColumn -import com.vitorpamplona.amethyst.ui.layouts.ChatHeaderLayout -import com.vitorpamplona.amethyst.ui.layouts.listItem.ListTokens.ListItemContainerElevation -import com.vitorpamplona.amethyst.ui.note.elements.TimeAgo -import com.vitorpamplona.amethyst.ui.painterRes -import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.NewItemsBubble -import com.vitorpamplona.quartz.utils.TimeUtils +import com.vitorpamplona.amethyst.commons.ui.layouts.listItem.ListTokens.ListItemContainerElevation +import kotlin.jvm.JvmInline import kotlin.math.max /** * This is a copy of Material3's ListItemLayout.kt file, with the only change being the padding change from 16.dp to 10.dp */ -private const val PREVIEW_AUTHOR = "This is my author" -private const val PREVIEW_MESSAGE = "This is a message from this person" - -@Composable -@Preview -fun ChannelNamePreview() { - ThemeComparisonColumn { - Column { - ChatHeaderLayout( - channelPicture = { - Image( - painter = painterRes(R.drawable.github, 1), - contentDescription = stringRes(id = Res.string.profile_banner), - contentScale = ContentScale.FillWidth, - ) - }, - firstRow = { - Text(PREVIEW_AUTHOR, Modifier.weight(1f)) - TimeAgo(TimeUtils.now()) - }, - secondRow = { - Text(PREVIEW_MESSAGE, Modifier.weight(1f)) - NewItemsBubble() - }, - onClick = {}, - ) - - HorizontalDivider(thickness = DividerThickness) - - SlimListItem( - headlineContent = { - Row(verticalAlignment = CenterVertically) { - Text(PREVIEW_AUTHOR, Modifier.weight(1f)) - TimeAgo(TimeUtils.now()) - } - }, - supportingContent = { - Row(verticalAlignment = CenterVertically) { - Text(PREVIEW_MESSAGE, Modifier.weight(1f)) - Spacer(modifier = Height4dpModifier) - NewItemsBubble() - } - }, - leadingContent = { - Image( - painter = painterRes(R.drawable.github, 2), - contentDescription = stringRes(id = Res.string.profile_banner), - contentScale = ContentScale.FillWidth, - modifier = Size55Modifier, - ) - }, - ) - - HorizontalDivider(thickness = DividerThickness) - - ListItem( - headlineContent = { - Row(verticalAlignment = CenterVertically) { - Text(PREVIEW_AUTHOR, Modifier.weight(1f)) - TimeAgo(TimeUtils.now()) - } - }, - supportingContent = { - Row(verticalAlignment = CenterVertically) { - Text(PREVIEW_MESSAGE, Modifier.weight(1f)) - Spacer(modifier = Height4dpModifier) - NewItemsBubble() - } - }, - leadingContent = { - Image( - painter = painterRes(R.drawable.github, 2), - contentDescription = stringRes(id = Res.string.profile_banner), - contentScale = ContentScale.FillWidth, - modifier = Size55Modifier, - ) - }, - ) - - HorizontalDivider(thickness = DividerThickness) - } - } -} - @Composable fun SlimListItem( headlineContent: @Composable () -> Unit, @@ -688,22 +582,22 @@ object ListTokens { // Container related defaults // TODO: Make sure these values stay up to date until replaced with tokens. -@VisibleForTesting internal val ListItemVerticalPadding = 8.dp +internal val ListItemVerticalPadding = 8.dp -@VisibleForTesting internal val ListItemThreeLineVerticalPadding = 12.dp +internal val ListItemThreeLineVerticalPadding = 12.dp -@VisibleForTesting internal val ListItemStartPadding = 10.dp +internal val ListItemStartPadding = 10.dp -@VisibleForTesting internal val ListItemEndPadding = 10.dp +internal val ListItemEndPadding = 10.dp // Icon related defaults. // TODO: Make sure these values stay up to date until replaced with tokens. -@VisibleForTesting internal val LeadingContentEndPadding = Modifier.padding(end = 10.dp) +internal val LeadingContentEndPadding = Modifier.padding(end = 10.dp) // Icon related defaults. // TODO: Make sure these values stay up to date until replaced with tokens. -@VisibleForTesting internal val SupportingContentTopPadding = Modifier.padding(top = 2.dp) +internal val SupportingContentTopPadding = Modifier.padding(top = 2.dp) // Trailing related defaults. // TODO: Make sure these values stay up to date until replaced with tokens. -@VisibleForTesting internal val TrailingContentStartPadding = Modifier.padding(start = 10.dp) +internal val TrailingContentStartPadding = Modifier.padding(start = 10.dp) From f1582b391b060e63515799c2d5bf10005d50f6b8 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 21:13:16 +0000 Subject: [PATCH 53/57] docs(commons): record the Tier 4 unlocks, the strings drift fix and the UI stragglers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjQQN9CgWHVtNCSWqnKoqY --- .../2026-08-30-commons-migration-sweep.md | 101 +++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/commons/plans/2026-08-30-commons-migration-sweep.md b/commons/plans/2026-08-30-commons-migration-sweep.md index 20982ddae2..d1a325d81e 100644 --- a/commons/plans/2026-08-30-commons-migration-sweep.md +++ b/commons/plans/2026-08-30-commons-migration-sweep.md @@ -771,11 +771,11 @@ Options, for the maintainer to pick: ### Next work, in recommended order (needs maintainer go-ahead per item) -- **Tier 4 unlocks** (small, mechanical): `NappletProtocolJson` +- **Tier 4 unlocks** — **done 2026-09-26**, see the last section. (Was: small, mechanical: `NappletProtocolJson` `java.util.Base64` → `kotlin.io.encoding.Base64` (frees `NappletIdentityWatch`); `ScheduledPostStore` Jackson+`java.io.File` → kotlinx-serialization+okio (frees `ScheduledPostWorkGate`). - `LargeSoftCache` stays parked (needs a WeakReference expect/actual). + `LargeSoftCache` stays parked (needs a WeakReference expect/actual).) - **Wave 2: LocalCache move-group** — **part A landed (2026-09-19)**, see the section below. Part B (repoint `desktopApp`, delete `DesktopLocalCache.kt`) is the remaining half. @@ -1302,3 +1302,100 @@ through an `ingest` helper that pins what the cache built for the lifetime of the test instance, the way a screen holds the notes it is showing in the app, and keeps the forced GC in the test that failed so the contract is asserted rather than left to the heap. + +## 2026-09-26 — Tier 4 unlocks, the strings drift, and the UI stragglers + +### Tier 4: two jvmAndroid groups promoted to `commonMain` + +- **Napplet wire protocol.** `NappletProtocolJson`, `NappletIdentityWatch` and + `NappletRequestRouter` moved to `commons/commonMain/…/napplet`. The only + pins were `java.util.Base64` and one `System.currentTimeMillis()`. Base64 is + now `kotlin.io.encoding.Base64`, decoding with `PaddingOption.PRESENT_OPTIONAL` + because `java.util.Base64.getDecoder()` accepted unpadded input and applets + may send it. The clock is `TimeUtils.now()`. +- **Scheduled posts.** `ScheduledPostStore` had already dropped Jackson for + kotlinx-serialization; what pinned it was `java.io.File` and a POSIX + `chmod`. It now takes an okio `Path` plus a `FileSystem` (default + `platformFileSystem`), and a `String` constructor so callers need no okio, + the same shape as `FileSystemNip95BlobStore`. The owner-only permission is a + new `expect fun restrictFileToOwner(path, tag)`: + `Files.setPosixFilePermissions` on jvmAndroid, POSIX `chmod(0600)` on iOS. + The temp-file swap is `FileSystem.atomicMove`, which replaces an existing + target on every platform, so the old "rename, else delete and rename again" + fallback went with it. `ScheduledPostWorkGate`, `ScheduledPostPublisher` and + `ScheduledPostNotifier` came along; none had a JVM pin of its own. + +### The strings drift, fixed + +Between the 2026-09-22 move and today, the cordn UI and the backup-conflict +review added **447 keys** to `amethyst/src/main/res` (`cordn_*`, `backup_*`), +taking it from 190 keys back to 597. All 447 moved with +`tools/strings-migrate/migrate.py` (1,131 elements over 57 locales) and the 18 +files that read them were repointed. The non-mechanical sites: + +- `stringRes(context, …)` inside `suspend` senders (`sendAttachment`, + `sendVoiceNote`) → `loadStringRes(…)`. `adminFailureText` became `suspend`; + its only caller is already in `scope.launch`. +- The backup review kept its labels as `@StringRes Int` (`DiffGroup.label`, + `ReviewRow.*Res`, `eventTypeName()`, the `countTiles`/`moneyHero`/`laneItems` + params) → `StringResource` / `PluralStringResource`. +- `rememberPresentation` resolved labels inside `remember { }` through + `LocalResources`. Compose resources have no non-suspend accessor, so the 16 + labels `presentationOf` writes into item text are resolved in composition into + a map, and the map is the `remember` key. +- `androidx.compose.ui.res.pluralStringResource` → the compose-resources one. + +Six moved keys have no reader today (`cordn_backup_restore_title`, +`cordn_coordinators_relays`, `cordn_create_admin_only_me`, +`cordn_create_coordinator`, `cordn_send`, `cordn_voice_play`). They moved +rather than being deleted; dropping them is the feature owner's call. +`pow_notification_sending` stays in Android `res/`: the PoW foreground service +reads it synchronously. + +The rule is now written down in `.claude/CLAUDE.md` ("Strings"), in +`commonsUI/ARCHITECTURE.md`, and in the `android-expert` and +`find-missing-translations` skills: new strings go in `commonsUI` +composeResources, even for Android-only screens. + +### UI stragglers moved to `commonsUI` + +A survey against `main` found that most of "Batch 4" had already landed in +other PRs (`dde228d2`, `1a563cf2`, `8dd409cb`, `1f1b6dab`): the theme +constants (in `commonsUI/…/theme/Shape.kt`, not the `Sizes.kt` this plan +named), the feed shell, the top bars, `M3ActionDialog`, `NoteComposeLayout`, +`RepostLayout` and the toast queue. This round moved what was left that had no +real blocker: + +| Moved | To | Note | +|---|---|---| +| `NewItemsBubble` (from `ChatroomHeaderCompose.kt`) | `commonsUI/…/ui/components` | | +| `ChatHeaderLayout`, `LeftPictureLayout` | `commonsUI/…/ui/layouts` | Their `@Preview`s use app drawables, `TimeAgo` and `TextCount`, so the previews stay app-side in `*Preview.kt` files | +| `listItem/SlimListItemLayout` | `commonsUI/…/ui/layouts/listItem` | Same preview split; `@VisibleForTesting` dropped (no androidx.annotation in commonMain) | +| `WatchScrollToTop` (list/grid/pager overloads) | `commonsUI/…/ui/feeds` | The `CardFeedContentState` overload stays in the app | +| app `StickToTopOnPrepend` | deleted | It was a copy of the commons one. The commons copy now collects with `collectAsStateWithLifecycle`, as the app copy did | +| `ChannelFeedState`, `ChannelFeedContentState` | `commons/commonMain/…/feeds` | `checkNotInMainThread()` → `LocalCache.appHost.assertNotMainThread()`, which Android wires to the same check | +| `ClickableBuzzInviteLink`, `ClickableConcordInviteLink`, `ClickableRelayGroupLink`, `ClickableRelayUrl`, `OutlinedThinPaddingTextField` | `commonsUI/…/ui/components` | | +| app `ClickableEmail`, `ClickablePhone` | deleted | Android now uses the commons ones (`mailto:` / `tel:` through `LocalUriHandler`) instead of `ACTION_SEND` / `ACTION_DIAL` intents. The commons `ClickablePhone` is new. Desktop still renders phone numbers as plain text, on purpose | + +**Still app-side, with the reason:** + +- `AmethystClickableIcon`: 9 lines around an Android debug action; moving it + only pushes `LocalContext` into its two callers. +- `ScreenLayout`: needs `LocalConfiguration` → `LocalWindowInfo`, and the + window-size-class breakpoints inlined. +- `SlidingCarousel`: needs `animatedViewerChromeInset` hoisted out of the + viewer-chrome file. +- `AudioWaveformReadOnly`: needs two enums from the Android-only waveform + library replaced. +- `FileAttachmentCard`: needs `extractFilename` hoisted. +- `PdfFetcher`: needs the disk cache injected. +- `ClickablePhone` / `ClickableEmail` on Desktop: deliberately unchanged. +- **`AmethystTheme` split** (the pure scheme/typography half to commonsUI; the + `Amethyst.instance` overload and the system-bar `SideEffect` stay). +- **`TimeAgo` split**: the labels, `NowProvider` and the style enum are pure; + the absolute and short formatters need expect/actual over + `android.text.format`. +- **Palette unification**: Desktop's `PlatformColorScheme` and the app palette + differ in primary, secondary, surfaces and outlines, and every shared token + (`placeholderText`, `chatBubbleThem`, …) is frozen from the app palette. This + is a design decision, not a move. From 3d03c82970d3c932c9952d5518b3e4a7bb7b8831 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 22:03:54 +0000 Subject: [PATCH 54/57] fix: audit follow-ups for the commons move - Compose string whitespace, backup labels, store edge cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The one real regression predates this branch: Compose resources draw a value's XML whitespace verbatim, where aapt collapsed it. Values wrapped over indented lines rendered with a leading line break and eight spaces, which turns the account-backup tips' markdown heading into a code block, and Crowdin's stray translator edge spaces (" miejsca zniknęły", Hindi's " दि॰" suffix) showed up. fix_escapes.py now applies aapt's rule to line-break/tab runs and trims an edge space a translation has but its source lacks. The Crowdin workflow already runs it after each sync, and compose_escaping_check.py now fails on raw line breaks. 598 values across 54 files repaired. Also: - rememberPresentation resolves only the labels its diff type writes, instead of all 16 on every recomposition. A test pins the list against presentationOf. - ScheduledPostStore: a failed stat is "no file" (okio posix throws on EACCES where File.exists() did not), symlinked stores still count, no chmod against an injected non-system FileSystem, the cleanup log keeps its throwable. - ClickableEmail percent-encodes '%' in the mailto: URI. - Dropped a misleading WatchScrollToTop import, a stray blank line, and a stale doc path; noted the Base64 pad-bit difference beside the decoder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjQQN9CgWHVtNCSWqnKoqY --- .claude/hooks/compose_escaping_check.py | 14 +++ .../backups/BackupConflictPresentation.kt | 29 +++++-- .../chats/cordnGroup/CordnGroupInfoScreen.kt | 1 - .../notifications/NotificationScreen.kt | 1 - .../backups/BackupPresentationLabelsTest.kt | 60 +++++++++++++ .../2026-08-30-commons-migration-sweep.md | 33 +++++++ .../napplet/protocol/NappletProtocolJson.kt | 2 + .../scheduledposts/ScheduledPostStore.kt | 41 +++++++-- .../commons/util/OwnerOnlyFile.ios.kt | 3 +- .../commons/util/OwnerOnlyFile.jvmAndroid.kt | 2 +- .../values-ar-rSA/strings.xml | 62 ++++---------- .../values-bn-rBD/strings.xml | 37 ++------ .../composeResources/values-cs/strings.xml | 34 ++------ .../values-de-rDE/strings.xml | 36 ++------ .../composeResources/values-de/strings.xml | 44 +++------- .../values-el-rGR/strings.xml | 40 ++------- .../values-eo-rUY/strings.xml | 39 ++------- .../composeResources/values-eo/strings.xml | 42 ++------- .../values-es-rES/strings.xml | 39 ++------- .../values-es-rMX/strings.xml | 37 ++------ .../values-es-rUS/strings.xml | 37 ++------ .../composeResources/values-es/strings.xml | 39 ++------- .../values-fa-rIR/strings.xml | 60 ++++--------- .../composeResources/values-fa/strings.xml | 53 +++--------- .../values-fi-rFI/strings.xml | 36 ++------ .../values-fr-rCA/strings.xml | 31 ++----- .../values-fr-rFR/strings.xml | 31 ++----- .../composeResources/values-fr/strings.xml | 31 ++----- .../values-hi-rIN/strings.xml | 43 +++------- .../values-hu-rHU/strings.xml | 48 +++-------- .../values-in-rID/strings.xml | 46 +++------- .../composeResources/values-in/strings.xml | 42 ++------- .../values-it-rIT/strings.xml | 37 ++------ .../values-ja-rJP/strings.xml | 39 ++------- .../composeResources/values-ja/strings.xml | 42 ++------- .../values-ko-rKR/strings.xml | 37 ++------ .../values-lv-rLV/strings.xml | 37 ++------ .../composeResources/values-nl/strings.xml | 17 +--- .../values-pl-rPL/strings.xml | 38 ++------- .../values-pt-rBR/strings.xml | 40 +++------ .../values-pt-rPT/strings.xml | 40 +++------ .../values-ru-rRU/strings.xml | 39 ++------- .../values-ru-rUA/strings.xml | 37 ++------ .../composeResources/values-ru/strings.xml | 41 ++------- .../values-sl-rSI/strings.xml | 85 ++++++------------- .../values-sr-rSP/strings.xml | 37 ++------ .../values-sv-rSE/strings.xml | 38 ++------- .../composeResources/values-sw/strings.xml | 37 ++------ .../values-ta-rIN/strings.xml | 49 +++-------- .../composeResources/values-ta/strings.xml | 52 +++--------- .../values-th-rTH/strings.xml | 26 ++---- .../composeResources/values-th/strings.xml | 26 ++---- .../values-tr-rTR/strings.xml | 39 ++------- .../composeResources/values-tr/strings.xml | 42 ++------- .../values-uk-rUA/strings.xml | 39 ++------- .../composeResources/values-uk/strings.xml | 42 ++------- .../values-uz-rUZ/strings.xml | 37 ++------ .../values-vi-rVN/strings.xml | 37 ++------ .../values-zh-rCN/strings.xml | 39 ++------- .../values-zh-rHK/strings.xml | 41 ++------- .../values-zh-rSG/strings.xml | 39 ++------- .../values-zh-rTW/strings.xml | 31 ++----- .../composeResources/values-zh/strings.xml | 39 ++------- .../composeResources/values/strings.xml | 40 ++------- .../commons/ui/components/ClickableLinks.kt | 3 +- .../plans/2026-06-21-napplet-desktop-host.md | 2 +- tools/strings-migrate/fix_escapes.py | 57 ++++++++++++- 67 files changed, 699 insertions(+), 1715 deletions(-) create mode 100644 amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupPresentationLabelsTest.kt diff --git a/.claude/hooks/compose_escaping_check.py b/.claude/hooks/compose_escaping_check.py index cd9b054eef..b5721481ae 100755 --- a/.claude/hooks/compose_escaping_check.py +++ b/.claude/hooks/compose_escaping_check.py @@ -27,6 +27,9 @@ Repair with: idempotent, quote-unwrapping is not, and a second unwrap strips the real display quotes from values like `import_follows_tips`. +Raw line breaks and tabs inside a value are the whitespace half of the same +mismatch: aapt collapsed them, Compose renders them (the same repair fixes them). + Only the Compose catalog is scanned. In an Android res tree the same escaping is correct and must be left alone. """ @@ -41,6 +44,10 @@ CATALOG = "*/src/*/composeResources/values*/strings.xml" # Compose resolves those itself. ANDROID_ESCAPE = re.compile(r"(?<!\\)\\(['\"?@])") TOOLS_ATTR = re.compile(r'tools:[\w.-]+="') +# A value whose text holds a raw line break or tab. aapt collapsed that XML layout to +# one space; Compose draws it, and a markdown value indented by it becomes a code block. +STRING_TEXT = re.compile(r"<(string|item)\b[^>]*>(.*?)</\1>", re.S) +LAYOUT_WS = re.compile(r"[\r\n\t]") def find_violations(root: Path): @@ -52,6 +59,13 @@ def find_violations(root: Path): n = len(TOOLS_ATTR.findall(text)) if n: found[path]["tools: attribute"] += n + n = sum( + 1 + for m in STRING_TEXT.finditer(text) + if "<![CDATA[" not in m.group(2) and LAYOUT_WS.search(m.group(2)) + ) + if n: + found[path]["raw line break/tab in a value"] += n return found diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt index ff28dfa6c3..0b4bb8af80 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupConflictPresentation.kt @@ -332,15 +332,23 @@ private fun arrow( */ @Composable fun rememberPresentation(diff: EventDiff): DiffPresentation { - // Compose resources resolve only in composition (or suspended), so the few labels - // [presentationOf] writes into item text are resolved here and handed in. The map - // compares by value, so a recomposition with the same locale keeps the cached result. - val labels = PRESENTATION_LABELS.associateWith { stringRes(it) } + // Compose resources resolve only in composition (or suspended), so the labels + // [presentationOf] writes into item text are resolved here and handed in. Only the + // diff types that write labels get any, so the rest pay for no resource reads. The + // map compares by value: a recomposition with the same locale keeps the cached result. + val labels = labelsWrittenBy(diff).associateWith { stringRes(it) } return remember(diff, labels) { presentationOf(diff) { labels.getValue(it) } } } -/** Every label [presentationOf] resolves through its `str` parameter. */ -private val PRESENTATION_LABELS = +/** Every label [presentationOf] resolves through its `str` parameter for [diff]. */ +internal fun labelsWrittenBy(diff: EventDiff): List<StringResource> = + when (diff) { + is MetadataDiff -> PROFILE_FIELD_LABELS + is AdvertisedRelayListDiff -> RELAY_MARKER_LABELS + else -> emptyList() + } + +private val PROFILE_FIELD_LABELS = listOf( Res.string.backup_profile_field_name, Res.string.backup_profile_field_display_name, @@ -355,12 +363,19 @@ private val PRESENTATION_LABELS = Res.string.backup_profile_field_pronouns, Res.string.backup_profile_field_birthday, Res.string.backup_profile_field_bot, + ) + +private val RELAY_MARKER_LABELS = + listOf( Res.string.backup_conflict_relay_read_write, Res.string.backup_conflict_relay_read_only, Res.string.backup_conflict_relay_write_only, ) -/** Turns each event's own diff into typed, labelled groups. [str] resolves the labels. */ +/** + * Turns each event's own diff into typed, labelled groups. [str] resolves the labels; a + * label it asks for must be in [labelsWrittenBy] for that diff type. + */ fun presentationOf( diff: EventDiff, str: (StringResource) -> String, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt index b08e44b341..e134442396 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/cordnGroup/CordnGroupInfoScreen.kt @@ -283,7 +283,6 @@ private fun CordnGroupInfo( * roster, and a rename stayed the old name. The runtime's own methods pair * each commit with that refresh. */ - fun runAdmin( who: String? = null, block: suspend (CordnRuntime) -> Unit, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt index 208c12bb85..cd772a90de 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/NotificationScreen.kt @@ -40,7 +40,6 @@ import com.vitorpamplona.amethyst.commons.resources.notification_tab_following import com.vitorpamplona.amethyst.commons.ui.feeds.PagerStateKeys import com.vitorpamplona.amethyst.commons.ui.feeds.RefresheableBox import com.vitorpamplona.amethyst.commons.ui.feeds.ScrollStateKeys -import com.vitorpamplona.amethyst.commons.ui.feeds.WatchScrollToTop import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverLazyListState import com.vitorpamplona.amethyst.commons.ui.feeds.rememberForeverPagerState import com.vitorpamplona.amethyst.commons.ui.navigation.navs.INav diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupPresentationLabelsTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupPresentationLabelsTest.kt new file mode 100644 index 0000000000..bd28de71ee --- /dev/null +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/backups/BackupPresentationLabelsTest.kt @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.ui.screen.loggedIn.backups + +import com.vitorpamplona.quartz.nip01Core.diff.EventDiff +import com.vitorpamplona.quartz.nip01Core.diff.ListDiff +import com.vitorpamplona.quartz.nip01Core.metadata.MetadataDiff +import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListDiff +import org.jetbrains.compose.resources.StringResource +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * rememberPresentation resolves labels in composition and hands presentationOf a lookup + * over exactly [labelsWrittenBy]; a label presentationOf asks for that is not in that list + * crashes the review screen. presentationOf asks for every label of a diff type + * regardless of which fields changed, so an empty diff of each type exercises them all. + */ +class BackupPresentationLabelsTest { + private fun <T> empty() = ListDiff<T>(emptyList(), emptyList(), emptyList()) + + private fun asked(diff: EventDiff): Set<StringResource> { + val asked = mutableSetOf<StringResource>() + presentationOf(diff) { + asked.add(it) + "" + } + return asked + } + + @Test + fun metadataLabelsAreAllProvided() { + val diff = MetadataDiff(null, null, null, null, null, null, null, null, null, null, null, null, null, empty(), empty()) + assertEquals(labelsWrittenBy(diff).toSet(), asked(diff)) + } + + @Test + fun relayListLabelsAreAllProvided() { + val diff = AdvertisedRelayListDiff(empty()) + assertEquals(labelsWrittenBy(diff).toSet(), asked(diff)) + } +} diff --git a/commons/plans/2026-08-30-commons-migration-sweep.md b/commons/plans/2026-08-30-commons-migration-sweep.md index d1a325d81e..46de62e8af 100644 --- a/commons/plans/2026-08-30-commons-migration-sweep.md +++ b/commons/plans/2026-08-30-commons-migration-sweep.md @@ -1399,3 +1399,36 @@ real blocker: differ in primary, secondary, surfaces and outlines, and every shared token (`placeholderText`, `chatBubbleThem`, …) is frozen from the app palette. This is a design decision, not a move. + +### Audit of the 2026-09-26 round + +The four commits were reviewed file by file against the originals. They had no +functional bugs. The follow-ups: + +- **Compose resources keep XML whitespace; Android didn't.** This is older than this + round (it dates back to the first string moves), and it is the one real + regression. aapt collapses every whitespace run in an unquoted value and trims + the ends; Compose draws the XML text verbatim. So the values wrapped over + indented lines (`account_backup_tips2_md`, `push_server_install_app_description`, + `couldnt_find_nwc_wallets_description`, the chat explainers, and 349 translated + values) rendered with a leading line break and eight spaces. In the `_md` strings + CommonMark turns that into a code block. Crowdin also exports a translator's stray + edge space, which aapt used to drop, for example ` miejsca zniknęły` and Hindi's + ` दि॰` time suffix. `fix_escapes.py` now applies aapt's rule to runs holding a line + break or tab. In a translation it also trims an edge space its source string lacks, + which keeps deliberate ones like `" and "`. The Crowdin workflow already runs it + after every sync, and `compose_escaping_check.py` now fails on raw line breaks, so + a sync can't bring it back. 598 values across 54 files were repaired. +- `rememberPresentation` read all 16 backup labels on every recomposition, even for + diff types that write none. It now reads only the ones its diff type uses, and + `BackupPresentationLabelsTest` fails if `presentationOf` asks for a label that list + lacks. +- `ScheduledPostStore`: a failed stat now counts as "no file" rather than throwing + (okio's posix metadata throws on EACCES where `File.exists()` returned false). + Symlinked store files still count as present. The chmod is skipped for an injected + non-system `FileSystem`, and the cleanup log keeps its throwable. +- `ClickableEmail` percent-encodes `%` in the `mailto:` URI (RFC 6068). +- Left as-is, by design: Kotlin's Base64 rejects non-zero pad bits (`"SGl="`) that + Java ignored, which no browser encoder produces. `%1$d` arguments now render ASCII + digits in every locale, the same as every other migrated string. + `ChannelFeedContentState` reaches `LocalCache.appHost` for its main-thread check. diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt index af171f6188..c72f1bf825 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/napplet/protocol/NappletProtocolJson.kt @@ -60,6 +60,8 @@ object NappletProtocolJson { private val json = Json { ignoreUnknownKeys = true } // Accepts unpadded input, as java.util.Base64's decoder did before this moved to commonMain. + // One difference remains: non-zero pad bits ("SGl=") are rejected where Java ignored them. + // Browsers' btoa/readAsDataURL never produce those, so only a hand-crafted payload hits it. private val lenientBase64 = Base64.withPadding(Base64.PaddingOption.PRESENT_OPTIONAL) /** The `type` discriminant of a request envelope, used to build the matching `.result` type. */ diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt index ec34e46725..c3eb84304f 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/scheduledposts/ScheduledPostStore.kt @@ -377,7 +377,7 @@ class ScheduledPostStore( // Secure a pre-existing file up front (an older build may have left it at the // 0644 umask default) so it's owner-only even if nothing mutates the store // this session. - if (fileSystem.exists(storageFile)) restrictFileToOwner(storageFile, TAG) + if (storeFileExists()) restrictToOwner(storageFile) var dirty = purgeStale(nowSec()) // Recover claims stranded by a crash-mid-publish so they aren't lost forever. if (recoverStuckClaimsLocked(nowSec())) dirty = true @@ -426,10 +426,12 @@ class ScheduledPostStore( try { storageFile.parent?.let { fileSystem.createDirectories(it) } fileSystem.write(tmp) { writeUtf8(json.encodeToString(ScheduledPostFile(version = 1, posts = snapshot))) } - // Restrict to owner-only BEFORE the rename so the store is never briefly + // Restrict to owner-only BEFORE the rename, so the store file itself is never // world-readable. It holds pre-signed events + the account's pubkey, which - // must not leak to other local users on a shared machine. - restrictFileToOwner(tmp, TAG) + // must not leak to other local users on a shared machine. (The tmp file is + // created at the umask default and narrowed right after its write; the + // directory around it is owner-only on every host that uses this store.) + restrictToOwner(tmp) // Replaces an existing target, including on Windows, where a plain rename // onto an existing file fails. fileSystem.atomicMove(tmp, storageFile) @@ -437,13 +439,38 @@ class ScheduledPostStore( Log.e(TAG, "Failed to persist scheduled posts to $storageFile", e) try { fileSystem.delete(tmp) - } catch (e: Exception) { - Log.w(TAG) { "Failed to clean up temp file $tmp after persist exception: ${e.message}" } + } catch (cleanupError: Exception) { + Log.w(TAG, "Failed to clean up temp file $tmp after persist exception", cleanupError) } } } - private fun hasContent(): Boolean = (fileSystem.metadataOrNull(storageFile)?.size ?: 0L) > 0L + /** + * Permissions are a property of the real disk, so a caller that injects another + * [FileSystem] (an in-memory fake) gets no chmod aimed at a same-named real path. + */ + private fun restrictToOwner(path: Path) { + if (fileSystem === platformFileSystem) restrictFileToOwner(path, TAG) + } + + /** + * The store file's metadata, or null when there is none. A directory is not a store + * file. A symlink counts: okio's metadata does not follow links, so its size is the + * link's, and reading it (which does follow) decides whether there is anything in it. + * A stat that fails (EACCES on iOS, where File.exists() used to answer false) is "no + * file" rather than an exception out of the store. + */ + private fun storeFileMetadata() = + try { + fileSystem.metadataOrNull(storageFile)?.takeIf { it.isRegularFile || it.symlinkTarget != null } + } catch (e: Exception) { + Log.w(TAG, "Could not stat $storageFile", e) + null + } + + private fun storeFileExists(): Boolean = storeFileMetadata() != null + + private fun hasContent(): Boolean = (storeFileMetadata()?.size ?: 0L) > 0L private fun readText(): String = fileSystem.read(storageFile) { readUtf8() } diff --git a/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt b/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt index 42b3c0c516..ebd18c664a 100644 --- a/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt +++ b/commons/src/iosMain/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.ios.kt @@ -35,6 +35,7 @@ actual fun restrictFileToOwner( tag: String, ) { if (chmod(path.toString(), (S_IRUSR or S_IWUSR).convert()) != 0) { - Log.w(tag) { "Could not restrict permissions on $path: errno $errno" } + val error = errno + Log.w(tag) { "Could not restrict permissions on $path: errno $error" } } } diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt index 5d4d16c3b7..cbcfe50038 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/util/OwnerOnlyFile.jvmAndroid.kt @@ -37,6 +37,6 @@ actual fun restrictFileToOwner( } catch (_: UnsupportedOperationException) { // Windows: no POSIX permissions; the user profile's NTFS ACLs apply instead. } catch (e: Exception) { - Log.w(tag) { "Could not restrict permissions on $path: ${e.message}" } + Log.w(tag, "Could not restrict permissions on $path", e) } } diff --git a/commonsUI/src/commonMain/composeResources/values-ar-rSA/strings.xml b/commonsUI/src/commonMain/composeResources/values-ar-rSA/strings.xml index c93820fa84..c9b3131eff 100644 --- a/commonsUI/src/commonMain/composeResources/values-ar-rSA/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ar-rSA/strings.xml @@ -234,7 +234,7 @@ <string name="copy_user_id">نسخ معرف المستخدم</string> <string name="unblock_user">إلغاء حظر عن مستخدم</string> <string name="user_is_blocked_hidden">هذا المستخدم محظور/مكتوم. منشوراته مخفية.</string> - <string name="npub_hex_username">npub, hex, username </string> + <string name="npub_hex_username">npub, hex, username</string> <string name="clear">نظف</string> <string name="app_logo">شعار التطبيق</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex private key</string> @@ -282,15 +282,8 @@ <string name="mark_all_known_as_read">ضع علامة على جميع الرسائل/الاشعارات المعروفة كمقروء</string> <string name="mark_all_new_as_read">تعيين الجديد كمقروء</string> <string name="mark_all_as_read">تعيين الكل كمقروء</string> - <string name="account_backup_tips2_md"> ## النصائح الرئيسية للنسخ الاحتياطي والسلامة - \n\n- يتم تأمين حسابك بمفتاح سري. المفتاح السري هو سلسلة عشوائية طويلة تبدأ بـ **nsec1**. أي شخص لديه مفتاحك السري يمكنه نشر المحتوى باستخدام هويتك. - \n\n- لا تقم بوضع مفتاحك السري في أي موقع أو برنامج لا تثق به. - \n- مطوري Amethyst لن يطلبوا منك **أبدا** المفتاح السري الخاص بك. - \n- حافظ على نسخة احتياطية آمنة لمفتاحك السري لاسترداد الحساب. نوصي باستخدام برنامج لادارة كلمات المرور. - </string> - <string name="account_backup_tips3_md"> للحصول على أمان إضافي، يمكنك تشفير مفتاحك الخاص بكلمة مرور. يبدأ هذا المفتاح المشفر بـ **ncryptsec1** ولا يمكن استخدامه دون كلمة المرور الخاصة بك. - \n\nإذا فقدت كلمة المرور، لن تتمكن من استرداد مفتاحك الخاص. - </string> + <string name="account_backup_tips2_md">## النصائح الرئيسية للنسخ الاحتياطي والسلامة \n\n- يتم تأمين حسابك بمفتاح سري. المفتاح السري هو سلسلة عشوائية طويلة تبدأ بـ **nsec1**. أي شخص لديه مفتاحك السري يمكنه نشر المحتوى باستخدام هويتك. \n\n- لا تقم بوضع مفتاحك السري في أي موقع أو برنامج لا تثق به. \n- مطوري Amethyst لن يطلبوا منك **أبدا** المفتاح السري الخاص بك. \n- حافظ على نسخة احتياطية آمنة لمفتاحك السري لاسترداد الحساب. نوصي باستخدام برنامج لادارة كلمات المرور.</string> + <string name="account_backup_tips3_md">للحصول على أمان إضافي، يمكنك تشفير مفتاحك الخاص بكلمة مرور. يبدأ هذا المفتاح المشفر بـ **ncryptsec1** ولا يمكن استخدامه دون كلمة المرور الخاصة بك. \n\nإذا فقدت كلمة المرور، لن تتمكن من استرداد مفتاحك الخاص.</string> <string name="encrypt_and_copy_my_secret_key">تشفير و نسخ المفتاح الخاص</string> <string name="badge_award_image_for">صورة شارة مكافئة ل %1$s</string> <string name="badge_award_image">"صورة منح الشارة</string> @@ -311,7 +304,7 @@ <string name="quick_action_request_deletion_gallery_alert_body_v2">إزالة هذه الوسائط من معرضك.</string> <string name="quick_action_request_deletion_alert_title">طلب حذفها</string> <string name="quick_action_request_deletion_alert_body">سيطلب Amethyst حذف ملاحظتك من المرحلات المتصل بها حاليا، لا يوجد ضمان لحذفها من هذه المرحلات أو من المرحلات الأخرى التي ربما حفظت فيها.</string> - <string name="quick_action_block_dialog_btn">حظر </string> + <string name="quick_action_block_dialog_btn">حظر</string> <string name="quick_action_delete_dialog_btn">حذف</string> <string name="quick_action_block">حظر</string> <string name="quick_action_report">التبليغ</string> @@ -693,8 +686,7 @@ <string name="add_caption">إضافة شرح توضيحي</string> <string name="add_caption_example">صديقي المميز</string> <string name="content_description">وصف المحتوى/المحتويات</string> - <string name="content_description_example">A blue boat in a white sandy beach at sunset -(قارب أزرق في شاطئ رملي أبيض عند غروب الشمس)</string> + <string name="content_description_example">A blue boat in a white sandy beach at sunset (قارب أزرق في شاطئ رملي أبيض عند غروب الشمس)</string> <string name="ai_suggested_alt_text_hint">اقتراح من الذكاء الاصطناعي، يمكنك تعديله</string> <string name="ai_suggested_alt_text_dismiss">رفض اقتراح الذكاء الاصطناعي</string> <string name="zap_type">نوع الزاب</string> @@ -847,7 +839,7 @@ <string name="relay_filter_since">منذ %1$s</string> <string name="relay_filter_until">حتى %1$s</string> <string name="relay_filter_limit">الحد %1$d</string> - <string name="minimum_prefix">الحد الأدنى لل prefix </string> + <string name="minimum_prefix">الحد الأدنى لل prefix</string> <string name="maximum_event_tags">الحد الأقصى لوسوم الحدث</string> <string name="max_content_length">الحد الأقصى لطول المحتوى</string> <string name="discards_older_than">تُهمَل أقدم من</string> @@ -886,10 +878,8 @@ <string name="followed_tags">العلامات المُتابعة</string> <string name="discover_follows_explainer">هذه قوائم بالمستخدمين التي توصي بها للآخرين. يُسمح فقط بالمستخدمين العامين.</string> <string name="community_approved_posts">المنشورات الموافق عليها</string> - <string name="groups_no_descriptor">هذه المجموعة ليس لديها وصف أو قواعد. - تحدث إلى المالك لإضافة مستخدم جديد</string> - <string name="community_no_descriptor">هذا المجتمع ليس لديه وصف أو قواعد. - تحدث إلى المالك لإضافة مستخدم جديد</string> + <string name="groups_no_descriptor">هذه المجموعة ليس لديها وصف أو قواعد. تحدث إلى المالك لإضافة مستخدم جديد</string> + <string name="community_no_descriptor">هذا المجتمع ليس لديه وصف أو قواعد. تحدث إلى المالك لإضافة مستخدم جديد</string> <string name="user_preferences">تفضيلات المستخدم</string> <string name="settings_search_placeholder">البحث في الإعدادات</string> <string name="settings_search_no_results">لا توجد إعدادات لـ "%1$s"</string> @@ -982,9 +972,7 @@ <string name="push_server_none_explainer">تعطيل الإشعارات</string> <string name="push_server_uses_app_explainer">يتم استخدام هذا التطبيق: %1$s</string> <string name="push_server_install_app">إعدادات الإشعارات</string> - <string name="push_server_install_app_description">لاستخدام الإشعارات حمل أي تطبيق يدعم ال [Unified Push](https://unifiedpush.org/) -مثل [Ntfy](https://ntfy.sh/). -بعد تثبيتك التطبيق قم باختياره من الإعدادات</string> + <string name="push_server_install_app_description">لاستخدام الإشعارات حمل أي تطبيق يدعم ال [Unified Push](https://unifiedpush.org/) مثل [Ntfy](https://ntfy.sh/). بعد تثبيتك التطبيق قم باختياره من الإعدادات</string> <string name="thread_title">الخيط</string> <string name="send_the_seller_a_message">أرسل رسالة إلى البائع</string> <string name="hi_there_is_this_still_available">مرحبًا، هل هذا لا يزال متاحًا؟</string> @@ -1876,7 +1864,7 @@ <string name="biometric_authentication_failed">فشلت المصادقة</string> <string name="biometric_authentication_failed_explainer">فشل التحقق البيومتري في مصادقة مالك هذا الهاتف</string> <string name="biometric_authentication_failed_explainer_with_error">فشل التحقق البيومتري في مصادقة مالك هذا الهاتف. الخطأ: %1$s</string> - <string name="block_only">حظر </string> + <string name="block_only">حظر</string> <string name="blocked_section_explainer">لن يتصل Amethyst أبدًا بهذه الـ relays</string> <string name="blocked_users">المستخدمين المحظورين</string> <string name="bookmark_list_creation_screen_title">قائمة إشارات مرجعية جديدة</string> @@ -1986,8 +1974,7 @@ <string name="cashu_settings_delete_confirm_body">نشر طلب حذف لتوصية kind:38000 الخاصة بك لـ %1$s. ستحذفها الـ relays التي تحترم NIP-09.</string> <string name="cashu_settings_restore_result">تم استرداد %1$s sats عبر %2$s أدلة.</string> <string name="cashu_successful_redemption">تم استلام Cashu</string> - <string name="cashu_successful_redemption_explainer">%1$s sats أرسلت الى محفظتك -(الرسوم: sats %2$s ) </string> + <string name="cashu_successful_redemption_explainer">%1$s sats أرسلت الى محفظتك (الرسوم: sats %2$s )</string> <plurals name="cashu_untrusted_mint_title"> <item quantity="zero">لا أموال محتجزة في mint غير مستخدم</item> <item quantity="one">أموال محتجزة في %1$d mint لا تستخدمه</item> @@ -2060,15 +2047,7 @@ <string name="could_not_fetch_invoice_from_details">تعذّر جلب الفاتورة من %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">تعذّر فتح الملف المضغوط</string> <string name="couldnt_find_nwc_wallets">لم يتم العثور على المحفظة</string> - <string name="couldnt_find_nwc_wallets_description">لم يتمكن Amethyst من العثور على أي تطبيقات محافظ تدعم Nostr Wallet Connect (NWC). -\n\nما يمكنك فعله: -\n\t1. التحقق من دعم NWC: تأكد من أن تطبيق محفظتك المفضل متوافق مع Nostr Wallet Connect. -\n\t2. إنشاء اتصال: انتقل إلى تطبيق محفظتك وأنشئ اتصال NWC جديدًا. -\n\t3. الربط بـ Amethyst: عادةً ما تتيح محفظتك ثلاثة خيارات: -\n\t\t3.1 ربط تلقائي: زر لفتح Amethyst والاتصال به تلقائيًا. إذا كان الأمر كذلك، اضغط على الزر، وافتح Amethyst واضغط على حفظ في الشاشة الجديدة. -\n\t\t3.2 ربط يدوي: عنوان URI للاتصال يمكنك نسخه والضغط على أيقونة اللصق في هذه الشاشة لإدخاله مباشرةً. -\n\t\t3.3 رمز QR: تنشئ المحفظة رمز QR يمكنك قراءته من زر رمز QR في هذه الشاشة. - </string> + <string name="couldnt_find_nwc_wallets_description">لم يتمكن Amethyst من العثور على أي تطبيقات محافظ تدعم Nostr Wallet Connect (NWC). \n\nما يمكنك فعله: \n\t1. التحقق من دعم NWC: تأكد من أن تطبيق محفظتك المفضل متوافق مع Nostr Wallet Connect. \n\t2. إنشاء اتصال: انتقل إلى تطبيق محفظتك وأنشئ اتصال NWC جديدًا. \n\t3. الربط بـ Amethyst: عادةً ما تتيح محفظتك ثلاثة خيارات: \n\t\t3.1 ربط تلقائي: زر لفتح Amethyst والاتصال به تلقائيًا. إذا كان الأمر كذلك، اضغط على الزر، وافتح Amethyst واضغط على حفظ في الشاشة الجديدة. \n\t\t3.2 ربط يدوي: عنوان URI للاتصال يمكنك نسخه والضغط على أيقونة اللصق في هذه الشاشة لإدخاله مباشرةً. \n\t\t3.3 رمز QR: تنشئ المحفظة رمز QR يمكنك قراءته من زر رمز QR في هذه الشاشة.</string> <string name="create">إنشاء</string> <string name="d">يوم</string> <string name="danger_zone">منطقة الخطر</string> @@ -2451,7 +2430,7 @@ <string name="login_with_a_private_key_to_be_able_to_send_zaps">قم بتسجيل الدخول باستخدام مفتاح خاص لتتمكن من إرسال Zaps</string> <string name="login_with_a_private_key_to_be_able_to_show_word">قم بتسجيل الدخول باستخدام مفتاحك السري لتتمكن من إظهار الكلمة أو الجملة</string> <string name="login_with_a_private_key_to_be_able_to_sign_events">أنت تستخدم مفتاحًا عامًا وهو للقراءة فقط. سجّل الدخول بمفتاح خاص لتتمكن من توقيع الأحداث</string> - <string name="login_with_a_private_key_to_be_able_to_unfollow">قم بتسجيل الدخول بمفتاحك الخاص للتتمكن من إلغاء متابعة المستخدمين </string> + <string name="login_with_a_private_key_to_be_able_to_unfollow">قم بتسجيل الدخول بمفتاحك الخاص للتتمكن من إلغاء متابعة المستخدمين</string> <string name="login_with_a_private_key_to_be_able_to_upload">أنت تستخدم مفتاحًا عامًا وهو للقراءة فقط. سجّل الدخول بمفتاح خاص لتتمكن من الرفع</string> <string name="login_with_a_private_key_to_like_posts">تسجيل الدخول باستخدام مفتاح خاص لإبداء الإعجاب بالمنشورات</string> <string name="longs">مقاطع فيديو</string> @@ -2786,8 +2765,7 @@ <string name="preview_card_image_for">معاينة صورة البطاقة لـ %1$s</string> <string name="privacy_options">خيارات الخصوصية</string> <string name="privacy_policy">سياسة الخصوصية</string> - <string name="private_conversation_notification"><استحالة فك تشفير الرسالة الخاصة> -\n\n أنت الآن في محادثة خاصة/مشفرة بين %1$s و %2$s .</string> + <string name="private_conversation_notification"><استحالة فك تشفير الرسالة الخاصة> \n\n أنت الآن في محادثة خاصة/مشفرة بين %1$s و %2$s .</string> <string name="private_inbox_section_explainer">أدخل ما بين 1 و3 relays لتكون صندوقًا واردًا خاصًا. سيستخدم الآخرون هذه الـ relays لإرسال رسائل مباشرة إليك. يجب أن تقبل DM Inbox relays أي رسالة من أي شخص، لكن تسمح لك وحدك بتنزيلها. خيارات جيدة:\n - inbox.nostr.wine (مدفوع)\n - auth.nostr1.com (مجاني)\n - you.nostr1.com (relays شخصية - مدفوعة)</string> <string name="private_inbox_section_explainer_profile">المستخدم يستقبل الرسائل المباشرة على هذه الـ relays</string> <string name="private_message">رسالة خاصة</string> @@ -2807,11 +2785,8 @@ <string name="propose_an_edit">اقتراح تعديل</string> <string name="proxy_section_explainer">الـ relays التجميعية التي يجب أن يستخدمها التطبيق لتنزيل تغذياتك منها، مثل filter.nostr.wine. هذا يستبدل نموذج outbox وسيجعل التطبيق يتصل فقط بالـ relays الموجودة في قوائمك.</string> <string name="public_chat">الدردشة العامة</string> - <string name="public_chat_explainer">المحادثات العامة مرئية للجميع على Nostr ويمكن لأي شخص - المشاركة فيها. إنها مناسبة للمجتمعات المفتوحة حول مواضيع محددة. - يمكن التحكم في الإشراف عبر حذف المنشورات على relay المجموعة</string> - <string name="public_chat_relays_explainer">أدخل من 1 إلى 3 relay تستضيف هذه المجموعة. - تستخدم تطبيقات Nostr هذا الإعداد لمعرفة مكان تنزيل الرسائل وإرسالها.</string> + <string name="public_chat_explainer">المحادثات العامة مرئية للجميع على Nostr ويمكن لأي شخص المشاركة فيها. إنها مناسبة للمجتمعات المفتوحة حول مواضيع محددة. يمكن التحكم في الإشراف عبر حذف المنشورات على relay المجموعة</string> + <string name="public_chat_relays_explainer">أدخل من 1 إلى 3 relay تستضيف هذه المجموعة. تستخدم تطبيقات Nostr هذا الإعداد لمعرفة مكان تنزيل الرسائل وإرسالها.</string> <string name="public_chat_title">بيانات المحادثة العامة</string> <string name="public_chats">المحادثات العامة</string> <string name="public_home_section_explainer">يخزّن هذا النوع من الـ relay جميع محتواك. سيرسل Amethyst منشوراتك إليها وسيستخدم الآخرون هذه الـ relays للعثور على محتواك. أدخل ما بين 1 و3 relays. يمكن أن تكون relays شخصية أو مدفوعة أو عامة.</string> @@ -2833,10 +2808,7 @@ <string name="read_only_user">مستخدم في وضع القراءة فقط</string> <string name="record_a_message_description">اضغط مطوّلًا لتسجيل رسالة</string> <string name="relay_chat">محادثة relay</string> - <string name="relay_chat_explainer">محادثات relay هي مجموعات دردشة يتحكم فيها الـ relay المضيف. - إنها مرئية للجميع على Nostr ويمكن لأي شخص المشاركة فيها. - إنها مناسبة للمجتمعات المفتوحة حول مواضيع محددة. بعض هذه المجموعات مؤقتة - وبالتالي تختفي رسائل الدردشة بمرور الوقت</string> + <string name="relay_chat_explainer">محادثات relay هي مجموعات دردشة يتحكم فيها الـ relay المضيف. إنها مرئية للجميع على Nostr ويمكن لأي شخص المشاركة فيها. إنها مناسبة للمجتمعات المفتوحة حول مواضيع محددة. بعض هذه المجموعات مؤقتة وبالتالي تختفي رسائل الدردشة بمرور الوقت</string> <string name="relay_chat_title">محادثات relay</string> <string name="relay_management_tab_events">الأحداث</string> <string name="relay_management_tab_ips">عناوين IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-bn-rBD/strings.xml b/commonsUI/src/commonMain/composeResources/values-bn-rBD/strings.xml index e575eee7eb..75664b26ee 100644 --- a/commonsUI/src/commonMain/composeResources/values-bn-rBD/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-bn-rBD/strings.xml @@ -271,15 +271,8 @@ <string name="mark_all_known_as_read">পরিচিত সবগুলোকে পঠিত হিসেবে চিহ্নিত করুন</string> <string name="mark_all_new_as_read">নতুন সবগুলোকে পঠিত হিসেবে চিহ্নিত করুন</string> <string name="mark_all_as_read">সবগুলোকে পঠিত হিসেবে চিহ্নিত করুন</string> - <string name="account_backup_tips2_md"> ## মূল ব্যাকআপ এবং নিরাপত্তা টিপস - \n\n আপনার অ্যাকাউন্ট একটি গোপন কী দ্বারা সুরক্ষিত। মূলটি হল অক্ষরগুলির একটি দীর্ঘ ক্রম যা শুরু হয় **nsec1**. যে কেউ এই গোপন কী অ্যাক্সেস করতে পারে পোস্ট এবং আপনার পরিচয় পরিবর্তন করতে পারেন. - \n\n- আপনি বিশ্বাস করেন না এমন কোনো ওয়েবসাইট বা সফ্টওয়্যারে আপনার গোপন কী **করবেন না**. - \n- অ্যামেথিস্ট ডেভেলপাররা **কখনই** আপনার গোপন কী চাইবে না. - \n- **করুন** অ্যাকাউন্ট পুনরুদ্ধারের জন্য আপনার গোপন কীটির একটি নিরাপদ ব্যাকআপ রাখুন৷. আমরা একটি পাসওয়ার্ড ম্যানেজার ব্যবহার করার পরামর্শ দিই।. - </string> - <string name="account_backup_tips3_md"> অতিরিক্ত নিরাপত্তার জন্য, আপনি একটি পাসওয়ার্ড দিয়ে আপনার কী এনক্রিপ্ট করতে পারেন. এই কী দিয়ে শুরু হয় **ncryptsec1** এবং আপনার পাসওয়ার্ড ছাড়া ব্যবহার করা যাবে না।. - \n\n আপনি যদি আপনার পাসওয়ার্ড হারিয়ে ফেলেন, আপনি আপনার কী পুনরুদ্ধার করতে পারবেন না।. - </string> + <string name="account_backup_tips2_md">## মূল ব্যাকআপ এবং নিরাপত্তা টিপস \n\n আপনার অ্যাকাউন্ট একটি গোপন কী দ্বারা সুরক্ষিত। মূলটি হল অক্ষরগুলির একটি দীর্ঘ ক্রম যা শুরু হয় **nsec1**. যে কেউ এই গোপন কী অ্যাক্সেস করতে পারে পোস্ট এবং আপনার পরিচয় পরিবর্তন করতে পারেন. \n\n- আপনি বিশ্বাস করেন না এমন কোনো ওয়েবসাইট বা সফ্টওয়্যারে আপনার গোপন কী **করবেন না**. \n- অ্যামেথিস্ট ডেভেলপাররা **কখনই** আপনার গোপন কী চাইবে না. \n- **করুন** অ্যাকাউন্ট পুনরুদ্ধারের জন্য আপনার গোপন কীটির একটি নিরাপদ ব্যাকআপ রাখুন৷. আমরা একটি পাসওয়ার্ড ম্যানেজার ব্যবহার করার পরামর্শ দিই।.</string> + <string name="account_backup_tips3_md">অতিরিক্ত নিরাপত্তার জন্য, আপনি একটি পাসওয়ার্ড দিয়ে আপনার কী এনক্রিপ্ট করতে পারেন. এই কী দিয়ে শুরু হয় **ncryptsec1** এবং আপনার পাসওয়ার্ড ছাড়া ব্যবহার করা যাবে না।. \n\n আপনি যদি আপনার পাসওয়ার্ড হারিয়ে ফেলেন, আপনি আপনার কী পুনরুদ্ধার করতে পারবেন না।.</string> <string name="encrypt_and_copy_my_secret_key">এনক্রিপ্ট এবং আমার গোপন কী অনুলিপি</string> <string name="badge_award_image_for">%1$s -এর জন্য ব্যাজ পুরষ্কারের ছবি</string> <string name="badge_award_image">"ব্যাজ পুরস্কার চিত্র</string> @@ -963,9 +956,7 @@ <string name="push_server_none_explainer">Push বিজ্ঞপ্তি নিষ্ক্রিয় করে</string> <string name="push_server_uses_app_explainer">অ্যাপ %1$s ব্যবহার করে</string> <string name="push_server_install_app">Push বিজ্ঞপ্তি সেটআপ</string> - <string name="push_server_install_app_description"> পুশ নোটিফিকেশন পেতে, [Unified Push](https://unifiedpush.org/) সমর্থন করে এমন যেকোনো অ্যাপ ইনস্টল করুন, যেমন [Ntfy](https://ntfy.sh/)। - ইনস্টল করার পরে, সেটিংসে আপনি যে অ্যাপটি ব্যবহার করতে চান তা নির্বাচন করুন। - </string> + <string name="push_server_install_app_description">পুশ নোটিফিকেশন পেতে, [Unified Push](https://unifiedpush.org/) সমর্থন করে এমন যেকোনো অ্যাপ ইনস্টল করুন, যেমন [Ntfy](https://ntfy.sh/)। ইনস্টল করার পরে, সেটিংসে আপনি যে অ্যাপটি ব্যবহার করতে চান তা নির্বাচন করুন।</string> <string name="thread_title">থ্রেড</string> <string name="send_the_seller_a_message">বিক্রেতাকে একটি বার্তা পাঠান</string> <string name="hi_there_is_this_still_available">হাই, এটা কি এখনও পাওয়া যায়?</string> @@ -2022,15 +2013,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s থেকে ইনভয়েস আনতে পারেনি: %2$s</string> <string name="could_not_open_the_compressed_file">সংকুচিত ফাইলটি খোলা যায়নি</string> <string name="couldnt_find_nwc_wallets">ওয়ালেট পাওয়া যায়নি</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst কোনো ওয়ালেট অ্যাপ খুঁজে পায়নি যা Nostr Wallet Connect (NWC) সমর্থন করে। -\n\nআপনি যা করতে পারেন: -\n\t১. NWC সমর্থন যাচাই করুন: নিশ্চিত করুন যে আপনার পছন্দের ওয়ালেট অ্যাপ Nostr Wallet Connect-এর সাথে সামঞ্জস্যপূর্ণ। -\n\t২. সংযোগ তৈরি করুন: আপনার ওয়ালেট অ্যাপে যান এবং একটি নতুন NWC সংযোগ তৈরি করুন। -\n\t৩. Amethyst-এ লিঙ্ক করুন: আপনার ওয়ালেট সাধারণত তিনটি বিকল্প দেবে: -\n\t\t৩.১ স্বয়ংক্রিয় লিঙ্ক: একটি বোতাম যা স্বয়ংক্রিয়ভাবে Amethyst খুলে সংযুক্ত করবে। যদি তাই হয়, সেই বোতামে ক্লিক করুন, Amethyst খুলুন এবং নতুন স্ক্রিনে সেভ চাপুন। -\n\t\t৩.২ ম্যানুয়াল লিঙ্ক: একটি Connection URI যা কপি করে এই স্ক্রিনের পেস্ট আইকনে ক্লিক করে সরাসরি ইনপুট করতে পারবেন। -\n\t\t৩.৩ QR কোড: ওয়ালেট একটি QR কোড তৈরি করে যা আপনি এই স্ক্রিনের QR কোড বোতাম থেকে পড়তে পারবেন। - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst কোনো ওয়ালেট অ্যাপ খুঁজে পায়নি যা Nostr Wallet Connect (NWC) সমর্থন করে। \n\nআপনি যা করতে পারেন: \n\t১. NWC সমর্থন যাচাই করুন: নিশ্চিত করুন যে আপনার পছন্দের ওয়ালেট অ্যাপ Nostr Wallet Connect-এর সাথে সামঞ্জস্যপূর্ণ। \n\t২. সংযোগ তৈরি করুন: আপনার ওয়ালেট অ্যাপে যান এবং একটি নতুন NWC সংযোগ তৈরি করুন। \n\t৩. Amethyst-এ লিঙ্ক করুন: আপনার ওয়ালেট সাধারণত তিনটি বিকল্প দেবে: \n\t\t৩.১ স্বয়ংক্রিয় লিঙ্ক: একটি বোতাম যা স্বয়ংক্রিয়ভাবে Amethyst খুলে সংযুক্ত করবে। যদি তাই হয়, সেই বোতামে ক্লিক করুন, Amethyst খুলুন এবং নতুন স্ক্রিনে সেভ চাপুন। \n\t\t৩.২ ম্যানুয়াল লিঙ্ক: একটি Connection URI যা কপি করে এই স্ক্রিনের পেস্ট আইকনে ক্লিক করে সরাসরি ইনপুট করতে পারবেন। \n\t\t৩.৩ QR কোড: ওয়ালেট একটি QR কোড তৈরি করে যা আপনি এই স্ক্রিনের QR কোড বোতাম থেকে পড়তে পারবেন।</string> <string name="create">তৈরি করুন</string> <string name="d">d</string> <string name="danger_zone">বিপদজনক এলাকা</string> @@ -2699,11 +2682,8 @@ <string name="proxy_section">প্রক্সি Relay</string> <string name="proxy_section_explainer">অ্যাগ্রিগেটর relay যা অ্যাপটিকে আপনার ফিড ডাউনলোড করতে অবশ্যই ব্যবহার করতে হবে, যেমন filter.nostr.wine। এটি আউটবক্স মডেলকে প্রতিস্থাপন করে এবং অ্যাপটিকে শুধুমাত্র আপনার তালিকার relay গুলোতে সংযুক্ত করবে।</string> <string name="public_chat">সার্বজনীন আলাপ</string> - <string name="public_chat_explainer">পাবলিক চ্যাটগুলো Nostr-এর সবার কাছে দৃশ্যমান এবং যে কেউ - এতে অংশগ্রহণ করতে পারে। নির্দিষ্ট বিষয়ের চারপাশে উন্মুক্ত সম্প্রদায়ের জন্য এগুলো দুর্দান্ত। - এর relay-তে পোস্ট মুছে পরিচালনা নিয়ন্ত্রণ করা যায়</string> - <string name="public_chat_relays_explainer">এই গ্রুপটি হোস্ট করে এমন ১-৩ টি relay যোগ করুন। - Nostr ক্লায়েন্টগুলো এই সেটিং ব্যবহার করে জানে যে কোথা থেকে বার্তা ডাউনলোড করতে হবে এবং আপনার বার্তা কোথায় পাঠাতে হবে।</string> + <string name="public_chat_explainer">পাবলিক চ্যাটগুলো Nostr-এর সবার কাছে দৃশ্যমান এবং যে কেউ এতে অংশগ্রহণ করতে পারে। নির্দিষ্ট বিষয়ের চারপাশে উন্মুক্ত সম্প্রদায়ের জন্য এগুলো দুর্দান্ত। এর relay-তে পোস্ট মুছে পরিচালনা নিয়ন্ত্রণ করা যায়</string> + <string name="public_chat_relays_explainer">এই গ্রুপটি হোস্ট করে এমন ১-৩ টি relay যোগ করুন। Nostr ক্লায়েন্টগুলো এই সেটিং ব্যবহার করে জানে যে কোথা থেকে বার্তা ডাউনলোড করতে হবে এবং আপনার বার্তা কোথায় পাঠাতে হবে।</string> <string name="public_chat_relays_title">Relay-গুলি</string> <string name="public_chat_title">পাবলিক চ্যাট মেটাডেটা</string> <string name="public_chats">পাবলিক চ্যাট</string> @@ -2728,10 +2708,7 @@ <string name="read_only_user">শুধু-পড়ার ব্যবহারকারী</string> <string name="record_a_message_description">একটি বার্তা রেকর্ড করতে ক্লিক করুন এবং ধরে রাখুন</string> <string name="relay_chat">Relay চ্যাট</string> - <string name="relay_chat_explainer">Relay চ্যাটগুলো হলো চ্যাট গ্রুপ যা তাদের হোম relay দ্বারা নিয়ন্ত্রিত হয়। - এগুলো Nostr-এর সবার কাছে দৃশ্যমান এবং যে কেউ এতে অংশগ্রহণ করতে পারে। - নির্দিষ্ট বিষয়ের চারপাশে উন্মুক্ত সম্প্রদায়ের জন্য এগুলো দুর্দান্ত। এই গ্রুপগুলোর কিছু ক্ষণস্থায়ী - এবং সেজন্য চ্যাট বার্তাগুলো সময়ের সাথে মুছে যায়</string> + <string name="relay_chat_explainer">Relay চ্যাটগুলো হলো চ্যাট গ্রুপ যা তাদের হোম relay দ্বারা নিয়ন্ত্রিত হয়। এগুলো Nostr-এর সবার কাছে দৃশ্যমান এবং যে কেউ এতে অংশগ্রহণ করতে পারে। নির্দিষ্ট বিষয়ের চারপাশে উন্মুক্ত সম্প্রদায়ের জন্য এগুলো দুর্দান্ত। এই গ্রুপগুলোর কিছু ক্ষণস্থায়ী এবং সেজন্য চ্যাট বার্তাগুলো সময়ের সাথে মুছে যায়</string> <string name="relay_chat_title">Relay চ্যাট</string> <string name="relay_management_tab_events">ইভেন্ট</string> <string name="relay_management_tab_ips">আইপি</string> diff --git a/commonsUI/src/commonMain/composeResources/values-cs/strings.xml b/commonsUI/src/commonMain/composeResources/values-cs/strings.xml index 4611482789..b21d6ee05a 100644 --- a/commonsUI/src/commonMain/composeResources/values-cs/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-cs/strings.xml @@ -473,13 +473,8 @@ <string name="mark_all_known_as_read">Označit všechny známé jako přečtené</string> <string name="mark_all_new_as_read">Označit všechny nové jako přečtené</string> <string name="mark_all_as_read">Označit všechny jako přečtené</string> - <string name="account_backup_tips2_md"> ## Tipy pro zálohování klíčů a bezpečnost - \n\nVaše konto je zabezpečeno tajným klíčem. Klíč je dlouhá posloupnost znaků začínající s **nsec1**. Kdo má přístup k tomuto tajnému klíči, může přispívat a měnit vaši identitu. - \n\n- **Nedávejte** svůj tajný klíč na žádnou webovou stránku nebo do žádného softwaru, kterému nedůvěřujete. - \n- Vývojáři Amethystu nikdy **nebudou** žádat o váš tajný klíč. - \n- **Udržujte** bezpečnou zálohu vašeho tajného klíče pro obnovení účtu. Doporučujeme použití správce hesel.</string> - <string name="account_backup_tips3_md"> Pro další zabezpečení můžete svůj klíč zašifrovat heslem. Tento klíč začíná s **ncryptsec1** a nelze ho použít bez vašeho hesla. - \n\nPokud zapomenete heslo, nebudete moci obnovit svůj klíč.</string> + <string name="account_backup_tips2_md">## Tipy pro zálohování klíčů a bezpečnost \n\nVaše konto je zabezpečeno tajným klíčem. Klíč je dlouhá posloupnost znaků začínající s **nsec1**. Kdo má přístup k tomuto tajnému klíči, může přispívat a měnit vaši identitu. \n\n- **Nedávejte** svůj tajný klíč na žádnou webovou stránku nebo do žádného softwaru, kterému nedůvěřujete. \n- Vývojáři Amethystu nikdy **nebudou** žádat o váš tajný klíč. \n- **Udržujte** bezpečnou zálohu vašeho tajného klíče pro obnovení účtu. Doporučujeme použití správce hesel.</string> + <string name="account_backup_tips3_md">Pro další zabezpečení můžete svůj klíč zašifrovat heslem. Tento klíč začíná s **ncryptsec1** a nelze ho použít bez vašeho hesla. \n\nPokud zapomenete heslo, nebudete moci obnovit svůj klíč.</string> <string name="backup_keys_nudge_title">Zálohujte si klíče</string> <string name="backup_keys_nudge_body">Váš tajný klíč je jediný způsob, jak se k tomuto účtu dostat. Pokud ho ztratíte, nelze ho už nikdy obnovit. Uložte si ho někam do bezpečí.</string> <string name="backup_keys_nudge_backup_now">Zálohovat nyní</string> @@ -1598,9 +1593,7 @@ <string name="push_server_none_explainer">Zakázat Push oznámení</string> <string name="push_server_uses_app_explainer">Použít aplikaci %1$s</string> <string name="push_server_install_app">Nastavení Push-oznámení</string> - <string name="push_server_install_app_description"> Pro příjem Push-oznámení nainstalujte libovolnou aplikaci, která podporuje [Unified Push](https://unifiedpush.org/), jako je [Ntfy](https://ntfy.sh/). - Po instalaci vyberte aplikaci kterou chcete používat v Nastavení. - </string> + <string name="push_server_install_app_description">Pro příjem Push-oznámení nainstalujte libovolnou aplikaci, která podporuje [Unified Push](https://unifiedpush.org/), jako je [Ntfy](https://ntfy.sh/). Po instalaci vyberte aplikaci kterou chcete používat v Nastavení.</string> <string name="thread_title">Vlákno</string> <string name="send_the_seller_a_message">Poslat prodejci zprávu</string> <string name="hi_there_is_this_still_available">Ahoj, je to stále k dispozici?</string> @@ -3393,14 +3386,7 @@ <string name="could_not_fetch_invoice_from_details">Nelze získat fakturu z %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Nepodařilo se otevřít komprimovaný soubor</string> <string name="couldnt_find_nwc_wallets">Peněženka nebyla nalezená</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst nenašel žádné aplikace peněženek, které podporují Nostr Wallet Connect (NWC). -\n\nCo můžete udělat: -\n\t1. Ověřte podporu NWC: Zkontrolujte, že vaše oblíbená peněženka podporuje Nostr Wallet Connect. -\n\t2. Vytvořte připojení: Otevřete svou peněženku a vytvořte nové NWC připojení. -\n\t3. Propojte s Amethyst: Vaše peněženka obvykle nabídne tři možnosti: -\n\t\t3.1 Automatické propojení: Tlačítko pro automatické otevření a připojení k Amethyst. Klikněte na něj, otevřete Amethyst a uložte na nové obrazovce. -\n\t\t3.2 Ruční propojení: URI připojení, které můžete zkopírovat a vložit přes ikonu vložení na této obrazovce. -\n\t\t3.3 QR kód: Peněženka vytvoří QR kód, který můžete naskenovat pomocí tlačítka QR kódu na této obrazovce.</string> + <string name="couldnt_find_nwc_wallets_description">Amethyst nenašel žádné aplikace peněženek, které podporují Nostr Wallet Connect (NWC). \n\nCo můžete udělat: \n\t1. Ověřte podporu NWC: Zkontrolujte, že vaše oblíbená peněženka podporuje Nostr Wallet Connect. \n\t2. Vytvořte připojení: Otevřete svou peněženku a vytvořte nové NWC připojení. \n\t3. Propojte s Amethyst: Vaše peněženka obvykle nabídne tři možnosti: \n\t\t3.1 Automatické propojení: Tlačítko pro automatické otevření a připojení k Amethyst. Klikněte na něj, otevřete Amethyst a uložte na nové obrazovce. \n\t\t3.2 Ruční propojení: URI připojení, které můžete zkopírovat a vložit přes ikonu vložení na této obrazovce. \n\t\t3.3 QR kód: Peněženka vytvoří QR kód, který můžete naskenovat pomocí tlačítka QR kódu na této obrazovce.</string> <string name="create">Vytvořit</string> <string name="d">d</string> <string name="danger_zone">Nebezpečná zóna</string> @@ -4611,11 +4597,8 @@ <string name="proxy_section">Proxy přenašeče</string> <string name="proxy_section_explainer">Agregační přenašeče, které aplikace používá ke stahování vašich zdrojů, jako např. filter.nostr.wine</string> <string name="public_chat">Veřejný chat</string> - <string name="public_chat_explainer">Veřejné konverzace jsou viditelné pro všechny na Nostru a kdokoli - se na nich může podílet. Jsou skvělé pro otevřené komunity kolem konkrétních témat. - Moderaci lze ovládat smazáním příspěvků na relé</string> - <string name="public_chat_relays_explainer">Vložte mezi 1–3 relé, které hostí tuto skupinu. - Klienti Nostr používají toto nastavení, aby věděli, kam stahovat zprávy a odesílat zprávy.</string> + <string name="public_chat_explainer">Veřejné konverzace jsou viditelné pro všechny na Nostru a kdokoli se na nich může podílet. Jsou skvělé pro otevřené komunity kolem konkrétních témat. Moderaci lze ovládat smazáním příspěvků na relé</string> + <string name="public_chat_relays_explainer">Vložte mezi 1–3 relé, které hostí tuto skupinu. Klienti Nostr používají toto nastavení, aby věděli, kam stahovat zprávy a odesílat zprávy.</string> <string name="public_chat_relays_title">Rele</string> <string name="public_chat_title">Metadata veřejného chatu</string> <string name="public_chats">Veřejné chaty</string> @@ -4684,10 +4667,7 @@ <string name="relay_auth_search_keywords">auth autentizace relay podepsat ověřit nip-42 identita</string> <string name="relay_auth_settings_title">Autentizace relay</string> <string name="relay_chat">Relé chat</string> - <string name="relay_chat_explainer">Relay chaty jsou chatové skupiny ovládané jejich domácí relé. - Jsou viditelné pro všechny na Nostru a každý se jich může zúčastnit. - Jsou skvělé pro otevřené komunity kolem konkrétních témat. Některé z těchto skupin jsou efemérní - a proto zprávy časem mizí</string> + <string name="relay_chat_explainer">Relay chaty jsou chatové skupiny ovládané jejich domácí relé. Jsou viditelné pro všechny na Nostru a každý se jich může zúčastnit. Jsou skvělé pro otevřené komunity kolem konkrétních témat. Některé z těchto skupin jsou efemérní a proto zprávy časem mizí</string> <string name="relay_chat_title">Relé chaty</string> <string name="relay_explain_account_data">Váš vlastní profil, nastavení a koncepty na vašich domovských relayích.</string> <string name="relay_explain_community_chats">Relaye, na které každá komunita publikuje své roviny.</string> diff --git a/commonsUI/src/commonMain/composeResources/values-de-rDE/strings.xml b/commonsUI/src/commonMain/composeResources/values-de-rDE/strings.xml index 076f687129..17617a8ae7 100644 --- a/commonsUI/src/commonMain/composeResources/values-de-rDE/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-de-rDE/strings.xml @@ -361,7 +361,7 @@ <string name="copy_user_id">Benutzer-ID kopieren</string> <string name="unblock_user">Benutzer freigeben</string> <string name="user_is_blocked_hidden">Dieser Nutzer ist blockiert/stummgeschaltet. Seine Beiträge sind ausgeblendet.</string> - <string name="npub_hex_username">npub, Benutzername, Text </string> + <string name="npub_hex_username">npub, Benutzername, Text</string> <string name="clear">Löschen</string> <string name="app_logo">App-Logo</string> <string name="nsec_npub_hex_private_key">nsec.. oder npub..</string> @@ -463,13 +463,8 @@ <string name="mark_all_known_as_read">Alle Kontakte als gelesen markieren</string> <string name="mark_all_new_as_read">Alle Unbekannten als gelesen markieren</string> <string name="mark_all_as_read">Alle als gelesen markieren</string> - <string name="account_backup_tips2_md"> ## Tipps zur Schlüsselsicherheit - \n\nDein Konto ist durch einen privaten Schlüssel gesichert. Der Schlüssel ist eine lange Zeichenfolge, die mit **nsec1** beginnt. Jeder, der Zugriff auf diesen privaten Schlüssel hat, kann in deinem Namen posten und dein Profil ändern. - \n\n- Lege deinen privaten Schlüssel **nicht** auf einer Website oder in einer Software ab, der du nicht vertraust. - \n- Die Entwickler von Amethyst werden dich **niemals** nach deinem privaten Schlüssel fragen. - \n- **Bewahre** eine sichere Kopie deines privaten Schlüssels zur Kontowiederherstellung auf. Wir empfehlen die Verwendung eines Passwort-Managers.</string> - <string name="account_backup_tips3_md"> Für zusätzliche Sicherheit kannst du deinen Schlüssel mit einem Passwort verschlüsseln. Dieser Schlüssel beginnt mit **ncryptsec1** und kann ohne dein Passwort nicht verwendet werden. - \n\nWenn du dein Passwort verlierst, kannst du deinen Schlüssel nicht wiederherstellen.</string> + <string name="account_backup_tips2_md">## Tipps zur Schlüsselsicherheit \n\nDein Konto ist durch einen privaten Schlüssel gesichert. Der Schlüssel ist eine lange Zeichenfolge, die mit **nsec1** beginnt. Jeder, der Zugriff auf diesen privaten Schlüssel hat, kann in deinem Namen posten und dein Profil ändern. \n\n- Lege deinen privaten Schlüssel **nicht** auf einer Website oder in einer Software ab, der du nicht vertraust. \n- Die Entwickler von Amethyst werden dich **niemals** nach deinem privaten Schlüssel fragen. \n- **Bewahre** eine sichere Kopie deines privaten Schlüssels zur Kontowiederherstellung auf. Wir empfehlen die Verwendung eines Passwort-Managers.</string> + <string name="account_backup_tips3_md">Für zusätzliche Sicherheit kannst du deinen Schlüssel mit einem Passwort verschlüsseln. Dieser Schlüssel beginnt mit **ncryptsec1** und kann ohne dein Passwort nicht verwendet werden. \n\nWenn du dein Passwort verlierst, kannst du deinen Schlüssel nicht wiederherstellen.</string> <string name="backup_keys_nudge_title">Sichere deine Schlüssel</string> <string name="backup_keys_nudge_body">Dein geheimer Schlüssel ist der einzige Weg zu diesem Konto. Wenn du ihn verlierst, kann er nie wiederhergestellt werden. Speichere ihn jetzt an einem sicheren Ort.</string> <string name="backup_keys_nudge_backup_now">Jetzt sichern</string> @@ -1584,9 +1579,7 @@ <string name="push_server_none_explainer">Push-Benachrichtigungen deaktivieren</string> <string name="push_server_uses_app_explainer">Verwendet die App %1$s</string> <string name="push_server_install_app">Push-Benachrichtigungen einrichten</string> - <string name="push_server_install_app_description"> Um Push-Benachrichtigungen zu erhalten, installiere eine App, die [Unified Push](https://unifiedpush.org/) unterstützt, wie zum Beispiel [Ntfy](https://ntfy.sh/). - Nach der Installation wähle in den Einstellungen die App aus, die du verwenden möchtest. - </string> + <string name="push_server_install_app_description">Um Push-Benachrichtigungen zu erhalten, installiere eine App, die [Unified Push](https://unifiedpush.org/) unterstützt, wie zum Beispiel [Ntfy](https://ntfy.sh/). Nach der Installation wähle in den Einstellungen die App aus, die du verwenden möchtest.</string> <string name="thread_title">Faden</string> <string name="send_the_seller_a_message">Dem Verkäufer eine Nachricht senden</string> <string name="hi_there_is_this_still_available">Hallo, ist das noch verfügbar?</string> @@ -3323,14 +3316,7 @@ <string name="could_not_fetch_invoice_from_details">Rechnung konnte nicht von %1$s abgerufen werden: %2$s</string> <string name="could_not_open_the_compressed_file">Konnte die komprimierte Datei nicht öffnen</string> <string name="couldnt_find_nwc_wallets">Wallet nicht gefunden</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst konnte keine Wallet-Apps finden, die Nostr Wallet Connect (NWC) unterstützen. -\n\nWas du tun kannst: -\n\t1. NWC-Unterstützung überprüfen: Stelle sicher, dass deine bevorzugte Wallet-App mit Nostr Wallet Connect kompatibel ist. -\n\t2. Verbindung erstellen: Öffne deine Wallet-App und erstelle eine neue NWC-Verbindung. -\n\t3. Mit Amethyst verknüpfen: Deine Wallet bietet normalerweise drei Optionen: -\n\t\t3.1 Automatische Verknüpfung: Eine Schaltfläche zum automatischen Öffnen und Verbinden mit Amethyst. Klicke darauf, öffne Amethyst und speichere auf dem neuen Bildschirm. -\n\t\t3.2 Manuelle Verknüpfung: Eine Verbindungs-URI, die du kopieren und über das Einfügesymbol auf diesem Bildschirm einfügen kannst. -\n\t\t3.3 QR-Code: Die Wallet erstellt einen QR-Code, den du über die QR-Schaltfläche auf diesem Bildschirm scannen kannst.</string> + <string name="couldnt_find_nwc_wallets_description">Amethyst konnte keine Wallet-Apps finden, die Nostr Wallet Connect (NWC) unterstützen. \n\nWas du tun kannst: \n\t1. NWC-Unterstützung überprüfen: Stelle sicher, dass deine bevorzugte Wallet-App mit Nostr Wallet Connect kompatibel ist. \n\t2. Verbindung erstellen: Öffne deine Wallet-App und erstelle eine neue NWC-Verbindung. \n\t3. Mit Amethyst verknüpfen: Deine Wallet bietet normalerweise drei Optionen: \n\t\t3.1 Automatische Verknüpfung: Eine Schaltfläche zum automatischen Öffnen und Verbinden mit Amethyst. Klicke darauf, öffne Amethyst und speichere auf dem neuen Bildschirm. \n\t\t3.2 Manuelle Verknüpfung: Eine Verbindungs-URI, die du kopieren und über das Einfügesymbol auf diesem Bildschirm einfügen kannst. \n\t\t3.3 QR-Code: Die Wallet erstellt einen QR-Code, den du über die QR-Schaltfläche auf diesem Bildschirm scannen kannst.</string> <string name="create">Erstellen</string> <string name="d">t</string> <string name="danger_zone">Gefahrenzone</string> @@ -4427,11 +4413,8 @@ <string name="proxy_section">Proxy-Relays</string> <string name="proxy_section_explainer">Aggregator-Relays wie filter.nostr.wine, von denen die App deine Feeds herunterlädt</string> <string name="public_chat">Öffentlicher Chat</string> - <string name="public_chat_explainer">Öffentliche Chats sind für jeden auf Nostr sichtbar und jeder - kann daran teilnehmen. Sie eignen sich hervorragend für offene Gemeinschaften rund um bestimmte Themen. - Moderation kann durch Löschen von Beiträgen auf den Relays gesteuert werden</string> - <string name="public_chat_relays_explainer">Füge zwischen 1–3 Relays ein, die diese Gruppe beherbergen. - Nostr Clients verwenden diese Einstellung, um zu wissen, woher sie Nachrichten herunterladen und an welche gesendet werden sollen.</string> + <string name="public_chat_explainer">Öffentliche Chats sind für jeden auf Nostr sichtbar und jeder kann daran teilnehmen. Sie eignen sich hervorragend für offene Gemeinschaften rund um bestimmte Themen. Moderation kann durch Löschen von Beiträgen auf den Relays gesteuert werden</string> + <string name="public_chat_relays_explainer">Füge zwischen 1–3 Relays ein, die diese Gruppe beherbergen. Nostr Clients verwenden diese Einstellung, um zu wissen, woher sie Nachrichten herunterladen und an welche gesendet werden sollen.</string> <string name="public_chat_relays_title">Relays</string> <string name="public_chat_title">Öffentliche Chat Metadaten</string> <string name="public_chats">Öffentliche Chats</string> @@ -4496,10 +4479,7 @@ <string name="relay_auth_search_keywords">auth authentifizierung relay signieren verifizieren nip-42 identität</string> <string name="relay_auth_settings_title">Relay-Authentifizierung</string> <string name="relay_chat">Relay-Chat</string> - <string name="relay_chat_explainer">Relay-Chats sind Chatgruppen, die von ihrem Home-Relay gesteuert werden. - Sie sind für jeden auf Nostr sichtbar und jeder kann an ihnen teilnehmen. - Sie eignen sich hervorragend für offene Communities rund um bestimmte Themen. Einige dieser Gruppen sind kurzsichtig - und daher verschwinden Chat-Nachrichten im Laufe der Zeit</string> + <string name="relay_chat_explainer">Relay-Chats sind Chatgruppen, die von ihrem Home-Relay gesteuert werden. Sie sind für jeden auf Nostr sichtbar und jeder kann an ihnen teilnehmen. Sie eignen sich hervorragend für offene Communities rund um bestimmte Themen. Einige dieser Gruppen sind kurzsichtig und daher verschwinden Chat-Nachrichten im Laufe der Zeit</string> <string name="relay_chat_title">Relay-Chats</string> <string name="relay_explain_account_data">Dein eigenes Profil, deine Einstellungen und Entwürfe auf deinen Heim-Relays.</string> <string name="relay_explain_community_chats">Die Relays, auf denen jede Community ihre Planes veröffentlicht.</string> diff --git a/commonsUI/src/commonMain/composeResources/values-de/strings.xml b/commonsUI/src/commonMain/composeResources/values-de/strings.xml index fe28311d40..a1bc04624c 100644 --- a/commonsUI/src/commonMain/composeResources/values-de/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-de/strings.xml @@ -211,7 +211,7 @@ <string name="copy_user_id">Benutzer-ID kopieren</string> <string name="unblock_user">Benutzer freigeben</string> <string name="user_is_blocked_hidden">Dieser Nutzer ist blockiert/stummgeschaltet. Seine Beiträge sind ausgeblendet.</string> - <string name="npub_hex_username">Npub, Hex, Benutzername </string> + <string name="npub_hex_username">Npub, Hex, Benutzername</string> <string name="clear">Löschen</string> <string name="app_logo">App-Logo</string> <string name="nsec_npub_hex_private_key">Nsec / Npub / Hex-Privatschlüssel</string> @@ -219,9 +219,7 @@ <string name="show_password">Passwort anzeigen</string> <string name="i_accept_the">Ich akzeptiere die </string> <string name="terms_of_use">Nutzungsbedingungen</string> - <string name="acceptance_of_terms_is_required">Die Akzept - -anz der Bedingungen ist erforderlich</string> + <string name="acceptance_of_terms_is_required">Die Akzept anz der Bedingungen ist erforderlich</string> <string name="login">Anmeldung</string> <string name="sign_up">Anmelden</string> <string name="create_account">Konto erstellen</string> @@ -261,13 +259,8 @@ anz der Bedingungen ist erforderlich</string> <string name="mark_all_known_as_read">Alle als bekannt markieren</string> <string name="mark_all_new_as_read">Alle als neu markieren</string> <string name="mark_all_as_read">Alle als gelesen markieren</string> - <string name="account_backup_tips2_md"> ## Schlüsselsicherheits-Tipps - \n\nIhr Konto ist durch einen geheimen Schlüssel gesichert. Der Schlüssel ist eine lange Zeichenfolge, die mit **nsec1** beginnt. Jeder, der Zugriff auf diesen geheimen Schlüssel hat, kann Ihre Identität posten und ändern. - \n\n- Legen Sie Ihren geheimen Schlüssel **nicht** auf eine Website oder in eine Software, der Sie nicht vertrauen. - \n- Die Entwickler von Amethyst werden Sie **niemals** nach Ihrem geheimen Schlüssel fragen. - \n- **Bewahren Sie** eine sichere Sicherung Ihres geheimen Schlüssels zur Kontowiederherstellung auf. Wir empfehlen die Verwendung eines Passwort-Managers.</string> - <string name="account_backup_tips3_md"> Für zusätzliche Sicherheit können Sie Ihren Schlüssel mit einem Passwort verschlüsseln. Dieser Schlüssel beginnt mit **ncryptsec1** und kann ohne Ihr Passwort nicht verwendet werden. - \n\nWenn Sie Ihr Passwort verlieren, können Sie Ihren Schlüssel nicht wiederherstellen.</string> + <string name="account_backup_tips2_md">## Schlüsselsicherheits-Tipps \n\nIhr Konto ist durch einen geheimen Schlüssel gesichert. Der Schlüssel ist eine lange Zeichenfolge, die mit **nsec1** beginnt. Jeder, der Zugriff auf diesen geheimen Schlüssel hat, kann Ihre Identität posten und ändern. \n\n- Legen Sie Ihren geheimen Schlüssel **nicht** auf eine Website oder in eine Software, der Sie nicht vertrauen. \n- Die Entwickler von Amethyst werden Sie **niemals** nach Ihrem geheimen Schlüssel fragen. \n- **Bewahren Sie** eine sichere Sicherung Ihres geheimen Schlüssels zur Kontowiederherstellung auf. Wir empfehlen die Verwendung eines Passwort-Managers.</string> + <string name="account_backup_tips3_md">Für zusätzliche Sicherheit können Sie Ihren Schlüssel mit einem Passwort verschlüsseln. Dieser Schlüssel beginnt mit **ncryptsec1** und kann ohne Ihr Passwort nicht verwendet werden. \n\nWenn Sie Ihr Passwort verlieren, können Sie Ihren Schlüssel nicht wiederherstellen.</string> <string name="encrypt_and_copy_my_secret_key">Verschlüsseln und kopieren Sie meinen geheimen Schlüssel</string> <string name="badge_award_image_for">Auszeichnungsbild für %1$s</string> <string name="badge_award_image">Auszeichnungsbild</string> @@ -960,9 +953,7 @@ anz der Bedingungen ist erforderlich</string> <string name="push_server_none_explainer">Push-Benachrichtigungen deaktivieren</string> <string name="push_server_uses_app_explainer">Verwendet die App %1$s</string> <string name="push_server_install_app">Push-Benachrichtigungen einrichten</string> - <string name="push_server_install_app_description"> Um Push-Benachrichtigungen zu erhalten, installieren Sie eine App, die [Unified Push](https://unifiedpush.org/) unterstützt, wie zum Beispiel [Ntfy](https://ntfy.sh/). - Nach der Installation wählen Sie die App aus, die Sie in den Einstellungen verwenden möchten. - </string> + <string name="push_server_install_app_description">Um Push-Benachrichtigungen zu erhalten, installieren Sie eine App, die [Unified Push](https://unifiedpush.org/) unterstützt, wie zum Beispiel [Ntfy](https://ntfy.sh/). Nach der Installation wählen Sie die App aus, die Sie in den Einstellungen verwenden möchten.</string> <string name="thread_title">Faden</string> <string name="send_the_seller_a_message">Dem Verkäufer eine Nachricht senden</string> <string name="hi_there_is_this_still_available">Hallo, ist das noch verfügbar?</string> @@ -2064,14 +2055,7 @@ anz der Bedingungen ist erforderlich</string> <string name="could_not_fetch_invoice_from_details">Rechnung konnte nicht von %1$s abgerufen werden: %2$s</string> <string name="could_not_open_the_compressed_file">Konnte die komprimierte Datei nicht öffnen</string> <string name="couldnt_find_nwc_wallets">Wallet nicht gefunden</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst konnte keine Wallet-Apps finden, die Nostr Wallet Connect (NWC) unterstützen. -\n\nWas du tun kannst: -\n\t1. NWC-Unterstützung überprüfen: Stelle sicher, dass deine bevorzugte Wallet-App mit Nostr Wallet Connect kompatibel ist. -\n\t2. Verbindung erstellen: Öffne deine Wallet-App und erstelle eine neue NWC-Verbindung. -\n\t3. Mit Amethyst verknüpfen: Deine Wallet bietet normalerweise drei Optionen: -\n\t\t3.1 Automatische Verknüpfung: Eine Schaltfläche zum automatischen Öffnen und Verbinden mit Amethyst. Klicke darauf, öffne Amethyst und speichere auf dem neuen Bildschirm. -\n\t\t3.2 Manuelle Verknüpfung: Eine Verbindungs-URI, die du kopieren und über das Einfügesymbol auf diesem Bildschirm einfügen kannst. -\n\t\t3.3 QR-Code: Die Wallet erstellt einen QR-Code, den du über die QR-Schaltfläche auf diesem Bildschirm scannen kannst.</string> + <string name="couldnt_find_nwc_wallets_description">Amethyst konnte keine Wallet-Apps finden, die Nostr Wallet Connect (NWC) unterstützen. \n\nWas du tun kannst: \n\t1. NWC-Unterstützung überprüfen: Stelle sicher, dass deine bevorzugte Wallet-App mit Nostr Wallet Connect kompatibel ist. \n\t2. Verbindung erstellen: Öffne deine Wallet-App und erstelle eine neue NWC-Verbindung. \n\t3. Mit Amethyst verknüpfen: Deine Wallet bietet normalerweise drei Optionen: \n\t\t3.1 Automatische Verknüpfung: Eine Schaltfläche zum automatischen Öffnen und Verbinden mit Amethyst. Klicke darauf, öffne Amethyst und speichere auf dem neuen Bildschirm. \n\t\t3.2 Manuelle Verknüpfung: Eine Verbindungs-URI, die du kopieren und über das Einfügesymbol auf diesem Bildschirm einfügen kannst. \n\t\t3.3 QR-Code: Die Wallet erstellt einen QR-Code, den du über die QR-Schaltfläche auf diesem Bildschirm scannen kannst.</string> <string name="create">Erstellen</string> <string name="d">t</string> <string name="danger_zone">Gefahrenzone</string> @@ -2274,9 +2258,7 @@ anz der Bedingungen ist erforderlich</string> <string name="http_status_508">Schleife erkannt - Der Server erkennt eine Endlosschleife, während er die Anfrage bearbeitet</string> <string name="http_status_511">Netzwerk-Authentifizierung erforderlich - Der Client muss authentifiziert werden, um auf das Netzwerk zuzugreifen</string> <string name="illegal_behavior">Illegales Verhalten</string> - <string name="image_saved_to_the_gallery">Bild in der Gal - -erie gespeichert</string> + <string name="image_saved_to_the_gallery">Bild in der Gal erie gespeichert</string> <string name="impersonation">Vortäuschung</string> <string name="import_follows_search_keywords">Kontakte, folgen, Folgeliste, importieren</string> <string name="inbox_relays_title">Eingehende Relays</string> @@ -2777,11 +2759,8 @@ erie gespeichert</string> <string name="proxy_section">Proxy-Relays</string> <string name="proxy_section_explainer">Aggregator-Relays wie filter.nostr.wine, von denen die App deine Feeds herunterlädt</string> <string name="public_chat">Öffentlicher Chat</string> - <string name="public_chat_explainer">Öffentliche Chats sind für jeden auf Nostr sichtbar und jeder - kann daran teilnehmen. Sie eignen sich hervorragend für offene Gemeinschaften rund um bestimmte Themen. - Moderation kann durch Löschen von Beiträgen auf den Relais gesteuert werden</string> - <string name="public_chat_relays_explainer">Fügen Sie zwischen 1–3 Relais ein, die diese Gruppe beherbergen. - Nostr Clients verwenden diese Einstellung, um zu wissen, woher sie Nachrichten herunterladen und an welche gesendet werden sollen.</string> + <string name="public_chat_explainer">Öffentliche Chats sind für jeden auf Nostr sichtbar und jeder kann daran teilnehmen. Sie eignen sich hervorragend für offene Gemeinschaften rund um bestimmte Themen. Moderation kann durch Löschen von Beiträgen auf den Relais gesteuert werden</string> + <string name="public_chat_relays_explainer">Fügen Sie zwischen 1–3 Relais ein, die diese Gruppe beherbergen. Nostr Clients verwenden diese Einstellung, um zu wissen, woher sie Nachrichten herunterladen und an welche gesendet werden sollen.</string> <string name="public_chat_relays_title">Relais</string> <string name="public_chat_title">Öffentliche Chat Metadaten</string> <string name="public_chats">Öffentliche Chats</string> @@ -2808,10 +2787,7 @@ erie gespeichert</string> <string name="read_only_user">Nur-Lese-Benutzer</string> <string name="record_a_message_description">Zum Aufnehmen einer Nachricht gedrückt halten</string> <string name="relay_chat">Relay-Chat</string> - <string name="relay_chat_explainer">Relaischats sind Chatgruppen, die von ihrem Home-Relais gesteuert werden. - Sie sind für jeden auf Nostr sichtbar und jeder kann an ihnen teilnehmen. - Sie eignen sich hervorragend für offene Communities rund um bestimmte Themen. Einige dieser Gruppen sind kurzsichtig - und daher verschwinden Chat-Nachrichten im Laufe der Zeit</string> + <string name="relay_chat_explainer">Relaischats sind Chatgruppen, die von ihrem Home-Relais gesteuert werden. Sie sind für jeden auf Nostr sichtbar und jeder kann an ihnen teilnehmen. Sie eignen sich hervorragend für offene Communities rund um bestimmte Themen. Einige dieser Gruppen sind kurzsichtig und daher verschwinden Chat-Nachrichten im Laufe der Zeit</string> <string name="relay_chat_title">Relay-Chats</string> <string name="relay_management_tab_events">Ereignisse</string> <string name="relay_management_tab_ips">IPs</string> diff --git a/commonsUI/src/commonMain/composeResources/values-el-rGR/strings.xml b/commonsUI/src/commonMain/composeResources/values-el-rGR/strings.xml index 6569dd09c3..ffe6a08835 100644 --- a/commonsUI/src/commonMain/composeResources/values-el-rGR/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-el-rGR/strings.xml @@ -271,15 +271,8 @@ <string name="mark_all_known_as_read">Σήμανση όλων των γνωστοποιήσεων ως αναγνωσμένων</string> <string name="mark_all_new_as_read">Σήμανση όλων ως αναγνωσμένων</string> <string name="mark_all_as_read">Σήμανση όλων ως αναγνωσμένα</string> - <string name="account_backup_tips2_md"> ## Συμβουλές ασφαλείας και δημιουργίας αντιγράφων ασφαλείας κλειδιού - \n\nΟ λογαριασμός σου ασφαλίζεται με ένα μυστικό κλειδί. Το κλειδί είναι μια μακρά ακολουθία χαρακτήρων που ξεκινά με **nsec1**. Όποιος έχει πρόσβαση σε αυτό το μυστικό κλειδί μπορεί να δημοσιεύει και να αλλάζει την ταυτότητά σου. - \n\n- **Μην** βάζεις το μυστικό σου κλειδί σε κανέναν ιστότοπο ή λογισμικό που δεν εμπιστεύεσαι. - \n- Οι προγραμματιστές του Amethyst **δεν** θα ζητήσουν ποτέ το μυστικό σου κλειδί. - \n- **Διατήρησε** ένα ασφαλές αντίγραφο ασφαλείας του μυστικού σου κλειδιού για ανάκτηση λογαριασμού. Συνιστούμε τη χρήση διαχειριστή κωδικών πρόσβασης. - </string> - <string name="account_backup_tips3_md"> Για πρόσθετη ασφάλεια, μπορείς να κρυπτογραφήσεις το κλειδί σου με κωδικό πρόσβασης. Αυτό το κλειδί ξεκινά με **ncryptsec1** και δεν μπορεί να χρησιμοποιηθεί χωρίς τον κωδικό σου. - \n\nΑν χάσεις τον κωδικό σου, δεν θα μπορείς να ανακτήσεις το κλειδί σου. - </string> + <string name="account_backup_tips2_md">## Συμβουλές ασφαλείας και δημιουργίας αντιγράφων ασφαλείας κλειδιού \n\nΟ λογαριασμός σου ασφαλίζεται με ένα μυστικό κλειδί. Το κλειδί είναι μια μακρά ακολουθία χαρακτήρων που ξεκινά με **nsec1**. Όποιος έχει πρόσβαση σε αυτό το μυστικό κλειδί μπορεί να δημοσιεύει και να αλλάζει την ταυτότητά σου. \n\n- **Μην** βάζεις το μυστικό σου κλειδί σε κανέναν ιστότοπο ή λογισμικό που δεν εμπιστεύεσαι. \n- Οι προγραμματιστές του Amethyst **δεν** θα ζητήσουν ποτέ το μυστικό σου κλειδί. \n- **Διατήρησε** ένα ασφαλές αντίγραφο ασφαλείας του μυστικού σου κλειδιού για ανάκτηση λογαριασμού. Συνιστούμε τη χρήση διαχειριστή κωδικών πρόσβασης.</string> + <string name="account_backup_tips3_md">Για πρόσθετη ασφάλεια, μπορείς να κρυπτογραφήσεις το κλειδί σου με κωδικό πρόσβασης. Αυτό το κλειδί ξεκινά με **ncryptsec1** και δεν μπορεί να χρησιμοποιηθεί χωρίς τον κωδικό σου. \n\nΑν χάσεις τον κωδικό σου, δεν θα μπορείς να ανακτήσεις το κλειδί σου.</string> <string name="encrypt_and_copy_my_secret_key">Κρυπτογράφηση και αντιγραφή του μυστικού μου κλειδιού</string> <string name="badge_award_image_for">Σήμα βράβευσης για %1$s</string> <string name="badge_award_image">"Εικόνα βραβείου παρασήμου</string> @@ -934,8 +927,7 @@ <string name="moderators">Συντονιστές</string> <string name="login_with_external_signer">Σύνδεση με Amber</string> <string name="status_update">Ενημέρωση κατάστασης</string> - <string name="poll_zap_value_min_max_explainer">Η ψηφοφορία σε μια δημοσίευση Δημοσκόπησης γίνεται με zaps. Τα zaps είναι μικροπληρωμές σε satoshi (sats). Τα sats είναι υποδιαίρεση του Bitcoin. Κάθε Bitcoin έχει 100.000.000 sats. -Η επιλογή με τα περισσότερα zaps (δηλαδή τα περισσότερα sats) είναι η επικρατέστερη. Μπορείτε να ορίσετε ένα ελάχιστο ποσό zap για να αποφύγετε την ψήφο spammers αλλά και ένα μέγιστο ποσό ώστε να αποφύγετε μεγάλους zappers (χρήστες που στέλνουν zaps) που επιθυμούν να χειραγωγήσουν την ψηφοφορία. Χρησιμοποιήστε το ίδιο ποσό και στα δύο πεδία για να βεβαιωθείτε ότι κάθε ψήφος αποτιμάται το ίδιο. Ή αφήστε τα πεδία κενά για να αποδεχτείτε οποιοδήποτε ποσό.</string> + <string name="poll_zap_value_min_max_explainer">Η ψηφοφορία σε μια δημοσίευση Δημοσκόπησης γίνεται με zaps. Τα zaps είναι μικροπληρωμές σε satoshi (sats). Τα sats είναι υποδιαίρεση του Bitcoin. Κάθε Bitcoin έχει 100.000.000 sats. Η επιλογή με τα περισσότερα zaps (δηλαδή τα περισσότερα sats) είναι η επικρατέστερη. Μπορείτε να ορίσετε ένα ελάχιστο ποσό zap για να αποφύγετε την ψήφο spammers αλλά και ένα μέγιστο ποσό ώστε να αποφύγετε μεγάλους zappers (χρήστες που στέλνουν zaps) που επιθυμούν να χειραγωγήσουν την ψηφοφορία. Χρησιμοποιήστε το ίδιο ποσό και στα δύο πεδία για να βεβαιωθείτε ότι κάθε ψήφος αποτιμάται το ίδιο. Ή αφήστε τα πεδία κενά για να αποδεχτείτε οποιοδήποτε ποσό.</string> <string name="error_dialog_talk_to_user">Μήνυμα στον Χρήστη</string> <string name="error_dialog_talk_to_user_name">Μήνυμα σε %1$s</string> <string name="error_dialog_button_ok">ΟΚ</string> @@ -963,9 +955,7 @@ <string name="push_server_none_explainer">Απενεργοποίηση Ειδοποιήσεων Push</string> <string name="push_server_uses_app_explainer">Χρήση εφαρμογής %1$s</string> <string name="push_server_install_app">Ρυθμίσεις Ειδοποιήσεων Push</string> - <string name="push_server_install_app_description"> Για να λαμβάνετε ειδοποιήσεις Push, εγκαταστήστε οποιαδήποτε εφαρμογή τις υποστηρίζει [Unified Push](https://unifiedpush.org/), όπως πχ το [Ntfy](https://ntfy.sh/). - Μετά την εγκατάσταση, επιλέξτε την εφαρμογή που θέλετε να χρησιμοποιήσετε από τις Ρυθμίσεις. - </string> + <string name="push_server_install_app_description">Για να λαμβάνετε ειδοποιήσεις Push, εγκαταστήστε οποιαδήποτε εφαρμογή τις υποστηρίζει [Unified Push](https://unifiedpush.org/), όπως πχ το [Ntfy](https://ntfy.sh/). Μετά την εγκατάσταση, επιλέξτε την εφαρμογή που θέλετε να χρησιμοποιήσετε από τις Ρυθμίσεις.</string> <string name="thread_title">Νήμα</string> <string name="send_the_seller_a_message">Στείλτε μήνυμα στον πωλητή</string> <string name="hi_there_is_this_still_available">Γεια σου, είναι ακόμα διαθέσιμο;</string> @@ -2008,15 +1998,7 @@ <string name="could_not_fetch_invoice_from_details">Δεν ήταν δυνατή η λήψη τιμολογίου από %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Δεν ήταν δυνατό το άνοιγμα του συμπιεσμένου αρχείου</string> <string name="couldnt_find_nwc_wallets">Το πορτοφόλι δεν βρέθηκε</string> - <string name="couldnt_find_nwc_wallets_description">Το Amethyst δεν βρήκε εφαρμογές πορτοφολιού που υποστηρίζουν Nostr Wallet Connect (NWC). -\n\nΤι μπορείτε να κάνετε: -\n\t1. Επαλήθευση υποστήριξης NWC: Βεβαιωθείτε ότι η προτιμώμενη εφαρμογή πορτοφολιού σας είναι συμβατή με Nostr Wallet Connect. -\n\t2. Δημιουργία σύνδεσης: Μεταβείτε στην εφαρμογή πορτοφολιού σας και δημιουργήστε μια νέα σύνδεση NWC. -\n\t3. Σύνδεση με το Amethyst: Το πορτοφόλι σας συνήθως θα σας δώσει τρεις επιλογές: -\n\t\t3.1 Αυτόματη σύνδεση: Ένα κουμπί για αυτόματο άνοιγμα και σύνδεση με το Amethyst. Αν ναι, κάντε κλικ σε αυτό το κουμπί, ανοίξτε το Amethyst και πατήστε αποθήκευση στη νέα οθόνη. -\n\t\t3.2 Χειροκίνητη σύνδεση: Ένα URI σύνδεσης που μπορείτε να αντιγράψετε και να κάνετε κλικ στο εικονίδιο επικόλλησης σε αυτή την οθόνη για απευθείας εισαγωγή. -\n\t\t3.3 Κωδικός QR: Το πορτοφόλι δημιουργεί κωδικό QR τον οποίο μπορείτε να σαρώσετε από το κουμπί κωδικού QR σε αυτή την οθόνη. - </string> + <string name="couldnt_find_nwc_wallets_description">Το Amethyst δεν βρήκε εφαρμογές πορτοφολιού που υποστηρίζουν Nostr Wallet Connect (NWC). \n\nΤι μπορείτε να κάνετε: \n\t1. Επαλήθευση υποστήριξης NWC: Βεβαιωθείτε ότι η προτιμώμενη εφαρμογή πορτοφολιού σας είναι συμβατή με Nostr Wallet Connect. \n\t2. Δημιουργία σύνδεσης: Μεταβείτε στην εφαρμογή πορτοφολιού σας και δημιουργήστε μια νέα σύνδεση NWC. \n\t3. Σύνδεση με το Amethyst: Το πορτοφόλι σας συνήθως θα σας δώσει τρεις επιλογές: \n\t\t3.1 Αυτόματη σύνδεση: Ένα κουμπί για αυτόματο άνοιγμα και σύνδεση με το Amethyst. Αν ναι, κάντε κλικ σε αυτό το κουμπί, ανοίξτε το Amethyst και πατήστε αποθήκευση στη νέα οθόνη. \n\t\t3.2 Χειροκίνητη σύνδεση: Ένα URI σύνδεσης που μπορείτε να αντιγράψετε και να κάνετε κλικ στο εικονίδιο επικόλλησης σε αυτή την οθόνη για απευθείας εισαγωγή. \n\t\t3.3 Κωδικός QR: Το πορτοφόλι δημιουργεί κωδικό QR τον οποίο μπορείτε να σαρώσετε από το κουμπί κωδικού QR σε αυτή την οθόνη.</string> <string name="create">Δημιουργία</string> <string name="d">η</string> <string name="danger_zone">Επικίνδυνη ζώνη</string> @@ -2653,11 +2635,8 @@ <string name="proxy_section">Relay Διαμεσολαβητή</string> <string name="proxy_section_explainer">Relay συγκεντρωτές που η εφαρμογή πρέπει να χρησιμοποιεί για να κατεβάσει τις τροφοδοσίες σας, όπως filter.nostr.wine. Αυτό αντικαθιστά το μοντέλο outbox και θα κάνει την εφαρμογή να συνδέεται μόνο στα relay στις λίστες σας.</string> <string name="public_chat">Δημόσια Συζήτηση</string> - <string name="public_chat_explainer">Οι δημόσιες συνομιλίες είναι ορατές σε όλους στο Nostr και οποιοσδήποτε - μπορεί να συμμετάσχει σε αυτές. Είναι ιδανικές για ανοιχτές κοινότητες γύρω από συγκεκριμένα θέματα. - Η εποπτεία μπορεί να ελεγχθεί με διαγραφή αναρτήσεων στα relay της</string> - <string name="public_chat_relays_explainer">Εισάγετε 1–3 relay που φιλοξενούν αυτή την ομάδα. - Οι πελάτες Nostr χρησιμοποιούν αυτή τη ρύθμιση για να γνωρίζουν πού να κατεβάσουν μηνύματα και πού να στέλνουν τα μηνύματά σου.</string> + <string name="public_chat_explainer">Οι δημόσιες συνομιλίες είναι ορατές σε όλους στο Nostr και οποιοσδήποτε μπορεί να συμμετάσχει σε αυτές. Είναι ιδανικές για ανοιχτές κοινότητες γύρω από συγκεκριμένα θέματα. Η εποπτεία μπορεί να ελεγχθεί με διαγραφή αναρτήσεων στα relay της</string> + <string name="public_chat_relays_explainer">Εισάγετε 1–3 relay που φιλοξενούν αυτή την ομάδα. Οι πελάτες Nostr χρησιμοποιούν αυτή τη ρύθμιση για να γνωρίζουν πού να κατεβάσουν μηνύματα και πού να στέλνουν τα μηνύματά σου.</string> <string name="public_chat_title">Μεταδεδομένα δημόσιας συνομιλίας</string> <string name="public_chats">Δημόσιες Συνομιλίες</string> <string name="public_home_section">Δημόσια Relay Εξερχόμενων/Αρχικής</string> @@ -2681,10 +2660,7 @@ <string name="read_only_user">Χρήστης μόνο για ανάγνωση</string> <string name="record_a_message_description">Πάτα παρατεταμένα για να καταγράψεις ένα μήνυμα</string> <string name="relay_chat">Συνομιλία relay</string> - <string name="relay_chat_explainer">Οι συνομιλίες relay είναι ομάδες συνομιλίας που ελέγχονται από το αρχικό τους relay. - Είναι ορατές σε όλους στο Nostr και οποιοσδήποτε μπορεί να συμμετάσχει σε αυτές. - Είναι ιδανικές για ανοιχτές κοινότητες γύρω από συγκεκριμένα θέματα. Ορισμένες από αυτές τις ομάδες είναι εφήμερες - και έτσι τα μηνύματα συνομιλίας εξαφανίζονται με την πάροδο του χρόνου</string> + <string name="relay_chat_explainer">Οι συνομιλίες relay είναι ομάδες συνομιλίας που ελέγχονται από το αρχικό τους relay. Είναι ορατές σε όλους στο Nostr και οποιοσδήποτε μπορεί να συμμετάσχει σε αυτές. Είναι ιδανικές για ανοιχτές κοινότητες γύρω από συγκεκριμένα θέματα. Ορισμένες από αυτές τις ομάδες είναι εφήμερες και έτσι τα μηνύματα συνομιλίας εξαφανίζονται με την πάροδο του χρόνου</string> <string name="relay_chat_title">Συνομιλίες relay</string> <string name="relay_management_tab_events">Συμβάντα</string> <string name="relay_management_tab_pubkeys">Χρήστες</string> diff --git a/commonsUI/src/commonMain/composeResources/values-eo-rUY/strings.xml b/commonsUI/src/commonMain/composeResources/values-eo-rUY/strings.xml index e55ddcf03c..35481e4172 100644 --- a/commonsUI/src/commonMain/composeResources/values-eo-rUY/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-eo-rUY/strings.xml @@ -225,7 +225,7 @@ <string name="copy_user_id">Kopii ID de uzanto</string> <string name="unblock_user">Malbloki Uzanton</string> <string name="user_is_blocked_hidden">Tiu ĉi uzanto estas blokita/silentita. Iliaj afiŝoj estas kaŝitaj.</string> - <string name="npub_hex_username">npub, hekso, uzantnomo </string> + <string name="npub_hex_username">npub, hekso, uzantnomo</string> <string name="clear">Klarigi</string> <string name="app_logo">Logo de Apo</string> <string name="nsec_npub_hex_private_key">nsec / npub / heksa privata ŝlosilo</string> @@ -273,15 +273,8 @@ <string name="mark_all_known_as_read">Marki ĉiujn Konatajn legitaj</string> <string name="mark_all_new_as_read">Marki ĉiujn Novajn legitaj</string> <string name="mark_all_as_read">Marki ĉiujn legitajn</string> - <string name="account_backup_tips2_md"> ## Konsiletoj pri Ŝlosila Sekurkopiao kaj Sekureco - \n\nVia konto estas sekurigita per sekreta ŝlosilo. La ŝlosilo estas longa sinsekvo de signoj komencanta per **nsec1**. Ĉiu kiu havas aliron al ĉi tiu sekreta ŝlosilo povas afiŝi kaj ŝanĝi vian identecon. - \n\n- **Ne** metu vian sekretan ŝlosilon en ajnan retejon aŭ programaron, kiun vi ne fidas. - \n- Amethyst-programistoj **neniam** petos vian sekretan ŝlosilon. - \n- **Faru** sekuran sekurkopion de via sekreta ŝlosilo por reakiro de konto. Ni rekomendas uzi pasvortan administrilon. - </string> - <string name="account_backup_tips3_md"> Por plia sekureco, vi povas ĉifri vian ŝlosilon per pasvorto. Ĉi tiu ŝlosilo komenciĝas per **ncryptsec1** kaj ne povas esti uzata sen via pasvorto. - \n\nSe vi perdas vian pasvorton, vi ne povos reakiri vian ŝlosilon. - </string> + <string name="account_backup_tips2_md">## Konsiletoj pri Ŝlosila Sekurkopiao kaj Sekureco \n\nVia konto estas sekurigita per sekreta ŝlosilo. La ŝlosilo estas longa sinsekvo de signoj komencanta per **nsec1**. Ĉiu kiu havas aliron al ĉi tiu sekreta ŝlosilo povas afiŝi kaj ŝanĝi vian identecon. \n\n- **Ne** metu vian sekretan ŝlosilon en ajnan retejon aŭ programaron, kiun vi ne fidas. \n- Amethyst-programistoj **neniam** petos vian sekretan ŝlosilon. \n- **Faru** sekuran sekurkopion de via sekreta ŝlosilo por reakiro de konto. Ni rekomendas uzi pasvortan administrilon.</string> + <string name="account_backup_tips3_md">Por plia sekureco, vi povas ĉifri vian ŝlosilon per pasvorto. Ĉi tiu ŝlosilo komenciĝas per **ncryptsec1** kaj ne povas esti uzata sen via pasvorto. \n\nSe vi perdas vian pasvorton, vi ne povos reakiri vian ŝlosilon.</string> <string name="encrypt_and_copy_my_secret_key">Ĉifri kaj kopii mian seketan ŝlosilon</string> <string name="badge_award_image_for">Ŝildeto-premia bildo por %1$s</string> <string name="badge_award_image">"Insigna premibildeto</string> @@ -971,9 +964,7 @@ <string name="push_server_none_explainer">Malaktivigi Puŝajn Sciigojn</string> <string name="push_server_uses_app_explainer">Uzas aplikaĵon %1$s</string> <string name="push_server_install_app">Puŝa Sciig-Agordo</string> - <string name="push_server_install_app_description"> Por ricevi puŝajn sciigojn, instalu ajnan aplikaĵon kiu subtenas [Unified Push](https://unifiedpush.org/), kiel ekzemple [Ntfy](https://ntfy.sh/). - Post instalado, elektu la aplikaĵon, kiun vi volas uzi en la Agordoj. - </string> + <string name="push_server_install_app_description">Por ricevi puŝajn sciigojn, instalu ajnan aplikaĵon kiu subtenas [Unified Push](https://unifiedpush.org/), kiel ekzemple [Ntfy](https://ntfy.sh/). Post instalado, elektu la aplikaĵon, kiun vi volas uzi en la Agordoj.</string> <string name="thread_title">Fadeno</string> <string name="send_the_seller_a_message">Sendi mesaĝon al la vendisto</string> <string name="hi_there_is_this_still_available">Saluton, ĉu ĉi tio ankoraŭ disponeblas?</string> @@ -2031,15 +2022,7 @@ <string name="could_not_fetch_invoice_from_details">Ne eblis preni fakturon de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Ne eblis malfermi la kunpremitan dosieron</string> <string name="couldnt_find_nwc_wallets">Monujo ne trovita</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst ne povis trovi ajnajn monujo-aplikojn, kiuj subtenas Nostr Wallet Connect (NWC). -\n\nKion vi povas fari: -\n\t1. Kontrolu NWC-subtenon: Duoble kontrolu, ĉu via preferata monujo-aplikaĵo estas kongrua kun Nostr Wallet Connect. -\n\t2. Krei Konekton: Iru al via monujo-aplikaĵo kaj kreu novan NWC-konekton. -\n\t3. Ligi al Amethyst: Via monujo kutime donos al vi tri opciojn: -\n\t\t3.1 Aŭtomata Ligo: Butono por aŭtomate malfermi kaj konekti al Amethyst. Se jes, alklaku tiun butonon, malfermu Amethyst kaj alklaku konservi sur la nova ekrano. -\n\t\t3.2 Mana Ligo: Konekta URI, kiun vi povas kopii kaj alklaki la algluu-ikonon sur ĉi tiu ekrano por rekte enigi ĝin. -\n\t\t3.3 QR-Kodo: La monujo kreas QR-kodon, kiun vi povas legi per la QR-koda butono sur ĉi tiu ekrano. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst ne povis trovi ajnajn monujo-aplikojn, kiuj subtenas Nostr Wallet Connect (NWC). \n\nKion vi povas fari: \n\t1. Kontrolu NWC-subtenon: Duoble kontrolu, ĉu via preferata monujo-aplikaĵo estas kongrua kun Nostr Wallet Connect. \n\t2. Krei Konekton: Iru al via monujo-aplikaĵo kaj kreu novan NWC-konekton. \n\t3. Ligi al Amethyst: Via monujo kutime donos al vi tri opciojn: \n\t\t3.1 Aŭtomata Ligo: Butono por aŭtomate malfermi kaj konekti al Amethyst. Se jes, alklaku tiun butonon, malfermu Amethyst kaj alklaku konservi sur la nova ekrano. \n\t\t3.2 Mana Ligo: Konekta URI, kiun vi povas kopii kaj alklaki la algluu-ikonon sur ĉi tiu ekrano por rekte enigi ĝin. \n\t\t3.3 QR-Kodo: La monujo kreas QR-kodon, kiun vi povas legi per la QR-koda butono sur ĉi tiu ekrano.</string> <string name="create">Krei</string> <string name="d">t</string> <string name="danger_zone">Danĝera Zono</string> @@ -2701,11 +2684,8 @@ <string name="proxy_section">Prokuro-Relay-oj</string> <string name="proxy_section_explainer">Agregataj relay-oj, kiujn la aplikaĵo devas uzi por elŝuti viajn fluojn, ekzemple filter.nostr.wine. Ĉi tio anstataŭas la sendkesta modelon kaj igos la aplikaĵon konektiĝi nur al la relay-oj en viaj listoj.</string> <string name="public_chat">Publika Babilado</string> - <string name="public_chat_explainer">Publikaj babilejoj estas videblaj al ĉiuj en Nostr kaj ĉiu ajn - povas partopreni en ili. Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. - Moderado povas esti kontrolata per forigo de afiŝoj sur siaj relays</string> - <string name="public_chat_relays_explainer">Enigu inter 1–3 relays, kiuj gastigas ĉi tiun grupon. - Nostr-klientoj uzas ĉi tiun agordon por scii, kie elŝuti mesaĝojn kaj kien sendi viajn mesaĝojn.</string> + <string name="public_chat_explainer">Publikaj babilejoj estas videblaj al ĉiuj en Nostr kaj ĉiu ajn povas partopreni en ili. Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. Moderado povas esti kontrolata per forigo de afiŝoj sur siaj relays</string> + <string name="public_chat_relays_explainer">Enigu inter 1–3 relays, kiuj gastigas ĉi tiun grupon. Nostr-klientoj uzas ĉi tiun agordon por scii, kie elŝuti mesaĝojn kaj kien sendi viajn mesaĝojn.</string> <string name="public_chat_relays_title">Relay-oj</string> <string name="public_chat_title">Publikaj Babilejaj Metadatenoj</string> <string name="public_chats">Publikaj Babilejoj</string> @@ -2730,10 +2710,7 @@ <string name="read_only_user">Nur-lega uzanto</string> <string name="record_a_message_description">Alklaku kaj tenu por registri mesaĝon</string> <string name="relay_chat">Relay-Babilejo</string> - <string name="relay_chat_explainer">Relay-babilejoj estas babilaj grupoj kontrolataj de sia hejma relay. - Ili estas videblaj al ĉiuj en Nostr kaj ĉiu ajn povas partopreni en ili. - Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. Kelkaj el ĉi tiuj grupoj estas efemeraj - kaj tial babilmesaĝoj malaperas kun la tempo</string> + <string name="relay_chat_explainer">Relay-babilejoj estas babilaj grupoj kontrolataj de sia hejma relay. Ili estas videblaj al ĉiuj en Nostr kaj ĉiu ajn povas partopreni en ili. Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. Kelkaj el ĉi tiuj grupoj estas efemeraj kaj tial babilmesaĝoj malaperas kun la tempo</string> <string name="relay_chat_title">Relay-Babilejaroj</string> <string name="relay_management_tab_events">Eventoj</string> <string name="relay_management_tab_ips">IP-oj</string> diff --git a/commonsUI/src/commonMain/composeResources/values-eo/strings.xml b/commonsUI/src/commonMain/composeResources/values-eo/strings.xml index f9cf0c8844..ef18a4b455 100644 --- a/commonsUI/src/commonMain/composeResources/values-eo/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-eo/strings.xml @@ -211,7 +211,7 @@ <string name="copy_user_id">Kopii ID de uzanto</string> <string name="unblock_user">Malbloki Uzanton</string> <string name="user_is_blocked_hidden">Tiu ĉi uzanto estas blokita/silentita. Iliaj afiŝoj estas kaŝitaj.</string> - <string name="npub_hex_username">npub, hekso, uzantnomo </string> + <string name="npub_hex_username">npub, hekso, uzantnomo</string> <string name="clear">Klarigi</string> <string name="app_logo">Logo de Apo</string> <string name="nsec_npub_hex_private_key">nsec / npub / heksa privata ŝlosilo</string> @@ -259,17 +259,8 @@ <string name="mark_all_known_as_read">Marki ĉiujn Konatajn legitaj</string> <string name="mark_all_new_as_read">Marki ĉiujn Novajn legitaj</string> <string name="mark_all_as_read">Marki ĉiujn legitajn</string> - <string name="account_backup_tips2_md"> - ## Konsiletoj pri Ŝlosila Sekurkopiao kaj Sekureco - \n\nVia konto estas sekurigita per sekreta ŝlosilo. La ŝlosilo estas longa sinsekvo de signoj komencanta per **nsec1**. Ĉiu kiu havas aliron al ĉi tiu sekreta ŝlosilo povas afiŝi kaj ŝanĝi vian identecon. - \n\n- **Ne** metu vian sekretan ŝlosilon en ajnan retejon aŭ programaron, kiun vi ne fidas. - \n- Amethyst-programistoj **neniam** petos vian sekretan ŝlosilon. - \n- **Faru** sekuran sekurkopion de via sekreta ŝlosilo por reakiro de konto. Ni rekomendas uzi pasvortan administrilon. - </string> - <string name="account_backup_tips3_md"> - Por plia sekureco, vi povas ĉifri vian ŝlosilon per pasvorto. Ĉi tiu ŝlosilo komenciĝas per **ncryptsec1** kaj ne povas esti uzata sen via pasvorto. - \n\nSe vi perdas vian pasvorton, vi ne povos reakiri vian ŝlosilon. - </string> + <string name="account_backup_tips2_md">## Konsiletoj pri Ŝlosila Sekurkopiao kaj Sekureco \n\nVia konto estas sekurigita per sekreta ŝlosilo. La ŝlosilo estas longa sinsekvo de signoj komencanta per **nsec1**. Ĉiu kiu havas aliron al ĉi tiu sekreta ŝlosilo povas afiŝi kaj ŝanĝi vian identecon. \n\n- **Ne** metu vian sekretan ŝlosilon en ajnan retejon aŭ programaron, kiun vi ne fidas. \n- Amethyst-programistoj **neniam** petos vian sekretan ŝlosilon. \n- **Faru** sekuran sekurkopion de via sekreta ŝlosilo por reakiro de konto. Ni rekomendas uzi pasvortan administrilon.</string> + <string name="account_backup_tips3_md">Por plia sekureco, vi povas ĉifri vian ŝlosilon per pasvorto. Ĉi tiu ŝlosilo komenciĝas per **ncryptsec1** kaj ne povas esti uzata sen via pasvorto. \n\nSe vi perdas vian pasvorton, vi ne povos reakiri vian ŝlosilon.</string> <string name="encrypt_and_copy_my_secret_key">Ĉifri kaj kopii mian seketan ŝlosilon</string> <string name="badge_award_image_for">Ŝildeto-premia bildo por %1$s</string> <string name="badge_award_image">"Insigna premibildeto</string> @@ -962,10 +953,7 @@ <string name="push_server_none_explainer">Malaktivigi Puŝajn Sciigojn</string> <string name="push_server_uses_app_explainer">Uzas aplikaĵon %1$s</string> <string name="push_server_install_app">Puŝa Sciig-Agordo</string> - <string name="push_server_install_app_description"> - Por ricevi puŝajn sciigojn, instalu ajnan aplikaĵon kiu subtenas [Unified Push](https://unifiedpush.org/), kiel ekzemple [Ntfy](https://ntfy.sh/). - Post instalado, elektu la aplikaĵon, kiun vi volas uzi en la Agordoj. - </string> + <string name="push_server_install_app_description">Por ricevi puŝajn sciigojn, instalu ajnan aplikaĵon kiu subtenas [Unified Push](https://unifiedpush.org/), kiel ekzemple [Ntfy](https://ntfy.sh/). Post instalado, elektu la aplikaĵon, kiun vi volas uzi en la Agordoj.</string> <string name="thread_title">Fadeno</string> <string name="send_the_seller_a_message">Sendi mesaĝon al la vendisto</string> <string name="hi_there_is_this_still_available">Saluton, ĉu ĉi tio ankoraŭ disponeblas?</string> @@ -2058,15 +2046,7 @@ <string name="could_not_fetch_invoice_from_details">Ne eblis preni fakturon de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Ne eblis malfermi la kunpremitan dosieron</string> <string name="couldnt_find_nwc_wallets">Monujo ne trovita</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst ne povis trovi ajnajn monujo-aplikojn, kiuj subtenas Nostr Wallet Connect (NWC). -\n\nKion vi povas fari: -\n\t1. Kontrolu NWC-subtenon: Duoble kontrolu, ĉu via preferata monujo-aplikaĵo estas kongrua kun Nostr Wallet Connect. -\n\t2. Krei Konekton: Iru al via monujo-aplikaĵo kaj kreu novan NWC-konekton. -\n\t3. Ligi al Amethyst: Via monujo kutime donos al vi tri opciojn: -\n\t\t3.1 Aŭtomata Ligo: Butono por aŭtomate malfermi kaj konekti al Amethyst. Se jes, alklaku tiun butonon, malfermu Amethyst kaj alklaku konservi sur la nova ekrano. -\n\t\t3.2 Mana Ligo: Konekta URI, kiun vi povas kopii kaj alklaki la algluu-ikonon sur ĉi tiu ekrano por rekte enigi ĝin. -\n\t\t3.3 QR-Kodo: La monujo kreas QR-kodon, kiun vi povas legi per la QR-koda butono sur ĉi tiu ekrano. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst ne povis trovi ajnajn monujo-aplikojn, kiuj subtenas Nostr Wallet Connect (NWC). \n\nKion vi povas fari: \n\t1. Kontrolu NWC-subtenon: Duoble kontrolu, ĉu via preferata monujo-aplikaĵo estas kongrua kun Nostr Wallet Connect. \n\t2. Krei Konekton: Iru al via monujo-aplikaĵo kaj kreu novan NWC-konekton. \n\t3. Ligi al Amethyst: Via monujo kutime donos al vi tri opciojn: \n\t\t3.1 Aŭtomata Ligo: Butono por aŭtomate malfermi kaj konekti al Amethyst. Se jes, alklaku tiun butonon, malfermu Amethyst kaj alklaku konservi sur la nova ekrano. \n\t\t3.2 Mana Ligo: Konekta URI, kiun vi povas kopii kaj alklaki la algluu-ikonon sur ĉi tiu ekrano por rekte enigi ĝin. \n\t\t3.3 QR-Kodo: La monujo kreas QR-kodon, kiun vi povas legi per la QR-koda butono sur ĉi tiu ekrano.</string> <string name="create">Krei</string> <string name="d">t</string> <string name="danger_zone">Danĝera Zono</string> @@ -2754,11 +2734,8 @@ <string name="proxy_section">Prokuro-Relay-oj</string> <string name="proxy_section_explainer">Agregataj relay-oj, kiujn la aplikaĵo devas uzi por elŝuti viajn fluojn, ekzemple filter.nostr.wine. Ĉi tio anstataŭas la sendkesta modelon kaj igos la aplikaĵon konektiĝi nur al la relay-oj en viaj listoj.</string> <string name="public_chat">Publika Babilado</string> - <string name="public_chat_explainer">Publikaj babilejoj estas videblaj al ĉiuj en Nostr kaj ĉiu ajn - povas partopreni en ili. Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. - Moderado povas esti kontrolata per forigo de afiŝoj sur siaj relays</string> - <string name="public_chat_relays_explainer">Enigu inter 1–3 relays, kiuj gastigas ĉi tiun grupon. - Nostr-klientoj uzas ĉi tiun agordon por scii, kie elŝuti mesaĝojn kaj kien sendi viajn mesaĝojn.</string> + <string name="public_chat_explainer">Publikaj babilejoj estas videblaj al ĉiuj en Nostr kaj ĉiu ajn povas partopreni en ili. Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. Moderado povas esti kontrolata per forigo de afiŝoj sur siaj relays</string> + <string name="public_chat_relays_explainer">Enigu inter 1–3 relays, kiuj gastigas ĉi tiun grupon. Nostr-klientoj uzas ĉi tiun agordon por scii, kie elŝuti mesaĝojn kaj kien sendi viajn mesaĝojn.</string> <string name="public_chat_relays_title">Relay-oj</string> <string name="public_chat_title">Publikaj Babilejaj Metadatenoj</string> <string name="public_chats">Publikaj Babilejoj</string> @@ -2783,10 +2760,7 @@ <string name="read_only_user">Nur-lega uzanto</string> <string name="record_a_message_description">Alklaku kaj tenu por registri mesaĝon</string> <string name="relay_chat">Relay-Babilejo</string> - <string name="relay_chat_explainer">Relay-babilejoj estas babilaj grupoj kontrolataj de sia hejma relay. - Ili estas videblaj al ĉiuj en Nostr kaj ĉiu ajn povas partopreni en ili. - Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. Kelkaj el ĉi tiuj grupoj estas efemeraj - kaj tial babilmesaĝoj malaperas kun la tempo</string> + <string name="relay_chat_explainer">Relay-babilejoj estas babilaj grupoj kontrolataj de sia hejma relay. Ili estas videblaj al ĉiuj en Nostr kaj ĉiu ajn povas partopreni en ili. Ili estas bonegaj por malfermitaj komunumoj pri specifaj temoj. Kelkaj el ĉi tiuj grupoj estas efemeraj kaj tial babilmesaĝoj malaperas kun la tempo</string> <string name="relay_chat_title">Relay-Babilejaroj</string> <string name="relay_management_tab_events">Eventoj</string> <string name="relay_management_tab_ips">IP-oj</string> diff --git a/commonsUI/src/commonMain/composeResources/values-es-rES/strings.xml b/commonsUI/src/commonMain/composeResources/values-es-rES/strings.xml index ee9c2f0a5b..45b069c10c 100644 --- a/commonsUI/src/commonMain/composeResources/values-es-rES/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-es-rES/strings.xml @@ -224,7 +224,7 @@ <string name="copy_user_id">Copiar ID de usuario</string> <string name="unblock_user">Desbloquear usuario</string> <string name="user_is_blocked_hidden">Este usuario está bloqueado/silenciado. Sus publicaciones están ocultas.</string> - <string name="npub_hex_username">npub, hex, username </string> + <string name="npub_hex_username">npub, hex, username</string> <string name="clear">Limpiar</string> <string name="app_logo">Logo de la app</string> <string name="nsec_npub_hex_private_key">nsec o npub</string> @@ -272,15 +272,8 @@ <string name="mark_all_known_as_read">Marcar los conocidos como leídos</string> <string name="mark_all_new_as_read">Marcar los nuevos como leídos</string> <string name="mark_all_as_read">Marcar todos como leídos</string> - <string name="account_backup_tips2_md"> ## Consejos sobre la protección y la copia de seguridad de las claves - \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. - \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. - \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. - \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas. - </string> - <string name="account_backup_tips3_md"> Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. - \n\nSi pierdes la contraseña, no podrás recuperar tu clave. - </string> + <string name="account_backup_tips2_md">## Consejos sobre la protección y la copia de seguridad de las claves \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas.</string> + <string name="account_backup_tips3_md">Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. \n\nSi pierdes la contraseña, no podrás recuperar tu clave.</string> <string name="encrypt_and_copy_my_secret_key">Cifrar y copiar mi clave secreta</string> <string name="badge_award_image_for">Imagen del Badge para %1$s</string> <string name="badge_award_image">"Imagen de premio de insignia</string> @@ -962,9 +955,7 @@ <string name="push_server_none_explainer">Desactiva las notificaciones push</string> <string name="push_server_uses_app_explainer">Usa la app %1$s</string> <string name="push_server_install_app">Configuración de notificaciones push</string> - <string name="push_server_install_app_description"> Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). - Tras la instalación, selecciona la aplicación que deseas usar en la configuración. - </string> + <string name="push_server_install_app_description">Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). Tras la instalación, selecciona la aplicación que deseas usar en la configuración.</string> <string name="thread_title">Conversación</string> <string name="send_the_seller_a_message">Envía un mensaje al vendedor</string> <string name="hi_there_is_this_still_available">Hola, ¿esto todavía está disponible?</string> @@ -2028,15 +2019,7 @@ <string name="could_not_fetch_invoice_from_details">No se ha podido obtener la factura de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">No se pudo abrir el archivo comprimido</string> <string name="couldnt_find_nwc_wallets">Cartera no encontrada</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). -\n\nQué puedes hacer: -\n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. -\n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. -\n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: -\n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. -\n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. -\n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). \n\nQué puedes hacer: \n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. \n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. \n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: \n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. \n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. \n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla.</string> <string name="create">Crear</string> <string name="d">d</string> <string name="danger_zone">Zona peligrosa</string> @@ -2715,11 +2698,8 @@ <string name="proxy_section">Relés de proxy</string> <string name="proxy_section_explainer">Relés recopiladores que la app debe usar para descargar tus fuentes, como filter.nostr.wine. Esto reemplaza el modelo de bandeja de salida y hará que la app se conecte solo a los relés de tus listas.</string> <string name="public_chat">Chat público</string> - <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera - puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. - La moderación puede controlarse eliminando publicaciones en sus relés.</string> - <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. - Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> + <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. La moderación puede controlarse eliminando publicaciones en sus relés.</string> + <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> <string name="public_chat_relays_title">Relés</string> <string name="public_chat_title">Metadatos públicos del chat</string> <string name="public_chats">Chats públicos</string> @@ -2744,10 +2724,7 @@ <string name="read_only_user">Usuario de solo lectura</string> <string name="record_a_message_description">Haz clic y mantén pulsado para grabar un mensaje</string> <string name="relay_chat">Chat en relé</string> - <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. - Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. - Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros - y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> + <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> <string name="relay_chat_title">Chats en relé</string> <string name="relay_management_tab_events">Eventos</string> <string name="relay_management_tab_kinds">Tipos</string> diff --git a/commonsUI/src/commonMain/composeResources/values-es-rMX/strings.xml b/commonsUI/src/commonMain/composeResources/values-es-rMX/strings.xml index f3e6fa1ca8..d941f9ea99 100644 --- a/commonsUI/src/commonMain/composeResources/values-es-rMX/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-es-rMX/strings.xml @@ -272,15 +272,8 @@ <string name="mark_all_known_as_read">Marcar todos los conocidos como leídos</string> <string name="mark_all_new_as_read">Marcar todos los nuevos como leídos</string> <string name="mark_all_as_read">Marcar todos como leídos</string> - <string name="account_backup_tips2_md"> ## Consejos sobre la protección y la copia de seguridad de las claves - \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. - \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. - \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. - \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas. - </string> - <string name="account_backup_tips3_md"> Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. - \n\nSi pierdes la contraseña, no podrás recuperar tu clave. - </string> + <string name="account_backup_tips2_md">## Consejos sobre la protección y la copia de seguridad de las claves \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas.</string> + <string name="account_backup_tips3_md">Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. \n\nSi pierdes la contraseña, no podrás recuperar tu clave.</string> <string name="encrypt_and_copy_my_secret_key">Cifrar y copiar mi clave secreta</string> <string name="badge_award_image_for">Imagen de premio de insignia por %1$s</string> <string name="badge_award_image">"Imagen de premio de insignia</string> @@ -961,9 +954,7 @@ <string name="push_server_none_explainer">Desactiva las notificaciones push</string> <string name="push_server_uses_app_explainer">Usa la app %1$s</string> <string name="push_server_install_app">Configuración de notificaciones push</string> - <string name="push_server_install_app_description"> Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). - Tras la instalación, selecciona la aplicación que deseas usar en la configuración. - </string> + <string name="push_server_install_app_description">Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). Tras la instalación, selecciona la aplicación que deseas usar en la configuración.</string> <string name="thread_title">Hilo</string> <string name="send_the_seller_a_message">Envía un mensaje al vendedor</string> <string name="hi_there_is_this_still_available">Hola, ¿esto todavía está disponible?</string> @@ -2027,15 +2018,7 @@ <string name="could_not_fetch_invoice_from_details">No se pudo obtener la factura de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">No se pudo abrir el archivo comprimido</string> <string name="couldnt_find_nwc_wallets">Billetera no encontrada</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). -\n\nQué puedes hacer: -\n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. -\n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. -\n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: -\n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. -\n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. -\n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). \n\nQué puedes hacer: \n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. \n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. \n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: \n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. \n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. \n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla.</string> <string name="create">Crear</string> <string name="d">d</string> <string name="danger_zone">Zona peligrosa</string> @@ -2708,11 +2691,8 @@ <string name="proxy_section">Relés de proxy</string> <string name="proxy_section_explainer">Relés recopiladores que la app debe usar para descargar tus feeds, como filter.nostr.wine. Esto reemplaza el modelo de bandeja de salida y hará que la app se conecte solo a los relés de tus listas.</string> <string name="public_chat">Chat público</string> - <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera - puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. - La moderación puede controlarse eliminando publicaciones en sus relés.</string> - <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. - Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> + <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. La moderación puede controlarse eliminando publicaciones en sus relés.</string> + <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> <string name="public_chat_relays_title">Relés</string> <string name="public_chat_title">Metadatos públicos del chat</string> <string name="public_chats">Chats públicos</string> @@ -2737,10 +2717,7 @@ <string name="read_only_user">Usuario de solo lectura</string> <string name="record_a_message_description">Haz clic y mantén presionado para grabar un mensaje</string> <string name="relay_chat">Chat en relé</string> - <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. - Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. - Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros - y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> + <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> <string name="relay_chat_title">Chats en relé</string> <string name="relay_management_tab_events">Eventos</string> <string name="relay_management_tab_kinds">Tipos</string> diff --git a/commonsUI/src/commonMain/composeResources/values-es-rUS/strings.xml b/commonsUI/src/commonMain/composeResources/values-es-rUS/strings.xml index a86f5c2aaf..3e6060ab9c 100644 --- a/commonsUI/src/commonMain/composeResources/values-es-rUS/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-es-rUS/strings.xml @@ -272,15 +272,8 @@ <string name="mark_all_known_as_read">Marcar todos los conocidos como leídos</string> <string name="mark_all_new_as_read">Marcar todos los nuevos como leídos</string> <string name="mark_all_as_read">Marcar todos como leídos</string> - <string name="account_backup_tips2_md"> ## Consejos sobre la protección y la copia de seguridad de las claves - \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. - \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. - \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. - \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas. - </string> - <string name="account_backup_tips3_md"> Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. - \n\nSi pierdes la contraseña, no podrás recuperar tu clave. - </string> + <string name="account_backup_tips2_md">## Consejos sobre la protección y la copia de seguridad de las claves \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas.</string> + <string name="account_backup_tips3_md">Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. \n\nSi pierdes la contraseña, no podrás recuperar tu clave.</string> <string name="encrypt_and_copy_my_secret_key">Cifrar y copiar mi clave secreta</string> <string name="badge_award_image_for">Imagen de premio de insignia por %1$s</string> <string name="badge_award_image">"Imagen de premio de insignia</string> @@ -961,9 +954,7 @@ <string name="push_server_none_explainer">Desactiva las notificaciones push</string> <string name="push_server_uses_app_explainer">Usa la app %1$s</string> <string name="push_server_install_app">Configuración de notificaciones push</string> - <string name="push_server_install_app_description"> Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). - Tras la instalación, selecciona la aplicación que deseas usar en la configuración. - </string> + <string name="push_server_install_app_description">Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). Tras la instalación, selecciona la aplicación que deseas usar en la configuración.</string> <string name="thread_title">Hilo</string> <string name="send_the_seller_a_message">Envía un mensaje al vendedor</string> <string name="hi_there_is_this_still_available">Hola, ¿esto todavía está disponible?</string> @@ -2027,15 +2018,7 @@ <string name="could_not_fetch_invoice_from_details">No se pudo obtener la factura de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">No se pudo abrir el archivo comprimido</string> <string name="couldnt_find_nwc_wallets">Billetera no encontrada</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). -\n\nQué puedes hacer: -\n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. -\n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. -\n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: -\n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. -\n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. -\n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). \n\nQué puedes hacer: \n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. \n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. \n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: \n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. \n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. \n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla.</string> <string name="create">Crear</string> <string name="d">d</string> <string name="danger_zone">Zona peligrosa</string> @@ -2708,11 +2691,8 @@ <string name="proxy_section">Relés de proxy</string> <string name="proxy_section_explainer">Relés recopiladores que la app debe usar para descargar tus feeds, como filter.nostr.wine. Esto reemplaza el modelo de bandeja de salida y hará que la app se conecte solo a los relés de tus listas.</string> <string name="public_chat">Chat público</string> - <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera - puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. - La moderación puede controlarse eliminando mensajes en sus relés.</string> - <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. - Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> + <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. La moderación puede controlarse eliminando mensajes en sus relés.</string> + <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> <string name="public_chat_relays_title">Relés</string> <string name="public_chat_title">Metadatos públicos del chat</string> <string name="public_chats">Chats públicos</string> @@ -2737,10 +2717,7 @@ <string name="read_only_user">Usuario de solo lectura</string> <string name="record_a_message_description">Haz clic y mantén presionado para grabar un mensaje</string> <string name="relay_chat">Chat en relé</string> - <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. - Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. - Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros - y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> + <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> <string name="relay_chat_title">Chats en relé</string> <string name="relay_management_tab_events">Eventos</string> <string name="relay_management_tab_kinds">Tipos</string> diff --git a/commonsUI/src/commonMain/composeResources/values-es/strings.xml b/commonsUI/src/commonMain/composeResources/values-es/strings.xml index d9570812e6..0f52873364 100644 --- a/commonsUI/src/commonMain/composeResources/values-es/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-es/strings.xml @@ -211,7 +211,7 @@ <string name="copy_user_id">Copiar ID de usuario</string> <string name="unblock_user">Desbloquear usuario</string> <string name="user_is_blocked_hidden">Este usuario está bloqueado/silenciado. Sus publicaciones están ocultas.</string> - <string name="npub_hex_username">npub, hex, username </string> + <string name="npub_hex_username">npub, hex, username</string> <string name="clear">Limpiar</string> <string name="app_logo">Logo de la app</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex private key</string> @@ -951,9 +951,7 @@ <string name="push_server_none_explainer">Desactiva las notificaciones push</string> <string name="push_server_uses_app_explainer">Usa la app %1$s</string> <string name="push_server_install_app">Configuración de notificaciones push</string> - <string name="push_server_install_app_description"> Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). - Tras la instalación, selecciona la aplicación que deseas usar en la configuración. - </string> + <string name="push_server_install_app_description">Para recibir notificaciones push, instala cualquier aplicación compatible con [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). Tras la instalación, selecciona la aplicación que deseas usar en la configuración.</string> <string name="thread_title">Conversación</string> <string name="send_the_seller_a_message">Envía un mensaje al vendedor</string> <string name="hi_there_is_this_still_available">Hola, ¿esto todavía está disponible?</string> @@ -1802,15 +1800,8 @@ <string name="ots_explorer_api_label">URL base de la API del explorador</string> <string name="dvm_pay_invoice_from_dvm">Pagar factura del DVM</string> <string name="dvm_pay_amount_to_dvm">Pagar %1$s sats al DVM</string> - <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips2_md" ns0:ignore="Typos"> ## Consejos sobre la protección y la copia de seguridad de las claves - \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. - \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. - \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. - \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas. - </string> - <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips3_md" ns0:ignore="Typos"> Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. - \n\nSi pierdes la contraseña, no podrás recuperar tu clave. - </string> + <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips2_md" ns0:ignore="Typos">## Consejos sobre la protección y la copia de seguridad de las claves \n\nTu cuenta está protegida por una clave secreta. La clave es una larga secuencia de caracteres que empieza por **nsec1**. Cualquiera que tenga acceso a esta clave secreta puede publicar y cambiar tu identidad. \n\n- **No** guardes la clave secreta en ningún sitio web o software en los que no confíes. \n- Los desarrolladores de Amethyst **nunca** te pedirán la clave secreta. \n- **Sí** puedes realizar una copia de seguridad de la clave secreta para recuperar la cuenta. Para ello, te recomendamos usar un gestor de contraseñas.</string> + <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips3_md" ns0:ignore="Typos">Para mayor seguridad, puedes cifrar la clave con una contraseña. Esta clave empieza por **ncryptsec1** y no puede utilizarse sin tu contraseña. \n\nSi pierdes la contraseña, no podrás recuperar tu clave.</string> <string name="use_direct_url">Usar URL directa</string> <string name="nsite_title">nSite: %1$s</string> <string name="napplet_card_title">nApplet: %1$s</string> @@ -2055,15 +2046,7 @@ <string name="could_not_fetch_invoice_from_details">No se ha podido obtener la factura de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">No se pudo abrir el archivo comprimido</string> <string name="couldnt_find_nwc_wallets">Cartera no encontrada</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). -\n\nQué puedes hacer: -\n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. -\n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. -\n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: -\n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. -\n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. -\n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst no encontró ninguna aplicación de cartera compatible con Nostr Wallet Connect (NWC). \n\nQué puedes hacer: \n\t1. Verificar la compatibilidad con NWC: Comprueba que tu aplicación de cartera preferida es compatible con Nostr Wallet Connect. \n\t2. Crear conexión: Ve a tu aplicación de cartera y crea una nueva conexión NWC. \n\t3. Vincular con Amethyst: Tu cartera normalmente te ofrecerá tres opciones: \n\t\t3.1 Enlace automático: Un botón para abrir y conectar automáticamente a Amethyst. Si es así, pulsa ese botón, abre Amethyst y guarda en la nueva pantalla. \n\t\t3.2 Enlace manual: Un URI de conexión que puedes copiar y pegar usando el icono de pegado en esta pantalla para introducirlo directamente. \n\t\t3.3 Código QR: La cartera genera un código QR que puedes leer con el botón de código QR en esta pantalla.</string> <string name="create">Crear</string> <string name="d">d</string> <string name="danger_zone">Zona peligrosa</string> @@ -2751,11 +2734,8 @@ <string name="proxy_section">Relés de proxy</string> <string name="proxy_section_explainer">Relés recopiladores que la app debe usar para descargar tus fuentes, como filter.nostr.wine. Esto reemplaza el modelo de bandeja de salida y hará que la app se conecte solo a los relés de tus listas.</string> <string name="public_chat">Chat público</string> - <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera - puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. - La moderación puede controlarse eliminando publicaciones en sus relés.</string> - <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. - Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> + <string name="public_chat_explainer">Los chats públicos son visibles para todos en Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas alrededor de temas específicos. La moderación puede controlarse eliminando publicaciones en sus relés.</string> + <string name="public_chat_relays_explainer">Inserta entre 1 y 3 relés que alojan este grupo. Los clientes de Nostr utilizan esta configuración para saber de dónde descargar y adónde enviar los mensajes.</string> <string name="public_chat_relays_title">Relés</string> <string name="public_chat_title">Metadatos públicos del chat</string> <string name="public_chats">Chats públicos</string> @@ -2780,10 +2760,7 @@ <string name="read_only_user">Usuario de solo lectura</string> <string name="record_a_message_description">Haz clic y mantén pulsado para grabar un mensaje</string> <string name="relay_chat">Chat en relé</string> - <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. - Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. - Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros - y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> + <string name="relay_chat_explainer">Los chats en relé son grupos de chat controlados por su relé de origen. Son visibles para todos los usuarios de Nostr y cualquiera puede participar en ellos. Son ideales para comunidades abiertas en torno a temas específicos. Algunos de estos grupos son efímeros y, por lo tanto, los mensajes del chat desaparecen con el tiempo</string> <string name="relay_chat_title">Chats en relé</string> <string name="relay_management_tab_events">Eventos</string> <string name="relay_management_tab_ips">IPs</string> diff --git a/commonsUI/src/commonMain/composeResources/values-fa-rIR/strings.xml b/commonsUI/src/commonMain/composeResources/values-fa-rIR/strings.xml index a92f92d82a..df5f3b4363 100644 --- a/commonsUI/src/commonMain/composeResources/values-fa-rIR/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-fa-rIR/strings.xml @@ -10,7 +10,7 @@ <!-- Accessibility --> <!-- Relay history paging (shared feed markers + status card) --> <!-- Notes & Replies --> - <string name="replying_to"> پاسخ به</string> + <string name="replying_to">پاسخ به</string> <!-- Static sites (NIP-5A) & napplets (NIP-5D) feed card --> <string name="napplet_card_permissions">مجوزها:</string> <string name="nsite_root_site">سایت اصلی</string> @@ -226,7 +226,7 @@ <string name="copy_user_id">کپی شناسه کاربر</string> <string name="unblock_user">از بلاک درآوردن کاربر</string> <string name="user_is_blocked_hidden">این کاربر مسدود/بی‌صدا شده است. پست‌های آن‌ها مخفی است.</string> - <string name="npub_hex_username">npub, hex, نام کاربری </string> + <string name="npub_hex_username">npub, hex, نام کاربری</string> <string name="clear">پاک کردن</string> <string name="app_logo">لوگوی اپ</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex کلید خصوصی</string> @@ -248,7 +248,7 @@ <string name="chats_reply_searching_history">در حال جستجوی پیام اصلی…</string> <string name="chats_reply_not_found">این پیام پیدا نشد</string> <string name="chats_reply_searched">همه relay ها جستجو شد · برای مشاهده ضربه بزنید</string> - <string name="error_loading_replies"> :خطا در بارگیری پاسخ ها</string> + <string name="error_loading_replies">:خطا در بارگیری پاسخ ها</string> <string name="try_again">دوباره تلاش کنید</string> <string name="notification_feed_is_empty">هنوز هیچ اعلانی نیست.</string> <string name="open_poll">نظرسنجی باز</string> @@ -274,14 +274,8 @@ <string name="mark_all_known_as_read">همه شناس ها خوانده شده کن</string> <string name="mark_all_new_as_read">همه جدیدها را خوانده شده کن</string> <string name="mark_all_as_read">همه را خوانده شده کن</string> - <string name="account_backup_tips2_md">نکات ایمنی و ذخیره کلید - -حساب کاربری شما با یک کلید خصوصی محافظت می شود. این کلید دنباله ای بلند از کاراکترها است که با **nsec1** آغاز می گردد. هر کس به این کلید خصوصی دسترسی داشته باشد می تواند بجای شما یادداشت پست کرده یا هویت شما را تغییر دهد. -هرگز کلید خصوصی خود را در هیچ وبسایت با نرم افزاری که به آن اطمینان ندارید **وارد نکنید**. -سازندگان امتیست **هرگز** کلیدتان را از شما نمی خواهند. -یک پشتیبان یدکی مخفی از کلید خود به منظور بازیابی **نگه دارید**. ما استفاده از نرم افزار مدیریت پسورد را توصیه می کنیم.</string> - <string name="account_backup_tips3_md">برای ایمنی بیشتر، می توانید کلید خود را با یک رمزعبور رمزنگاری کنید. این نوع کلید با **ncryptsec1** آغاز می شود و نمی تواند بدون رمز عبور شما استفاده شود. -اگر پسوردتان را گم کنید، نخواهید توانست کلیدتان را بازیابی کنید.</string> + <string name="account_backup_tips2_md">نکات ایمنی و ذخیره کلید حساب کاربری شما با یک کلید خصوصی محافظت می شود. این کلید دنباله ای بلند از کاراکترها است که با **nsec1** آغاز می گردد. هر کس به این کلید خصوصی دسترسی داشته باشد می تواند بجای شما یادداشت پست کرده یا هویت شما را تغییر دهد. هرگز کلید خصوصی خود را در هیچ وبسایت با نرم افزاری که به آن اطمینان ندارید **وارد نکنید**. سازندگان امتیست **هرگز** کلیدتان را از شما نمی خواهند. یک پشتیبان یدکی مخفی از کلید خود به منظور بازیابی **نگه دارید**. ما استفاده از نرم افزار مدیریت پسورد را توصیه می کنیم.</string> + <string name="account_backup_tips3_md">برای ایمنی بیشتر، می توانید کلید خود را با یک رمزعبور رمزنگاری کنید. این نوع کلید با **ncryptsec1** آغاز می شود و نمی تواند بدون رمز عبور شما استفاده شود. اگر پسوردتان را گم کنید، نخواهید توانست کلیدتان را بازیابی کنید.</string> <string name="encrypt_and_copy_my_secret_key">رمزنگاری و کپی کلید من</string> <string name="badge_award_image_for">تصویر مدال پاداش برای %1$s</string> <string name="badge_award_image">تصویر جایزه نشان</string> @@ -301,7 +295,7 @@ <string name="quick_action_request_deletion_gallery_title">حذف از گالری</string> <string name="quick_action_request_deletion_gallery_alert_body_v2">این رسانه را از گالری خود حذف کنید.</string> <string name="quick_action_request_deletion_alert_title">درخواست حذف</string> - <string name="quick_action_request_deletion_alert_body">آماتیست درخواست می کند که یادداشت شما از رله هایی که درحال حاضر به آن متصل هستید حذف شود. هیچ تضمینی نیست که یادداشت شما برای همیشه از آن رله ها یا از رله های دیگری که ممکن است در آنها ذخیره شده باشد حذف خواهد شد.. </string> + <string name="quick_action_request_deletion_alert_body">آماتیست درخواست می کند که یادداشت شما از رله هایی که درحال حاضر به آن متصل هستید حذف شود. هیچ تضمینی نیست که یادداشت شما برای همیشه از آن رله ها یا از رله های دیگری که ممکن است در آنها ذخیره شده باشد حذف خواهد شد..</string> <string name="quick_action_block_dialog_btn">بلاک</string> <string name="quick_action_delete_dialog_btn">حذف</string> <string name="quick_action_block">بلاک</string> @@ -970,9 +964,7 @@ <string name="push_server_none_explainer">غیرفعال سازی اعلان ها</string> <string name="push_server_uses_app_explainer">از اپلیکیشن %1$s استفاده می کند</string> <string name="push_server_install_app">تنظیمات اعلان ها</string> - <string name="push_server_install_app_description">برای دریافت اعلان ها، می توانید هر اپلیکیشنی که از [Unified Push](https://unifiedpush.org/) پشتیبانی می کند نصب کنید، مانند[Ntfy](https://ntfy.sh/). - پس از نصب، اپلیکیشنی را که می خواهید استفاده کنید در تنظیمات انتخاب کنید. - </string> + <string name="push_server_install_app_description">برای دریافت اعلان ها، می توانید هر اپلیکیشنی که از [Unified Push](https://unifiedpush.org/) پشتیبانی می کند نصب کنید، مانند[Ntfy](https://ntfy.sh/). پس از نصب، اپلیکیشنی را که می خواهید استفاده کنید در تنظیمات انتخاب کنید.</string> <string name="thread_title">رسته</string> <string name="send_the_seller_a_message">به فروشنده پیغام دهید</string> <string name="hi_there_is_this_still_available">سلام، هنوز موجوده؟</string> @@ -1315,10 +1307,7 @@ <string name="show_nprofile_as_a_qr_code">نمایش nprofile به عنوان کد QR</string> <string name="dm_relays_not_found">تنظیم رله های صندوق دریافت خصوصی</string> <string name="dm_relays_not_found_description">با این تنظیمات همه می توانند بدانند که هنگام ارسال پیام به شما از کدام رله ها استفاده کنند. بدون این تنظیمات ممکن است برخی پیام ها را از دست بدهید.</string> - <string name="dm_relays_not_found_examples2">گزینه های خوب: -- inbox.nostr.wine (پولی) -- auth.nostr1.com (رایگان) -- you.nostr1.com (رله شخصی - پولی)</string> + <string name="dm_relays_not_found_examples2">گزینه های خوب: - inbox.nostr.wine (پولی) - auth.nostr1.com (رایگان) - you.nostr1.com (رله شخصی - پولی)</string> <string name="dm_relays_not_found_editing">از ۱ تا ۳ رله به عنوان رله خصوصی وارد کنید. رله های صندوق دربافت پیام های خصوصی می بایست هر پیامی از هرکس را بپذیرند، ولی تنها به شما اجازه بارگیری پیام ها را می دهند.</string> <string name="dm_relays_not_found_create_now">هم اکنون تنظیم شود</string> <string name="recipient_missing_dm_relays">relay های صندوق ورودی DM یافت نشد. پیام‌ها تحویل داده نمی‌شوند تا زمانی که لیست relay خود را پیکربندی کنند.</string> @@ -1345,7 +1334,7 @@ <string name="zap_the_devs_title">به توسعه دهندگان رپ دهید!</string> <string name="zap_the_devs_description">هدیه شما به ما برای تاثیرگذاری کمک می کند. هر ساتوشی به حساب می آید!</string> <string name="donate_now">اکنون کمک کنید</string> - <string name="brought_to_you_by">تقدیم از طرف: </string> + <string name="brought_to_you_by">تقدیم از طرف:</string> <string name="this_version_brought_to_you_by">این نسخه نرم‌افزار پیشکش از:</string> <string name="version_name">نسخه %1$s</string> <string name="thank_you">متشکریم!</string> @@ -2025,7 +2014,7 @@ <string name="copied_note_id_to_clipboard">(@note1)شناسه یادداشت در کلیپبورد کپی شد</string> <string name="copied_note_text_to_clipboard">یادداشت در کلیپبورد کپی شد</string> <string name="copied_to_clipboard">در کلیپ‌بورد کپی شد</string> - <string name="copied_user_id_to_clipboard">@npubنویسنده در کلیپبورد کپی شد </string> + <string name="copied_user_id_to_clipboard">@npubنویسنده در کلیپبورد کپی شد</string> <string name="copy_my_secret_key">کلید خصوصیم را کپی کن</string> <string name="copy_to_clipboard">کپی به کلیپ‌بورد</string> <string name="could_not_assemble_lnurl_from_lightning_address_check_the_user_s_setup">LNUrl از آدرس لایتنینگ "%1$s" بدست نیامد. تنظیمات کاربر را بررسی کنید.</string> @@ -2034,15 +2023,7 @@ <string name="could_not_fetch_invoice_from_details">صورتحساب از %1$s گرفته نشد: %2$s</string> <string name="could_not_open_the_compressed_file">فایل فشرده باز نشد</string> <string name="couldnt_find_nwc_wallets">کیف پول یافت نشد</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst هیچ برنامه کیف پولی که از Nostr Wallet Connect (NWC) پشتیبانی کند پیدا نکرد. -\n\nکارهایی که می‌توانید انجام دهید: -\n\t1. بررسی پشتیبانی NWC: مطمئن شوید که برنامه کیف پول مورد نظر شما با Nostr Wallet Connect سازگار است. -\n\t2. ایجاد اتصال: به برنامه کیف پول خود بروید و یک اتصال NWC جدید ایجاد کنید. -\n\t3. اتصال به Amethyst: کیف پول شما معمولاً سه گزینه ارائه می‌دهد: -\n\t\t3.1 اتصال خودکار: دکمه‌ای برای باز کردن و اتصال خودکار به Amethyst. اگر این گزینه وجود دارد، آن دکمه را بزنید، Amethyst را باز کنید و روی صفحه جدید ذخیره کنید. -\n\t\t3.2 اتصال دستی: یک URI اتصال که می‌توانید کپی کنید و با کلیک روی آیکون paste در این صفحه مستقیماً وارد کنید. -\n\t\t3.3 کد QR: کیف پول یک کد QR ایجاد می‌کند که می‌توانید با دکمه کد QR در این صفحه آن را بخوانید. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst هیچ برنامه کیف پولی که از Nostr Wallet Connect (NWC) پشتیبانی کند پیدا نکرد. \n\nکارهایی که می‌توانید انجام دهید: \n\t1. بررسی پشتیبانی NWC: مطمئن شوید که برنامه کیف پول مورد نظر شما با Nostr Wallet Connect سازگار است. \n\t2. ایجاد اتصال: به برنامه کیف پول خود بروید و یک اتصال NWC جدید ایجاد کنید. \n\t3. اتصال به Amethyst: کیف پول شما معمولاً سه گزینه ارائه می‌دهد: \n\t\t3.1 اتصال خودکار: دکمه‌ای برای باز کردن و اتصال خودکار به Amethyst. اگر این گزینه وجود دارد، آن دکمه را بزنید، Amethyst را باز کنید و روی صفحه جدید ذخیره کنید. \n\t\t3.2 اتصال دستی: یک URI اتصال که می‌توانید کپی کنید و با کلیک روی آیکون paste در این صفحه مستقیماً وارد کنید. \n\t\t3.3 کد QR: کیف پول یک کد QR ایجاد می‌کند که می‌توانید با دکمه کد QR در این صفحه آن را بخوانید.</string> <string name="create">ساختن</string> <string name="d">روز</string> <string name="danger_zone">منطقه خطر</string> @@ -2689,10 +2670,7 @@ <string name="privacy_policy">سیاست حریم خصوصی</string> <string name="private_conversation_notification"><پیام خصوصی رمزگشایی نشد>\\n\nدر یک پیام خصوصی/رمزنگاری شده بین %1$s و %2$s نام شما آمده بود.</string> <string name="private_inbox_section">رله های صندوق دریافت پیام خصوصی</string> - <string name="private_inbox_section_explainer">بین ۱-۳ رله به عنوان رله صندوق ورودی خصوصی وارد کنید. دیگران از این رله ها برای ارسال پیام خصوصی به شما استفاده خواهند کرد. رله های صندوق دریافت پیام خصوصی می بایست هر پیامی از هر کسی را بپذیرند، اما فقط بگذارند شما آن ها را بارگیری کنید. انتخاب های خوب شامل: - - inbox.nostr.wine (پولی) -- auth.nostr1.com (رایگان) -- you.nostr1.com (رله پولی یا شخصی)</string> + <string name="private_inbox_section_explainer">بین ۱-۳ رله به عنوان رله صندوق ورودی خصوصی وارد کنید. دیگران از این رله ها برای ارسال پیام خصوصی به شما استفاده خواهند کرد. رله های صندوق دریافت پیام خصوصی می بایست هر پیامی از هر کسی را بپذیرند، اما فقط بگذارند شما آن ها را بارگیری کنید. انتخاب های خوب شامل: - inbox.nostr.wine (پولی) - auth.nostr1.com (رایگان) - you.nostr1.com (رله پولی یا شخصی)</string> <string name="private_inbox_section_explainer_profile">کاربر DM ها را روی این relay ها دریافت می‌کند</string> <string name="private_message">پیام خصوصی</string> <string name="private_note">خصوصی کردن: یادداشت را به صورت gift-wrap فقط برای کاربران مطلع‌شده ارسال کن</string> @@ -2713,11 +2691,8 @@ <string name="proxy_section">relay های پراکسی</string> <string name="proxy_section_explainer">relay های تجمیع‌کننده که برنامه باید برای دانلود فیدهای شما از آن‌ها استفاده کند، مانند filter.nostr.wine. این جایگزین مدل outbox می‌شود و باعث می‌شود برنامه فقط به relay های موجود در لیست‌هایتان متصل شود.</string> <string name="public_chat">گفتگوی عمومی</string> - <string name="public_chat_explainer">گفتگوهای عمومی در ناستر برای همه نمایان هستند - می توانند در آن شرکت کنند. آنها برای انجمن های باز درباره موضوعات به‌خصوص عالی هستند. - نظارت می تواند توسط حذف پست ها از رله ها انجام گیرد</string> - <string name="public_chat_relays_explainer">برای میزبانی این گروه ۱تا ۳ رله وارد کنید. - کلاینت های ناستر از این تنظیمات استفاده می کنند تا بدانند پیام ها را از کجا بارگیری کنند و به کجا بفرستند.</string> + <string name="public_chat_explainer">گفتگوهای عمومی در ناستر برای همه نمایان هستند می توانند در آن شرکت کنند. آنها برای انجمن های باز درباره موضوعات به‌خصوص عالی هستند. نظارت می تواند توسط حذف پست ها از رله ها انجام گیرد</string> + <string name="public_chat_relays_explainer">برای میزبانی این گروه ۱تا ۳ رله وارد کنید. کلاینت های ناستر از این تنظیمات استفاده می کنند تا بدانند پیام ها را از کجا بارگیری کنند و به کجا بفرستند.</string> <string name="public_chat_relays_title">رله ها</string> <string name="public_chat_title">فراداده گفتگوی عمومی</string> <string name="public_chats">گفتگوهای عمومی</string> @@ -2742,10 +2717,7 @@ <string name="read_only_user">کاربر با امکان خواندن فقط</string> <string name="record_a_message_description">برای ضبط پیام کلیک کنید و نگه دارید</string> <string name="relay_chat">گفتگوی relay</string> - <string name="relay_chat_explainer">گفتگوهای relay گروه‌های چت هستند که توسط relay خانگی خود کنترل می‌شوند. - آن‌ها برای همه در Nostr قابل مشاهده هستند و هر کسی می‌تواند در آن‌ها شرکت کند. - آن‌ها برای جوامع باز حول موضوعات خاص عالی هستند. برخی از این گروه‌ها ناپایدار - هستند و بنابراین پیام‌های چت با گذشت زمان ناپدید می‌شوند</string> + <string name="relay_chat_explainer">گفتگوهای relay گروه‌های چت هستند که توسط relay خانگی خود کنترل می‌شوند. آن‌ها برای همه در Nostr قابل مشاهده هستند و هر کسی می‌تواند در آن‌ها شرکت کند. آن‌ها برای جوامع باز حول موضوعات خاص عالی هستند. برخی از این گروه‌ها ناپایدار هستند و بنابراین پیام‌های چت با گذشت زمان ناپدید می‌شوند</string> <string name="relay_chat_title">گفتگوهای relay</string> <string name="relay_management_tab_events">رویدادها</string> <string name="relay_management_tab_ips">آدرس‌های IP</string> @@ -2903,7 +2875,7 @@ <string name="tor_use_new_relays_explainer">تور را برای رله های ارسال/دریافت الزامی کن</string> <string name="tor_use_nip05_verification">تایید آدرس ناستر</string> <string name="tor_use_nip05_verification_explainer">تور را برای تایید آدرس های NIP-05 الزامی کن</string> - <string name="tor_use_onion_address">رله ها / آدرس های Onion </string> + <string name="tor_use_onion_address">رله ها / آدرس های Onion</string> <string name="tor_use_onion_address_explainer">از تور برای هر آدرس اونیون استفاده کن</string> <string name="tor_use_profile_pictures">تصاویر نمایه</string> <string name="tor_use_profile_pictures_explainer">تور را برای بارگیری تصاویر نمایه اجباری کن</string> diff --git a/commonsUI/src/commonMain/composeResources/values-fa/strings.xml b/commonsUI/src/commonMain/composeResources/values-fa/strings.xml index a20d36b070..cf8347e236 100644 --- a/commonsUI/src/commonMain/composeResources/values-fa/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-fa/strings.xml @@ -88,7 +88,7 @@ <string name="quote">نقل قول</string> <string name="fork">فورک</string> <string name="new_amount_in_sats">مبلغ جدید به ساتوشی</string> - <string name="replying_to"> پاسخ به</string> + <string name="replying_to">پاسخ به</string> <string name="and"> و </string> <string name="following">دنبال شونده</string> <string name="followers">دنبال کننده</string> @@ -211,7 +211,7 @@ <string name="copy_user_id">کپی شناسه کاربر</string> <string name="unblock_user">از بلاک درآوردن کاربر</string> <string name="user_is_blocked_hidden">این کاربر مسدود/بی‌صدا شده است. پست‌های آن‌ها مخفی است.</string> - <string name="npub_hex_username">npub, hex, نام کاربری </string> + <string name="npub_hex_username">npub, hex, نام کاربری</string> <string name="clear">پاک کردن</string> <string name="app_logo">لوگوی اپ</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex کلید خصوصی</string> @@ -233,7 +233,7 @@ <string name="chats_reply_searching_history">در حال جستجوی پیام اصلی…</string> <string name="chats_reply_not_found">این پیام پیدا نشد</string> <string name="chats_reply_searched">همه relay ها جستجو شد · برای مشاهده ضربه بزنید</string> - <string name="error_loading_replies"> :خطا در بارگیری پاسخ ها</string> + <string name="error_loading_replies">:خطا در بارگیری پاسخ ها</string> <string name="try_again">دوباره تلاش کنید</string> <string name="notification_feed_is_empty">هنوز هیچ اعلانی نیست.</string> <string name="open_poll">نظرسنجی باز</string> @@ -259,14 +259,8 @@ <string name="mark_all_known_as_read">همه شناس ها خوانده شده کن</string> <string name="mark_all_new_as_read">همه جدیدها را خوانده شده کن</string> <string name="mark_all_as_read">همه را خوانده شده کن</string> - <string name="account_backup_tips2_md">نکات ایمنی و ذخیره کلید - -حساب کاربری شما با یک کلید خصوصی محافظت می شود. این کلید دنباله ای بلند از کاراکترها است که با **nsec1** آغاز می گردد. هر کس به این کلید خصوصی دسترسی داشته باشد می تواند بجای شما یادداشت پست کرده یا هویت شما را تغییر دهد. -هرگز کلید خصوصی خود را در هیچ وبسایت با نرم افزاری که به آن اطمینان ندارید **وارد نکنید**. -سازندگان امتیست **هرگز** کلیدتان را از شما نمی خواهند. -یک پشتیبان یدکی مخفی از کلید خود به منظور بازیابی **نگه دارید**. ما استفاده از نرم افزار مدیریت پسورد را توصیه می کنیم.</string> - <string name="account_backup_tips3_md">برای ایمنی بیشتر، می توانید کلید خود را با یک رمزعبور رمزنگاری کنید. این نوع کلید با **ncryptsec1** آغاز می شود و نمی تواند بدون رمز عبور شما استفاده شود. -اگر پسوردتان را گم کنید، نخواهید توانست کلیدتان را بازیابی کنید.</string> + <string name="account_backup_tips2_md">نکات ایمنی و ذخیره کلید حساب کاربری شما با یک کلید خصوصی محافظت می شود. این کلید دنباله ای بلند از کاراکترها است که با **nsec1** آغاز می گردد. هر کس به این کلید خصوصی دسترسی داشته باشد می تواند بجای شما یادداشت پست کرده یا هویت شما را تغییر دهد. هرگز کلید خصوصی خود را در هیچ وبسایت با نرم افزاری که به آن اطمینان ندارید **وارد نکنید**. سازندگان امتیست **هرگز** کلیدتان را از شما نمی خواهند. یک پشتیبان یدکی مخفی از کلید خود به منظور بازیابی **نگه دارید**. ما استفاده از نرم افزار مدیریت پسورد را توصیه می کنیم.</string> + <string name="account_backup_tips3_md">برای ایمنی بیشتر، می توانید کلید خود را با یک رمزعبور رمزنگاری کنید. این نوع کلید با **ncryptsec1** آغاز می شود و نمی تواند بدون رمز عبور شما استفاده شود. اگر پسوردتان را گم کنید، نخواهید توانست کلیدتان را بازیابی کنید.</string> <string name="encrypt_and_copy_my_secret_key">رمزنگاری و کپی کلید من</string> <string name="badge_award_image_for">تصویر مدال پاداش برای %1$s</string> <string name="badge_award_image">تصویر جایزه نشان</string> @@ -286,7 +280,7 @@ <string name="quick_action_request_deletion_gallery_title">حذف از گالری</string> <string name="quick_action_request_deletion_gallery_alert_body_v2">این رسانه را از گالری خود حذف کنید.</string> <string name="quick_action_request_deletion_alert_title">درخواست حذف</string> - <string name="quick_action_request_deletion_alert_body">آماتیست درخواست می کند که یادداشت شما از رله هایی که درحال حاضر به آن متصل هستید حذف شود. هیچ تضمینی نیست که یادداشت شما برای همیشه از آن رله ها یا از رله های دیگری که ممکن است در آنها ذخیره شده باشد حذف خواهد شد.. </string> + <string name="quick_action_request_deletion_alert_body">آماتیست درخواست می کند که یادداشت شما از رله هایی که درحال حاضر به آن متصل هستید حذف شود. هیچ تضمینی نیست که یادداشت شما برای همیشه از آن رله ها یا از رله های دیگری که ممکن است در آنها ذخیره شده باشد حذف خواهد شد..</string> <string name="quick_action_block_dialog_btn">بلاک</string> <string name="quick_action_delete_dialog_btn">حذف</string> <string name="quick_action_block">بلاک</string> @@ -959,9 +953,7 @@ <string name="push_server_none_explainer">غیرفعال سازی اعلان ها</string> <string name="push_server_uses_app_explainer">از اپلیکیشن %1$s استفاده می کند</string> <string name="push_server_install_app">تنظیمات اعلان ها</string> - <string name="push_server_install_app_description">برای دریافت اعلان ها، می توانید هر اپلیکیشنی که از [Unified Push](https://unifiedpush.org/) پشتیبانی می کند نصب کنید، مانند[Ntfy](https://ntfy.sh/). - پس از نصب، اپلیکیشنی را که می خواهید استفاده کنید در تنظیمات انتخاب کنید. - </string> + <string name="push_server_install_app_description">برای دریافت اعلان ها، می توانید هر اپلیکیشنی که از [Unified Push](https://unifiedpush.org/) پشتیبانی می کند نصب کنید، مانند[Ntfy](https://ntfy.sh/). پس از نصب، اپلیکیشنی را که می خواهید استفاده کنید در تنظیمات انتخاب کنید.</string> <string name="thread_title">رسته</string> <string name="send_the_seller_a_message">به فروشنده پیغام دهید</string> <string name="hi_there_is_this_still_available">سلام، هنوز موجوده؟</string> @@ -1313,10 +1305,7 @@ <string name="show_nprofile_as_a_qr_code">نمایش nprofile به عنوان کد QR</string> <string name="dm_relays_not_found">تنظیم رله های صندوق دریافت خصوصی</string> <string name="dm_relays_not_found_description">با این تنظیمات همه می توانند بدانند که هنگام ارسال پیام به شما از کدام رله ها استفاده کنند. بدون این تنظیمات ممکن است برخی پیام ها را از دست بدهید.</string> - <string name="dm_relays_not_found_examples2">گزینه های خوب: -- inbox.nostr.wine (پولی) -- auth.nostr1.com (رایگان) -- you.nostr1.com (رله شخصی - پولی)</string> + <string name="dm_relays_not_found_examples2">گزینه های خوب: - inbox.nostr.wine (پولی) - auth.nostr1.com (رایگان) - you.nostr1.com (رله شخصی - پولی)</string> <string name="dm_relays_not_found_editing">از ۱ تا ۳ رله به عنوان رله خصوصی وارد کنید. رله های صندوق دربافت پیام های خصوصی می بایست هر پیامی از هرکس را بپذیرند، ولی تنها به شما اجازه بارگیری پیام ها را می دهند.</string> <string name="dm_relays_not_found_create_now">هم اکنون تنظیم شود</string> <string name="recipient_missing_dm_relays">relay های صندوق ورودی DM یافت نشد. پیام‌ها تحویل داده نمی‌شوند تا زمانی که لیست relay خود را پیکربندی کنند.</string> @@ -1343,7 +1332,7 @@ <string name="zap_the_devs_title">به توسعه دهندگان رپ دهید!</string> <string name="zap_the_devs_description">هدیه شما به ما برای تاثیرگذاری کمک می کند. هر ساتوشی به حساب می آید!</string> <string name="donate_now">اکنون کمک کنید</string> - <string name="brought_to_you_by">تقدیم از طرف: </string> + <string name="brought_to_you_by">تقدیم از طرف:</string> <string name="this_version_brought_to_you_by">این نسخه نرم‌افزار پیشکش از:</string> <string name="version_name">نسخه %1$s</string> <string name="thank_you">متشکریم!</string> @@ -2048,7 +2037,7 @@ <string name="copied_note_id_to_clipboard">(@note1)شناسه یادداشت در کلیپبورد کپی شد</string> <string name="copied_note_text_to_clipboard">یادداشت در کلیپبورد کپی شد</string> <string name="copied_to_clipboard">در کلیپ‌بورد کپی شد</string> - <string name="copied_user_id_to_clipboard">@npubنویسنده در کلیپبورد کپی شد </string> + <string name="copied_user_id_to_clipboard">@npubنویسنده در کلیپبورد کپی شد</string> <string name="copy_my_secret_key">کلید خصوصیم را کپی کن</string> <string name="copy_to_clipboard">کپی به کلیپ‌بورد</string> <string name="could_not_assemble_lnurl_from_lightning_address_check_the_user_s_setup">LNUrl از آدرس لایتنینگ "%1$s" بدست نیامد. تنظیمات کاربر را بررسی کنید.</string> @@ -2057,15 +2046,7 @@ <string name="could_not_fetch_invoice_from_details">صورتحساب از %1$s گرفته نشد: %2$s</string> <string name="could_not_open_the_compressed_file">فایل فشرده باز نشد</string> <string name="couldnt_find_nwc_wallets">کیف پول یافت نشد</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst هیچ برنامه کیف پولی که از Nostr Wallet Connect (NWC) پشتیبانی کند پیدا نکرد. -\n\nکارهایی که می‌توانید انجام دهید: -\n\t1. بررسی پشتیبانی NWC: مطمئن شوید که برنامه کیف پول مورد نظر شما با Nostr Wallet Connect سازگار است. -\n\t2. ایجاد اتصال: به برنامه کیف پول خود بروید و یک اتصال NWC جدید ایجاد کنید. -\n\t3. اتصال به Amethyst: کیف پول شما معمولاً سه گزینه ارائه می‌دهد: -\n\t\t3.1 اتصال خودکار: دکمه‌ای برای باز کردن و اتصال خودکار به Amethyst. اگر این گزینه وجود دارد، آن دکمه را بزنید، Amethyst را باز کنید و روی صفحه جدید ذخیره کنید. -\n\t\t3.2 اتصال دستی: یک URI اتصال که می‌توانید کپی کنید و با کلیک روی آیکون paste در این صفحه مستقیماً وارد کنید. -\n\t\t3.3 کد QR: کیف پول یک کد QR ایجاد می‌کند که می‌توانید با دکمه کد QR در این صفحه آن را بخوانید. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst هیچ برنامه کیف پولی که از Nostr Wallet Connect (NWC) پشتیبانی کند پیدا نکرد. \n\nکارهایی که می‌توانید انجام دهید: \n\t1. بررسی پشتیبانی NWC: مطمئن شوید که برنامه کیف پول مورد نظر شما با Nostr Wallet Connect سازگار است. \n\t2. ایجاد اتصال: به برنامه کیف پول خود بروید و یک اتصال NWC جدید ایجاد کنید. \n\t3. اتصال به Amethyst: کیف پول شما معمولاً سه گزینه ارائه می‌دهد: \n\t\t3.1 اتصال خودکار: دکمه‌ای برای باز کردن و اتصال خودکار به Amethyst. اگر این گزینه وجود دارد، آن دکمه را بزنید، Amethyst را باز کنید و روی صفحه جدید ذخیره کنید. \n\t\t3.2 اتصال دستی: یک URI اتصال که می‌توانید کپی کنید و با کلیک روی آیکون paste در این صفحه مستقیماً وارد کنید. \n\t\t3.3 کد QR: کیف پول یک کد QR ایجاد می‌کند که می‌توانید با دکمه کد QR در این صفحه آن را بخوانید.</string> <string name="create">ساختن</string> <string name="d">روز</string> <string name="danger_zone">منطقه خطر</string> @@ -2732,10 +2713,7 @@ <string name="privacy_policy">سیاست حریم خصوصی</string> <string name="private_conversation_notification"><پیام خصوصی رمزگشایی نشد>\\n\nدر یک پیام خصوصی/رمزنگاری شده بین %1$s و %2$s نام شما آمده بود.</string> <string name="private_inbox_section">رله های صندوق دریافت پیام خصوصی</string> - <string name="private_inbox_section_explainer">بین ۱-۳ رله به عنوان رله صندوق ورودی خصوصی وارد کنید. دیگران از این رله ها برای ارسال پیام خصوصی به شما استفاده خواهند کرد. رله های صندوق دریافت پیام خصوصی می بایست هر پیامی از هر کسی را بپذیرند، اما فقط بگذارند شما آن ها را بارگیری کنید. انتخاب های خوب شامل: - - inbox.nostr.wine (پولی) -- auth.nostr1.com (رایگان) -- you.nostr1.com (رله پولی یا شخصی)</string> + <string name="private_inbox_section_explainer">بین ۱-۳ رله به عنوان رله صندوق ورودی خصوصی وارد کنید. دیگران از این رله ها برای ارسال پیام خصوصی به شما استفاده خواهند کرد. رله های صندوق دریافت پیام خصوصی می بایست هر پیامی از هر کسی را بپذیرند، اما فقط بگذارند شما آن ها را بارگیری کنید. انتخاب های خوب شامل: - inbox.nostr.wine (پولی) - auth.nostr1.com (رایگان) - you.nostr1.com (رله پولی یا شخصی)</string> <string name="private_inbox_section_explainer_profile">کاربر DM ها را روی این relay ها دریافت می‌کند</string> <string name="private_message">پیام خصوصی</string> <string name="private_note">خصوصی کردن: یادداشت را به صورت gift-wrap فقط برای کاربران مطلع‌شده ارسال کن</string> @@ -2782,10 +2760,7 @@ <string name="read_only_user">کاربر با امکان خواندن فقط</string> <string name="record_a_message_description">برای ضبط پیام کلیک کنید و نگه دارید</string> <string name="relay_chat">گفتگوی relay</string> - <string name="relay_chat_explainer">گفتگوهای relay گروه‌های چت هستند که توسط relay خانگی خود کنترل می‌شوند. - آن‌ها برای همه در Nostr قابل مشاهده هستند و هر کسی می‌تواند در آن‌ها شرکت کند. - آن‌ها برای جوامع باز حول موضوعات خاص عالی هستند. برخی از این گروه‌ها ناپایدار - هستند و بنابراین پیام‌های چت با گذشت زمان ناپدید می‌شوند</string> + <string name="relay_chat_explainer">گفتگوهای relay گروه‌های چت هستند که توسط relay خانگی خود کنترل می‌شوند. آن‌ها برای همه در Nostr قابل مشاهده هستند و هر کسی می‌تواند در آن‌ها شرکت کند. آن‌ها برای جوامع باز حول موضوعات خاص عالی هستند. برخی از این گروه‌ها ناپایدار هستند و بنابراین پیام‌های چت با گذشت زمان ناپدید می‌شوند</string> <string name="relay_chat_title">گفتگوهای relay</string> <string name="relay_management_tab_events">رویدادها</string> <string name="relay_management_tab_ips">آدرس‌های IP</string> @@ -2943,7 +2918,7 @@ <string name="tor_use_new_relays_explainer">تور را برای رله های ارسال/دریافت الزامی کن</string> <string name="tor_use_nip05_verification">تایید آدرس ناستر</string> <string name="tor_use_nip05_verification_explainer">تور را برای تایید آدرس های NIP-05 الزامی کن</string> - <string name="tor_use_onion_address">رله ها / آدرس های Onion </string> + <string name="tor_use_onion_address">رله ها / آدرس های Onion</string> <string name="tor_use_onion_address_explainer">از تور برای هر آدرس اونیون استفاده کن</string> <string name="tor_use_profile_pictures">تصاویر نمایه</string> <string name="tor_use_profile_pictures_explainer">تور را برای بارگیری تصاویر نمایه اجباری کن</string> diff --git a/commonsUI/src/commonMain/composeResources/values-fi-rFI/strings.xml b/commonsUI/src/commonMain/composeResources/values-fi-rFI/strings.xml index ede84f29eb..f2784cced4 100644 --- a/commonsUI/src/commonMain/composeResources/values-fi-rFI/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-fi-rFI/strings.xml @@ -268,15 +268,8 @@ <string name="mark_all_known_as_read">Merkitse kaikki Tunnetut luetuiksi</string> <string name="mark_all_new_as_read">Merkitse kaikki Uudet luetuiksi</string> <string name="mark_all_as_read">Merkitse kaikki luetuiksi</string> - <string name="account_backup_tips2_md"> ## Avainten varmuuskopiointi ja turvallisuusvinkit - \n\nTilisi on suojattu salaisella avaimella. Avain on pitkä merkkijono, joka alkaa **nsec1**:llä. Kuka tahansa, jolla on pääsy tähän salaiseen avaimeen, voi julkaista ja muuttaa henkilöllisyyttäsi. - \n\n- **Älä** anna salaista avaintasi mihinkään verkkosivustoon tai ohjelmistoon, johon et luota. - \n- Amethystin kehittäjät eivät **koskaan** pyydä salaista avaintasi. - \n- **Tee** turvallinen varmuuskopio salaisesta avaimestasi tilin palauttamista varten. Suosittelemme salasananhallintaohjelman käyttöä. - </string> - <string name="account_backup_tips3_md"> Lisäturvallisuuden vuoksi voit salata avaimesi salasanalla. Tämä avain alkaa **ncryptsec1**:llä eikä sitä voi käyttää ilman salasanaasi. - \n\nJos kadotat salasanasi, et pysty palauttamaan avaintasi. - </string> + <string name="account_backup_tips2_md">## Avainten varmuuskopiointi ja turvallisuusvinkit \n\nTilisi on suojattu salaisella avaimella. Avain on pitkä merkkijono, joka alkaa **nsec1**:llä. Kuka tahansa, jolla on pääsy tähän salaiseen avaimeen, voi julkaista ja muuttaa henkilöllisyyttäsi. \n\n- **Älä** anna salaista avaintasi mihinkään verkkosivustoon tai ohjelmistoon, johon et luota. \n- Amethystin kehittäjät eivät **koskaan** pyydä salaista avaintasi. \n- **Tee** turvallinen varmuuskopio salaisesta avaimestasi tilin palauttamista varten. Suosittelemme salasananhallintaohjelman käyttöä.</string> + <string name="account_backup_tips3_md">Lisäturvallisuuden vuoksi voit salata avaimesi salasanalla. Tämä avain alkaa **ncryptsec1**:llä eikä sitä voi käyttää ilman salasanaasi. \n\nJos kadotat salasanasi, et pysty palauttamaan avaintasi.</string> <string name="encrypt_and_copy_my_secret_key">Salaa ja kopioi salainen avaimeni</string> <string name="badge_award_image_for">Merkki kohteelle %1$s</string> <string name="badge_award_image">"Merkkipalkinnon kuva</string> @@ -959,8 +952,7 @@ <string name="push_server_none_explainer">Poistaa Push-ilmoitukset käytöstä</string> <string name="push_server_uses_app_explainer">Käyttää sovellusta %1$s</string> <string name="push_server_install_app">Push-ilmoituksen asennus</string> - <string name="push_server_install_app_description"> Saadaksesi push-ilmoituksia, asenna mikä tahansa sovellus, joka tukee Unified Push:ia, kuten Ntfy. - Asennuksen jälkeen valitse Asetuksista sovellus, jota haluat käyttää.</string> + <string name="push_server_install_app_description">Saadaksesi push-ilmoituksia, asenna mikä tahansa sovellus, joka tukee Unified Push:ia, kuten Ntfy. Asennuksen jälkeen valitse Asetuksista sovellus, jota haluat käyttää.</string> <string name="thread_title">Keskusteluketju</string> <string name="send_the_seller_a_message">Lähetä myyjälle viesti</string> <string name="hi_there_is_this_still_available">Hei, onko tämä vielä saatavilla?</string> @@ -2011,15 +2003,7 @@ <string name="could_not_fetch_invoice_from_details">Laskun hakeminen epäonnistui kohteesta %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Pakattua tiedostoa ei voitu avata</string> <string name="couldnt_find_nwc_wallets">Lompakkoa ei löydy</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst ei löytänyt yhtään lompakkosovellusta, joka tukee Nostr Wallet Connect (NWC) -toimintoa. -\n\nMitä voit tehdä: -\n\t1. Tarkista NWC-tuki: Varmista, että haluamasi lompakkosovellus on yhteensopiva Nostr Wallet Connectin kanssa. -\n\t2. Luo yhteys: Siirry lompakkosovellukseesi ja luo uusi NWC-yhteys. -\n\t3. Linkitä Amethystiin: Lompakkosi tarjoaa yleensä kolme vaihtoehtoa: -\n\t\t3.1 Automaattinen linkitys: Painike, joka avaa Amethystin ja yhdistää automaattisesti. Jos näet sen, paina painiketta, avaa Amethyst ja tallenna uudella näytöllä. -\n\t\t3.2 Manuaalinen linkitys: YhteysURI, jonka voit kopioida ja liittää tämän näytön liitä-kuvakkeella. -\n\t\t3.3 QR-koodi: Lompakko luo QR-koodin, jonka voit lukea tämän näytön QR-koodipainikkeella. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst ei löytänyt yhtään lompakkosovellusta, joka tukee Nostr Wallet Connect (NWC) -toimintoa. \n\nMitä voit tehdä: \n\t1. Tarkista NWC-tuki: Varmista, että haluamasi lompakkosovellus on yhteensopiva Nostr Wallet Connectin kanssa. \n\t2. Luo yhteys: Siirry lompakkosovellukseesi ja luo uusi NWC-yhteys. \n\t3. Linkitä Amethystiin: Lompakkosi tarjoaa yleensä kolme vaihtoehtoa: \n\t\t3.1 Automaattinen linkitys: Painike, joka avaa Amethystin ja yhdistää automaattisesti. Jos näet sen, paina painiketta, avaa Amethyst ja tallenna uudella näytöllä. \n\t\t3.2 Manuaalinen linkitys: YhteysURI, jonka voit kopioida ja liittää tämän näytön liitä-kuvakkeella. \n\t\t3.3 QR-koodi: Lompakko luo QR-koodin, jonka voit lukea tämän näytön QR-koodipainikkeella.</string> <string name="create">Luo</string> <string name="d">pv</string> <string name="danger_zone">Vaara-alue</string> @@ -2677,11 +2661,8 @@ <string name="proxy_section">Proxy-relait</string> <string name="proxy_section_explainer">Aggregaattorirelait, joita sovelluksen täytyy käyttää feedien lataamiseen, kuten filter.nostr.wine. Tämä korvaa outbox-mallin ja saa sovelluksen yhdistämään vain listoissasi oleviin relaihin.</string> <string name="public_chat">Julkinen keskustelu</string> - <string name="public_chat_explainer">Julkiset chatit ovat näkyvissä kaikille Nostrissa ja kuka tahansa - voi osallistua niihin. Ne sopivat hyvin avoimiin yhteisöihin tiettyjen aiheiden ympärille. - Moderointia voidaan hallita poistamalla julkaisuja sen relay-palvelimilta</string> - <string name="public_chat_relays_explainer">Syötä 1–3 relay-palvelinta, jotka isännöivät tätä ryhmää. - Nostr-asiakkaat käyttävät tätä asetusta tietääkseen, mistä ladata viestejä ja mihin lähettää viestisi.</string> + <string name="public_chat_explainer">Julkiset chatit ovat näkyvissä kaikille Nostrissa ja kuka tahansa voi osallistua niihin. Ne sopivat hyvin avoimiin yhteisöihin tiettyjen aiheiden ympärille. Moderointia voidaan hallita poistamalla julkaisuja sen relay-palvelimilta</string> + <string name="public_chat_relays_explainer">Syötä 1–3 relay-palvelinta, jotka isännöivät tätä ryhmää. Nostr-asiakkaat käyttävät tätä asetusta tietääkseen, mistä ladata viestejä ja mihin lähettää viestisi.</string> <string name="public_chat_relays_title">relay-palvelimet</string> <string name="public_chat_title">Julkisen chatin metatiedot</string> <string name="public_chats">Julkiset keskustelut</string> @@ -2706,10 +2687,7 @@ <string name="read_only_user">Vain luku -käyttäjä</string> <string name="record_a_message_description">Paina ja pidä pohjassa tallentaaksesi ääniviesti</string> <string name="relay_chat">relay-chat</string> - <string name="relay_chat_explainer">relay-chatit ovat chat-ryhmiä, joita hallinnoi niiden kotipalvelin. - Ne ovat näkyvissä kaikille Nostrissa ja kuka tahansa voi osallistua niihin. - Ne sopivat hyvin avoimiin yhteisöihin tiettyjen aiheiden ympärille. Osa näistä ryhmistä on katoavia, - joten chat-viestit häviävät ajan myötä</string> + <string name="relay_chat_explainer">relay-chatit ovat chat-ryhmiä, joita hallinnoi niiden kotipalvelin. Ne ovat näkyvissä kaikille Nostrissa ja kuka tahansa voi osallistua niihin. Ne sopivat hyvin avoimiin yhteisöihin tiettyjen aiheiden ympärille. Osa näistä ryhmistä on katoavia, joten chat-viestit häviävät ajan myötä</string> <string name="relay_chat_title">relay-chatit</string> <string name="relay_management_tab_events">Tapahtumat</string> <string name="relay_management_tab_ips">IP-osoitteet</string> diff --git a/commonsUI/src/commonMain/composeResources/values-fr-rCA/strings.xml b/commonsUI/src/commonMain/composeResources/values-fr-rCA/strings.xml index 6dbdac7e80..677d4afb32 100644 --- a/commonsUI/src/commonMain/composeResources/values-fr-rCA/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-fr-rCA/strings.xml @@ -218,7 +218,7 @@ <string name="copy_user_id">Copier l'ID utilisateur</string> <string name="unblock_user">Débloquer l'utilisateur</string> <string name="user_is_blocked_hidden">Cet utilisateur est bloqué/muet. Ses publications sont masquées.</string> - <string name="npub_hex_username">npub, hex, nom d'utilisateur </string> + <string name="npub_hex_username">npub, hex, nom d'utilisateur</string> <string name="clear">Nettoyer</string> <string name="app_logo">Logo de l'App</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex private key</string> @@ -266,15 +266,8 @@ <string name="mark_all_known_as_read">Marquer tous les Connus comme lu</string> <string name="mark_all_new_as_read">Marquer tous les Nouveaux comme lu</string> <string name="mark_all_as_read">Tout marquer comme lu</string> - <string name="account_backup_tips2_md"> ## Sauvegarde des Clés et Conseils de Sécurité - \n\nVotre compte est sécurisé par une clé secrète. La clé est une longue séquence de caractères commençant par **nsec1**. Toute personne ayant accès à cette clé secrète peut publier et modifier votre identité. - \n\n- Ne mettez **pas** votre clé secrète sur un site web ou un logiciel auquel vous ne faites pas confiance. - \n- Les développeurs d'Amethyst ne vous demanderont **jamais** votre clé secrète. - \n- **Faites** une sauvegarde sécurisée de votre clé secrète pour la récupération de votre compte. Nous vous recommandons d'utiliser un gestionnaire de mots de passe. - </string> - <string name="account_backup_tips3_md"> Pour plus de sécurité, vous pouvez chiffrer votre clé avec un mot de passe. Cette clé commence par **ncryptsec1** et ne peut être utilisée sans votre mot de passe. - \n\nSi vous perdez votre mot de passe, vous ne pourrez pas récupérer votre clé. - </string> + <string name="account_backup_tips2_md">## Sauvegarde des Clés et Conseils de Sécurité \n\nVotre compte est sécurisé par une clé secrète. La clé est une longue séquence de caractères commençant par **nsec1**. Toute personne ayant accès à cette clé secrète peut publier et modifier votre identité. \n\n- Ne mettez **pas** votre clé secrète sur un site web ou un logiciel auquel vous ne faites pas confiance. \n- Les développeurs d'Amethyst ne vous demanderont **jamais** votre clé secrète. \n- **Faites** une sauvegarde sécurisée de votre clé secrète pour la récupération de votre compte. Nous vous recommandons d'utiliser un gestionnaire de mots de passe.</string> + <string name="account_backup_tips3_md">Pour plus de sécurité, vous pouvez chiffrer votre clé avec un mot de passe. Cette clé commence par **ncryptsec1** et ne peut être utilisée sans votre mot de passe. \n\nSi vous perdez votre mot de passe, vous ne pourrez pas récupérer votre clé.</string> <string name="encrypt_and_copy_my_secret_key">Chiffrer et copier ma clé secrète</string> <string name="badge_award_image_for">Image de badge pour %1$s</string> <string name="badge_award_image">Image du badge de récompense</string> @@ -823,7 +816,7 @@ <string name="max_subs">Souscription maximale</string> <string name="max_filters_per_sub">Nombre maximum de filtres par sub</string> <string name="max_limit_events_returning">Limite Max (Renvoi des Évènements)</string> - <string name="max_subid_length">Longueur maximale du SubID </string> + <string name="max_subid_length">Longueur maximale du SubID</string> <string name="cashu_mint_label">Mint : %1$s</string> <string name="cashu_redeem">Échanger</string> <string name="cashu_copy_token">Copier le Jeton</string> @@ -938,9 +931,7 @@ <string name="push_server_none_explainer">Désactive les Notifications Push</string> <string name="push_server_uses_app_explainer">Utilise l'application %1$s</string> <string name="push_server_install_app">Configuration des Notifications Push</string> - <string name="push_server_install_app_description"> Pour recevoir des notifications push, installez n'importe quelle application qui supporte les [Unified Push](https://unifiedpush.org/), tel que [Ntfy](https://ntfy.sh/). - Après installation, sélectionnez l'application que vous voulez utiliser dans les Paramètres. - </string> + <string name="push_server_install_app_description">Pour recevoir des notifications push, installez n'importe quelle application qui supporte les [Unified Push](https://unifiedpush.org/), tel que [Ntfy](https://ntfy.sh/). Après installation, sélectionnez l'application que vous voulez utiliser dans les Paramètres.</string> <string name="thread_title">Fil de discussion</string> <string name="send_the_seller_a_message">Envoyer un message au vendeur</string> <string name="hi_there_is_this_still_available">Bonjour, est-ce toujours disponible ?</string> @@ -2603,11 +2594,8 @@ <string name="proxy_section">Relais Proxy</string> <string name="proxy_section_explainer">Relais agrégateurs que l'application doit utiliser pour télécharger vos flux, tels que filter.nostr.wine. Cela remplace le modèle de boîte d'envoi et permettra à l'application de se connecter uniquement aux relais de vos listes.</string> <string name="public_chat">Chat public</string> - <string name="public_chat_explainer">Les conversations publiques sont visibles pour tout le monde sur Nostr et n'importe qui - peut y participer. Elles sont idéales pour les communautés ouvertes autour de sujets spécifiques. - La modération peut être contrôlée en supprimant les messages sur ses relais</string> - <string name="public_chat_relays_explainer">Insérez entre 1 et 3 relais qui hébergent ce groupe. - Les clients Nostr utilisent ce paramètre pour savoir où télécharger les messages et où les envoyer.</string> + <string name="public_chat_explainer">Les conversations publiques sont visibles pour tout le monde sur Nostr et n'importe qui peut y participer. Elles sont idéales pour les communautés ouvertes autour de sujets spécifiques. La modération peut être contrôlée en supprimant les messages sur ses relais</string> + <string name="public_chat_relays_explainer">Insérez entre 1 et 3 relais qui hébergent ce groupe. Les clients Nostr utilisent ce paramètre pour savoir où télécharger les messages et où les envoyer.</string> <string name="public_chat_relays_title">Relais</string> <string name="public_chat_title">Métadonnées de tchat public</string> <string name="public_chats">Chats publics</string> @@ -2632,10 +2620,7 @@ <string name="read_only_user">Utilisateur en lecture seule</string> <string name="record_a_message_description">Cliquez et maintenez pour enregistrer un message</string> <string name="relay_chat">Relais de discussion</string> - <string name="relay_chat_explainer">Les relais de discussions sont des groupes de discussion contrôlés par leur relais d'origine. - Ils sont visibles par tous les utilisateurs de Nostr et tout le monde peut y participer. - Ils sont idéaux pour les communautés ouvertes autour de sujets spécifiques. Certains de ces groupes sont éphémères - et, par conséquent, les messages de discussion disparaissent avec le temps</string> + <string name="relay_chat_explainer">Les relais de discussions sont des groupes de discussion contrôlés par leur relais d'origine. Ils sont visibles par tous les utilisateurs de Nostr et tout le monde peut y participer. Ils sont idéaux pour les communautés ouvertes autour de sujets spécifiques. Certains de ces groupes sont éphémères et, par conséquent, les messages de discussion disparaissent avec le temps</string> <string name="relay_chat_title">Relais de discussions</string> <string name="relay_management_tab_events">Événements</string> <string name="relay_management_tab_pubkeys">Utilisateurs</string> diff --git a/commonsUI/src/commonMain/composeResources/values-fr-rFR/strings.xml b/commonsUI/src/commonMain/composeResources/values-fr-rFR/strings.xml index 41d6f05237..76a4f93daf 100644 --- a/commonsUI/src/commonMain/composeResources/values-fr-rFR/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-fr-rFR/strings.xml @@ -220,7 +220,7 @@ <string name="copy_user_id">Copier l'ID utilisateur</string> <string name="unblock_user">Débloquer l'utilisateur</string> <string name="user_is_blocked_hidden">Cet utilisateur est bloqué/muet. Ses publications sont masquées.</string> - <string name="npub_hex_username">npub, hex, nom d'utilisateur </string> + <string name="npub_hex_username">npub, hex, nom d'utilisateur</string> <string name="clear">Nettoyer</string> <string name="app_logo">Logo de l'App</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex private key</string> @@ -268,15 +268,8 @@ <string name="mark_all_known_as_read">Marquer tous les Connus comme lu</string> <string name="mark_all_new_as_read">Marquer tous les Nouveaux comme lu</string> <string name="mark_all_as_read">Tout marquer comme lu</string> - <string name="account_backup_tips2_md"> ## Sauvegarde des Clés et Conseils de Sécurité - \n\nVotre compte est sécurisé par une clé secrète. La clé est une longue séquence de caractères commençant par **nsec1**. Toute personne ayant accès à cette clé secrète peut publier et modifier votre identité. - \n\n- Ne mettez **pas** votre clé secrète sur un site web ou un logiciel auquel vous ne faites pas confiance. - \n- Les développeurs d'Amethyst ne vous demanderont **jamais** votre clé secrète. - \n- **Faites** une sauvegarde sécurisée de votre clé secrète pour la récupération de votre compte. Nous vous recommandons d'utiliser un gestionnaire de mots de passe. - </string> - <string name="account_backup_tips3_md"> Pour plus de sécurité, vous pouvez chiffrer votre clé avec un mot de passe. Cette clé commence par **ncryptsec1** et ne peut être utilisée sans votre mot de passe. - \n\nSi vous perdez votre mot de passe, vous ne pourrez pas récupérer votre clé. - </string> + <string name="account_backup_tips2_md">## Sauvegarde des Clés et Conseils de Sécurité \n\nVotre compte est sécurisé par une clé secrète. La clé est une longue séquence de caractères commençant par **nsec1**. Toute personne ayant accès à cette clé secrète peut publier et modifier votre identité. \n\n- Ne mettez **pas** votre clé secrète sur un site web ou un logiciel auquel vous ne faites pas confiance. \n- Les développeurs d'Amethyst ne vous demanderont **jamais** votre clé secrète. \n- **Faites** une sauvegarde sécurisée de votre clé secrète pour la récupération de votre compte. Nous vous recommandons d'utiliser un gestionnaire de mots de passe.</string> + <string name="account_backup_tips3_md">Pour plus de sécurité, vous pouvez chiffrer votre clé avec un mot de passe. Cette clé commence par **ncryptsec1** et ne peut être utilisée sans votre mot de passe. \n\nSi vous perdez votre mot de passe, vous ne pourrez pas récupérer votre clé.</string> <string name="encrypt_and_copy_my_secret_key">Chiffrer et copier ma clé secrète</string> <string name="badge_award_image_for">Image de badge pour %1$s</string> <string name="badge_award_image">Image du badge de récompense</string> @@ -905,7 +898,7 @@ <string name="max_subs">Souscription maximale</string> <string name="max_filters_per_sub">Nombre maximum de filtres par sub</string> <string name="max_limit_events_returning">Limite Max (Renvoi des Évènements)</string> - <string name="max_subid_length">Longueur maximale du SubID </string> + <string name="max_subid_length">Longueur maximale du SubID</string> <string name="cashu_mint_label">Mint : %1$s</string> <string name="cashu_redeem">Échanger</string> <string name="cashu_copy_token">Copier le Jeton</string> @@ -1039,9 +1032,7 @@ <string name="push_server_none_explainer">Désactive les Notifications Push</string> <string name="push_server_uses_app_explainer">Utilise l'application %1$s</string> <string name="push_server_install_app">Configuration des Notifications Push</string> - <string name="push_server_install_app_description"> Pour recevoir des notifications push, installez n'importe quelle application qui supporte les [Unified Push](https://unifiedpush.org/), tel que [Ntfy](https://ntfy.sh/). - Après installation, sélectionnez l'application que vous voulez utiliser dans les Paramètres. - </string> + <string name="push_server_install_app_description">Pour recevoir des notifications push, installez n'importe quelle application qui supporte les [Unified Push](https://unifiedpush.org/), tel que [Ntfy](https://ntfy.sh/). Après installation, sélectionnez l'application que vous voulez utiliser dans les Paramètres.</string> <string name="thread_title">Fil de discussion</string> <string name="send_the_seller_a_message">Envoyer un message au vendeur</string> <string name="hi_there_is_this_still_available">Bonjour, est-ce toujours disponible ?</string> @@ -2883,11 +2874,8 @@ <string name="proxy_section">Relais Proxy</string> <string name="proxy_section_explainer">Relais agrégateurs que l'application doit utiliser pour télécharger vos flux, tels que filter.nostr.wine. Cela remplace le modèle de boîte d'envoi et permettra à l'application de se connecter uniquement aux relais de vos listes.</string> <string name="public_chat">Chat public</string> - <string name="public_chat_explainer">Les conversations publiques sont visibles pour tout le monde sur Nostr et n'importe qui - peut y participer. Elles sont idéales pour les communautés ouvertes autour de sujets spécifiques. - La modération peut être contrôlée en supprimant les messages sur ses relais</string> - <string name="public_chat_relays_explainer">Insérez entre 1 et 3 relais qui hébergent ce groupe. - Les clients Nostr utilisent ce paramètre pour savoir où télécharger les messages et où les envoyer.</string> + <string name="public_chat_explainer">Les conversations publiques sont visibles pour tout le monde sur Nostr et n'importe qui peut y participer. Elles sont idéales pour les communautés ouvertes autour de sujets spécifiques. La modération peut être contrôlée en supprimant les messages sur ses relais</string> + <string name="public_chat_relays_explainer">Insérez entre 1 et 3 relais qui hébergent ce groupe. Les clients Nostr utilisent ce paramètre pour savoir où télécharger les messages et où les envoyer.</string> <string name="public_chat_relays_title">Relais</string> <string name="public_chat_title">Métadonnées de tchat public</string> <string name="public_chats">Chats publics</string> @@ -2912,10 +2900,7 @@ <string name="read_only_user">Utilisateur en lecture seule</string> <string name="record_a_message_description">Cliquez et maintenez pour enregistrer un message</string> <string name="relay_chat">Relais de discussion</string> - <string name="relay_chat_explainer">Les relais de discussions sont des groupes de discussion contrôlés par leur relais d'origine. - Ils sont visibles par tous les utilisateurs de Nostr et tout le monde peut y participer. - Ils sont idéaux pour les communautés ouvertes autour de sujets spécifiques. Certains de ces groupes sont éphémères - et, par conséquent, les messages de discussion disparaissent avec le temps</string> + <string name="relay_chat_explainer">Les relais de discussions sont des groupes de discussion contrôlés par leur relais d'origine. Ils sont visibles par tous les utilisateurs de Nostr et tout le monde peut y participer. Ils sont idéaux pour les communautés ouvertes autour de sujets spécifiques. Certains de ces groupes sont éphémères et, par conséquent, les messages de discussion disparaissent avec le temps</string> <string name="relay_chat_title">Relais de discussions</string> <string name="relay_group_flag_private">Privé</string> <string name="relay_management_tab_events">Événements</string> diff --git a/commonsUI/src/commonMain/composeResources/values-fr/strings.xml b/commonsUI/src/commonMain/composeResources/values-fr/strings.xml index 2f9de43271..41b7112fcb 100644 --- a/commonsUI/src/commonMain/composeResources/values-fr/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-fr/strings.xml @@ -211,7 +211,7 @@ <string name="copy_user_id">Copier l'ID utilisateur</string> <string name="unblock_user">Débloquer l'utilisateur</string> <string name="user_is_blocked_hidden">Cet utilisateur est bloqué/muet. Ses publications sont masquées.</string> - <string name="npub_hex_username">npub, hex, nom d'utilisateur </string> + <string name="npub_hex_username">npub, hex, nom d'utilisateur</string> <string name="clear">Nettoyer</string> <string name="app_logo">Logo de l'App</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex private key</string> @@ -259,15 +259,8 @@ <string name="mark_all_known_as_read">Marquer tous les Connus comme lu</string> <string name="mark_all_new_as_read">Marquer tous les Nouveaux comme lu</string> <string name="mark_all_as_read">Tout marquer comme lu</string> - <string name="account_backup_tips2_md"> ## Sauvegarde des Clés et Conseils de Sécurité - \n\nVotre compte est sécurisé par une clé secrète. La clé est une longue séquence de caractères commençant par **nsec1**. Toute personne ayant accès à cette clé secrète peut publier et modifier votre identité. - \n\n- Ne mettez **pas** votre clé secrète sur un site web ou un logiciel auquel vous ne faites pas confiance. - \n- Les développeurs d'Amethyst ne vous demanderont **jamais** votre clé secrète. - \n- **Faites** une sauvegarde sécurisée de votre clé secrète pour la récupération de votre compte. Nous vous recommandons d'utiliser un gestionnaire de mots de passe. - </string> - <string name="account_backup_tips3_md"> Pour plus de sécurité, vous pouvez chiffrer votre clé avec un mot de passe. Cette clé commence par **ncryptsec1** et ne peut être utilisée sans votre mot de passe. - \n\nSi vous perdez votre mot de passe, vous ne pourrez pas récupérer votre clé. - </string> + <string name="account_backup_tips2_md">## Sauvegarde des Clés et Conseils de Sécurité \n\nVotre compte est sécurisé par une clé secrète. La clé est une longue séquence de caractères commençant par **nsec1**. Toute personne ayant accès à cette clé secrète peut publier et modifier votre identité. \n\n- Ne mettez **pas** votre clé secrète sur un site web ou un logiciel auquel vous ne faites pas confiance. \n- Les développeurs d'Amethyst ne vous demanderont **jamais** votre clé secrète. \n- **Faites** une sauvegarde sécurisée de votre clé secrète pour la récupération de votre compte. Nous vous recommandons d'utiliser un gestionnaire de mots de passe.</string> + <string name="account_backup_tips3_md">Pour plus de sécurité, vous pouvez chiffrer votre clé avec un mot de passe. Cette clé commence par **ncryptsec1** et ne peut être utilisée sans votre mot de passe. \n\nSi vous perdez votre mot de passe, vous ne pourrez pas récupérer votre clé.</string> <string name="encrypt_and_copy_my_secret_key">Chiffrer et copier ma clé secrète</string> <string name="badge_award_image_for">Image de badge pour %1$s</string> <string name="badge_award_image">Image du badge de récompense</string> @@ -844,7 +837,7 @@ <string name="max_subs">Souscription maximale</string> <string name="max_filters_per_sub">Nombre maximum de filtres par sub</string> <string name="max_limit_events_returning">Limite Max (Renvoi des Évènements)</string> - <string name="max_subid_length">Longueur maximale du SubID </string> + <string name="max_subid_length">Longueur maximale du SubID</string> <string name="cashu_mint_label">Mint : %1$s</string> <string name="cashu_redeem">Échanger</string> <string name="cashu_copy_token">Copier le Jeton</string> @@ -960,9 +953,7 @@ <string name="push_server_none_explainer">Désactive les Notifications Push</string> <string name="push_server_uses_app_explainer">Utilise l'application %1$s</string> <string name="push_server_install_app">Configuration des Notifications Push</string> - <string name="push_server_install_app_description"> Pour recevoir des notifications push, installez n'importe quelle application qui supporte les [Unified Push](https://unifiedpush.org/), tel que [Ntfy](https://ntfy.sh/). - Après installation, sélectionnez l'application que vous voulez utiliser dans les Paramètres. - </string> + <string name="push_server_install_app_description">Pour recevoir des notifications push, installez n'importe quelle application qui supporte les [Unified Push](https://unifiedpush.org/), tel que [Ntfy](https://ntfy.sh/). Après installation, sélectionnez l'application que vous voulez utiliser dans les Paramètres.</string> <string name="thread_title">Fil de discussion</string> <string name="send_the_seller_a_message">Envoyer un message au vendeur</string> <string name="hi_there_is_this_still_available">Bonjour, est-ce toujours disponible ?</string> @@ -2743,11 +2734,8 @@ <string name="proxy_section">Relais Proxy</string> <string name="proxy_section_explainer">Relais agrégateurs que l'application doit utiliser pour télécharger vos flux, tels que filter.nostr.wine. Cela remplace le modèle de boîte d'envoi et permettra à l'application de se connecter uniquement aux relais de vos listes.</string> <string name="public_chat">Chat public</string> - <string name="public_chat_explainer">Les conversations publiques sont visibles pour tout le monde sur Nostr et n'importe qui - peut y participer. Elles sont idéales pour les communautés ouvertes autour de sujets spécifiques. - La modération peut être contrôlée en supprimant les messages sur ses relais</string> - <string name="public_chat_relays_explainer">Insérez entre 1 et 3 relais qui hébergent ce groupe. - Les clients Nostr utilisent ce paramètre pour savoir où télécharger les messages et où les envoyer.</string> + <string name="public_chat_explainer">Les conversations publiques sont visibles pour tout le monde sur Nostr et n'importe qui peut y participer. Elles sont idéales pour les communautés ouvertes autour de sujets spécifiques. La modération peut être contrôlée en supprimant les messages sur ses relais</string> + <string name="public_chat_relays_explainer">Insérez entre 1 et 3 relais qui hébergent ce groupe. Les clients Nostr utilisent ce paramètre pour savoir où télécharger les messages et où les envoyer.</string> <string name="public_chat_relays_title">Relais</string> <string name="public_chat_title">Métadonnées de tchat public</string> <string name="public_chats">Chats publics</string> @@ -2772,10 +2760,7 @@ <string name="read_only_user">Utilisateur en lecture seule</string> <string name="record_a_message_description">Cliquez et maintenez pour enregistrer un message</string> <string name="relay_chat">Relais de discussion</string> - <string name="relay_chat_explainer">Les relais de discussions sont des groupes de discussion contrôlés par leur relais d'origine. - Ils sont visibles par tous les utilisateurs de Nostr et tout le monde peut y participer. - Ils sont idéaux pour les communautés ouvertes autour de sujets spécifiques. Certains de ces groupes sont éphémères - et, par conséquent, les messages de discussion disparaissent avec le temps</string> + <string name="relay_chat_explainer">Les relais de discussions sont des groupes de discussion contrôlés par leur relais d'origine. Ils sont visibles par tous les utilisateurs de Nostr et tout le monde peut y participer. Ils sont idéaux pour les communautés ouvertes autour de sujets spécifiques. Certains de ces groupes sont éphémères et, par conséquent, les messages de discussion disparaissent avec le temps</string> <string name="relay_chat_title">Relais de discussions</string> <string name="relay_management_tab_events">Événements</string> <string name="relay_management_tab_ips">IPs</string> diff --git a/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml b/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml index 2d16c9c513..cde8a721e1 100644 --- a/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-hi-rIN/strings.xml @@ -646,15 +646,8 @@ <string name="mark_all_known_as_read">सब ज्ञात को पढ लिया चिह्नित करें</string> <string name="mark_all_new_as_read">सब नये को पढ लिया चिह्नित करें</string> <string name="mark_all_as_read">सब को पढ लिया चिह्नित करें</string> - <string name="account_backup_tips2_md">## कुंचिका सुरक्षार्थ अनुकृति तथा सुरक्षा सुझाव - \n\nआपकी लेखा एक गुप्त कुंचिका से सुरक्षित किया गया है। कुंचिका अक्षरों की एक लम्बी श्रृंखला है जो **nsec1** से आरम्भ होता है। जिस किसी के पास यह कुंचिका है वह पत्र प्रकाशित कर सकेगा तथा आपका परिचय परिवर्तित कर सकेगा। - \n\n- आपकी गुप्त कुंचिका किसी भी जालस्थान अथवा क्रमक में **ना** डालें जिसपर आपका विश्वास ना हो। - \n- अमेथिस्ट क्रमलेख विकासकर्ता आपकी गुप्त कुंचिका **कभी नहीं** पूछेंगे। - \n- आपकी गुप्त कुंचिका की एक सुरक्षित अनुकृति **अवश्य** रखें अपनी लेखा पुनः प्राप्त करने के लिए। पारणशब्ध प्रबंधन क्रमक की पुनः प्रशंसा करते हैं। - </string> - <string name="account_backup_tips3_md"> अधिक सुरक्षा के लिए आप अपनी कुंचिका का रहस्यीकरण कर सकते हैं एक पारणशब्द के साथ। यह कुंचिका आरम्भ होगी **ncryptsec1** से तथा पारणशब्द के बिना प्रयोग साध्य नहीं। - \n\n यदि आप अपना पारणशब्द खो देते हैं, तो आप अपनी कुंचिका को पुनः प्राप्त नहीं कर सकते। - </string> + <string name="account_backup_tips2_md">## कुंचिका सुरक्षार्थ अनुकृति तथा सुरक्षा सुझाव \n\nआपकी लेखा एक गुप्त कुंचिका से सुरक्षित किया गया है। कुंचिका अक्षरों की एक लम्बी श्रृंखला है जो **nsec1** से आरम्भ होता है। जिस किसी के पास यह कुंचिका है वह पत्र प्रकाशित कर सकेगा तथा आपका परिचय परिवर्तित कर सकेगा। \n\n- आपकी गुप्त कुंचिका किसी भी जालस्थान अथवा क्रमक में **ना** डालें जिसपर आपका विश्वास ना हो। \n- अमेथिस्ट क्रमलेख विकासकर्ता आपकी गुप्त कुंचिका **कभी नहीं** पूछेंगे। \n- आपकी गुप्त कुंचिका की एक सुरक्षित अनुकृति **अवश्य** रखें अपनी लेखा पुनः प्राप्त करने के लिए। पारणशब्ध प्रबंधन क्रमक की पुनः प्रशंसा करते हैं।</string> + <string name="account_backup_tips3_md">अधिक सुरक्षा के लिए आप अपनी कुंचिका का रहस्यीकरण कर सकते हैं एक पारणशब्द के साथ। यह कुंचिका आरम्भ होगी **ncryptsec1** से तथा पारणशब्द के बिना प्रयोग साध्य नहीं। \n\n यदि आप अपना पारणशब्द खो देते हैं, तो आप अपनी कुंचिका को पुनः प्राप्त नहीं कर सकते।</string> <string name="backup_keys_nudge_title">अपने कुंचिकाओं को सुरक्षित रखें</string> <string name="backup_keys_nudge_body">आपकी गुप्त कुंचिका एकमात्र विधि है इस लेखा का अभिगमन करने के लिए। यदि आप इसे खो देते हैं तो इसे कभी भी पुनःप्राप्त नहीं कर सकते। इसे कहीं सुरक्षित रखें अभी इस समय।</string> <string name="backup_keys_nudge_backup_now">अभी इसी समय सुरक्षित अनुकृति बनाएँ</string> @@ -1834,9 +1827,7 @@ <string name="push_server_none_explainer">प्रेषित सूचनाएँ अक्षम करता है</string> <string name="push_server_uses_app_explainer">%1$s क्रमक का प्रयोग करता है</string> <string name="push_server_install_app">प्रेषित सूचना स्थापन</string> - <string name="push_server_install_app_description"> प्रेषित सूचनाएँ प्राप्त करने के लिए, किसी भी क्रमक की स्थापना करें जो [संयुक्त प्रेषण](https://unifiedpush.org/) का अवलम्बन करता है, जैसे [एनटीफै](https://ntfy.sh/)। - स्थापना पश्चात, जिस क्रमक का उपयोग करना चाहते हैं उसका चयन करें स्थापना विकल्पों में। - </string> + <string name="push_server_install_app_description">प्रेषित सूचनाएँ प्राप्त करने के लिए, किसी भी क्रमक की स्थापना करें जो [संयुक्त प्रेषण](https://unifiedpush.org/) का अवलम्बन करता है, जैसे [एनटीफै](https://ntfy.sh/)। स्थापना पश्चात, जिस क्रमक का उपयोग करना चाहते हैं उसका चयन करें स्थापना विकल्पों में।</string> <string name="thread_title">सूत्र</string> <string name="send_the_seller_a_message">विक्रेता को संदेश भेजें</string> <string name="hi_there_is_this_still_available">नमस्ते, क्या यह अब भी उपलब्ध है?</string> @@ -3585,17 +3576,9 @@ <string name="could_not_fetch_invoice_from_details">चालान नहीं लाया जा सका %1$s से : %2$s</string> <string name="could_not_open_the_compressed_file">संकुचित अभिलेख को खोल नहीं पाए</string> <string name="couldnt_find_nwc_wallets">धनकोष अप्राप्त</string> - <string name="couldnt_find_nwc_wallets_description">अमेथिस्ट को कोई धनकोष क्रमक प्राप्य नहीं जो नोस्टर धनकोष संयोजन का अवलम्बन करता हो। -\n\nआप यह कर सकते हैं : -\n\t१॰ नोस्टर धनकोष संयोजन अवलम्बन का सत्यापन करें। दुबारा जाँचें की आपका मनचाहा धनकोष क्रमक नोस्टर धनकोष संयोजन के साथ संगत है। -\n\t२॰ संयोजन बनाएँ। आपके धनकोष क्रमक में जाकर एक नया नोस्टर धनकोष संयोजन बनाएँ। -\n\t३॰ अमेथिस्ट के साथ जोडें। आपका धनकोष क्रमक सामान्यतः तीन विकल्प देगा। -\n\t\t३॰१ स्वचालित जोड। एक घुण्डी जिससे स्वचालित रूप से खोलें तथा अमेथिस्ट से जोडें। यदि हो तो उस घुण्डी को टाँकें तथा अमेथिस्ट खोलें तथा नव्य पटल पर अभिलेखन करें। -\n\t\t३॰२ मनुष्यकृत जोड। एक संयोजन वैश्विकसंसाधनपरिचायक जिसकी अनुकृति करके सीधे इस पटल पर प्रविष्ट कर सकते हैं। -\n\t\t३॰३ क्यूआर॰ चित्र अक्षरराशि। धनकोष क्रमक एक क्यूआर॰ चित्र अक्षरराशि बनएगा जिसे आप परख सकते हैं इस पटल पर क्यूआर॰ क्रमचित्र घुण्डी द्वारा। - </string> + <string name="couldnt_find_nwc_wallets_description">अमेथिस्ट को कोई धनकोष क्रमक प्राप्य नहीं जो नोस्टर धनकोष संयोजन का अवलम्बन करता हो। \n\nआप यह कर सकते हैं : \n\t१॰ नोस्टर धनकोष संयोजन अवलम्बन का सत्यापन करें। दुबारा जाँचें की आपका मनचाहा धनकोष क्रमक नोस्टर धनकोष संयोजन के साथ संगत है। \n\t२॰ संयोजन बनाएँ। आपके धनकोष क्रमक में जाकर एक नया नोस्टर धनकोष संयोजन बनाएँ। \n\t३॰ अमेथिस्ट के साथ जोडें। आपका धनकोष क्रमक सामान्यतः तीन विकल्प देगा। \n\t\t३॰१ स्वचालित जोड। एक घुण्डी जिससे स्वचालित रूप से खोलें तथा अमेथिस्ट से जोडें। यदि हो तो उस घुण्डी को टाँकें तथा अमेथिस्ट खोलें तथा नव्य पटल पर अभिलेखन करें। \n\t\t३॰२ मनुष्यकृत जोड। एक संयोजन वैश्विकसंसाधनपरिचायक जिसकी अनुकृति करके सीधे इस पटल पर प्रविष्ट कर सकते हैं। \n\t\t३॰३ क्यूआर॰ चित्र अक्षरराशि। धनकोष क्रमक एक क्यूआर॰ चित्र अक्षरराशि बनएगा जिसे आप परख सकते हैं इस पटल पर क्यूआर॰ क्रमचित्र घुण्डी द्वारा।</string> <string name="create">बनाएँ</string> - <string name="d"> दि॰</string> + <string name="d">दि॰</string> <string name="danger_zone">संकट क्षेत्र</string> <string name="dark">अन्धकारमय</string> <string name="description">विवरण</string> @@ -3791,7 +3774,7 @@ <string name="git_repositories_search_close">छलनी आवृत</string> <string name="git_repositories_search_open">क्रमलेखकोश छलनी</string> <string name="goal_progress">%1$s वित्तपोषित %2$s साट्स उद्देश्य में से</string> - <string name="h"> घं॰</string> + <string name="h">घं॰</string> <string name="hash_verification_failed">यह विषयवस्तु परिवर्तित हुआ है। हो सकता है लेखक ने परिवर्तन देखा नहीं अथवा अनुमति दिया नहीं।</string> <string name="hash_verification_info_title">इसका अर्थ क्या है?</string> <string name="hash_verification_passed">यह विषयवस्तु वैसे ही है जैसे पत्र प्रकाशन पर</string> @@ -4080,7 +4063,7 @@ <string name="login_with_a_private_key_to_be_able_to_upload">आप ख्याप्य कुंचिका का प्रयोग कर रहे हैं जिससे केवल पढ सकते हैं। आरोहण करने के लिए गुप्त कुंचिका के साथ प्रवेशांकन करें</string> <string name="login_with_a_private_key_to_like_posts">आप ख्याप्य कुंचिका का प्रयोग कर रहे हैं जिससे केवल पढ सकते हैं। प्रकाशित पत्रों को चाहने के लिए गुप्त कुंचिका के साथ प्रवेशांकन करें</string> <string name="longs">चलचित्र</string> - <string name="m"> मि॰</string> + <string name="m">मि॰</string> <string name="manage_emoji_packs">मेरे भावचिह्न पोटलियाँ</string> <string name="marmot_add_photo">चित्र जोडें</string> <string name="marmot_adding_user">जोडा जा रहा है %1$s…</string> @@ -4711,11 +4694,8 @@ <string name="proxy_section">प्रतिनिधि पुनःप्रसारक</string> <string name="proxy_section_explainer">संग्रहकर्ता पुनःप्रसारक जो क्रमक द्वारा उपयुक्त होना चाहिए आपके सूचनावलियों का अवरोहण करने के लिए। जैसे कि filter.nostr.wine । यह निर्गतपेटिका प्रतिरूप को प्रतिस्थापित करेगा तथा क्रमक आपके सूचियों में पुनःप्रसारकों के साथ ही जुडेगा।</string> <string name="public_chat">सार्वजनिक चर्चा</string> - <string name="public_chat_explainer">सार्वजनिक चर्चाएँ सबके लिए दृश्यमान हैं नोस्टर पर तथा सभी - इनमें भाग ले सकते हैं। ये उत्कृष्ट हैं खुले समुदायों के लिए विशिष्ट विषयों के प्रसंग में। - नियमन का नियन्त्रण किया जा सकता है पत्रों को मिटाने से पुनःप्रसारकों में</string> - <string name="public_chat_relays_explainer">इस समुदाय के निवास के लिए १ - ३ पुनःप्रसारकों को जोडें। - नोस्टर ग्राहक इस स्थापना विकल्प का प्रयोग करेंगे यह जानने के लिए कि कहाँ से सन्देशों का अवरोहण करना है तथा कहाँ आपके सन्देश भेजने हैं।</string> + <string name="public_chat_explainer">सार्वजनिक चर्चाएँ सबके लिए दृश्यमान हैं नोस्टर पर तथा सभी इनमें भाग ले सकते हैं। ये उत्कृष्ट हैं खुले समुदायों के लिए विशिष्ट विषयों के प्रसंग में। नियमन का नियन्त्रण किया जा सकता है पत्रों को मिटाने से पुनःप्रसारकों में</string> + <string name="public_chat_relays_explainer">इस समुदाय के निवास के लिए १ - ३ पुनःप्रसारकों को जोडें। नोस्टर ग्राहक इस स्थापना विकल्प का प्रयोग करेंगे यह जानने के लिए कि कहाँ से सन्देशों का अवरोहण करना है तथा कहाँ आपके सन्देश भेजने हैं।</string> <string name="public_chat_relays_title">पुनःप्रसारक</string> <string name="public_chat_title">सार्वजनिक चर्चा उपतथ्य</string> <string name="public_chats">सार्वजनिक चर्चा</string> @@ -4780,10 +4760,7 @@ <string name="relay_auth_search_keywords">प्रमाण प्रमाणीकरण प्रवेशांकन पुनःप्रसारक हस्ताक्षरण सत्यापन निप॰४२ परिचय</string> <string name="relay_auth_settings_title">पुनःप्रसारक प्रमाणीकरण</string> <string name="relay_chat">पुनःप्रसारक चर्चा</string> - <string name="relay_chat_explainer">पुनःप्रसारक चर्चाएँ आवासी पुनःप्रसारक द्वारा नियन्त्रित चर्चा समुदाएँ हैं। - वे नोस्टर पर सभी के लिए दृश्य हैं तथा उनमें सभी भाग ले सकते हैं। - वे उत्कृष्ट हैं खुले समुदायों के लिए विशिष्ट विषयों पर। इनमें से कुछ समुदाएँ अस्थायी हैं। - तथा इसीलिए समय के साथ चर्चा सन्देश अदृश्य हो जाते हैं</string> + <string name="relay_chat_explainer">पुनःप्रसारक चर्चाएँ आवासी पुनःप्रसारक द्वारा नियन्त्रित चर्चा समुदाएँ हैं। वे नोस्टर पर सभी के लिए दृश्य हैं तथा उनमें सभी भाग ले सकते हैं। वे उत्कृष्ट हैं खुले समुदायों के लिए विशिष्ट विषयों पर। इनमें से कुछ समुदाएँ अस्थायी हैं। तथा इसीलिए समय के साथ चर्चा सन्देश अदृश्य हो जाते हैं</string> <string name="relay_chat_title">पुनःप्रसारक चर्चाएँ</string> <string name="relay_explain_account_data">आपके अपने परिचय तथा स्थापना विकल्प तथा पाण्डुलिपियाँ। आपके मुख्य पुनःप्रसारकों पर।</string> <string name="relay_explain_community_chats">पुनःप्रसारक जिनपर प्रत्येक समुदाय अपने समतलों को प्रकाशित करते हैं।</string> diff --git a/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml b/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml index 4931f70f61..f7872f3f26 100644 --- a/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-hu-rHU/strings.xml @@ -311,7 +311,7 @@ <string name="podcast_value_split_percent">%1$d%%</string> <string name="podcast_value_for_value">Értéket az értékért</string> <string name="relay_monitor_rtt_open">Megnyitás</string> - <string name="relay_monitor_rtt_read">Olvasás </string> + <string name="relay_monitor_rtt_read">Olvasás</string> <string name="relay_monitor_rtt_write">Írás</string> <string name="relay_monitor_network">Hálózat</string> <string name="relay_monitor_relay_type">Típus</string> @@ -461,8 +461,7 @@ <string name="send_payment_receipt_section">Zap-igazolás</string> <string name="send_payment_receipt_clink">Közvetlen lightning-fizetés - nem lesz zapigazolás közzétéve a Nostr-on.</string> <string name="send_payment_receipt_onchain">Egy láncon belüli zapigazolás közzé lesz téve a Nostr-on, így a címzett megtalálhatja a kifizetést.</string> - <string name="send_payment_receipt_onchain_address">Fizetés közvetlenül a láncon belüli pénztárcából a profil megadott bitcoin-címére (%1$s) - nem lesz zapigazolás közzétéve. -</string> + <string name="send_payment_receipt_onchain_address">Fizetés közvetlenül a láncon belüli pénztárcából a profil megadott bitcoin-címére (%1$s) - nem lesz zapigazolás közzétéve.</string> <string name="send_payment_receipt_cashu">A nutzap-esemény magát az ecasht kézbesíti, így az mindig közzé lesz téve.</string> <string name="send_payment_requesting_invoice">Számla kérése…</string> <string name="send_payment_requesting_invoice_nostr">Számla kérése a Nostr hálózaton keresztül…</string> @@ -647,15 +646,8 @@ <string name="mark_all_known_as_read">Az összes ismert megjelölése olvasottként</string> <string name="mark_all_new_as_read">Az összes új üzenet megjelölése olvasottként</string> <string name="mark_all_as_read">Összes megjelölése olvasottként</string> - <string name="account_backup_tips2_md"> ## Kulcs- és biztonsági mentési tippek - \n\nFiókját egy titkos kulcs védi. A kulcs egy hosszú véletlenszerű karakterlánc, amely **nsec1**-vel kezdődik. Bárki, aki az Ön titkos kulcsához hozzáfér, az Ön személyazonosságának használatával bármilyen tartalmat közzétehet. - \n\n- **Ne** helyezze el a titkos kulcsát olyan webhelyen vagy szoftverben, amelyben nem bízik. - \n- Az Amethyst fejlesztői az Ön titkos kulcsát **soha** nem fogják Öntől elkérni. - \n- A fiók-helyreállításának érdekében, a titkos kulcsáról **mindig** készítsen biztonsági másolatot. Javasoljuk egy jelszókezelő használatát. - </string> - <string name="account_backup_tips3_md"> A nagyobb biztonság érdekében titkosítsa egy jelszóval. A jelszóval védett kulcs **ncryptsec1**-vel kezdődik, és a jelszava nélkül nem használható. - \n\nHa elveszíti a jelszavát, nem tudja visszaállítani a kulcsát. - </string> + <string name="account_backup_tips2_md">## Kulcs- és biztonsági mentési tippek \n\nFiókját egy titkos kulcs védi. A kulcs egy hosszú véletlenszerű karakterlánc, amely **nsec1**-vel kezdődik. Bárki, aki az Ön titkos kulcsához hozzáfér, az Ön személyazonosságának használatával bármilyen tartalmat közzétehet. \n\n- **Ne** helyezze el a titkos kulcsát olyan webhelyen vagy szoftverben, amelyben nem bízik. \n- Az Amethyst fejlesztői az Ön titkos kulcsát **soha** nem fogják Öntől elkérni. \n- A fiók-helyreállításának érdekében, a titkos kulcsáról **mindig** készítsen biztonsági másolatot. Javasoljuk egy jelszókezelő használatát.</string> + <string name="account_backup_tips3_md">A nagyobb biztonság érdekében titkosítsa egy jelszóval. A jelszóval védett kulcs **ncryptsec1**-vel kezdődik, és a jelszava nélkül nem használható. \n\nHa elveszíti a jelszavát, nem tudja visszaállítani a kulcsát.</string> <string name="backup_keys_nudge_title">Biztonsági mentés készítése a kulcsokról</string> <string name="backup_keys_nudge_body">A titkos kulcs megadása az egyetlen módja a fiók elérésének. Ha elveszíti, akkor soha nem tudja visszaszerezni. Mentse el biztonságos helyre most.</string> <string name="backup_keys_nudge_backup_now">Biztonsági mentés most</string> @@ -779,7 +771,7 @@ <string name="award_badge_remove_recipient">Eltávolítás</string> <string name="badge_untitled">Cím nélküli kitűző</string> <string name="badge_awardees_label">A kitűzőt %1$d érdemelte ki</string> - <string name="profile_badges_header">Kitűzők · %1$d </string> + <string name="profile_badges_header">Kitűzők · %1$d</string> <string name="profile_badges_description">Válassza ki, hogy a megszerzett kitűzők közül melyek jelenjenek meg a profilban.</string> <string name="profile_badges_empty">Ön még nem kapott kitűzőt.</string> <string name="profile_apps_header">Alkalmazások · %1$d</string> @@ -1835,9 +1827,7 @@ <string name="push_server_none_explainer">Push-értesítések letiltása</string> <string name="push_server_uses_app_explainer">%1$s alkalmazást használ</string> <string name="push_server_install_app">Push-értesítések beállítása</string> - <string name="push_server_install_app_description"> A push-értesítések fogadásához olyan alkalmazást telepítsen, amely támogatja a [Unified Push](https://unifiedpush.org/), például az [Ntfy](https://ntfy.sh/) alkalmazást. - A telepítés után a beállításokban válassza ki a használni kívánt alkalmazást. - </string> + <string name="push_server_install_app_description">A push-értesítések fogadásához olyan alkalmazást telepítsen, amely támogatja a [Unified Push](https://unifiedpush.org/), például az [Ntfy](https://ntfy.sh/) alkalmazást. A telepítés után a beállításokban válassza ki a használni kívánt alkalmazást.</string> <string name="thread_title">Bejegyzés</string> <string name="send_the_seller_a_message">Üzenet küldése az eladónak</string> <string name="hi_there_is_this_still_available">Tisztelt hölgyem / uram! Ez még aktuális?</string> @@ -3124,7 +3114,7 @@ <string name="app_notification_calls_channel_description">Értesítések a bejövő hang- és videóhívásokhoz</string> <string name="app_notification_calls_channel_name">Bejövő hívások</string> <string name="app_notification_chess_challenge_accepted">%1$s elfogadta az Ön sakk-kihívását</string> - <string name="app_notification_chess_channel_description">Értesítés a sakkjátékkal kapcsolatos eseményekre </string> + <string name="app_notification_chess_channel_description">Értesítés a sakkjátékkal kapcsolatos eseményekre</string> <string name="app_notification_chess_channel_name">Sakk</string> <string name="app_notification_chess_summary">Sakkfrissítések</string> <string name="app_notification_chess_your_turn">%1$s lépett - Ön következik</string> @@ -3586,15 +3576,7 @@ <string name="could_not_fetch_invoice_from_details">Nem sikerült lekérni a számlát a következőtől: %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Nem sikerült megnyitni a tömörített fájlt</string> <string name="couldnt_find_nwc_wallets">Nem található pénztárca</string> - <string name="couldnt_find_nwc_wallets_description">Az Amethyst nem talált olyan pénztárca-alkalmazást, amely támogatja a Nostr Wallet Connect (NWC) szolgáltatást. -\n\nAmit tehet: -\n\t1. NWC-támogatás ellenőrzése: Ellenőrizze, hogy a kívánt pénztárca-alkalmazás kompatibilis-e a Nostr Wallet Connect szolgáltatással. -\n\t2. Kapcsolat létrehozása: Nyissa meg a pénztárcaalkalmazást, és hozzon létre egy új NWC-kapcsolatot. -\n\t3. Kapcsolódás az Amethysthez: A pénztárcája általában három lehetőséget kínál: -\n\t\t3.1 Automatikus kapcsolódás: Egy gomb az Amethyst automatikus megnyitásához és kapcsolódáshoz. Koppintson erre a gombra, nyissa meg az Amethyst alkalmazást, és mentse el az új képernyőn. -\n\t\t3.2 Kézi kapcsolódás: Egy kapcsolódási cím, amelyet kimásolhat, és a képernyőn található beillesztés gombra koppintva közvetlenül beírhatja. -\n\t\t3.3 QR-kód: A pénztárca létrehoz egy QR-kódot, amelyet a képernyőn található QR-kód gombról olvashat be. - </string> + <string name="couldnt_find_nwc_wallets_description">Az Amethyst nem talált olyan pénztárca-alkalmazást, amely támogatja a Nostr Wallet Connect (NWC) szolgáltatást. \n\nAmit tehet: \n\t1. NWC-támogatás ellenőrzése: Ellenőrizze, hogy a kívánt pénztárca-alkalmazás kompatibilis-e a Nostr Wallet Connect szolgáltatással. \n\t2. Kapcsolat létrehozása: Nyissa meg a pénztárcaalkalmazást, és hozzon létre egy új NWC-kapcsolatot. \n\t3. Kapcsolódás az Amethysthez: A pénztárcája általában három lehetőséget kínál: \n\t\t3.1 Automatikus kapcsolódás: Egy gomb az Amethyst automatikus megnyitásához és kapcsolódáshoz. Koppintson erre a gombra, nyissa meg az Amethyst alkalmazást, és mentse el az új képernyőn. \n\t\t3.2 Kézi kapcsolódás: Egy kapcsolódási cím, amelyet kimásolhat, és a képernyőn található beillesztés gombra koppintva közvetlenül beírhatja. \n\t\t3.3 QR-kód: A pénztárca létrehoz egy QR-kódot, amelyet a képernyőn található QR-kód gombról olvashat be.</string> <string name="create">Létrehozás</string> <string name="d">n</string> <string name="danger_zone">Kritikus beállítások</string> @@ -3884,7 +3866,7 @@ <string name="kind_adventure_reading">Kalandos olvasmány</string> <string name="kind_adventure_scene">Kalandjelenet</string> <string name="kind_app_curation_set">Alkalmazáslista</string> - <string name="kind_app_recommendations">Ajánlott alkalmazások </string> + <string name="kind_app_recommendations">Ajánlott alkalmazások</string> <string name="kind_appointment">Találkozó</string> <string name="kind_apps">Alkalmazások</string> <string name="kind_appt_rsvp">Időpont-visszaigazolás</string> @@ -4712,11 +4694,8 @@ <string name="proxy_section">Proxyzott átjátszók</string> <string name="proxy_section_explainer">Összesítő átjátszók, amelyeket az alkalmazásnak használnia kell a hírfolyamok letöltéséhez, például filter.nostr.wine. Ez helyettesíti a kimeneti modellt, és az alkalmazás csak a listákban szereplő átjátszókhoz fog csatlakozni.</string> <string name="public_chat">Nyilvános csevegés</string> - <string name="public_chat_explainer">A nyilvános csevegések mindenki számára láthatóak a Nostr-on, és bárki - részt vehet bennük. Ezek kiválóan alkalmasak bizonyos témák köré szerveződő nyílt közösségek számára. - A moderálás az átjátszókon lévő hozzászólások törlésével szabályozható</string> - <string name="public_chat_relays_explainer">Adjon hozzá 1–3 olyan átjátszót, amelyek kiszolgálják ezt a csoportot. - A Nostr-kliensek ezt a beállítást használják arra, hogy tudják, honnan töltsék le az üzeneteket, és hová küldjék az üzeneteket.</string> + <string name="public_chat_explainer">A nyilvános csevegések mindenki számára láthatóak a Nostr-on, és bárki részt vehet bennük. Ezek kiválóan alkalmasak bizonyos témák köré szerveződő nyílt közösségek számára. A moderálás az átjátszókon lévő hozzászólások törlésével szabályozható</string> + <string name="public_chat_relays_explainer">Adjon hozzá 1–3 olyan átjátszót, amelyek kiszolgálják ezt a csoportot. A Nostr-kliensek ezt a beállítást használják arra, hogy tudják, honnan töltsék le az üzeneteket, és hová küldjék az üzeneteket.</string> <string name="public_chat_relays_title">Átjátszók</string> <string name="public_chat_title">Nyilvános csevegés metaadatai</string> <string name="public_chats">Nyilvános csevegések</string> @@ -4781,10 +4760,7 @@ <string name="relay_auth_search_keywords">hitelesítés, átjátszó, aláírás, ellenőrzés, nip-42, azonosság</string> <string name="relay_auth_settings_title">Átjátszó-hitelesítés</string> <string name="relay_chat">Átjátszócsevegés</string> - <string name="relay_chat_explainer">Az átjátszócsevegések olyan csevegőcsoportok, amelyeket az otthoni átjátszó irányít. - Ezek mindenki számára láthatóak a Nostr-on, és bárki részt vehet rajtuk. - Remekül alkalmasak nyitott közösségek kialakítására bizonyos témák körül. Néhány ilyen csoport - rövid élettartamú, ezért a csevegési üzenetek idővel eltűnnek</string> + <string name="relay_chat_explainer">Az átjátszócsevegések olyan csevegőcsoportok, amelyeket az otthoni átjátszó irányít. Ezek mindenki számára láthatóak a Nostr-on, és bárki részt vehet rajtuk. Remekül alkalmasak nyitott közösségek kialakítására bizonyos témák körül. Néhány ilyen csoport rövid élettartamú, ezért a csevegési üzenetek idővel eltűnnek</string> <string name="relay_chat_title">Átjátszócsevegések</string> <string name="relay_explain_account_data">Saját profil, -beállítások és -piszkozatok a gazda-átjátszókon.</string> <string name="relay_explain_community_chats">Azok az átjátszók, amelyekre az egyes közösségek közzéteszik a terveiket.</string> diff --git a/commonsUI/src/commonMain/composeResources/values-in-rID/strings.xml b/commonsUI/src/commonMain/composeResources/values-in-rID/strings.xml index 7b53a2b3e2..3ce5510f41 100644 --- a/commonsUI/src/commonMain/composeResources/values-in-rID/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-in-rID/strings.xml @@ -266,15 +266,8 @@ <string name="mark_all_known_as_read">Tandai semua yang dikenal sebagai telah dibaca</string> <string name="mark_all_new_as_read">Tandai semua yang baru sebagai telah dibaca</string> <string name="mark_all_as_read">Tandai semua sebagai telah dibaca</string> - <string name="account_backup_tips2_md"> ## Tips Cadangan Kunci dan Keamanan - \n\nAkun Anda diamankan dengan kunci rahasia. Kunci ini adalah rangkaian karakter panjang yang diawali dengan **nsec1**. Siapa pun yang memiliki akses ke kunci rahasia ini dapat memposting dan mengubah identitas Anda. - \n\n- **Jangan** memasukkan kunci rahasia Anda ke situs web atau perangkat lunak yang tidak Anda percaya. - \n- Pengembang Amethyst **tidak akan pernah** meminta kunci rahasia Anda. - \n- **Lakukan** pencadangan kunci rahasia Anda secara aman untuk pemulihan akun. Kami merekomendasikan penggunaan pengelola kata sandi. - </string> - <string name="account_backup_tips3_md"> Untuk keamanan tambahan, Anda dapat mengenkripsi kunci dengan kata sandi. Kunci ini diawali dengan **ncryptsec1** dan tidak dapat digunakan tanpa kata sandi Anda. - \n\nJika Anda kehilangan kata sandi, Anda tidak akan dapat memulihkan kunci Anda. - </string> + <string name="account_backup_tips2_md">## Tips Cadangan Kunci dan Keamanan \n\nAkun Anda diamankan dengan kunci rahasia. Kunci ini adalah rangkaian karakter panjang yang diawali dengan **nsec1**. Siapa pun yang memiliki akses ke kunci rahasia ini dapat memposting dan mengubah identitas Anda. \n\n- **Jangan** memasukkan kunci rahasia Anda ke situs web atau perangkat lunak yang tidak Anda percaya. \n- Pengembang Amethyst **tidak akan pernah** meminta kunci rahasia Anda. \n- **Lakukan** pencadangan kunci rahasia Anda secara aman untuk pemulihan akun. Kami merekomendasikan penggunaan pengelola kata sandi.</string> + <string name="account_backup_tips3_md">Untuk keamanan tambahan, Anda dapat mengenkripsi kunci dengan kata sandi. Kunci ini diawali dengan **ncryptsec1** dan tidak dapat digunakan tanpa kata sandi Anda. \n\nJika Anda kehilangan kata sandi, Anda tidak akan dapat memulihkan kunci Anda.</string> <string name="encrypt_and_copy_my_secret_key">Enkripsi dan salin kunci rahasia saya</string> <string name="badge_award_image_for">Gambar penghargaan lencana untuk %1$s</string> <string name="badge_award_image">"Gambar penghargaan lencana</string> @@ -853,13 +846,11 @@ <string name="meeting_space_closed_tag">DITUTUP</string> <string name="meeting_space_planned_tag">TERJADWAL</string> <string name="meeting_space_planned_starts_at">Mulai %1$s</string> - <string name="are_you_sure_you_want_to_log_out">Keluar akan menghapus semua informasi yang disimpan secara lokal. -Pastikan kunci pribadi Anda telah simpan untuk menghindari kehilangan akun Anda. Apakah Anda ingin melanjutkan?</string> + <string name="are_you_sure_you_want_to_log_out">Keluar akan menghapus semua informasi yang disimpan secara lokal. Pastikan kunci pribadi Anda telah simpan untuk menghindari kehilangan akun Anda. Apakah Anda ingin melanjutkan?</string> <string name="followed_tags">Tags yang Diikuti</string> <string name="discover_follows_explainer">Ini adalah daftar pengguna yang Anda rekomendasikan kepada orang lain. Hanya pengguna publik yang diizinkan.</string> <string name="community_approved_posts">Post yang disetujui</string> - <string name="groups_no_descriptor">Grup ini tidak memiliki deskripsi atau peraturan. -Beri tahu kepada pemilik untuk menambahnya</string> + <string name="groups_no_descriptor">Grup ini tidak memiliki deskripsi atau peraturan. Beri tahu kepada pemilik untuk menambahnya</string> <string name="community_no_descriptor">Komunitas ini tidak memiliki deskripsi. Beri tahu kepada pemilik untuk menambahnya</string> <string name="user_preferences">Preferensi Pengguna</string> <string name="settings_search_placeholder">Cari pengaturan</string> @@ -951,9 +942,7 @@ Beri tahu kepada pemilik untuk menambahnya</string> <string name="push_server_none_explainer">Matikan Pemberitahuan Push</string> <string name="push_server_uses_app_explainer">Memakai aplikasi %1$s</string> <string name="push_server_install_app">Pengaturan Pemberitahuan Push</string> - <string name="push_server_install_app_description"> Untuk menerima Pemberitahuan Push, Install aplikasi yang mendukung [Unified Push](https://unifiedpush.org/), seperti [Ntfy](https://ntfy.sh/). - Setelah diinstall, Pilih aplikasi yang ingin digunakan di pengaturan. - </string> + <string name="push_server_install_app_description">Untuk menerima Pemberitahuan Push, Install aplikasi yang mendukung [Unified Push](https://unifiedpush.org/), seperti [Ntfy](https://ntfy.sh/). Setelah diinstall, Pilih aplikasi yang ingin digunakan di pengaturan.</string> <string name="thread_title">Utas</string> <string name="send_the_seller_a_message">Kirim pesan ke penjual</string> <string name="hi_there_is_this_still_available">Halo, apakah ini masih tersedia?</string> @@ -1991,15 +1980,7 @@ Beri tahu kepada pemilik untuk menambahnya</string> <string name="could_not_fetch_invoice_from_details">Tidak dapat mengambil invoice dari %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Tidak dapat membuka file terkompresi</string> <string name="couldnt_find_nwc_wallets">Dompet tidak ditemukan</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst tidak dapat menemukan aplikasi dompet apa pun yang mendukung Nostr Wallet Connect (NWC). -\n\nYang dapat Anda lakukan: -\n\t1. Verifikasi Dukungan NWC: Pastikan aplikasi dompet pilihan Anda kompatibel dengan Nostr Wallet Connect. -\n\t2. Buat Koneksi: Buka aplikasi dompet Anda dan buat koneksi NWC baru. -\n\t3. Hubungkan ke Amethyst: Dompet Anda biasanya akan memberikan tiga pilihan: -\n\t\t3.1 Tautan Otomatis: Tombol untuk secara otomatis membuka dan terhubung ke Amethyst. Jika ada, klik tombol tersebut, buka Amethyst dan tekan simpan di layar baru. -\n\t\t3.2 Tautan Manual: URI Koneksi yang dapat Anda salin dan klik ikon tempel di layar ini untuk memasukkannya secara langsung. -\n\t\t3.3 Kode QR: Dompet membuat kode QR yang dapat Anda baca dari tombol kode QR di layar ini. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst tidak dapat menemukan aplikasi dompet apa pun yang mendukung Nostr Wallet Connect (NWC). \n\nYang dapat Anda lakukan: \n\t1. Verifikasi Dukungan NWC: Pastikan aplikasi dompet pilihan Anda kompatibel dengan Nostr Wallet Connect. \n\t2. Buat Koneksi: Buka aplikasi dompet Anda dan buat koneksi NWC baru. \n\t3. Hubungkan ke Amethyst: Dompet Anda biasanya akan memberikan tiga pilihan: \n\t\t3.1 Tautan Otomatis: Tombol untuk secara otomatis membuka dan terhubung ke Amethyst. Jika ada, klik tombol tersebut, buka Amethyst dan tekan simpan di layar baru. \n\t\t3.2 Tautan Manual: URI Koneksi yang dapat Anda salin dan klik ikon tempel di layar ini untuk memasukkannya secara langsung. \n\t\t3.3 Kode QR: Dompet membuat kode QR yang dapat Anda baca dari tombol kode QR di layar ini.</string> <string name="create">Buat</string> <string name="d">h</string> <string name="danger_zone">Zona Berbahaya</string> @@ -2183,8 +2164,7 @@ Beri tahu kepada pemilik untuk menambahnya</string> <string name="image_saved_to_the_gallery">Gambar disimpan ke galeri</string> <string name="impersonation">Identitas palsu</string> <string name="inbox_relays_title">Relay Kotak Masuk</string> - <string name="incorrect_invoice_amount_sats_from_it_should_have_been">Jumlah faktur salah (%1$s sat) dari %2$s. -Seharusnya %3$s</string> + <string name="incorrect_invoice_amount_sats_from_it_should_have_been">Jumlah faktur salah (%1$s sat) dari %2$s. Seharusnya %3$s</string> <string name="indexer_section">Relay Indeks</string> <string name="indexer_section_explainer">Relay yang berspesialisasi dalam menyimpan metadata dan daftar relay semua orang, seperti purplepag.es. Amethyst akan menggunakan relay ini untuk menemukan pengguna yang tidak ada dalam daftar Anda.</string> <string name="interest_set_creation_screen_title">Kumpulan Minat Baru</string> @@ -2618,11 +2598,8 @@ Seharusnya %3$s</string> <string name="proxy_section">Relay Proxy</string> <string name="proxy_section_explainer">Relay agregator yang harus digunakan aplikasi untuk mengunduh feed Anda, seperti filter.nostr.wine. Ini menggantikan model outbox dan akan membuat aplikasi hanya terhubung ke relay dalam daftar Anda.</string> <string name="public_chat">Obrolan Publik</string> - <string name="public_chat_explainer">Obrolan publik terlihat oleh semua orang di Nostr dan siapa pun - dapat berpartisipasi. Sangat cocok untuk komunitas terbuka seputar topik tertentu. - Moderasi dapat dilakukan dengan menghapus postingan di relay-nya</string> - <string name="public_chat_relays_explainer">Masukkan antara 1–3 relay yang menjadi host grup ini. - Klien Nostr menggunakan pengaturan ini untuk mengetahui tempat mengunduh dan mengirim pesan Anda.</string> + <string name="public_chat_explainer">Obrolan publik terlihat oleh semua orang di Nostr dan siapa pun dapat berpartisipasi. Sangat cocok untuk komunitas terbuka seputar topik tertentu. Moderasi dapat dilakukan dengan menghapus postingan di relay-nya</string> + <string name="public_chat_relays_explainer">Masukkan antara 1–3 relay yang menjadi host grup ini. Klien Nostr menggunakan pengaturan ini untuk mengetahui tempat mengunduh dan mengirim pesan Anda.</string> <string name="public_chat_relays_title">relay</string> <string name="public_chat_title">Metadata Obrolan Publik</string> <string name="public_chats">Obrolan Publik</string> @@ -2647,10 +2624,7 @@ Seharusnya %3$s</string> <string name="read_only_user">Pengguna hanya-baca</string> <string name="record_a_message_description">Tekan dan tahan untuk merekam pesan</string> <string name="relay_chat">Obrolan relay</string> - <string name="relay_chat_explainer">Obrolan relay adalah grup obrolan yang dikendalikan oleh relay induknya. - Obrolan ini terlihat oleh semua orang di Nostr dan siapa pun dapat berpartisipasi. - Sangat cocok untuk komunitas terbuka seputar topik tertentu. Beberapa grup ini bersifat sementara - sehingga pesan obrolan akan menghilang seiring waktu</string> + <string name="relay_chat_explainer">Obrolan relay adalah grup obrolan yang dikendalikan oleh relay induknya. Obrolan ini terlihat oleh semua orang di Nostr dan siapa pun dapat berpartisipasi. Sangat cocok untuk komunitas terbuka seputar topik tertentu. Beberapa grup ini bersifat sementara sehingga pesan obrolan akan menghilang seiring waktu</string> <string name="relay_chat_title">Obrolan relay</string> <string name="relay_management_tab_events">Acara</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-in/strings.xml b/commonsUI/src/commonMain/composeResources/values-in/strings.xml index 7635510369..2fe9f6457e 100644 --- a/commonsUI/src/commonMain/composeResources/values-in/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-in/strings.xml @@ -172,7 +172,7 @@ <string name="username">Nama pengguna</string> <string name="about_me">Tentang saya</string> <string name="avatar_url">URL Avatar</string> - <string name="banner_url">URL Spanduk/Banner </string> + <string name="banner_url">URL Spanduk/Banner</string> <string name="website_url">URL Situs Web</string> <string name="pronouns">Kata ganti</string> <string name="stale_relay_hint_label">relay sumber mungkin sudah usang</string> @@ -257,17 +257,8 @@ <string name="mark_all_known_as_read">Tandai semua yg dikenal telah dibaca</string> <string name="mark_all_new_as_read">Tandai pesan baru telah dibaca</string> <string name="mark_all_as_read">Tandai semua telah dibaca</string> - <string name="account_backup_tips2_md"> - ## Tips Cadangan Kunci dan Keamanan - \n\nAkun Anda diamankan dengan kunci rahasia. Kunci ini adalah rangkaian karakter panjang yang diawali dengan **nsec1**. Siapa pun yang memiliki akses ke kunci rahasia ini dapat memposting dan mengubah identitas Anda. - \n\n- **Jangan** memasukkan kunci rahasia Anda ke situs web atau perangkat lunak yang tidak Anda percaya. - \n- Pengembang Amethyst **tidak akan pernah** meminta kunci rahasia Anda. - \n- **Lakukan** pencadangan kunci rahasia Anda secara aman untuk pemulihan akun. Kami merekomendasikan penggunaan pengelola kata sandi. - </string> - <string name="account_backup_tips3_md"> - Untuk keamanan tambahan, Anda dapat mengenkripsi kunci dengan kata sandi. Kunci ini diawali dengan **ncryptsec1** dan tidak dapat digunakan tanpa kata sandi Anda. - \n\nJika Anda kehilangan kata sandi, Anda tidak akan dapat memulihkan kunci Anda. - </string> + <string name="account_backup_tips2_md">## Tips Cadangan Kunci dan Keamanan \n\nAkun Anda diamankan dengan kunci rahasia. Kunci ini adalah rangkaian karakter panjang yang diawali dengan **nsec1**. Siapa pun yang memiliki akses ke kunci rahasia ini dapat memposting dan mengubah identitas Anda. \n\n- **Jangan** memasukkan kunci rahasia Anda ke situs web atau perangkat lunak yang tidak Anda percaya. \n- Pengembang Amethyst **tidak akan pernah** meminta kunci rahasia Anda. \n- **Lakukan** pencadangan kunci rahasia Anda secara aman untuk pemulihan akun. Kami merekomendasikan penggunaan pengelola kata sandi.</string> + <string name="account_backup_tips3_md">Untuk keamanan tambahan, Anda dapat mengenkripsi kunci dengan kata sandi. Kunci ini diawali dengan **ncryptsec1** dan tidak dapat digunakan tanpa kata sandi Anda. \n\nJika Anda kehilangan kata sandi, Anda tidak akan dapat memulihkan kunci Anda.</string> <string name="encrypt_and_copy_my_secret_key">Enkripsi dan salin kunci rahasia saya</string> <string name="badge_award_image_for">Gambar penghargaan lencana untuk %1$s</string> <string name="badge_award_image">"Gambar penghargaan lencana</string> @@ -960,10 +951,7 @@ <string name="push_server_none_explainer">Menonaktifkan Notifikasi Push</string> <string name="push_server_uses_app_explainer">Menggunakan aplikasi %1$s</string> <string name="push_server_install_app">Pengaturan Notifikasi Push</string> - <string name="push_server_install_app_description"> - Untuk menerima notifikasi push, instal aplikasi yang mendukung [Unified Push](https://unifiedpush.org/), seperti [Ntfy](https://ntfy.sh/). - Setelah menginstal, pilih aplikasi yang ingin Anda gunakan di Pengaturan. - </string> + <string name="push_server_install_app_description">Untuk menerima notifikasi push, instal aplikasi yang mendukung [Unified Push](https://unifiedpush.org/), seperti [Ntfy](https://ntfy.sh/). Setelah menginstal, pilih aplikasi yang ingin Anda gunakan di Pengaturan.</string> <string name="thread_title">Utas</string> <string name="send_the_seller_a_message">Kirim pesan ke penjual</string> <string name="hi_there_is_this_still_available">Halo, apakah ini masih tersedia?</string> @@ -2048,15 +2036,7 @@ <string name="could_not_fetch_invoice_from_details">Tidak dapat mengambil invoice dari %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Tidak dapat membuka file terkompresi</string> <string name="couldnt_find_nwc_wallets">Dompet tidak ditemukan</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst tidak dapat menemukan aplikasi dompet apa pun yang mendukung Nostr Wallet Connect (NWC). -\n\nYang dapat Anda lakukan: -\n\t1. Verifikasi Dukungan NWC: Pastikan aplikasi dompet pilihan Anda kompatibel dengan Nostr Wallet Connect. -\n\t2. Buat Koneksi: Buka aplikasi dompet Anda dan buat koneksi NWC baru. -\n\t3. Hubungkan ke Amethyst: Dompet Anda biasanya akan memberikan tiga pilihan: -\n\t\t3.1 Tautan Otomatis: Tombol untuk secara otomatis membuka dan terhubung ke Amethyst. Jika ada, klik tombol tersebut, buka Amethyst dan tekan simpan di layar baru. -\n\t\t3.2 Tautan Manual: URI Koneksi yang dapat Anda salin dan klik ikon tempel di layar ini untuk memasukkannya secara langsung. -\n\t\t3.3 Kode QR: Dompet membuat kode QR yang dapat Anda baca dari tombol kode QR di layar ini. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst tidak dapat menemukan aplikasi dompet apa pun yang mendukung Nostr Wallet Connect (NWC). \n\nYang dapat Anda lakukan: \n\t1. Verifikasi Dukungan NWC: Pastikan aplikasi dompet pilihan Anda kompatibel dengan Nostr Wallet Connect. \n\t2. Buat Koneksi: Buka aplikasi dompet Anda dan buat koneksi NWC baru. \n\t3. Hubungkan ke Amethyst: Dompet Anda biasanya akan memberikan tiga pilihan: \n\t\t3.1 Tautan Otomatis: Tombol untuk secara otomatis membuka dan terhubung ke Amethyst. Jika ada, klik tombol tersebut, buka Amethyst dan tekan simpan di layar baru. \n\t\t3.2 Tautan Manual: URI Koneksi yang dapat Anda salin dan klik ikon tempel di layar ini untuk memasukkannya secara langsung. \n\t\t3.3 Kode QR: Dompet membuat kode QR yang dapat Anda baca dari tombol kode QR di layar ini.</string> <string name="create">Buat</string> <string name="d">hari</string> <string name="danger_zone">Zona Berbahaya</string> @@ -2723,11 +2703,8 @@ <string name="proxy_section">Relay Proxy</string> <string name="proxy_section_explainer">Relay agregator yang harus digunakan aplikasi untuk mengunduh feed Anda, seperti filter.nostr.wine. Ini menggantikan model outbox dan akan membuat aplikasi hanya terhubung ke relay dalam daftar Anda.</string> <string name="public_chat">Percakapan Publik</string> - <string name="public_chat_explainer">Obrolan publik terlihat oleh semua orang di Nostr dan siapa pun - dapat berpartisipasi. Sangat cocok untuk komunitas terbuka seputar topik tertentu. - Moderasi dapat dilakukan dengan menghapus postingan di relay-nya</string> - <string name="public_chat_relays_explainer">Masukkan antara 1–3 relay yang menjadi host grup ini. - Klien Nostr menggunakan pengaturan ini untuk mengetahui tempat mengunduh dan mengirim pesan Anda.</string> + <string name="public_chat_explainer">Obrolan publik terlihat oleh semua orang di Nostr dan siapa pun dapat berpartisipasi. Sangat cocok untuk komunitas terbuka seputar topik tertentu. Moderasi dapat dilakukan dengan menghapus postingan di relay-nya</string> + <string name="public_chat_relays_explainer">Masukkan antara 1–3 relay yang menjadi host grup ini. Klien Nostr menggunakan pengaturan ini untuk mengetahui tempat mengunduh dan mengirim pesan Anda.</string> <string name="public_chat_relays_title">relay</string> <string name="public_chat_title">Metadata Obrolan Publik</string> <string name="public_chats">Obrolan Publik</string> @@ -2752,10 +2729,7 @@ <string name="read_only_user">Pengguna hanya-baca</string> <string name="record_a_message_description">Tekan dan tahan untuk merekam pesan</string> <string name="relay_chat">Obrolan relay</string> - <string name="relay_chat_explainer">Obrolan relay adalah grup obrolan yang dikendalikan oleh relay induknya. - Obrolan ini terlihat oleh semua orang di Nostr dan siapa pun dapat berpartisipasi. - Sangat cocok untuk komunitas terbuka seputar topik tertentu. Beberapa grup ini bersifat sementara - sehingga pesan obrolan akan menghilang seiring waktu</string> + <string name="relay_chat_explainer">Obrolan relay adalah grup obrolan yang dikendalikan oleh relay induknya. Obrolan ini terlihat oleh semua orang di Nostr dan siapa pun dapat berpartisipasi. Sangat cocok untuk komunitas terbuka seputar topik tertentu. Beberapa grup ini bersifat sementara sehingga pesan obrolan akan menghilang seiring waktu</string> <string name="relay_chat_title">Obrolan relay</string> <string name="relay_management_tab_events">Acara</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-it-rIT/strings.xml b/commonsUI/src/commonMain/composeResources/values-it-rIT/strings.xml index aff7bdaf21..54245dec39 100644 --- a/commonsUI/src/commonMain/composeResources/values-it-rIT/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-it-rIT/strings.xml @@ -266,15 +266,8 @@ <string name="mark_all_known_as_read">Segna tutti i conosciuti come letti</string> <string name="mark_all_new_as_read">Segna tutti i nuovi come letti</string> <string name="mark_all_as_read">Segna tutti come letti</string> - <string name="account_backup_tips2_md"> ## Suggerimenti per il backup e la sicurezza della chiave - \n\nIl tuo account è protetto da una chiave segreta. La chiave è una lunga sequenza di caratteri che inizia con **nsec1**. Chiunque abbia accesso a questa chiave segreta può pubblicare e modificare la tua identità. - \n\n- **Non** inserire la tua chiave segreta in nessun sito web o software di cui non ti fidi. - \n- Gli sviluppatori di Amethyst non chiederanno **mai** la tua chiave segreta. - \n- **Conserva** un backup sicuro della tua chiave segreta per il recupero dell'account. Si consiglia l'uso di un gestore di password. - </string> - <string name="account_backup_tips3_md"> Per maggiore sicurezza, puoi cifrare la tua chiave con una password. Questa chiave inizia con **ncryptsec1** e non può essere utilizzata senza la tua password. - \n\nSe perdi la password, non potrai recuperare la tua chiave. - </string> + <string name="account_backup_tips2_md">## Suggerimenti per il backup e la sicurezza della chiave \n\nIl tuo account è protetto da una chiave segreta. La chiave è una lunga sequenza di caratteri che inizia con **nsec1**. Chiunque abbia accesso a questa chiave segreta può pubblicare e modificare la tua identità. \n\n- **Non** inserire la tua chiave segreta in nessun sito web o software di cui non ti fidi. \n- Gli sviluppatori di Amethyst non chiederanno **mai** la tua chiave segreta. \n- **Conserva** un backup sicuro della tua chiave segreta per il recupero dell'account. Si consiglia l'uso di un gestore di password.</string> + <string name="account_backup_tips3_md">Per maggiore sicurezza, puoi cifrare la tua chiave con una password. Questa chiave inizia con **ncryptsec1** e non può essere utilizzata senza la tua password. \n\nSe perdi la password, non potrai recuperare la tua chiave.</string> <string name="encrypt_and_copy_my_secret_key">Cifra e copia la mia chiave segreta</string> <string name="badge_award_image_for">Immagine premio badge per %1$s</string> <string name="badge_award_image">"Immagine del premio badge</string> @@ -947,9 +940,7 @@ <string name="push_server_none_explainer">Disabilita le notifiche push</string> <string name="push_server_uses_app_explainer">Usa l'app %1$s</string> <string name="push_server_install_app">Configurazione notifiche push</string> - <string name="push_server_install_app_description"> Per ricevere notifiche push, installa qualsiasi app che supporta [Unified Push](https://unifiedpush.org/), come [Ntfy](https://ntfy.sh/). - Dopo l'installazione, seleziona l'app che desideri usare nelle Impostazioni. - </string> + <string name="push_server_install_app_description">Per ricevere notifiche push, installa qualsiasi app che supporta [Unified Push](https://unifiedpush.org/), come [Ntfy](https://ntfy.sh/). Dopo l'installazione, seleziona l'app che desideri usare nelle Impostazioni.</string> <string name="send_the_seller_a_message">Invia un messaggio al venditore</string> <string name="hi_there_is_this_still_available">Ciao, è ancora disponibile?</string> <string name="classifieds_title">Titolo</string> @@ -1986,15 +1977,7 @@ <string name="could_not_fetch_invoice_from_details">Impossibile recuperare la fattura da %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Impossibile aprire il file compresso</string> <string name="couldnt_find_nwc_wallets">Wallet non trovato</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst non ha trovato app wallet compatibili con Nostr Wallet Connect (NWC). -\n\nCosa puoi fare: -\n\t1. Verifica il supporto NWC: controlla che la tua app wallet preferita sia compatibile con Nostr Wallet Connect. -\n\t2. Crea connessione: vai nella tua app wallet e crea una nuova connessione NWC. -\n\t3. Collega ad Amethyst: la tua app wallet ti offrirà solitamente tre opzioni: -\n\t\t3.1 Collegamento automatico: un pulsante per aprire e connettersi automaticamente ad Amethyst. In tal caso, clicca quel pulsante, apri Amethyst e premi salva nella nuova schermata. -\n\t\t3.2 Collegamento manuale: un URI di connessione che puoi copiare e incollare tramite l'icona di incolla in questa schermata. -\n\t\t3.3 Codice QR: il wallet crea un codice QR che puoi leggere tramite il pulsante QR in questa schermata. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst non ha trovato app wallet compatibili con Nostr Wallet Connect (NWC). \n\nCosa puoi fare: \n\t1. Verifica il supporto NWC: controlla che la tua app wallet preferita sia compatibile con Nostr Wallet Connect. \n\t2. Crea connessione: vai nella tua app wallet e crea una nuova connessione NWC. \n\t3. Collega ad Amethyst: la tua app wallet ti offrirà solitamente tre opzioni: \n\t\t3.1 Collegamento automatico: un pulsante per aprire e connettersi automaticamente ad Amethyst. In tal caso, clicca quel pulsante, apri Amethyst e premi salva nella nuova schermata. \n\t\t3.2 Collegamento manuale: un URI di connessione che puoi copiare e incollare tramite l'icona di incolla in questa schermata. \n\t\t3.3 Codice QR: il wallet crea un codice QR che puoi leggere tramite il pulsante QR in questa schermata.</string> <string name="create">Crea</string> <string name="d">g</string> <string name="danger_zone">Zona pericolosa</string> @@ -2645,11 +2628,8 @@ <string name="proxy_section">Relay proxy</string> <string name="proxy_section_explainer">Relay aggregatori che l'app deve usare per scaricare i tuoi feed, come filter.nostr.wine. Questo sostituisce il modello outbox e farà connettere l'app solo ai relay nelle tue liste.</string> <string name="public_chat">Chat Pubblica</string> - <string name="public_chat_explainer">Le chat pubbliche sono visibili a tutti su Nostr e chiunque - può parteciparvi. Sono ideali per comunità aperte su argomenti specifici. - La moderazione può essere controllata eliminando i post sui relay associati</string> - <string name="public_chat_relays_explainer">Inserisci tra 1 e 3 relay che ospitano questo gruppo. - I client Nostr usano questa impostazione per sapere da dove scaricare i messaggi e dove inviare i tuoi messaggi.</string> + <string name="public_chat_explainer">Le chat pubbliche sono visibili a tutti su Nostr e chiunque può parteciparvi. Sono ideali per comunità aperte su argomenti specifici. La moderazione può essere controllata eliminando i post sui relay associati</string> + <string name="public_chat_relays_explainer">Inserisci tra 1 e 3 relay che ospitano questo gruppo. I client Nostr usano questa impostazione per sapere da dove scaricare i messaggi e dove inviare i tuoi messaggi.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Metadati chat pubblica</string> <string name="public_chats">Chat pubbliche</string> @@ -2674,10 +2654,7 @@ <string name="read_only_user">Utente in sola lettura</string> <string name="record_a_message_description">Tieni premuto per registrare un messaggio</string> <string name="relay_chat">Chat relay</string> - <string name="relay_chat_explainer">Le chat relay sono gruppi di chat controllati dal loro relay di riferimento. - Sono visibili a tutti su Nostr e chiunque può parteciparvi. - Sono ideali per comunità aperte su argomenti specifici. Alcuni di questi gruppi sono effimeri - e quindi i messaggi della chat scompaiono nel tempo</string> + <string name="relay_chat_explainer">Le chat relay sono gruppi di chat controllati dal loro relay di riferimento. Sono visibili a tutti su Nostr e chiunque può parteciparvi. Sono ideali per comunità aperte su argomenti specifici. Alcuni di questi gruppi sono effimeri e quindi i messaggi della chat scompaiono nel tempo</string> <string name="relay_chat_title">Chat relay</string> <string name="relay_management_tab_events">Eventi</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ja-rJP/strings.xml b/commonsUI/src/commonMain/composeResources/values-ja-rJP/strings.xml index 04d9abd43e..089c9f9857 100644 --- a/commonsUI/src/commonMain/composeResources/values-ja-rJP/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ja-rJP/strings.xml @@ -69,7 +69,7 @@ <string name="scan_qr">QRコードをスキャン</string> <string name="show_anyway">それでも表示する</string> <string name="post_was_hidden">このポストは、非表示にしているユーザーまたはワードが含まれているため隠されています</string> - <string name="post_was_flagged_as_inappropriate_by">このユーザによって投稿が不適切なものとしてマークされています: </string> + <string name="post_was_flagged_as_inappropriate_by">このユーザによって投稿が不適切なものとしてマークされています:</string> <string name="post_not_found">投稿が見つかりません</string> <string name="channel_image">チャンネル画像</string> <string name="referenced_event_not_found">参照先のイベントが見つかりません</string> @@ -271,15 +271,8 @@ <string name="mark_all_known_as_read">すべての「知り合い」を既読にする</string> <string name="mark_all_new_as_read">すべての「新規リクエスト」を既読にする</string> <string name="mark_all_as_read">すべて既読にする</string> - <string name="account_backup_tips2_md"> ## 鍵のバックアップとセキュリティのヒント - \n\nアカウントは秘密鍵によって保護されています。この鍵は **nsec1** で始まる長い文字列です。この秘密鍵にアクセスできる人は誰でも、あなたの名前でポストしたり、プロフィールを変更したりできます。 - \n\n- 信頼していないウェブサイトやアプリに秘密鍵を **入力しないでください**。 - \n- Amethyst の開発者が秘密鍵を **求めることは絶対にありません**。 - \n- アカウントの復元のために、秘密鍵の安全なバックアップを **必ず** 保管してください。パスワードマネージャーの使用をお勧めします。 - </string> - <string name="account_backup_tips3_md"> さらにセキュリティを高めるために、鍵をパスワードで暗号化することができます。この鍵は **ncryptsec1** で始まり、パスワードなしでは使用できません。 - \n\nパスワードを忘れると、鍵を復元できなくなります。 - </string> + <string name="account_backup_tips2_md">## 鍵のバックアップとセキュリティのヒント \n\nアカウントは秘密鍵によって保護されています。この鍵は **nsec1** で始まる長い文字列です。この秘密鍵にアクセスできる人は誰でも、あなたの名前でポストしたり、プロフィールを変更したりできます。 \n\n- 信頼していないウェブサイトやアプリに秘密鍵を **入力しないでください**。 \n- Amethyst の開発者が秘密鍵を **求めることは絶対にありません**。 \n- アカウントの復元のために、秘密鍵の安全なバックアップを **必ず** 保管してください。パスワードマネージャーの使用をお勧めします。</string> + <string name="account_backup_tips3_md">さらにセキュリティを高めるために、鍵をパスワードで暗号化することができます。この鍵は **ncryptsec1** で始まり、パスワードなしでは使用できません。 \n\nパスワードを忘れると、鍵を復元できなくなります。</string> <string name="encrypt_and_copy_my_secret_key">秘密鍵を暗号化してコピー</string> <string name="badge_award_image_for">%1$sのバッジ授与画像</string> <string name="badge_award_image">バッジ授与の画像</string> @@ -965,9 +958,7 @@ <string name="push_server_none_explainer">プッシュ通知を無効にします</string> <string name="push_server_uses_app_explainer">アプリ%1$sを使用</string> <string name="push_server_install_app">プッシュ通知の設定</string> - <string name="push_server_install_app_description"> プッシュ通知を受け取るには、[Ntfy](https://ntfy.sh/)など[Unified Push](https://unifiedpush.org/)に対応したアプリをインストールしてください。 - インストール後、設定で使用するアプリを選択してください。 - </string> + <string name="push_server_install_app_description">プッシュ通知を受け取るには、[Ntfy](https://ntfy.sh/)など[Unified Push](https://unifiedpush.org/)に対応したアプリをインストールしてください。 インストール後、設定で使用するアプリを選択してください。</string> <string name="thread_title">スレッド</string> <string name="send_the_seller_a_message">出品者にメッセージを送る</string> <string name="hi_there_is_this_still_available">こんにちは、こちらはまだ入手可能ですか?</string> @@ -2016,15 +2007,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s から請求書を取得できませんでした: %2$s</string> <string name="could_not_open_the_compressed_file">圧縮ファイルを開けませんでした</string> <string name="couldnt_find_nwc_wallets">ウォレットが見つかりません</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst は Nostr Wallet Connect(NWC)に対応したウォレットアプリを見つけられませんでした。 -\n\n対処方法: -\n\t1. NWC サポートを確認: お使いのウォレットアプリが Nostr Wallet Connect に対応しているか再確認してください。 -\n\t2. 接続を作成: ウォレットアプリで新しい NWC 接続を作成してください。 -\n\t3. Amethyst にリンク: ウォレットは通常、以下の3つの方法を提供します: -\n\t\t3.1 自動リンク: 自動的に Amethyst を開いて接続するボタン。その場合、ボタンをクリックして Amethyst を開き、新しい画面で保存を押してください。 -\n\t\t3.2 手動リンク: この画面の貼り付けアイコンをクリックして直接入力できる接続 URI。 -\n\t\t3.3 QR コード: ウォレットが作成する QR コード。この画面の QR コードボタンから読み取れます。 - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst は Nostr Wallet Connect(NWC)に対応したウォレットアプリを見つけられませんでした。 \n\n対処方法: \n\t1. NWC サポートを確認: お使いのウォレットアプリが Nostr Wallet Connect に対応しているか再確認してください。 \n\t2. 接続を作成: ウォレットアプリで新しい NWC 接続を作成してください。 \n\t3. Amethyst にリンク: ウォレットは通常、以下の3つの方法を提供します: \n\t\t3.1 自動リンク: 自動的に Amethyst を開いて接続するボタン。その場合、ボタンをクリックして Amethyst を開き、新しい画面で保存を押してください。 \n\t\t3.2 手動リンク: この画面の貼り付けアイコンをクリックして直接入力できる接続 URI。 \n\t\t3.3 QR コード: ウォレットが作成する QR コード。この画面の QR コードボタンから読み取れます。</string> <string name="create">作成</string> <string name="d">日</string> <string name="danger_zone">危険ゾーン</string> @@ -2667,11 +2650,8 @@ <string name="proxy_section">Proxy Relay</string> <string name="proxy_section_explainer">filter.nostr.wine のように、アプリがフィードをダウンロードするために使用するアグリゲーター relay です。これにより outbox モデルが置き換えられ、アプリはリスト内の relay のみに接続するようになります。</string> <string name="public_chat">公開チャット</string> - <string name="public_chat_explainer">パブリックチャットは Nostr 上の全員に公開されており、誰でも - 参加できます。特定のトピックを中心としたオープンなコミュニティに最適です。 - モデレーションは、その relay 上のポストを削除することで管理できます</string> - <string name="public_chat_relays_explainer">このグループをホストする relay を 1〜3 件入力してください。 - Nostr クライアントはこの設定を使用して、メッセージのダウンロード先と送信先を決定します。</string> + <string name="public_chat_explainer">パブリックチャットは Nostr 上の全員に公開されており、誰でも 参加できます。特定のトピックを中心としたオープンなコミュニティに最適です。 モデレーションは、その relay 上のポストを削除することで管理できます</string> + <string name="public_chat_relays_explainer">このグループをホストする relay を 1〜3 件入力してください。 Nostr クライアントはこの設定を使用して、メッセージのダウンロード先と送信先を決定します。</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">パブリックチャットのメタデータ</string> <string name="public_chats">パブリックチャット</string> @@ -2696,10 +2676,7 @@ <string name="read_only_user">読み取り専用ユーザー</string> <string name="record_a_message_description">長押ししてメッセージを録音</string> <string name="relay_chat">relay チャット</string> - <string name="relay_chat_explainer">relay チャットは、ホスト relay によって管理されるチャットグループです。 - Nostr 上の全員に公開されており、誰でも参加できます。 - 特定のトピックを中心としたオープンなコミュニティに最適です。一部のグループは一時的なもので、 - チャットメッセージは時間とともに消えます</string> + <string name="relay_chat_explainer">relay チャットは、ホスト relay によって管理されるチャットグループです。 Nostr 上の全員に公開されており、誰でも参加できます。 特定のトピックを中心としたオープンなコミュニティに最適です。一部のグループは一時的なもので、 チャットメッセージは時間とともに消えます</string> <string name="relay_chat_title">relay チャット</string> <string name="relay_management_tab_events">イベント</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ja/strings.xml b/commonsUI/src/commonMain/composeResources/values-ja/strings.xml index a9b6f5afcf..8e2365c27e 100644 --- a/commonsUI/src/commonMain/composeResources/values-ja/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ja/strings.xml @@ -49,7 +49,7 @@ <string name="scan_qr">QRコードをスキャン</string> <string name="show_anyway">それでも表示する</string> <string name="post_was_hidden">このポストは、非表示にしているユーザーまたはワードが含まれているため隠されています</string> - <string name="post_was_flagged_as_inappropriate_by">このユーザによって投稿が不適切なものとしてマークされています: </string> + <string name="post_was_flagged_as_inappropriate_by">このユーザによって投稿が不適切なものとしてマークされています:</string> <string name="post_not_found">投稿が見つかりません</string> <string name="post_not_found_short">👀</string> <string name="channel_image">チャンネル画像</string> @@ -257,17 +257,8 @@ <string name="mark_all_known_as_read">すべての「知り合い」を既読にする</string> <string name="mark_all_new_as_read">すべての「新規リクエスト」を既読にする</string> <string name="mark_all_as_read">すべて既読にする</string> - <string name="account_backup_tips2_md"> - ## 鍵のバックアップとセキュリティのヒント - \n\nアカウントは秘密鍵によって保護されています。この鍵は **nsec1** で始まる長い文字列です。この秘密鍵にアクセスできる人は誰でも、あなたの名前でポストしたり、プロフィールを変更したりできます。 - \n\n- 信頼していないウェブサイトやアプリに秘密鍵を **入力しないでください**。 - \n- Amethyst の開発者が秘密鍵を **求めることは絶対にありません**。 - \n- アカウントの復元のために、秘密鍵の安全なバックアップを **必ず** 保管してください。パスワードマネージャーの使用をお勧めします。 - </string> - <string name="account_backup_tips3_md"> - さらにセキュリティを高めるために、鍵をパスワードで暗号化することができます。この鍵は **ncryptsec1** で始まり、パスワードなしでは使用できません。 - \n\nパスワードを忘れると、鍵を復元できなくなります。 - </string> + <string name="account_backup_tips2_md">## 鍵のバックアップとセキュリティのヒント \n\nアカウントは秘密鍵によって保護されています。この鍵は **nsec1** で始まる長い文字列です。この秘密鍵にアクセスできる人は誰でも、あなたの名前でポストしたり、プロフィールを変更したりできます。 \n\n- 信頼していないウェブサイトやアプリに秘密鍵を **入力しないでください**。 \n- Amethyst の開発者が秘密鍵を **求めることは絶対にありません**。 \n- アカウントの復元のために、秘密鍵の安全なバックアップを **必ず** 保管してください。パスワードマネージャーの使用をお勧めします。</string> + <string name="account_backup_tips3_md">さらにセキュリティを高めるために、鍵をパスワードで暗号化することができます。この鍵は **ncryptsec1** で始まり、パスワードなしでは使用できません。 \n\nパスワードを忘れると、鍵を復元できなくなります。</string> <string name="encrypt_and_copy_my_secret_key">秘密鍵を暗号化してコピー</string> <string name="badge_award_image_for">%1$sのバッジ授与画像</string> <string name="badge_award_image">バッジ授与の画像</string> @@ -960,10 +951,7 @@ <string name="push_server_none_explainer">プッシュ通知を無効にします</string> <string name="push_server_uses_app_explainer">アプリ%1$sを使用</string> <string name="push_server_install_app">プッシュ通知の設定</string> - <string name="push_server_install_app_description"> - プッシュ通知を受け取るには、[Ntfy](https://ntfy.sh/)など[Unified Push](https://unifiedpush.org/)に対応したアプリをインストールしてください。 - インストール後、設定で使用するアプリを選択してください。 - </string> + <string name="push_server_install_app_description">プッシュ通知を受け取るには、[Ntfy](https://ntfy.sh/)など[Unified Push](https://unifiedpush.org/)に対応したアプリをインストールしてください。 インストール後、設定で使用するアプリを選択してください。</string> <string name="thread_title">スレッド</string> <string name="send_the_seller_a_message">出品者にメッセージを送る</string> <string name="hi_there_is_this_still_available">こんにちは、こちらはまだ入手可能ですか?</string> @@ -2048,15 +2036,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s から請求書を取得できませんでした: %2$s</string> <string name="could_not_open_the_compressed_file">圧縮ファイルを開けませんでした</string> <string name="couldnt_find_nwc_wallets">ウォレットが見つかりません</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst は Nostr Wallet Connect(NWC)に対応したウォレットアプリを見つけられませんでした。 -\n\n対処方法: -\n\t1. NWC サポートを確認: お使いのウォレットアプリが Nostr Wallet Connect に対応しているか再確認してください。 -\n\t2. 接続を作成: ウォレットアプリで新しい NWC 接続を作成してください。 -\n\t3. Amethyst にリンク: ウォレットは通常、以下の3つの方法を提供します: -\n\t\t3.1 自動リンク: 自動的に Amethyst を開いて接続するボタン。その場合、ボタンをクリックして Amethyst を開き、新しい画面で保存を押してください。 -\n\t\t3.2 手動リンク: この画面の貼り付けアイコンをクリックして直接入力できる接続 URI。 -\n\t\t3.3 QR コード: ウォレットが作成する QR コード。この画面の QR コードボタンから読み取れます。 - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst は Nostr Wallet Connect(NWC)に対応したウォレットアプリを見つけられませんでした。 \n\n対処方法: \n\t1. NWC サポートを確認: お使いのウォレットアプリが Nostr Wallet Connect に対応しているか再確認してください。 \n\t2. 接続を作成: ウォレットアプリで新しい NWC 接続を作成してください。 \n\t3. Amethyst にリンク: ウォレットは通常、以下の3つの方法を提供します: \n\t\t3.1 自動リンク: 自動的に Amethyst を開いて接続するボタン。その場合、ボタンをクリックして Amethyst を開き、新しい画面で保存を押してください。 \n\t\t3.2 手動リンク: この画面の貼り付けアイコンをクリックして直接入力できる接続 URI。 \n\t\t3.3 QR コード: ウォレットが作成する QR コード。この画面の QR コードボタンから読み取れます。</string> <string name="create">作成</string> <string name="d">日</string> <string name="danger_zone">危険ゾーン</string> @@ -2723,11 +2703,8 @@ <string name="proxy_section">Proxy Relay</string> <string name="proxy_section_explainer">filter.nostr.wine のように、アプリがフィードをダウンロードするために使用するアグリゲーター relay です。これにより outbox モデルが置き換えられ、アプリはリスト内の relay のみに接続するようになります。</string> <string name="public_chat">公開チャット</string> - <string name="public_chat_explainer">パブリックチャットは Nostr 上の全員に公開されており、誰でも - 参加できます。特定のトピックを中心としたオープンなコミュニティに最適です。 - モデレーションは、その relay 上のポストを削除することで管理できます</string> - <string name="public_chat_relays_explainer">このグループをホストする relay を 1〜3 件入力してください。 - Nostr クライアントはこの設定を使用して、メッセージのダウンロード先と送信先を決定します。</string> + <string name="public_chat_explainer">パブリックチャットは Nostr 上の全員に公開されており、誰でも 参加できます。特定のトピックを中心としたオープンなコミュニティに最適です。 モデレーションは、その relay 上のポストを削除することで管理できます</string> + <string name="public_chat_relays_explainer">このグループをホストする relay を 1〜3 件入力してください。 Nostr クライアントはこの設定を使用して、メッセージのダウンロード先と送信先を決定します。</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">パブリックチャットのメタデータ</string> <string name="public_chats">パブリックチャット</string> @@ -2752,10 +2729,7 @@ <string name="read_only_user">読み取り専用ユーザー</string> <string name="record_a_message_description">長押ししてメッセージを録音</string> <string name="relay_chat">relay チャット</string> - <string name="relay_chat_explainer">relay チャットは、ホスト relay によって管理されるチャットグループです。 - Nostr 上の全員に公開されており、誰でも参加できます。 - 特定のトピックを中心としたオープンなコミュニティに最適です。一部のグループは一時的なもので、 - チャットメッセージは時間とともに消えます</string> + <string name="relay_chat_explainer">relay チャットは、ホスト relay によって管理されるチャットグループです。 Nostr 上の全員に公開されており、誰でも参加できます。 特定のトピックを中心としたオープンなコミュニティに最適です。一部のグループは一時的なもので、 チャットメッセージは時間とともに消えます</string> <string name="relay_chat_title">relay チャット</string> <string name="relay_management_tab_events">イベント</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ko-rKR/strings.xml b/commonsUI/src/commonMain/composeResources/values-ko-rKR/strings.xml index 5ef5365607..4e876d3cf0 100644 --- a/commonsUI/src/commonMain/composeResources/values-ko-rKR/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ko-rKR/strings.xml @@ -266,15 +266,8 @@ <string name="mark_all_known_as_read">알려진 항목 모두 읽음 표시</string> <string name="mark_all_new_as_read">새 항목 모두 읽음 표시</string> <string name="mark_all_as_read">모두 읽음 표시</string> - <string name="account_backup_tips2_md"> ## 키 백업 및 보안 팁 - \n\n계정은 비밀 키로 보호됩니다. 키는 **nsec1**로 시작하는 긴 문자열입니다. 이 비밀 키에 접근할 수 있는 누구든 게시물 작성 및 신원 변경이 가능합니다. - \n\n- 신뢰하지 않는 웹사이트나 소프트웨어에 비밀 키를 **입력하지** 마세요. - \n- Amethyst 개발자는 **절대** 비밀 키를 요청하지 않습니다. - \n- 계정 복구를 위해 비밀 키를 안전하게 백업해 **두세요**. 비밀번호 관리자 사용을 권장합니다. - </string> - <string name="account_backup_tips3_md"> 추가 보안을 위해 비밀번호로 키를 암호화할 수 있습니다. 이 키는 **ncryptsec1**로 시작하며 비밀번호 없이는 사용할 수 없습니다. - \n\n비밀번호를 분실하면 키를 복구할 수 없습니다. - </string> + <string name="account_backup_tips2_md">## 키 백업 및 보안 팁 \n\n계정은 비밀 키로 보호됩니다. 키는 **nsec1**로 시작하는 긴 문자열입니다. 이 비밀 키에 접근할 수 있는 누구든 게시물 작성 및 신원 변경이 가능합니다. \n\n- 신뢰하지 않는 웹사이트나 소프트웨어에 비밀 키를 **입력하지** 마세요. \n- Amethyst 개발자는 **절대** 비밀 키를 요청하지 않습니다. \n- 계정 복구를 위해 비밀 키를 안전하게 백업해 **두세요**. 비밀번호 관리자 사용을 권장합니다.</string> + <string name="account_backup_tips3_md">추가 보안을 위해 비밀번호로 키를 암호화할 수 있습니다. 이 키는 **ncryptsec1**로 시작하며 비밀번호 없이는 사용할 수 없습니다. \n\n비밀번호를 분실하면 키를 복구할 수 없습니다.</string> <string name="encrypt_and_copy_my_secret_key">내 비밀 키 암호화 및 복사</string> <string name="badge_award_image_for">%1$s의 배지 수상 이미지</string> <string name="badge_award_image">"배지 수상 이미지</string> @@ -958,9 +951,7 @@ <string name="push_server_none_explainer">푸시 알림 비활성화</string> <string name="push_server_uses_app_explainer">앱 %1$s 사용</string> <string name="push_server_install_app">푸시 알림 설정</string> - <string name="push_server_install_app_description"> 푸시 알림을 받으려면 [Ntfy](https://ntfy.sh/)와 같은 [Unified Push](https://unifiedpush.org/)를 지원하는 앱을 설치하세요. - 설치 후 설정에서 사용할 앱을 선택하세요. - </string> + <string name="push_server_install_app_description">푸시 알림을 받으려면 [Ntfy](https://ntfy.sh/)와 같은 [Unified Push](https://unifiedpush.org/)를 지원하는 앱을 설치하세요. 설치 후 설정에서 사용할 앱을 선택하세요.</string> <string name="thread_title">스레드</string> <string name="send_the_seller_a_message">판매자에게 메시지 보내기</string> <string name="hi_there_is_this_still_available">안녕하세요, 아직 구매 가능한가요?</string> @@ -2005,15 +1996,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s에서 인보이스를 가져올 수 없습니다: %2$s</string> <string name="could_not_open_the_compressed_file">압축 파일을 열 수 없습니다</string> <string name="couldnt_find_nwc_wallets">지갑을 찾을 수 없음</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst에서 Nostr Wallet Connect (NWC)를 지원하는 지갑 앱을 찾을 수 없습니다. -\n\n할 수 있는 작업: -\n\t1. NWC 지원 확인: 사용하려는 지갑 앱이 Nostr Wallet Connect와 호환되는지 다시 확인하세요. -\n\t2. 연결 생성: 지갑 앱에서 새 NWC 연결을 생성하세요. -\n\t3. Amethyst에 연결: 지갑에서 보통 세 가지 옵션을 제공합니다: -\n\t\t3.1 자동 연결: Amethyst를 자동으로 열고 연결하는 버튼. 해당 버튼을 클릭하고 Amethyst를 열어 새 화면에서 저장을 누르세요. -\n\t\t3.2 수동 연결: 연결 URI를 복사하고 이 화면의 붙여넣기 아이콘을 클릭하여 직접 입력하세요. -\n\t\t3.3 QR 코드: 지갑이 QR 코드를 생성하면 이 화면의 QR 코드 버튼으로 읽을 수 있습니다. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst에서 Nostr Wallet Connect (NWC)를 지원하는 지갑 앱을 찾을 수 없습니다. \n\n할 수 있는 작업: \n\t1. NWC 지원 확인: 사용하려는 지갑 앱이 Nostr Wallet Connect와 호환되는지 다시 확인하세요. \n\t2. 연결 생성: 지갑 앱에서 새 NWC 연결을 생성하세요. \n\t3. Amethyst에 연결: 지갑에서 보통 세 가지 옵션을 제공합니다: \n\t\t3.1 자동 연결: Amethyst를 자동으로 열고 연결하는 버튼. 해당 버튼을 클릭하고 Amethyst를 열어 새 화면에서 저장을 누르세요. \n\t\t3.2 수동 연결: 연결 URI를 복사하고 이 화면의 붙여넣기 아이콘을 클릭하여 직접 입력하세요. \n\t\t3.3 QR 코드: 지갑이 QR 코드를 생성하면 이 화면의 QR 코드 버튼으로 읽을 수 있습니다.</string> <string name="create">만들기</string> <string name="d">일</string> <string name="danger_zone">위험 구역</string> @@ -2653,11 +2636,8 @@ <string name="proxy_section">프록시 Relay</string> <string name="proxy_section_explainer">filter.nostr.wine 같이 피드를 다운로드하는 데 앱이 사용해야 하는 집계 relay입니다. 이 설정은 아웃박스 모델을 대체하며 앱이 목록에 있는 relay에만 연결하도록 합니다.</string> <string name="public_chat">공개 채팅</string> - <string name="public_chat_explainer">공개 채팅은 Nostr의 모든 사람에게 공개되며 - 누구나 참여할 수 있습니다. 특정 주제에 관한 열린 커뮤니티에 적합합니다. - relay에서 게시물을 삭제하여 관리할 수 있습니다</string> - <string name="public_chat_relays_explainer">이 그룹을 호스팅하는 relay를 1~3개 입력하세요. - Nostr 클라이언트는 이 설정을 통해 메시지를 다운로드하고 전송할 위치를 파악합니다.</string> + <string name="public_chat_explainer">공개 채팅은 Nostr의 모든 사람에게 공개되며 누구나 참여할 수 있습니다. 특정 주제에 관한 열린 커뮤니티에 적합합니다. relay에서 게시물을 삭제하여 관리할 수 있습니다</string> + <string name="public_chat_relays_explainer">이 그룹을 호스팅하는 relay를 1~3개 입력하세요. Nostr 클라이언트는 이 설정을 통해 메시지를 다운로드하고 전송할 위치를 파악합니다.</string> <string name="public_chat_relays_title">relay</string> <string name="public_chat_title">공개 채팅 메타데이터</string> <string name="public_chats">공개 채팅</string> @@ -2682,10 +2662,7 @@ <string name="read_only_user">읽기 전용 사용자</string> <string name="record_a_message_description">길게 눌러 메시지를 녹음하세요</string> <string name="relay_chat">relay 채팅</string> - <string name="relay_chat_explainer">relay 채팅은 홈 relay가 관리하는 채팅 그룹입니다. - Nostr의 모든 사람에게 공개되며 누구나 참여할 수 있습니다. - 특정 주제에 관한 열린 커뮤니티에 적합합니다. 일부 그룹은 임시적이라 - 채팅 메시지가 시간이 지나면 사라집니다</string> + <string name="relay_chat_explainer">relay 채팅은 홈 relay가 관리하는 채팅 그룹입니다. Nostr의 모든 사람에게 공개되며 누구나 참여할 수 있습니다. 특정 주제에 관한 열린 커뮤니티에 적합합니다. 일부 그룹은 임시적이라 채팅 메시지가 시간이 지나면 사라집니다</string> <string name="relay_chat_title">relay 채팅</string> <string name="relay_management_tab_events">이벤트</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-lv-rLV/strings.xml b/commonsUI/src/commonMain/composeResources/values-lv-rLV/strings.xml index 0ce2714a9a..2cb28ecf8f 100644 --- a/commonsUI/src/commonMain/composeResources/values-lv-rLV/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-lv-rLV/strings.xml @@ -277,15 +277,8 @@ <string name="mark_all_known_as_read">Atzīmēt visu zināmo kā lasītu</string> <string name="mark_all_new_as_read">Atzīmēt visu jauno kā lasītu</string> <string name="mark_all_as_read">Atzīmēt visu kā lasītu</string> - <string name="account_backup_tips2_md"> ## Atslēgas dublēšanas un drošības padomi - \n\nJūsu konts ir aizsargāts ar slepeno atslēgu. Atslēga ir gara rakstzīmju secība, kas sākas ar **nsec1**. Ikviens, kam ir piekļuve šai slepenai atslēgai, var publicēt un mainīt jūsu identitāti. - \n\n- **Neievietojiet** savu slepeno atslēgu nevienā tīmekļa vietnē vai programmatūrā, kurai neuzticaties. - \n- Amethyst izstrādātāji **nekad** neprasīs jūsu slepeno atslēgu. - \n- **Glabājiet** drošu slepenas atslēgas dublējumu konta atjaunošanai. Mēs iesakām izmantot paroļu pārvaldnieku. - </string> - <string name="account_backup_tips3_md"> Papildu drošībai variet šifrēt atslēgu ar paroli. Šī atslēga sāksies ar **ncryptsec1** virkni un to nevarēs izmantot bez šīs paroles. - \n\nJa jūs aizmirsīsiet paroli, vairs nevarēsiet atgūt savu atslēgu. - </string> + <string name="account_backup_tips2_md">## Atslēgas dublēšanas un drošības padomi \n\nJūsu konts ir aizsargāts ar slepeno atslēgu. Atslēga ir gara rakstzīmju secība, kas sākas ar **nsec1**. Ikviens, kam ir piekļuve šai slepenai atslēgai, var publicēt un mainīt jūsu identitāti. \n\n- **Neievietojiet** savu slepeno atslēgu nevienā tīmekļa vietnē vai programmatūrā, kurai neuzticaties. \n- Amethyst izstrādātāji **nekad** neprasīs jūsu slepeno atslēgu. \n- **Glabājiet** drošu slepenas atslēgas dublējumu konta atjaunošanai. Mēs iesakām izmantot paroļu pārvaldnieku.</string> + <string name="account_backup_tips3_md">Papildu drošībai variet šifrēt atslēgu ar paroli. Šī atslēga sāksies ar **ncryptsec1** virkni un to nevarēs izmantot bez šīs paroles. \n\nJa jūs aizmirsīsiet paroli, vairs nevarēsiet atgūt savu atslēgu.</string> <string name="backup_keys_nudge_body">Jūsu slepenā atslēga ir vienīgais veids, kā piekļūt šim kontam. Ja to pazaudēsiet, tad nekad nevarēsiet atgūt piekļuvi kontam. Saglabājiet atslēgu drošā vietā tagad.</string> <string name="backup_keys_nudge_already_saved">Esiet tās saglabājuši</string> <string name="encrypt_and_copy_my_secret_key">Šifrēt un kopēt manu slepeno atslēgu</string> @@ -970,9 +963,7 @@ <string name="push_server_none_explainer">Atspējo push paziņojumus</string> <string name="push_server_uses_app_explainer">Izmanto lietotni %1$s</string> <string name="push_server_install_app">Push paziņojumu iestatīšana</string> - <string name="push_server_install_app_description"> Lai saņemtu push paziņojumus, instalējiet jebkuru lietotni, kas atbalsta [Unified Push](https://unifiedpush.org/), piemēram, [Ntfy](https://ntfy.sh/). - Pēc instalēšanas iestatījumos atlasiet lietotni, kuru vēlaties izmantot. - </string> + <string name="push_server_install_app_description">Lai saņemtu push paziņojumus, instalējiet jebkuru lietotni, kas atbalsta [Unified Push](https://unifiedpush.org/), piemēram, [Ntfy](https://ntfy.sh/). Pēc instalēšanas iestatījumos atlasiet lietotni, kuru vēlaties izmantot.</string> <string name="thread_title">Diskusija</string> <string name="send_the_seller_a_message">Nosūtīt pārdevējam ziņojumu</string> <string name="hi_there_is_this_still_available">Sveiki, vai tas joprojām ir pieejams?</string> @@ -2037,15 +2028,7 @@ <string name="could_not_fetch_invoice_from_details">Nevarēja iegūt rēķinu no %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Nevarēja atvērt saspiestu failu</string> <string name="couldnt_find_nwc_wallets">Maks nav atrasts</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst nevarēja atrast nevienu maka lietotni, kas atbalsta Nostr Wallet Connect (NWC). -\n\nKo varat darīt: -\n\t1. Pārbaudiet NWC atbalstu: Pārliecinieties, vai jūsu vēlamā maka lietotne ir saderīga ar Nostr Wallet Connect. -\n\t2. Izveidojiet savienojumu: Atveriet savu maka lietotni un izveidojiet jaunu NWC savienojumu. -\n\t3. Saistiet ar Amethyst: Jūsu maks parasti piedāvās trīs iespējas: -\n\t\t3.1 Automātiska saistīšana: Poga, lai automātiski atvērtu un savienotu ar Amethyst. Ja tā, noklikšķiniet uz šīs pogas, atveriet Amethyst un nospiediet saglabāt jaunajā ekrānā. -\n\t\t3.2 Manuāla saistīšana: Savienojuma URI, ko varat kopēt un noklikšķināt uz ielīmēšanas ikonas šajā ekrānā, lai to ievadītu tieši. -\n\t\t3.3 QR kods: Maks izveido QR kodu, kuru varat nolasīt ar QR koda pogu šajā ekrānā. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst nevarēja atrast nevienu maka lietotni, kas atbalsta Nostr Wallet Connect (NWC). \n\nKo varat darīt: \n\t1. Pārbaudiet NWC atbalstu: Pārliecinieties, vai jūsu vēlamā maka lietotne ir saderīga ar Nostr Wallet Connect. \n\t2. Izveidojiet savienojumu: Atveriet savu maka lietotni un izveidojiet jaunu NWC savienojumu. \n\t3. Saistiet ar Amethyst: Jūsu maks parasti piedāvās trīs iespējas: \n\t\t3.1 Automātiska saistīšana: Poga, lai automātiski atvērtu un savienotu ar Amethyst. Ja tā, noklikšķiniet uz šīs pogas, atveriet Amethyst un nospiediet saglabāt jaunajā ekrānā. \n\t\t3.2 Manuāla saistīšana: Savienojuma URI, ko varat kopēt un noklikšķināt uz ielīmēšanas ikonas šajā ekrānā, lai to ievadītu tieši. \n\t\t3.3 QR kods: Maks izveido QR kodu, kuru varat nolasīt ar QR koda pogu šajā ekrānā.</string> <string name="create">Izveidot</string> <string name="danger_zone">Bīstamā zona</string> <string name="dark">Tumšs</string> @@ -2724,11 +2707,8 @@ <string name="proxy_section">Starpniekservera Relay</string> <string name="proxy_section_explainer">Agregātori relay, ko lietotnei jāizmanto, lai lejupielādētu jūsu plūsmas, piemēram, filter.nostr.wine. Tas aizstāj izejošo ziņojumu modeli un liks lietotnei pieslēgties tikai jūsu sarakstos esošajiem relay.</string> <string name="public_chat">Publiskā tērzēšana</string> - <string name="public_chat_explainer">Publiskās tērzēšanas ir redzamas visiem Nostr lietotājiem un ikviens - var tajās piedalīties. Tās ir lieliski piemērotas atvērtām kopienām par konkrētām tēmām. - Moderēšanu var kontrolēt, dzēšot ierakstus tās relay</string> - <string name="public_chat_relays_explainer">Ievadiet no 1 līdz 3 relay, kas mitina šo grupu. - Nostr klienti izmanto šo iestatījumu, lai zinātu, no kurienes lejupielādēt ziņojumus un kur nosūtīt jūsu ziņojumus.</string> + <string name="public_chat_explainer">Publiskās tērzēšanas ir redzamas visiem Nostr lietotājiem un ikviens var tajās piedalīties. Tās ir lieliski piemērotas atvērtām kopienām par konkrētām tēmām. Moderēšanu var kontrolēt, dzēšot ierakstus tās relay</string> + <string name="public_chat_relays_explainer">Ievadiet no 1 līdz 3 relay, kas mitina šo grupu. Nostr klienti izmanto šo iestatījumu, lai zinātu, no kurienes lejupielādēt ziņojumus un kur nosūtīt jūsu ziņojumus.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Publiskās tērzēšanas metadati</string> <string name="public_chats">Publiskie čati</string> @@ -2753,10 +2733,7 @@ <string name="read_only_user">Tikai lasāms lietotājs</string> <string name="record_a_message_description">Noklikšķiniet un turiet, lai ierakstītu ziņojumu</string> <string name="relay_chat">Relay tērzēšana</string> - <string name="relay_chat_explainer">Relay tērzēšanas ir tērzēšanas grupas, kuras kontrolē to mājas relay. - Tās ir redzamas visiem Nostr lietotājiem un ikviens var tajās piedalīties. - Tās ir lieliski piemērotas atvērtām kopienām par konkrētām tēmām. Dažas no šīm grupām ir īslaicīgas - un tāpēc tērzēšanas ziņojumi laika gaitā pazūd</string> + <string name="relay_chat_explainer">Relay tērzēšanas ir tērzēšanas grupas, kuras kontrolē to mājas relay. Tās ir redzamas visiem Nostr lietotājiem un ikviens var tajās piedalīties. Tās ir lieliski piemērotas atvērtām kopienām par konkrētām tēmām. Dažas no šīm grupām ir īslaicīgas un tāpēc tērzēšanas ziņojumi laika gaitā pazūd</string> <string name="relay_chat_title">Relay tērzēšanas</string> <string name="relay_management_tab_events">Notikumi</string> <string name="relay_management_tab_ips">IP adreses</string> diff --git a/commonsUI/src/commonMain/composeResources/values-nl/strings.xml b/commonsUI/src/commonMain/composeResources/values-nl/strings.xml index 70ca1190a6..5ddca3ba0e 100644 --- a/commonsUI/src/commonMain/composeResources/values-nl/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-nl/strings.xml @@ -211,7 +211,7 @@ <string name="copy_user_id">Kopieer gebruiker ID</string> <string name="unblock_user">Deblokkeer gebruiker</string> <string name="user_is_blocked_hidden">Deze gebruiker is geblokkeerd/gedempt. Hun berichten zijn verborgen.</string> - <string name="npub_hex_username">npub, hex, gebruikersnaam </string> + <string name="npub_hex_username">npub, hex, gebruikersnaam</string> <string name="clear">Wissen</string> <string name="app_logo">App logo</string> <string name="nsec_npub_hex_private_key">nsec.. of npub..</string> @@ -259,15 +259,8 @@ <string name="mark_all_known_as_read">Bekende markeren als gelezen</string> <string name="mark_all_new_as_read">Nieuwe markeren als gelezen</string> <string name="mark_all_as_read">Alles markeren als gelezen</string> - <string name="account_backup_tips2_md"> ## Sleutel back-up en veiligheidstips - \n\nUw account is beveiligd met een privésleutel. De sleutel is een lange, willekeurige reeks die begint met **nsec1**. Iedereen die toegang heeft tot uw privésleutel kan inhoud publiceren met uw identiteit. - \n\n- Voer uw privésleutel **nooit** in een website of software die u niet vertrouwt. - \n- Amethyst ontwikkelaars zullen u **nooit** om uw privésleutel vragen. - \n- **Bewaar** een veilige back-up van uw privésleutel voor accountherstel. Wij raden u aan een wachtwoordmanager te gebruiken. - </string> - <string name="account_backup_tips3_md"> Voor meer veiligheid kan je je sleutel versleutelen met een wachtwoord. Deze sleutel begint met **ncryptsec1** en kan niet worden gebruikt zonder uw wachtwoord. - \n\nAls je je wachtwoord verliest, je kan je sleutel niet herstellen. - </string> + <string name="account_backup_tips2_md">## Sleutel back-up en veiligheidstips \n\nUw account is beveiligd met een privésleutel. De sleutel is een lange, willekeurige reeks die begint met **nsec1**. Iedereen die toegang heeft tot uw privésleutel kan inhoud publiceren met uw identiteit. \n\n- Voer uw privésleutel **nooit** in een website of software die u niet vertrouwt. \n- Amethyst ontwikkelaars zullen u **nooit** om uw privésleutel vragen. \n- **Bewaar** een veilige back-up van uw privésleutel voor accountherstel. Wij raden u aan een wachtwoordmanager te gebruiken.</string> + <string name="account_backup_tips3_md">Voor meer veiligheid kan je je sleutel versleutelen met een wachtwoord. Deze sleutel begint met **ncryptsec1** en kan niet worden gebruikt zonder uw wachtwoord. \n\nAls je je wachtwoord verliest, je kan je sleutel niet herstellen.</string> <string name="encrypt_and_copy_my_secret_key">Versleutel en kopieer mijn geheime sleutel</string> <string name="badge_award_image_for">Badge award afbeelding voor %1$s</string> <string name="badge_award_image">Badge-awardafbeelding</string> @@ -960,9 +953,7 @@ <string name="push_server_none_explainer">Push-notificaties uitschakelen</string> <string name="push_server_uses_app_explainer">Gebruikt app %1$s</string> <string name="push_server_install_app">Instellen Push-notificaties</string> - <string name="push_server_install_app_description"> Om push-notificaties te ontvangen, installeer een app die [Unified Push] ondersteunt](https://unifiedpush.org/), zoals [Ntfy](https://ntfy.sh/). - Na installatie selecteer de app die je wilt gebruiken in de instellingen. - </string> + <string name="push_server_install_app_description">Om push-notificaties te ontvangen, installeer een app die [Unified Push] ondersteunt](https://unifiedpush.org/), zoals [Ntfy](https://ntfy.sh/). Na installatie selecteer de app die je wilt gebruiken in de instellingen.</string> <string name="thread_title">Draad</string> <string name="send_the_seller_a_message">Stuur de verkoper een bericht</string> <string name="hi_there_is_this_still_available">Hallo daar, is dit nog steeds beschikbaar?</string> diff --git a/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml b/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml index 6b3fd3bf9a..570f8fc2b1 100644 --- a/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-pl-rPL/strings.xml @@ -508,8 +508,7 @@ <string name="about_us">Informacja o grupie…</string> <string name="search_and_add_a_user">Szukaj i dodaj użytkownika</string> <string name="add_a_relay">Dodaj Transmiter</string> - <string name="relay_url_not_valid">Nieprawidłowy adres transmitera. Użyj nazwy hosta lub adresu IP w nawiasach (na przykład -[201:d0e:9ba5:8bbc::1]:8080).</string> + <string name="relay_url_not_valid">Nieprawidłowy adres transmitera. Użyj nazwy hosta lub adresu IP w nawiasach (na przykład [201:d0e:9ba5:8bbc::1]:8080).</string> <string name="my_name">Moje imię @tag</string> <string name="display_name">Nazwa użytkownika</string> <string name="my_display_name">Mój nick</string> @@ -657,15 +656,8 @@ <string name="mark_all_known_as_read">Zaznacz wszystkie popularne jako przeczytane</string> <string name="mark_all_new_as_read">Zaznacz wszystkie nowe jako przeczytane</string> <string name="mark_all_as_read">Zaznacz wszystkie jako przeczytane</string> - <string name="account_backup_tips2_md"> ## Porady dotyczące kopii zapasowej i bezpieczeństwa - \n\nTwoje konto jest zabezpieczone tajnym kluczem. Kluczem jest długa sekwencja znaków, zaczynająca się od **nsec1**. Każdy, kto ma dostęp do tego tajnego klucza może publikować i zmieniać Twoją tożsamość. - \n\n- **nie** umiejszczaj swojego tajnego klucza na żadnej stronie internetowej lub oprogramowaniu, któremu nie ufasz. - \n- Deweloperzy Ametyst **nigdy** nie będą prosić o Twój tajny klucz. - \n- **Zrób ** bezpieczną kopię zapasową swojego tajnego klucza do ewentualnego odzyskania konta. Zalecamy użycie menedżera haseł. - </string> - <string name="account_backup_tips3_md"> Dla dodatkowego bezpieczeństwa możesz zaszyfrować swój klucz hasłem. Ten klucz zaczyna się od **ncryptsec1** i nie może być użyty bez hasła. - \n\nJeśli zgubisz hasło, nie będziesz w stanie odzyskać swojego klucza. - </string> + <string name="account_backup_tips2_md">## Porady dotyczące kopii zapasowej i bezpieczeństwa \n\nTwoje konto jest zabezpieczone tajnym kluczem. Kluczem jest długa sekwencja znaków, zaczynająca się od **nsec1**. Każdy, kto ma dostęp do tego tajnego klucza może publikować i zmieniać Twoją tożsamość. \n\n- **nie** umiejszczaj swojego tajnego klucza na żadnej stronie internetowej lub oprogramowaniu, któremu nie ufasz. \n- Deweloperzy Ametyst **nigdy** nie będą prosić o Twój tajny klucz. \n- **Zrób ** bezpieczną kopię zapasową swojego tajnego klucza do ewentualnego odzyskania konta. Zalecamy użycie menedżera haseł.</string> + <string name="account_backup_tips3_md">Dla dodatkowego bezpieczeństwa możesz zaszyfrować swój klucz hasłem. Ten klucz zaczyna się od **ncryptsec1** i nie może być użyty bez hasła. \n\nJeśli zgubisz hasło, nie będziesz w stanie odzyskać swojego klucza.</string> <string name="backup_keys_nudge_title">Kopia zapasowa kluczy</string> <string name="backup_keys_nudge_body">Twój tajny klucz jest jedynym sposobem na dostęp do tego konta. Jeśli go zgubisz, nigdy nie będzie można go odzyskać. Zapisz go w bezpiecznym miejscu.</string> <string name="backup_keys_nudge_backup_now">Utwórz kopię zapasową</string> @@ -1849,9 +1841,7 @@ <string name="push_server_none_explainer">Wyłącz powiadomienia</string> <string name="push_server_uses_app_explainer">Używa aplikacji %1$s</string> <string name="push_server_install_app">Ustawienia powiadomień</string> - <string name="push_server_install_app_description"> Aby otrzymywać powiadomienia, zainstaluj dowolną aplikację, która obsługuje [Unified Push](https://unifiedpush. rg/), np. [Ntfy](https://ntfy.sh/). - Po zainstalowaniu, wybierz w ustawieniach aplikację, którą chcesz użyć. - </string> + <string name="push_server_install_app_description">Aby otrzymywać powiadomienia, zainstaluj dowolną aplikację, która obsługuje [Unified Push](https://unifiedpush. rg/), np. [Ntfy](https://ntfy.sh/). Po zainstalowaniu, wybierz w ustawieniach aplikację, którą chcesz użyć.</string> <string name="thread_title">Wątek</string> <string name="send_the_seller_a_message">Wyślij sprzedawcy wiadomość</string> <string name="hi_there_is_this_still_available">Cześć, czy to jest nadal dostępne?</string> @@ -3656,15 +3646,7 @@ <string name="could_not_fetch_invoice_from_details">Nie można pobrać faktury od %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Nie można otworzyć skompresowanego pliku</string> <string name="couldnt_find_nwc_wallets">Nie znaleziono portfela</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst nie znalazł żadnej aplikacji portfela obsługującej Nostr Wallet Connect (NWC). -\n\nCo możesz zrobić: -\n\t1. Zweryfikuj wsparcie NWC: Sprawdź, czy preferowana aplikacja portfela jest kompatybilna z Nostr Wallet Connect. -\n\t2. Utwórz połączenie: Przejdź do aplikacji portfela i utwórz nowe połączenie NWC. -\n\t3. Połącz z Amethyst: Twój portfel zazwyczaj oferuje trzy opcje: -\n\t\t3. Automatyczne połączenie: przycisk, który automatycznie otwiera i łączy się z Amethyst. Jeśli tak, kliknij ten przycisk, otwórz Ametyst i naciśnij przycisk "Zapisz" na nowym ekranie. -\n\t\t3. Połączenie ręczne: adres URI połączenia, który można skopiować i wkleić, klikając ikonę wklejania na tym ekranie, aby wprowadzić go bezpośrednio. -\n\t\t3. Kod QR: Portfel tworzy kod QR, który można odczytać z przycisku QR na tym ekranie. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst nie znalazł żadnej aplikacji portfela obsługującej Nostr Wallet Connect (NWC). \n\nCo możesz zrobić: \n\t1. Zweryfikuj wsparcie NWC: Sprawdź, czy preferowana aplikacja portfela jest kompatybilna z Nostr Wallet Connect. \n\t2. Utwórz połączenie: Przejdź do aplikacji portfela i utwórz nowe połączenie NWC. \n\t3. Połącz z Amethyst: Twój portfel zazwyczaj oferuje trzy opcje: \n\t\t3. Automatyczne połączenie: przycisk, który automatycznie otwiera i łączy się z Amethyst. Jeśli tak, kliknij ten przycisk, otwórz Ametyst i naciśnij przycisk "Zapisz" na nowym ekranie. \n\t\t3. Połączenie ręczne: adres URI połączenia, który można skopiować i wkleić, klikając ikonę wklejania na tym ekranie, aby wprowadzić go bezpośrednio. \n\t\t3. Kod QR: Portfel tworzy kod QR, który można odczytać z przycisku QR na tym ekranie.</string> <string name="create">Utwórz</string> <string name="d">d</string> <string name="danger_zone">Niebezpieczna strefa</string> @@ -4966,10 +4948,7 @@ <string name="relay_auth_search_keywords">auth uwierzytelnianie transmiter podpis weryfikacja nip-42 tożsamość</string> <string name="relay_auth_settings_title">Uwierzytelnianie transmitera</string> <string name="relay_chat">Czat Transmitera</string> - <string name="relay_chat_explainer">Czaty transmiterów to grupy czatów kontrolowane przez ich macierzyste transmitery. - Są one widoczne dla wszystkich użytkowników Nostr i każdy może w nich uczestniczyć. - Świetnie nadają się do tworzenia otwartych społeczności wokół określonych tematów. Niektóre z tych grup są efemeryczne - i dlatego wiadomości czatu znikają z czasem</string> + <string name="relay_chat_explainer">Czaty transmiterów to grupy czatów kontrolowane przez ich macierzyste transmitery. Są one widoczne dla wszystkich użytkowników Nostr i każdy może w nich uczestniczyć. Świetnie nadają się do tworzenia otwartych społeczności wokół określonych tematów. Niektóre z tych grup są efemeryczne i dlatego wiadomości czatu znikają z czasem</string> <string name="relay_chat_title">Czaty Transmitera</string> <string name="relay_explain_account_data">Twój profil, ustawienia i wersje robocze na Twoich domowych transmiterach.</string> <string name="relay_explain_community_chats">Transmitery, na których każda społeczność publikuje swoje plany.</string> @@ -5178,8 +5157,7 @@ <string name="route_podcasts">Podcasty</string> <string name="schedule_post_button_add">Zaplanuj post</string> <string name="schedule_post_button_remove">Anuluj planowanie</string> - <string name="schedule_post_warning_multi">Wpisy zaplanowane mogą nie zostać opublikowane, dopóki nie uruchomisz ponownie aplikacji. -Zaplanowane posty z innych kont nie zostaną opublikowane, dopóki to konto jest aktywne. Włącz opcję „Zawsze włączone” w menu Ustawienia → Preferencje interfejsu użytkownika, aby zapewnić niezawodne planowanie zadań w tle.</string> + <string name="schedule_post_warning_multi">Wpisy zaplanowane mogą nie zostać opublikowane, dopóki nie uruchomisz ponownie aplikacji. Zaplanowane posty z innych kont nie zostaną opublikowane, dopóki to konto jest aktywne. Włącz opcję „Zawsze włączone” w menu Ustawienia → Preferencje interfejsu użytkownika, aby zapewnić niezawodne planowanie zadań w tle.</string> <string name="schedule_post_warning_single">Zaplanowane posty mogą nie zostać opublikowane, dopóki nie uruchomisz ponownie aplikacji. Aby zapewnić niezawodne planowanie zadań w tle, włącz opcję „Zawsze włączone” w Ustawieniach → Preferencje dotyczące niezawodnego planowania zadań w tle.</string> <string name="scheduled_posts">Zaplanowane posty</string> <string name="scheduled_posts_action_send_now">Wyślij teraz</string> @@ -5792,7 +5770,7 @@ Zaplanowane posty z innych kont nie zostaną opublikowane, dopóki to konto jest <item quantity="other">%1$d sposoby płatności zostały usunięte</item> </plurals> <string name="backup_review_payments_explainer">Osoby, które Ci płacą, widzą tylko to, co znajduje się na tej liście.</string> - <string name="backup_review_places_gone"> miejsca zniknęły</string> + <string name="backup_review_places_gone">miejsca zniknęły</string> <string name="backup_review_places_you_follow">Miejsca które obserwujesz</string> <string name="backup_review_private_added_body">Są teraz zaszyfrowane, co prawdopodobnie wyjaśnia, gdzie podziały się powyższe elementy publiczne.</string> <string name="backup_review_private_added_title">Ustawiłeś te pozycje jako prywatne</string> diff --git a/commonsUI/src/commonMain/composeResources/values-pt-rBR/strings.xml b/commonsUI/src/commonMain/composeResources/values-pt-rBR/strings.xml index 19715d92c0..1a156efffd 100644 --- a/commonsUI/src/commonMain/composeResources/values-pt-rBR/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-pt-rBR/strings.xml @@ -361,7 +361,7 @@ <string name="copy_user_id">Copiar ID do usuário</string> <string name="unblock_user">Desbloquear Usuário</string> <string name="user_is_blocked_hidden">Este usuário está bloqueado/silenciado. Suas publicações estão ocultas.</string> - <string name="npub_hex_username">npub, hex, usuário </string> + <string name="npub_hex_username">npub, hex, usuário</string> <string name="clear">Limpar</string> <string name="app_logo">Logo do aplicativo</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex chave privada</string> @@ -449,8 +449,8 @@ <string name="paid_relay">Retransmissor pago</string> <string name="tor_relay">Forçar uso do Tor ao conectar</string> <string name="posts_received">postagens recebidas</string> - <string name="translations_auto">Autotraduzido </string> - <string name="translations_translated_from"> de </string> + <string name="translations_auto">Autotraduzido</string> + <string name="translations_translated_from">de</string> <string name="translations_to">para</string> <string name="translations_show_in_lang_first">Mostrar em %1$s primeiro</string> <string name="chat_about_topic">Chat público sobre %1$s</string> @@ -463,13 +463,8 @@ <string name="mark_all_known_as_read">Marcar todos conhecidos como lidos</string> <string name="mark_all_new_as_read">Marcar todas novas solicitações como lidas</string> <string name="mark_all_as_read">Marcar todas como lidas</string> - <string name="account_backup_tips2_md"> ## Dicas de Backup de Chave e Segurança - \n\nSua conta é protegida por uma chave secreta. A chave é uma sequência longa de caracteres que começa com **nsec1**. Qualquer pessoa que tenha acesso a esta chave secreta pode postar e alterar sua identidade. - \n\n- **Não** coloque sua chave secreta em nenhum site ou software que você não confie. - \n- Os desenvolvedores da Amethyst **nunca** pedirão sua chave secreta. - \n- **Mantenha** uma cópia de segurança segura de sua chave secreta para recuperação da conta. Recomendamos o uso de um gerenciador de senhas.</string> - <string name="account_backup_tips3_md"> Para segurança adicional, você pode criptografar sua chave com uma senha. Esta chave começa com **ncryptsec1** e não pode ser usada sem sua senha. - \n\nSe você perder sua senha, não será possível recuperar sua chave.</string> + <string name="account_backup_tips2_md">## Dicas de Backup de Chave e Segurança \n\nSua conta é protegida por uma chave secreta. A chave é uma sequência longa de caracteres que começa com **nsec1**. Qualquer pessoa que tenha acesso a esta chave secreta pode postar e alterar sua identidade. \n\n- **Não** coloque sua chave secreta em nenhum site ou software que você não confie. \n- Os desenvolvedores da Amethyst **nunca** pedirão sua chave secreta. \n- **Mantenha** uma cópia de segurança segura de sua chave secreta para recuperação da conta. Recomendamos o uso de um gerenciador de senhas.</string> + <string name="account_backup_tips3_md">Para segurança adicional, você pode criptografar sua chave com uma senha. Esta chave começa com **ncryptsec1** e não pode ser usada sem sua senha. \n\nSe você perder sua senha, não será possível recuperar sua chave.</string> <string name="backup_keys_nudge_title">Faça backup das suas chaves</string> <string name="backup_keys_nudge_body">Sua chave secreta é a única forma de acessar esta conta. Se você perdê-la, ela nunca poderá ser recuperada. Guarde-a em um lugar seguro agora.</string> <string name="backup_keys_nudge_backup_now">Fazer backup agora</string> @@ -1584,9 +1579,7 @@ <string name="push_server_none_explainer">Desativa as Notificações Push</string> <string name="push_server_uses_app_explainer">Usa o aplicativo %1$s</string> <string name="push_server_install_app">Configuração de Notificações Push</string> - <string name="push_server_install_app_description"> Para receber notificações push, instale qualquer aplicativo que suporte [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). - Após a instalação, selecione o aplicativo que deseja usar nas configurações. - </string> + <string name="push_server_install_app_description">Para receber notificações push, instale qualquer aplicativo que suporte [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). Após a instalação, selecione o aplicativo que deseja usar nas configurações.</string> <string name="thread_title">Linha</string> <string name="send_the_seller_a_message">Envie uma mensagem para o vendedor</string> <string name="hi_there_is_this_still_available">Olá, ainda está disponível?</string> @@ -3323,14 +3316,7 @@ <string name="could_not_fetch_invoice_from_details">Não foi possível obter a fatura de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Não foi possível abrir o arquivo compactado</string> <string name="couldnt_find_nwc_wallets">Carteira não encontrada</string> - <string name="couldnt_find_nwc_wallets_description">O Amethyst não conseguiu encontrar nenhum aplicativo de carteira que suporte Nostr Wallet Connect (NWC). -\n\nO que você pode fazer: -\n\t1. Verifique o suporte NWC: Confirme se o aplicativo da sua carteira é compatível com o Nostr Wallet Connect. -\n\t2. Criar conexão: Vá até o aplicativo da sua carteira e crie uma nova conexão NWC. -\n\t3. Vincular ao Amethyst: Sua carteira geralmente oferece três opções: -\n\t\t3.1 Link Automático: Um botão para abrir e conectar automaticamente ao Amethyst. Clique nele, abra o Amethyst e salve na nova tela. -\n\t\t3.2 Link Manual: Um URI de conexão que você pode copiar e colar usando o ícone de colar nesta tela. -\n\t\t3.3 Código QR: A carteira gera um código QR que você pode ler usando o botão de código QR nesta tela.</string> + <string name="couldnt_find_nwc_wallets_description">O Amethyst não conseguiu encontrar nenhum aplicativo de carteira que suporte Nostr Wallet Connect (NWC). \n\nO que você pode fazer: \n\t1. Verifique o suporte NWC: Confirme se o aplicativo da sua carteira é compatível com o Nostr Wallet Connect. \n\t2. Criar conexão: Vá até o aplicativo da sua carteira e crie uma nova conexão NWC. \n\t3. Vincular ao Amethyst: Sua carteira geralmente oferece três opções: \n\t\t3.1 Link Automático: Um botão para abrir e conectar automaticamente ao Amethyst. Clique nele, abra o Amethyst e salve na nova tela. \n\t\t3.2 Link Manual: Um URI de conexão que você pode copiar e colar usando o ícone de colar nesta tela. \n\t\t3.3 Código QR: A carteira gera um código QR que você pode ler usando o botão de código QR nesta tela.</string> <string name="create">Criar</string> <string name="d">d</string> <string name="danger_zone">Zona de Perigo</string> @@ -4427,11 +4413,8 @@ <string name="proxy_section">Relays proxy</string> <string name="proxy_section_explainer">Relays agregadores que o app usa para baixar seus feeds, como filter.nostr.wine. Isso substitui o modelo outbox e faz o app se conectar apenas aos relays das suas listas.</string> <string name="public_chat">Chat público</string> - <string name="public_chat_explainer">Os chats públicos são visíveis para todos no Nostr, e qualquer pessoa - pode participar deles. Eles são ótimos para comunidades abertas em torno de tópicos específicos. - A moderação pode ser controlada excluindo postagens em seus relays</string> - <string name="public_chat_relays_explainer">Inserir entre 1–3 relés que hospedam esse grupo. - os clientes Nostr usam essa configuração para saber de onde fazer o download de mensagens e enviar suas mensagens.</string> + <string name="public_chat_explainer">Os chats públicos são visíveis para todos no Nostr, e qualquer pessoa pode participar deles. Eles são ótimos para comunidades abertas em torno de tópicos específicos. A moderação pode ser controlada excluindo postagens em seus relays</string> + <string name="public_chat_relays_explainer">Inserir entre 1–3 relés que hospedam esse grupo. os clientes Nostr usam essa configuração para saber de onde fazer o download de mensagens e enviar suas mensagens.</string> <string name="public_chat_relays_title">Relés</string> <string name="public_chat_title">Metadados do Chat Público</string> <string name="public_chats">Chats públicos</string> @@ -4496,10 +4479,7 @@ <string name="relay_auth_search_keywords">auth autenticação relay assinar verificar nip-42 identidade</string> <string name="relay_auth_settings_title">Autenticação de relay</string> <string name="relay_chat">Chat Relé</string> - <string name="relay_chat_explainer">Chat Relés são grupos de chat controlados por seu relé de origem. - Eles são visíveis para todos no Nostr e qualquer pessoa pode participar. - São ótimos para comunidades abertas em torno de tópicos específicos. Alguns desses grupos são efêmeros, - portanto, as mensagens desaparecem com o tempo</string> + <string name="relay_chat_explainer">Chat Relés são grupos de chat controlados por seu relé de origem. Eles são visíveis para todos no Nostr e qualquer pessoa pode participar. São ótimos para comunidades abertas em torno de tópicos específicos. Alguns desses grupos são efêmeros, portanto, as mensagens desaparecem com o tempo</string> <string name="relay_chat_title">Chat Relés</string> <string name="relay_explain_account_data">Seu próprio perfil, configurações e rascunhos, nos seus relays de origem.</string> <string name="relay_explain_community_chats">Os relays em que cada comunidade publica seus planos.</string> diff --git a/commonsUI/src/commonMain/composeResources/values-pt-rPT/strings.xml b/commonsUI/src/commonMain/composeResources/values-pt-rPT/strings.xml index b1953ebdcd..d722a0814b 100644 --- a/commonsUI/src/commonMain/composeResources/values-pt-rPT/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-pt-rPT/strings.xml @@ -223,7 +223,7 @@ <string name="copy_user_id">Copiar ID do usuário</string> <string name="unblock_user">Desbloquear Usuário</string> <string name="user_is_blocked_hidden">Este usuário está bloqueado/silenciado. Suas publicações estão ocultas.</string> - <string name="npub_hex_username">npub, hex, usuário </string> + <string name="npub_hex_username">npub, hex, usuário</string> <string name="clear">Limpar</string> <string name="app_logo">Logo do aplicativo</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex chave privada</string> @@ -257,8 +257,8 @@ <string name="paid_relay">Retransmissor pago</string> <string name="tor_relay">Forçar uso do Tor ao conectar</string> <string name="posts_received">postagens recebidas</string> - <string name="translations_auto">Autotraduzido </string> - <string name="translations_translated_from"> de </string> + <string name="translations_auto">Autotraduzido</string> + <string name="translations_translated_from">de</string> <string name="translations_to">para</string> <string name="translations_show_in_lang_first">Mostrar em %1$s primeiro</string> <string name="chat_about_topic">Chat público sobre %1$s</string> @@ -271,13 +271,8 @@ <string name="mark_all_known_as_read">Marcar todos conhecidos como lidos</string> <string name="mark_all_new_as_read">Marcar todas novas solicitações como lidas</string> <string name="mark_all_as_read">Marcar todas como lidas</string> - <string name="account_backup_tips2_md"> ## Dicas de Backup de Chave e Segurança - \n\nSua conta é protegida por uma chave secreta. A chave é uma sequência longa de caracteres que começa com **nsec1**. Qualquer pessoa que tenha acesso a esta chave secreta pode postar e alterar sua identidade. - \n\n- **Não** coloque sua chave secreta em nenhum site ou software que você não confie. - \n- Os desenvolvedores da Amethyst **nunca** pedirão sua chave secreta. - \n- **Mantenha** uma cópia de segurança segura de sua chave secreta para recuperação da conta. Recomendamos o uso de um gerenciador de senhas.</string> - <string name="account_backup_tips3_md"> Para segurança adicional, você pode criptografar sua chave com uma senha. Esta chave começa com **ncryptsec1** e não pode ser usada sem sua senha. - \n\nSe você perder sua senha, não será possível recuperar sua chave.</string> + <string name="account_backup_tips2_md">## Dicas de Backup de Chave e Segurança \n\nSua conta é protegida por uma chave secreta. A chave é uma sequência longa de caracteres que começa com **nsec1**. Qualquer pessoa que tenha acesso a esta chave secreta pode postar e alterar sua identidade. \n\n- **Não** coloque sua chave secreta em nenhum site ou software que você não confie. \n- Os desenvolvedores da Amethyst **nunca** pedirão sua chave secreta. \n- **Mantenha** uma cópia de segurança segura de sua chave secreta para recuperação da conta. Recomendamos o uso de um gerenciador de senhas.</string> + <string name="account_backup_tips3_md">Para segurança adicional, você pode criptografar sua chave com uma senha. Esta chave começa com **ncryptsec1** e não pode ser usada sem sua senha. \n\nSe você perder sua senha, não será possível recuperar sua chave.</string> <string name="encrypt_and_copy_my_secret_key">Criptografar e copiar minha chave secreta</string> <string name="badge_award_image_for">Imagem da medalha para %1$s</string> <string name="badge_award_image">Imagem do prêmio</string> @@ -958,9 +953,7 @@ <string name="push_server_none_explainer">Desativa as Notificações Push</string> <string name="push_server_uses_app_explainer">Usa o aplicativo %1$s</string> <string name="push_server_install_app">Configuração de Notificações Push</string> - <string name="push_server_install_app_description"> Para receber notificações push, instale qualquer aplicativo que suporte [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). - Após a instalação, selecione o aplicativo que deseja usar nas configurações. - </string> + <string name="push_server_install_app_description">Para receber notificações push, instale qualquer aplicativo que suporte [Unified Push](https://unifiedpush.org/), como [Ntfy](https://ntfy.sh/). Após a instalação, selecione o aplicativo que deseja usar nas configurações.</string> <string name="thread_title">Linha</string> <string name="send_the_seller_a_message">Envie uma mensagem para o vendedor</string> <string name="hi_there_is_this_still_available">Olá, ainda está disponível?</string> @@ -2003,14 +1996,7 @@ <string name="could_not_fetch_invoice_from_details">Não foi possível obter a fatura de %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Não foi possível abrir o arquivo compactado</string> <string name="couldnt_find_nwc_wallets">Carteira não encontrada</string> - <string name="couldnt_find_nwc_wallets_description">O Amethyst não conseguiu encontrar nenhum aplicativo de carteira que suporte Nostr Wallet Connect (NWC). -\n\nO que você pode fazer: -\n\t1. Verifique o suporte NWC: Confirme se o aplicativo da sua carteira é compatível com o Nostr Wallet Connect. -\n\t2. Criar conexão: Vá até o aplicativo da sua carteira e crie uma nova conexão NWC. -\n\t3. Vincular ao Amethyst: Sua carteira geralmente oferece três opções: -\n\t\t3.1 Link Automático: Um botão para abrir e conectar automaticamente ao Amethyst. Clique nele, abra o Amethyst e salve na nova tela. -\n\t\t3.2 Link Manual: Um URI de conexão que você pode copiar e colar usando o ícone de colar nesta tela. -\n\t\t3.3 Código QR: A carteira gera um código QR que você pode ler usando o botão de código QR nesta tela.</string> + <string name="couldnt_find_nwc_wallets_description">O Amethyst não conseguiu encontrar nenhum aplicativo de carteira que suporte Nostr Wallet Connect (NWC). \n\nO que você pode fazer: \n\t1. Verifique o suporte NWC: Confirme se o aplicativo da sua carteira é compatível com o Nostr Wallet Connect. \n\t2. Criar conexão: Vá até o aplicativo da sua carteira e crie uma nova conexão NWC. \n\t3. Vincular ao Amethyst: Sua carteira geralmente oferece três opções: \n\t\t3.1 Link Automático: Um botão para abrir e conectar automaticamente ao Amethyst. Clique nele, abra o Amethyst e salve na nova tela. \n\t\t3.2 Link Manual: Um URI de conexão que você pode copiar e colar usando o ícone de colar nesta tela. \n\t\t3.3 Código QR: A carteira gera um código QR que você pode ler usando o botão de código QR nesta tela.</string> <string name="create">Criar</string> <string name="danger_zone">Zona de Perigo</string> <string name="dark">Escuro</string> @@ -2662,11 +2648,8 @@ <string name="proxy_section">Relays proxy</string> <string name="proxy_section_explainer">Relays agregadores que o app usa para baixar seus feeds, como filter.nostr.wine. Isso substitui o modelo outbox e faz o app se conectar apenas aos relays das suas listas.</string> <string name="public_chat">Chat público</string> - <string name="public_chat_explainer">Os chats públicos são visíveis para todos no Nostr, e qualquer pessoa - pode participar deles. Eles são ótimos para comunidades abertas em torno de tópicos específicos. - A moderação pode ser controlada excluindo postagens em seus relays</string> - <string name="public_chat_relays_explainer">Inserir entre 1–3 relés que hospedam esse grupo. - os clientes Nostr usam essa configuração para saber de onde fazer o download de mensagens e enviar suas mensagens.</string> + <string name="public_chat_explainer">Os chats públicos são visíveis para todos no Nostr, e qualquer pessoa pode participar deles. Eles são ótimos para comunidades abertas em torno de tópicos específicos. A moderação pode ser controlada excluindo postagens em seus relays</string> + <string name="public_chat_relays_explainer">Inserir entre 1–3 relés que hospedam esse grupo. os clientes Nostr usam essa configuração para saber de onde fazer o download de mensagens e enviar suas mensagens.</string> <string name="public_chat_relays_title">Relés</string> <string name="public_chat_title">Metadados do Chat Público</string> <string name="public_chats">Chats públicos</string> @@ -2691,10 +2674,7 @@ <string name="read_only_user">Usuário somente leitura</string> <string name="record_a_message_description">Clique e segure para gravar uma mensagem</string> <string name="relay_chat">Chat Relé</string> - <string name="relay_chat_explainer">Chat Relés são grupos de chat controlados por seu relé de origem. - Eles são visíveis para todos no Nostr e qualquer pessoa pode participar. - São ótimos para comunidades abertas em torno de tópicos específicos. Alguns desses grupos são efêmeros, - portanto, as mensagens desaparecem com o tempo</string> + <string name="relay_chat_explainer">Chat Relés são grupos de chat controlados por seu relé de origem. Eles são visíveis para todos no Nostr e qualquer pessoa pode participar. São ótimos para comunidades abertas em torno de tópicos específicos. Alguns desses grupos são efêmeros, portanto, as mensagens desaparecem com o tempo</string> <string name="relay_chat_title">Chat Relés</string> <string name="relay_management_tab_events">Eventos</string> <string name="relay_management_tab_kinds">Tipos</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ru-rRU/strings.xml b/commonsUI/src/commonMain/composeResources/values-ru-rRU/strings.xml index 42c411c558..d89352fd93 100644 --- a/commonsUI/src/commonMain/composeResources/values-ru-rRU/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ru-rRU/strings.xml @@ -226,7 +226,7 @@ <string name="copy_user_id">Копировать ID пользователя</string> <string name="unblock_user">Разблокировать</string> <string name="user_is_blocked_hidden">Этот пользователь заблокирован/заглушён. Его посты скрыты.</string> - <string name="npub_hex_username">npub, hex, никнейм </string> + <string name="npub_hex_username">npub, hex, никнейм</string> <string name="clear">Очистить</string> <string name="app_logo">Логотип приложения</string> <string name="nsec_npub_hex_private_key">nsec / npub / приватный ключ в hex</string> @@ -274,15 +274,8 @@ <string name="mark_all_known_as_read">Отметить все известные прочитанными</string> <string name="mark_all_new_as_read">Отметить все новые прочитанными</string> <string name="mark_all_as_read">Отметить всё прочитанным</string> - <string name="account_backup_tips2_md"> ## Советы по резервному копированию и безопасности ключей - \n\nВаш аккаунт защищён секретным ключом. Ключ — это длинная последовательность символов, начинающаяся с **nsec1**. Любой, кто получит доступ к этому секретному ключу, сможет публиковать записи и менять вашу личность. - \n\n- **Не** вводите свой секретный ключ на сайтах или в приложениях, которым не доверяете. - \n- Разработчики Amethyst **никогда** не будут запрашивать ваш секретный ключ. - \n- **Обязательно** сохраните надёжную резервную копию секретного ключа для восстановления аккаунта. Рекомендуем использовать менеджер паролей. - </string> - <string name="account_backup_tips3_md"> Для дополнительной безопасности вы можете зашифровать ваш ключ с помощью пароля. Этот ключ начинается с **ncryptsec1** и не может быть использован без пароля. - \n\nЕсли вы потеряете свой пароль, вы не сможете восстановить ваш ключ. - </string> + <string name="account_backup_tips2_md">## Советы по резервному копированию и безопасности ключей \n\nВаш аккаунт защищён секретным ключом. Ключ — это длинная последовательность символов, начинающаяся с **nsec1**. Любой, кто получит доступ к этому секретному ключу, сможет публиковать записи и менять вашу личность. \n\n- **Не** вводите свой секретный ключ на сайтах или в приложениях, которым не доверяете. \n- Разработчики Amethyst **никогда** не будут запрашивать ваш секретный ключ. \n- **Обязательно** сохраните надёжную резервную копию секретного ключа для восстановления аккаунта. Рекомендуем использовать менеджер паролей.</string> + <string name="account_backup_tips3_md">Для дополнительной безопасности вы можете зашифровать ваш ключ с помощью пароля. Этот ключ начинается с **ncryptsec1** и не может быть использован без пароля. \n\nЕсли вы потеряете свой пароль, вы не сможете восстановить ваш ключ.</string> <string name="encrypt_and_copy_my_secret_key">Зашифровать и копировать мой секретный ключ</string> <string name="badge_award_image_for">Картинка значка-награды %1$s</string> <string name="badge_award_image">Изображение награды за значок</string> @@ -970,9 +963,7 @@ <string name="push_server_none_explainer">Отключает push-уведомления</string> <string name="push_server_uses_app_explainer">Использует приложение %1$s</string> <string name="push_server_install_app">Настройки push-уведомлений</string> - <string name="push_server_install_app_description"> Для получения push-уведомлений, установите приложение, которое поддерживает [Unified Push](https://unifiedpush.org/), например [Ntfy](https://ntfy.sh/). - После установки выберите приложение, которое хотите использовать, в настройках. - </string> + <string name="push_server_install_app_description">Для получения push-уведомлений, установите приложение, которое поддерживает [Unified Push](https://unifiedpush.org/), например [Ntfy](https://ntfy.sh/). После установки выберите приложение, которое хотите использовать, в настройках.</string> <string name="thread_title">Ветка</string> <string name="send_the_seller_a_message">Написать продавцу</string> <string name="hi_there_is_this_still_available">Привет, это ещё в наличии?</string> @@ -2046,15 +2037,7 @@ <string name="could_not_fetch_invoice_from_details">Не удалось получить счёт от %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Не удалось открыть сжатый файл</string> <string name="couldnt_find_nwc_wallets">Кошелёк не найден</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst не нашёл ни одного приложения кошелька с поддержкой Nostr Wallet Connect (NWC). -\n\nЧто можно сделать: -\n\t1. Проверьте поддержку NWC: убедитесь, что ваш кошелёк совместим с Nostr Wallet Connect. -\n\t2. Создайте подключение: откройте приложение кошелька и создайте новое NWC-подключение. -\n\t3. Привяжите к Amethyst: обычно кошелёк предлагает три варианта: -\n\t\t3.1 Автоматическая привязка: кнопка для автоматического открытия и подключения к Amethyst. Нажмите её, откройте Amethyst и сохраните новый экран. -\n\t\t3.2 Ручная привязка: URI подключения, который можно скопировать и вставить с помощью значка вставки на этом экране. -\n\t\t3.3 QR-код: кошелёк создаёт QR-код, который можно считать кнопкой QR-кода на этом экране. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst не нашёл ни одного приложения кошелька с поддержкой Nostr Wallet Connect (NWC). \n\nЧто можно сделать: \n\t1. Проверьте поддержку NWC: убедитесь, что ваш кошелёк совместим с Nostr Wallet Connect. \n\t2. Создайте подключение: откройте приложение кошелька и создайте новое NWC-подключение. \n\t3. Привяжите к Amethyst: обычно кошелёк предлагает три варианта: \n\t\t3.1 Автоматическая привязка: кнопка для автоматического открытия и подключения к Amethyst. Нажмите её, откройте Amethyst и сохраните новый экран. \n\t\t3.2 Ручная привязка: URI подключения, который можно скопировать и вставить с помощью значка вставки на этом экране. \n\t\t3.3 QR-код: кошелёк создаёт QR-код, который можно считать кнопкой QR-кода на этом экране.</string> <string name="create">Создать</string> <string name="d">д</string> <string name="danger_zone">Опасная зона</string> @@ -2737,11 +2720,8 @@ <string name="propose_an_edit">Предложить изменение</string> <string name="proxy_section_explainer">Агрегирующие relay-серверы, которые приложение использует для загрузки ваших лент, например filter.nostr.wine. Это заменяет модель outbox и позволит приложению подключаться только к relay-серверам из ваших списков.</string> <string name="public_chat">Публичный чат</string> - <string name="public_chat_explainer">Публичные чаты видны всем в Nostr и открыты - для участия любого желающего. Они отлично подходят для открытых сообществ по определённым темам. - Модерация осуществляется путём удаления постов на relay</string> - <string name="public_chat_relays_explainer">Укажите от 1 до 3 relay, на которых размещена эта группа. - Клиенты Nostr используют эту настройку, чтобы знать, откуда загружать сообщения и куда их отправлять.</string> + <string name="public_chat_explainer">Публичные чаты видны всем в Nostr и открыты для участия любого желающего. Они отлично подходят для открытых сообществ по определённым темам. Модерация осуществляется путём удаления постов на relay</string> + <string name="public_chat_relays_explainer">Укажите от 1 до 3 relay, на которых размещена эта группа. Клиенты Nostr используют эту настройку, чтобы знать, откуда загружать сообщения и куда их отправлять.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Метаданные публичного чата</string> <string name="public_chats">Публичные чаты</string> @@ -2766,10 +2746,7 @@ <string name="read_only_user">Пользователь только для чтения</string> <string name="record_a_message_description">Нажмите и удерживайте, чтобы записать сообщение</string> <string name="relay_chat">Чат relay</string> - <string name="relay_chat_explainer">Чаты relay — это групповые чаты, управляемые их домашним relay. - Они видны всем в Nostr, и любой может в них участвовать. - Они отлично подходят для открытых сообществ по определённым темам. Некоторые группы эфемерны, - поэтому сообщения исчезают со временем</string> + <string name="relay_chat_explainer">Чаты relay — это групповые чаты, управляемые их домашним relay. Они видны всем в Nostr, и любой может в них участвовать. Они отлично подходят для открытых сообществ по определённым темам. Некоторые группы эфемерны, поэтому сообщения исчезают со временем</string> <string name="relay_chat_title">Чаты relay</string> <string name="relay_management_tab_events">События</string> <string name="relay_management_tab_ips">IP-адреса</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ru-rUA/strings.xml b/commonsUI/src/commonMain/composeResources/values-ru-rUA/strings.xml index f88269516e..4b2c8833b7 100644 --- a/commonsUI/src/commonMain/composeResources/values-ru-rUA/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ru-rUA/strings.xml @@ -267,15 +267,8 @@ <string name="mark_all_known_as_read">Отметить все известные как прочитанные</string> <string name="mark_all_new_as_read">Отметить все новые как прочитанные</string> <string name="mark_all_as_read">Отметить все как прочитанные</string> - <string name="account_backup_tips2_md"> ## Советы по резервному копированию и безопасности ключей - \n\nВаш аккаунт защищён секретным ключом. Ключ — это длинная последовательность символов, начинающаяся с **nsec1**. Любой, кто получит доступ к этому секретному ключу, сможет публиковать записи и менять вашу личность. - \n\n- **Не** вводите свой секретный ключ на сайтах или в приложениях, которым не доверяете. - \n- Разработчики Amethyst **никогда** не будут запрашивать ваш секретный ключ. - \n- **Обязательно** сохраните надёжную резервную копию секретного ключа для восстановления аккаунта. Рекомендуем использовать менеджер паролей. - </string> - <string name="account_backup_tips3_md"> Для дополнительной безопасности вы можете зашифровать ваш ключ паролем. Этот ключ начинается с **ncryptsec1** и не может быть использован без вашего пароля. - \n\nЕсли вы потеряете пароль, вы не сможете восстановить ключ. - </string> + <string name="account_backup_tips2_md">## Советы по резервному копированию и безопасности ключей \n\nВаш аккаунт защищён секретным ключом. Ключ — это длинная последовательность символов, начинающаяся с **nsec1**. Любой, кто получит доступ к этому секретному ключу, сможет публиковать записи и менять вашу личность. \n\n- **Не** вводите свой секретный ключ на сайтах или в приложениях, которым не доверяете. \n- Разработчики Amethyst **никогда** не будут запрашивать ваш секретный ключ. \n- **Обязательно** сохраните надёжную резервную копию секретного ключа для восстановления аккаунта. Рекомендуем использовать менеджер паролей.</string> + <string name="account_backup_tips3_md">Для дополнительной безопасности вы можете зашифровать ваш ключ паролем. Этот ключ начинается с **ncryptsec1** и не может быть использован без вашего пароля. \n\nЕсли вы потеряете пароль, вы не сможете восстановить ключ.</string> <string name="encrypt_and_copy_my_secret_key">Зашифровать и скопировать мой секретный ключ</string> <string name="badge_award_image_for">Изображение награды для %1$s</string> <string name="badge_award_image">Изображение награды за значок</string> @@ -960,9 +953,7 @@ <string name="push_server_none_explainer">Отключает push-уведомления</string> <string name="push_server_uses_app_explainer">Использует приложение %1$s</string> <string name="push_server_install_app">Настройка push-уведомлений</string> - <string name="push_server_install_app_description"> Для получения push-уведомлений установите любое приложение, поддерживающее [Unified Push](https://unifiedpush.org/), например [Ntfy](https://ntfy.sh/). - После установки выберите нужное приложение в Настройках. - </string> + <string name="push_server_install_app_description">Для получения push-уведомлений установите любое приложение, поддерживающее [Unified Push](https://unifiedpush.org/), например [Ntfy](https://ntfy.sh/). После установки выберите нужное приложение в Настройках.</string> <string name="thread_title">Тред</string> <string name="send_the_seller_a_message">Написать продавцу</string> <string name="hi_there_is_this_still_available">Привет, это ещё в наличии?</string> @@ -2032,15 +2023,7 @@ <string name="could_not_fetch_invoice_from_details">Не удалось получить счёт от %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Не удалось открыть сжатый файл</string> <string name="couldnt_find_nwc_wallets">Кошелёк не найден</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst не нашёл ни одного приложения кошелька с поддержкой Nostr Wallet Connect (NWC). -\n\nЧто можно сделать: -\n\t1. Проверьте поддержку NWC: убедитесь, что ваш кошелёк совместим с Nostr Wallet Connect. -\n\t2. Создайте подключение: откройте приложение кошелька и создайте новое NWC-подключение. -\n\t3. Привяжите к Amethyst: обычно кошелёк предлагает три варианта: -\n\t\t3.1 Автоматическая привязка: кнопка для автоматического открытия и подключения к Amethyst. Нажмите её, откройте Amethyst и сохраните новый экран. -\n\t\t3.2 Ручная привязка: URI подключения, который можно скопировать и вставить с помощью значка вставки на этом экране. -\n\t\t3.3 QR-код: кошелёк создаёт QR-код, который можно считать кнопкой QR-кода на этом экране. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst не нашёл ни одного приложения кошелька с поддержкой Nostr Wallet Connect (NWC). \n\nЧто можно сделать: \n\t1. Проверьте поддержку NWC: убедитесь, что ваш кошелёк совместим с Nostr Wallet Connect. \n\t2. Создайте подключение: откройте приложение кошелька и создайте новое NWC-подключение. \n\t3. Привяжите к Amethyst: обычно кошелёк предлагает три варианта: \n\t\t3.1 Автоматическая привязка: кнопка для автоматического открытия и подключения к Amethyst. Нажмите её, откройте Amethyst и сохраните новый экран. \n\t\t3.2 Ручная привязка: URI подключения, который можно скопировать и вставить с помощью значка вставки на этом экране. \n\t\t3.3 QR-код: кошелёк создаёт QR-код, который можно считать кнопкой QR-кода на этом экране.</string> <string name="create">Создать</string> <string name="danger_zone">Опасная зона</string> <string name="dark">Тёмная</string> @@ -2719,11 +2702,8 @@ <string name="propose_an_edit">Предложить правку</string> <string name="proxy_section_explainer">Агрегирующие relay-серверы, которые приложение использует для загрузки ваших лент, например filter.nostr.wine. Это заменяет модель outbox и позволит приложению подключаться только к relay-серверам из ваших списков.</string> <string name="public_chat">Публичный чат</string> - <string name="public_chat_explainer">Публичные чаты видны всем в Nostr и открыты - для участия любого желающего. Они отлично подходят для открытых сообществ по определённым темам. - Модерация осуществляется путём удаления постов на relay</string> - <string name="public_chat_relays_explainer">Укажите от 1 до 3 relay, на которых размещена эта группа. - Клиенты Nostr используют эту настройку, чтобы знать, откуда загружать сообщения и куда их отправлять.</string> + <string name="public_chat_explainer">Публичные чаты видны всем в Nostr и открыты для участия любого желающего. Они отлично подходят для открытых сообществ по определённым темам. Модерация осуществляется путём удаления постов на relay</string> + <string name="public_chat_relays_explainer">Укажите от 1 до 3 relay, на которых размещена эта группа. Клиенты Nostr используют эту настройку, чтобы знать, откуда загружать сообщения и куда их отправлять.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Метаданные публичного чата</string> <string name="public_chats">Публичные чаты</string> @@ -2748,10 +2728,7 @@ <string name="read_only_user">Пользователь только для чтения</string> <string name="record_a_message_description">Нажмите и удерживайте для записи сообщения</string> <string name="relay_chat">Чат relay</string> - <string name="relay_chat_explainer">Чаты relay — это групповые чаты, управляемые их домашним relay. - Они видны всем в Nostr, и любой может в них участвовать. - Они отлично подходят для открытых сообществ по определённым темам. Некоторые группы эфемерны, - поэтому сообщения исчезают со временем</string> + <string name="relay_chat_explainer">Чаты relay — это групповые чаты, управляемые их домашним relay. Они видны всем в Nostr, и любой может в них участвовать. Они отлично подходят для открытых сообществ по определённым темам. Некоторые группы эфемерны, поэтому сообщения исчезают со временем</string> <string name="relay_chat_title">Чаты relay</string> <string name="relay_management_tab_events">События</string> <string name="relay_management_tab_ips">IP-адреса</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ru/strings.xml b/commonsUI/src/commonMain/composeResources/values-ru/strings.xml index 5a3a0ea0eb..9ceaec1f2a 100644 --- a/commonsUI/src/commonMain/composeResources/values-ru/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ru/strings.xml @@ -215,7 +215,7 @@ <string name="copy_user_id">Копировать ID пользователя</string> <string name="unblock_user">Разблокировать</string> <string name="user_is_blocked_hidden">Этот пользователь заблокирован/заглушён. Его посты скрыты.</string> - <string name="npub_hex_username">npub, hex, никнейм </string> + <string name="npub_hex_username">npub, hex, никнейм</string> <string name="clear">Очистить</string> <string name="app_logo">Логотип приложения</string> <string name="nsec_npub_hex_private_key">nsec / npub / приватный ключ в hex</string> @@ -263,17 +263,8 @@ <string name="mark_all_known_as_read">Отметить все известные прочитанными</string> <string name="mark_all_new_as_read">Отметить все новые прочитанными</string> <string name="mark_all_as_read">Отметить всё прочитанным</string> - <string name="account_backup_tips2_md"> - ## Советы по резервному копированию и безопасности ключей - \n\nВаш аккаунт защищён секретным ключом. Ключ — это длинная последовательность символов, начинающаяся с **nsec1**. Любой, кто получит доступ к этому секретному ключу, сможет публиковать записи и менять вашу личность. - \n\n- **Не** вводите свой секретный ключ на сайтах или в приложениях, которым не доверяете. - \n- Разработчики Amethyst **никогда** не будут запрашивать ваш секретный ключ. - \n- **Обязательно** сохраните надёжную резервную копию секретного ключа для восстановления аккаунта. Рекомендуем использовать менеджер паролей. - </string> - <string name="account_backup_tips3_md"> - Для дополнительной безопасности вы можете зашифровать ваш ключ паролем. Этот ключ начинается с **ncryptsec1** и не может быть использован без вашего пароля. - \n\nЕсли вы потеряете пароль, вы не сможете восстановить ваш ключ. - </string> + <string name="account_backup_tips2_md">## Советы по резервному копированию и безопасности ключей \n\nВаш аккаунт защищён секретным ключом. Ключ — это длинная последовательность символов, начинающаяся с **nsec1**. Любой, кто получит доступ к этому секретному ключу, сможет публиковать записи и менять вашу личность. \n\n- **Не** вводите свой секретный ключ на сайтах или в приложениях, которым не доверяете. \n- Разработчики Amethyst **никогда** не будут запрашивать ваш секретный ключ. \n- **Обязательно** сохраните надёжную резервную копию секретного ключа для восстановления аккаунта. Рекомендуем использовать менеджер паролей.</string> + <string name="account_backup_tips3_md">Для дополнительной безопасности вы можете зашифровать ваш ключ паролем. Этот ключ начинается с **ncryptsec1** и не может быть использован без вашего пароля. \n\nЕсли вы потеряете пароль, вы не сможете восстановить ваш ключ.</string> <string name="encrypt_and_copy_my_secret_key">Зашифровать и скопировать секретный ключ</string> <string name="badge_award_image_for">Картинка значка-награды %1$s</string> <string name="badge_award_image">Изображение награды за значок</string> @@ -966,9 +957,7 @@ <string name="push_server_none_explainer">Отключает push-уведомления</string> <string name="push_server_uses_app_explainer">Использует приложение %1$s</string> <string name="push_server_install_app">Настройки push-уведомлений</string> - <string name="push_server_install_app_description"> Для получения push-уведомлений, установите приложение, которое поддерживает [Unified Push](https://unifiedpush.org/), например [Ntfy](https://ntfy.sh/). - После установки выберите приложение, которое хотите использовать, в настройках. - </string> + <string name="push_server_install_app_description">Для получения push-уведомлений, установите приложение, которое поддерживает [Unified Push](https://unifiedpush.org/), например [Ntfy](https://ntfy.sh/). После установки выберите приложение, которое хотите использовать, в настройках.</string> <string name="thread_title">Ветка</string> <string name="send_the_seller_a_message">Написать продавцу</string> <string name="hi_there_is_this_still_available">Привет, это ещё в наличии?</string> @@ -2077,15 +2066,7 @@ <string name="could_not_fetch_invoice_from_details">Не удалось получить счёт от %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Не удалось открыть сжатый файл</string> <string name="couldnt_find_nwc_wallets">Кошелёк не найден</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst не нашёл ни одного приложения кошелька с поддержкой Nostr Wallet Connect (NWC). -\n\nЧто можно сделать: -\n\t1. Проверьте поддержку NWC: убедитесь, что ваш кошелёк совместим с Nostr Wallet Connect. -\n\t2. Создайте подключение: откройте приложение кошелька и создайте новое NWC-подключение. -\n\t3. Привяжите к Amethyst: обычно кошелёк предлагает три варианта: -\n\t\t3.1 Автоматическая привязка: кнопка для автоматического открытия и подключения к Amethyst. Нажмите её, откройте Amethyst и сохраните новый экран. -\n\t\t3.2 Ручная привязка: URI подключения, который можно скопировать и вставить с помощью значка вставки на этом экране. -\n\t\t3.3 QR-код: кошелёк создаёт QR-код, который можно считать кнопкой QR-кода на этом экране. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst не нашёл ни одного приложения кошелька с поддержкой Nostr Wallet Connect (NWC). \n\nЧто можно сделать: \n\t1. Проверьте поддержку NWC: убедитесь, что ваш кошелёк совместим с Nostr Wallet Connect. \n\t2. Создайте подключение: откройте приложение кошелька и создайте новое NWC-подключение. \n\t3. Привяжите к Amethyst: обычно кошелёк предлагает три варианта: \n\t\t3.1 Автоматическая привязка: кнопка для автоматического открытия и подключения к Amethyst. Нажмите её, откройте Amethyst и сохраните новый экран. \n\t\t3.2 Ручная привязка: URI подключения, который можно скопировать и вставить с помощью значка вставки на этом экране. \n\t\t3.3 QR-код: кошелёк создаёт QR-код, который можно считать кнопкой QR-кода на этом экране.</string> <string name="create">Создать</string> <string name="d">д</string> <string name="danger_zone">Опасная зона</string> @@ -2815,11 +2796,8 @@ <string name="proxy_section">Proxy Relays</string> <string name="proxy_section_explainer">Агрегирующие relay-серверы, которые приложение использует для загрузки ваших лент, например filter.nostr.wine. Это заменяет модель outbox и позволит приложению подключаться только к relay-серверам из ваших списков.</string> <string name="public_chat">Публичный чат</string> - <string name="public_chat_explainer">Публичные чаты видны всем в Nostr и открыты - для участия любого желающего. Они отлично подходят для открытых сообществ по определённым темам. - Модерация осуществляется путём удаления постов на relay</string> - <string name="public_chat_relays_explainer">Укажите от 1 до 3 relay, на которых размещена эта группа. - Клиенты Nostr используют эту настройку, чтобы знать, откуда загружать сообщения и куда их отправлять.</string> + <string name="public_chat_explainer">Публичные чаты видны всем в Nostr и открыты для участия любого желающего. Они отлично подходят для открытых сообществ по определённым темам. Модерация осуществляется путём удаления постов на relay</string> + <string name="public_chat_relays_explainer">Укажите от 1 до 3 relay, на которых размещена эта группа. Клиенты Nostr используют эту настройку, чтобы знать, откуда загружать сообщения и куда их отправлять.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Метаданные публичного чата</string> <string name="public_chats">Публичные чаты</string> @@ -2844,10 +2822,7 @@ <string name="read_only_user">Пользователь только для чтения</string> <string name="record_a_message_description">Нажмите и удерживайте для записи сообщения</string> <string name="relay_chat">Чат relay</string> - <string name="relay_chat_explainer">Чаты relay — это групповые чаты, управляемые их домашним relay. - Они видны всем в Nostr, и любой может в них участвовать. - Они отлично подходят для открытых сообществ по определённым темам. Некоторые группы эфемерны, - поэтому сообщения исчезают со временем</string> + <string name="relay_chat_explainer">Чаты relay — это групповые чаты, управляемые их домашним relay. Они видны всем в Nostr, и любой может в них участвовать. Они отлично подходят для открытых сообществ по определённым темам. Некоторые группы эфемерны, поэтому сообщения исчезают со временем</string> <string name="relay_chat_title">Чаты relay</string> <string name="relay_management_tab_events">События</string> <string name="relay_management_tab_ips">IP-адреса</string> diff --git a/commonsUI/src/commonMain/composeResources/values-sl-rSI/strings.xml b/commonsUI/src/commonMain/composeResources/values-sl-rSI/strings.xml index 2f5ff233bb..8ae6e95125 100644 --- a/commonsUI/src/commonMain/composeResources/values-sl-rSI/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-sl-rSI/strings.xml @@ -472,16 +472,8 @@ <string name="mark_all_known_as_read">Označi vse znane kot prebrane</string> <string name="mark_all_new_as_read">Označi vse nove kot prebrane</string> <string name="mark_all_as_read">Označi vse kot prebrane</string> - <string name="account_backup_tips2_md"> - ## Varnostna kopija ključev in varnostni nasveti - \n\nVaš račun je zaščiten z privatnim ključem. Ta ključ ima dolgo sekvenco znakov kateri se začnejo z **nsec1**. Kdorkoli ima dostop, do tega privatnega ključa, lahko pošiljajo zapiske in spremenijo vašo digitalno identiteto. - \n\n- Nikoli in **Nikdar** ne vpisuj svojega privatnega ključa v spletne strani in aplikacije katerim ne zaupaš. - \n- Amethyst ustvarjalci vas ne bojo **nikoli** vprašali po vašem privatnem ključu. - \n- Ustvari **varnostno kopijo** svojega privatnega ključa, za obnovitev računa. Priporoča se uporaba upravljalnika gesel. - </string> - <string name="account_backup_tips3_md"> Za dodatno varnost, lahko šifriraš svoj ključ z dodatnim geslom. Ta ključ se začne z **ncryptsec1** in ne more bit uporabljen brez dodatnega gesla. - \n\nČe izgubiš geslo, obnova ključa ni več mogoča. - </string> + <string name="account_backup_tips2_md">## Varnostna kopija ključev in varnostni nasveti \n\nVaš račun je zaščiten z privatnim ključem. Ta ključ ima dolgo sekvenco znakov kateri se začnejo z **nsec1**. Kdorkoli ima dostop, do tega privatnega ključa, lahko pošiljajo zapiske in spremenijo vašo digitalno identiteto. \n\n- Nikoli in **Nikdar** ne vpisuj svojega privatnega ključa v spletne strani in aplikacije katerim ne zaupaš. \n- Amethyst ustvarjalci vas ne bojo **nikoli** vprašali po vašem privatnem ključu. \n- Ustvari **varnostno kopijo** svojega privatnega ključa, za obnovitev računa. Priporoča se uporaba upravljalnika gesel.</string> + <string name="account_backup_tips3_md">Za dodatno varnost, lahko šifriraš svoj ključ z dodatnim geslom. Ta ključ se začne z **ncryptsec1** in ne more bit uporabljen brez dodatnega gesla. \n\nČe izgubiš geslo, obnova ključa ni več mogoča.</string> <string name="backup_keys_nudge_title">Varno shrani ključe</string> <string name="backup_keys_nudge_body">Vaš zasebni ključ je edini način za dostop do tega računa. Če ga izgubite, ga ne boste mogli več obnoviti. Shranite ga na varno mesto.</string> <string name="backup_keys_nudge_backup_now">Varno shrani zdaj</string> @@ -1593,9 +1585,7 @@ <string name="push_server_none_explainer">Onemogoči potisna obvestila</string> <string name="push_server_uses_app_explainer">Uporablja aplikacijo %1$s</string> <string name="push_server_install_app">Nastavitev potisnih obvestil</string> - <string name="push_server_install_app_description"> Za prejemanje potisnih obvestil namestite aplikacijo, ki podpira [Unified Push](https://unifiedpush.org/), na primer [Ntfy](https://ntfy.sh/). - Po namestitvi izberite aplikacijo, ki jo želite uporabljati, v nastavitvah. - </string> + <string name="push_server_install_app_description">Za prejemanje potisnih obvestil namestite aplikacijo, ki podpira [Unified Push](https://unifiedpush.org/), na primer [Ntfy](https://ntfy.sh/). Po namestitvi izberite aplikacijo, ki jo želite uporabljati, v nastavitvah.</string> <string name="thread_title">Niz objav</string> <string name="send_the_seller_a_message">Pošlji prodajalcu sporočilo</string> <string name="hi_there_is_this_still_available">Živjo, je to še na voljo?</string> @@ -1856,7 +1846,7 @@ <string name="calendar_day_a11y_today_suffix">danes</string> <string name="calendar_day_a11y_selected_suffix">izbrano</string> <string name="calendar_fab_new_event">Ustvari nov koledarski dogodek</string> - <string name="calendar_fab_new_collection">Ustvari novo zbirko koledarjev </string> + <string name="calendar_fab_new_collection">Ustvari novo zbirko koledarjev</string> <string name="calendar_fab_toggle">Ustvari novo zbirko koledarjev</string> <string name="calendar_untitled">(neimenovano)</string> <string name="calendar_all_day">Ves dan</string> @@ -2042,7 +2032,7 @@ <string name="buzz_dm_more">Več</string> <string name="buzz_dm_add_member">Dodaj člana</string> <string name="buzz_dm_add_member_title">Dodaj nekoga v to ZS</string> - <string name="buzz_dm_add_member_invalid">Neveljaven npub ali hex ključ </string> + <string name="buzz_dm_add_member_invalid">Neveljaven npub ali hex ključ</string> <string name="buzz_dm_just_you">Samo vi</string> <string name="buzz_dm_workspace">Delovni prostor</string> <string name="buzz_dm_recipients">Za</string> @@ -2091,8 +2081,7 @@ <string name="dm_relays_not_found">Nastavite releje za predal zasebnih sporočil</string> <string name="dm_relays_not_found_description">Ta nastavitev omogoča vsem, da vedo, katere releje uporabiti, ko vam pošiljajo sporočila. Brez njih bi lahko zgrešili nekatera sporočila.</string> <string name="dm_relays_not_found_examples2">Dobre možnosti so:\n - auth.nostr1.com (brezplačen)\n - inbox.nostr.wine (plačljiv)\n - relay.0xchat.com (brezplačen)</string> - <string name="dm_relays_not_found_editing">Vnesite 1–3 releje, ki bodo služili kot vaš predal - za zasebna sporočila. Releji za zasebna sporočila bi morali sprejeti katero koli sporočilo od kogar koli, vendar samo vam dovoliti njihov prenos.</string> + <string name="dm_relays_not_found_editing">Vnesite 1–3 releje, ki bodo služili kot vaš predal za zasebna sporočila. Releji za zasebna sporočila bi morali sprejeti katero koli sporočilo od kogar koli, vendar samo vam dovoliti njihov prenos.</string> <string name="dm_relays_not_found_create_now">Nastavi zdaj</string> <string name="recipient_missing_dm_relays">Releji za prejeto pošto (ZS) niso bili najdeni. Sporočil ni mogoče dostaviti, dokler uporabnik ne nastavi seznama svojih relejev.</string> <string name="search_relays_not_found">Nastavi iskalne releje</string> @@ -2339,7 +2328,7 @@ <string name="new_chess_game">Nova partija šaha</string> <string name="chess_loading_game">Nalagam partijo\u2026</string> <string name="chess_game_not_found">Partija ni najdena</string> - <string name="chess_game_waiting">Ta partija je zaključena ali pa, čaka na nasprotnika </string> + <string name="chess_game_waiting">Ta partija je zaključena ali pa, čaka na nasprotnika</string> <string name="chess_game_id">ID Partije: %1$s\u2026</string> <string name="badge_and_n_others"> in %1$d ostalih</string> <string name="remove_language">Odstrani %1$s</string> @@ -2664,9 +2653,7 @@ committed the change, %2$s the member it concerns, %3$s the new name. --> <string name="marmot_remove_photo">Odstrani fotografijo</string> <string name="marmot_keypackage_relays_not_set_title">KeyPackage releji niso nastavljeni</string> - <string name="marmot_keypackage_relays_not_set_message">Še nimate seznama relejev za KeyPackage (MIP-00). Ta seznam drugim sporoča, kje je objavljen vaš KeyPackage, da vas lahko povabijo v skupinske klepete. - -Ali želite za to uporabiti trenutne releje iz odhodnega predala?</string> + <string name="marmot_keypackage_relays_not_set_message">Še nimate seznama relejev za KeyPackage (MIP-00). Ta seznam drugim sporoča, kje je objavljen vaš KeyPackage, da vas lahko povabijo v skupinske klepete. Ali želite za to uporabiti trenutne releje iz odhodnega predala?</string> <string name="marmot_use_outbox_relays">Uporabi odhodne releje</string> <string name="marmot_skip_for_now">Zaenkrat preskoči</string> <string name="marmot_group_info_title">Podatki o skupini</string> @@ -3337,15 +3324,7 @@ Ali želite za to uporabiti trenutne releje iz odhodnega predala?</string> <string name="could_not_fetch_invoice_from_details">Ni bilo mogoče pridobiti fakture od %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Stisnjene datoteke ni bilo mogoče odpreti</string> <string name="couldnt_find_nwc_wallets">Ne najdem denarnice</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst ni našel nobene denarnice, ki podpira Nostr Wallet Connect (NWC). -\n\nKaj lahko storiš: -\n\t1. Preverite podporo za NWC: Ponovno\t preverite, ali vaša priljubljena denarnica podpira Nostr Wallet Connect. -\n\t2. Ustvari povezavo: Odprite svojo denarnico in ustvarite novo NWC povezavo. -\n\t3. Povežite z Amethyst: Vaša denarnica vam bo ponavadi ponudila tri možnosti: -\n\t\t3.1 Samodejna povezava: Gumb za samodejno odprtje in povezavo z Amethyst. Če je na voljo, kliknite ta gumb, odprite Amethyst in na novem zaslonu pritisnite shrani. -\n\t\tRočna povezava: Povezovalni URI, ki ga lahko kopirate, nato pa na tem zaslonu kliknite ikono za lepljenje, da ga neposredno vnesete. -\n\t\tQR koda: Denarnica ustvari QR-kodo, ki jo skenirajte z gumbom za QR na tem zaslonu. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst ni našel nobene denarnice, ki podpira Nostr Wallet Connect (NWC). \n\nKaj lahko storiš: \n\t1. Preverite podporo za NWC: Ponovno\t preverite, ali vaša priljubljena denarnica podpira Nostr Wallet Connect. \n\t2. Ustvari povezavo: Odprite svojo denarnico in ustvarite novo NWC povezavo. \n\t3. Povežite z Amethyst: Vaša denarnica vam bo ponavadi ponudila tri možnosti: \n\t\t3.1 Samodejna povezava: Gumb za samodejno odprtje in povezavo z Amethyst. Če je na voljo, kliknite ta gumb, odprite Amethyst in na novem zaslonu pritisnite shrani. \n\t\tRočna povezava: Povezovalni URI, ki ga lahko kopirate, nato pa na tem zaslonu kliknite ikono za lepljenje, da ga neposredno vnesete. \n\t\tQR koda: Denarnica ustvari QR-kodo, ki jo skenirajte z gumbom za QR na tem zaslonu.</string> <string name="create">Ustvari</string> <string name="d">d</string> <string name="danger_zone">Nevarno območje</string> @@ -3804,26 +3783,16 @@ Ali želite za to uporabiti trenutne releje iz odhodnega predala?</string> <string name="location_change_place">Spremeni lokacijo na karti</string> <string name="location_channels">Lokacijski kanali</string> <string name="location_pick_on_map">Izberi lokacijo na karti</string> - <string name="login_with_a_private_key_to_be_able_to_boost_posts">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavi se s privatnim ključem za posredovanje sporočila</string> - <string name="login_with_a_private_key_to_be_able_to_follow">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavi se s privatnim ključem, za sledenje uporabnika</string> - <string name="login_with_a_private_key_to_be_able_to_hide_word">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavi se s privatnim ključem, za cenzuro besed ali stavkov</string> - <string name="login_with_a_private_key_to_be_able_to_reply">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavi se s privatnim ključem, da omogočiš tudi pisanje</string> - <string name="login_with_a_private_key_to_be_able_to_send_zaps">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavite se s privatnim ključem, da boste lahko pošiljali Zape</string> - <string name="login_with_a_private_key_to_be_able_to_show_word">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavi se s privatnim ključem, za prikaz skritih besed in stavkov</string> - <string name="login_with_a_private_key_to_be_able_to_sign_events">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Za podpisovanje se je potrebno prijaviti s privatnim ključem</string> - <string name="login_with_a_private_key_to_be_able_to_unfollow">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavi se s privatnim ključem, za odstranitev iz seznama sledljivih</string> - <string name="login_with_a_private_key_to_be_able_to_upload">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Za nalaganje se je potrebno prijaviti s privatnim ključem</string> - <string name="login_with_a_private_key_to_like_posts">Uporabljaš javni ključ in javni ključi omogočajo le branje. -Prijavi se s privatnim ključem za všečkanje sporočila</string> + <string name="login_with_a_private_key_to_be_able_to_boost_posts">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavi se s privatnim ključem za posredovanje sporočila</string> + <string name="login_with_a_private_key_to_be_able_to_follow">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavi se s privatnim ključem, za sledenje uporabnika</string> + <string name="login_with_a_private_key_to_be_able_to_hide_word">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavi se s privatnim ključem, za cenzuro besed ali stavkov</string> + <string name="login_with_a_private_key_to_be_able_to_reply">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavi se s privatnim ključem, da omogočiš tudi pisanje</string> + <string name="login_with_a_private_key_to_be_able_to_send_zaps">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavite se s privatnim ključem, da boste lahko pošiljali Zape</string> + <string name="login_with_a_private_key_to_be_able_to_show_word">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavi se s privatnim ključem, za prikaz skritih besed in stavkov</string> + <string name="login_with_a_private_key_to_be_able_to_sign_events">Uporabljaš javni ključ in javni ključi omogočajo le branje. Za podpisovanje se je potrebno prijaviti s privatnim ključem</string> + <string name="login_with_a_private_key_to_be_able_to_unfollow">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavi se s privatnim ključem, za odstranitev iz seznama sledljivih</string> + <string name="login_with_a_private_key_to_be_able_to_upload">Uporabljaš javni ključ in javni ključi omogočajo le branje. Za nalaganje se je potrebno prijaviti s privatnim ključem</string> + <string name="login_with_a_private_key_to_like_posts">Uporabljaš javni ključ in javni ključi omogočajo le branje. Prijavi se s privatnim ključem za všečkanje sporočila</string> <string name="longs">Videoposnetki</string> <string name="m">m</string> <string name="manage_emoji_packs">Moji emoji paketi</string> @@ -4122,7 +4091,7 @@ Prijavi se s privatnim ključem za všečkanje sporočila</string> <string name="new_conversation_public_chat_con_2">Brez moderacije</string> <string name="new_conversation_public_chat_cta">Ustvari nov javen klepet</string> <string name="new_conversation_public_chat_pro_1">Pridruži se lahko kdorkoli</string> - <string name="new_conversation_public_chat_pro_2">Preprosto in zlahka dosegljivo </string> + <string name="new_conversation_public_chat_pro_2">Preprosto in zlahka dosegljivo</string> <string name="new_conversation_public_chat_tagline">Javna sporočila na releju</string> <string name="new_conversation_public_chat_title">Javni klepet</string> <string name="new_conversation_relay_group_best">Skupine, ki jih moderira njihov gostiteljski rele</string> @@ -4531,11 +4500,8 @@ Prijavi se s privatnim ključem za všečkanje sporočila</string> <string name="proxy_section">Proxy releji</string> <string name="proxy_section_explainer">Agregatorji, ki jih mora aplikacija uporabljati za prenos vaših vsebin, na primer filter.nostr.wine. To nadomesti model odhodne pošte (outbox model) in bo prisililo aplikacijo k povezovanju prek relejev iz vašega seznama.</string> <string name="public_chat">Javni pogovor</string> - <string name="public_chat_explainer">Javni klepeti so vidni vsem na Nostru in vsakdo - se lahko pridruži. So odlični za odprte skupnosti o specifičnih temah. - Moderiranje je možno z brisanjem objav na njihovih relejih</string> - <string name="public_chat_relays_explainer">Vnesi 1–3 releje, ki gostijo to skupino. - Nostr odjemalci uporabljajo to nastavitev, da vedo, od kod prenesti vaša sporočila in kam jih poslati.</string> + <string name="public_chat_explainer">Javni klepeti so vidni vsem na Nostru in vsakdo se lahko pridruži. So odlični za odprte skupnosti o specifičnih temah. Moderiranje je možno z brisanjem objav na njihovih relejih</string> + <string name="public_chat_relays_explainer">Vnesi 1–3 releje, ki gostijo to skupino. Nostr odjemalci uporabljajo to nastavitev, da vedo, od kod prenesti vaša sporočila in kam jih poslati.</string> <string name="public_chat_relays_title">Releji</string> <string name="public_chat_title">Metapodatki Javnega Klepeta</string> <string name="public_chats">Javni klepeti</string> @@ -4595,10 +4561,7 @@ Prijavi se s privatnim ključem za všečkanje sporočila</string> <string name="relay_auth_search_keywords">Preverjanje pristnosti (Auth), rele (Relay), podpis (Sign), preverjanje (Verify), NIP-42, identiteta</string> <string name="relay_auth_settings_title">Avtentikacija releja</string> <string name="relay_chat">Rele klepet</string> - <string name="relay_chat_explainer">Pogovori prek relejev so pogovorne skupine, ki jih nadzoruje njihov domači rele. - Vidne so vsem na Nostru in v njih lahko sodeluje kdorkoli. - So odlične za odprte skupnosti, povezane s specifičnimi temami. Nekatere od teh skupin so kratkotrajne - zato sporočila v klepetu sčasoma izginejo</string> + <string name="relay_chat_explainer">Pogovori prek relejev so pogovorne skupine, ki jih nadzoruje njihov domači rele. Vidne so vsem na Nostru in v njih lahko sodeluje kdorkoli. So odlične za odprte skupnosti, povezane s specifičnimi temami. Nekatere od teh skupin so kratkotrajne zato sporočila v klepetu sčasoma izginejo</string> <string name="relay_chat_title">Rele klepeti</string> <string name="relay_explain_account_data">Vaš profil, nastavitve in osnutki na vaših domačih relejih.</string> <string name="relay_explain_community_chats">Releji, kamor vsaka skupnost objavlja svoje načrte.</string> @@ -4732,7 +4695,7 @@ Prijavi se s privatnim ključem za všečkanje sporočila</string> <string name="resource_usage_memory_native">Lokalni pomnilnik</string> <string name="resource_usage_memory_notes">Zapiski v pomnilniku</string> <string name="resource_usage_memory_section">Trenutni pomnilnik</string> - <string name="resource_usage_memory_users">Profili v pomnilniku </string> + <string name="resource_usage_memory_users">Profili v pomnilniku</string> <string name="resource_usage_nests">Čas v zvočnih sobah</string> <string name="resource_usage_pow">Rudarjenje PoW</string> <string name="resource_usage_radio_bursts">Obuditve radijskega modula za prenose (ocena)</string> diff --git a/commonsUI/src/commonMain/composeResources/values-sr-rSP/strings.xml b/commonsUI/src/commonMain/composeResources/values-sr-rSP/strings.xml index 6ea50394e6..9aee9b1e4d 100644 --- a/commonsUI/src/commonMain/composeResources/values-sr-rSP/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-sr-rSP/strings.xml @@ -271,15 +271,8 @@ <string name="mark_all_known_as_read">Označi sve poznate kao pročitano</string> <string name="mark_all_new_as_read">Označi sve novo kao pročitano</string> <string name="mark_all_as_read">Označi sve kao pročitano</string> - <string name="account_backup_tips2_md"> ## Saveti za bekap ključa i bezbednost - \n\nVaš nalog je zaštićen tajnim ključem. Ključ je dugačak niz znakova koji počinje sa **nsec1**. Svako ko ima pristup ovom tajnom ključu može da objavljuje i menja vaš identitet. - \n\n- **Ne** unosite vaš tajni ključ ni na jedan veb-sajt ili softver kojemu ne verujete. - \n- Amethyst programeri **nikada** neće tražiti vaš tajni ključ. - \n- **Čuvajte** bezbednu kopiju vašeg tajnog ključa radi oporavka naloga. Preporučujemo korišćenje menadžera lozinki. - </string> - <string name="account_backup_tips3_md"> Za dodatnu bezbednost, možete šifrovati vaš ključ lozinkom. Ovaj ključ počinje sa **ncryptsec1** i ne može se koristiti bez vaše lozinke. - \n\nAko izgubite lozinku, nećete moći da obnovite ključ. - </string> + <string name="account_backup_tips2_md">## Saveti za bekap ključa i bezbednost \n\nVaš nalog je zaštićen tajnim ključem. Ključ je dugačak niz znakova koji počinje sa **nsec1**. Svako ko ima pristup ovom tajnom ključu može da objavljuje i menja vaš identitet. \n\n- **Ne** unosite vaš tajni ključ ni na jedan veb-sajt ili softver kojemu ne verujete. \n- Amethyst programeri **nikada** neće tražiti vaš tajni ključ. \n- **Čuvajte** bezbednu kopiju vašeg tajnog ključa radi oporavka naloga. Preporučujemo korišćenje menadžera lozinki.</string> + <string name="account_backup_tips3_md">Za dodatnu bezbednost, možete šifrovati vaš ključ lozinkom. Ovaj ključ počinje sa **ncryptsec1** i ne može se koristiti bez vaše lozinke. \n\nAko izgubite lozinku, nećete moći da obnovite ključ.</string> <string name="encrypt_and_copy_my_secret_key">Šifruj i kopiraj moj tajni ključ</string> <string name="badge_award_image_for">Slika značke za %1$s</string> <string name="badge_award_image">"Slika značke</string> @@ -959,9 +952,7 @@ <string name="push_server_none_explainer">Onemogućava push obaveštenja</string> <string name="push_server_uses_app_explainer">Koristi aplikaciju %1$s</string> <string name="push_server_install_app">Podešavanje push obaveštenja</string> - <string name="push_server_install_app_description"> Da biste primali push obaveštenja, instalirajte bilo koju aplikaciju koja podržava [Unified Push](https://unifiedpush.org/), kao što je [Ntfy](https://ntfy.sh/). - Nakon instalacije, izaberite aplikaciju koju želite da koristite u Postavkama. - </string> + <string name="push_server_install_app_description">Da biste primali push obaveštenja, instalirajte bilo koju aplikaciju koja podržava [Unified Push](https://unifiedpush.org/), kao što je [Ntfy](https://ntfy.sh/). Nakon instalacije, izaberite aplikaciju koju želite da koristite u Postavkama.</string> <string name="thread_title">Nit</string> <string name="send_the_seller_a_message">Pošaljite prodavcu poruku</string> <string name="hi_there_is_this_still_available">Zdravo, da li je ovo još uvek dostupno?</string> @@ -2014,15 +2005,7 @@ <string name="could_not_fetch_invoice_from_details">Nije moguće dohvatiti fakturu od %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Komprimovana datoteka se ne može otvoriti</string> <string name="couldnt_find_nwc_wallets">Novčanik nije pronađen</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst nije mogao da pronađe nijednu aplikaciju novčanika koja podržava Nostr Wallet Connect (NWC). -\n\nŠta možete da uradite: -\n\t1. Proverite NWC podršku: Proverite da li vaša preferovana aplikacija novčanika podržava Nostr Wallet Connect. -\n\t2. Kreirajte vezu: Idite na aplikaciju novčanika i kreirajte novu NWC vezu. -\n\t3. Povežite sa Amethyst: Vaš novčanik će obično ponuditi tri opcije: -\n\t\t3.1 Automatska veza: Dugme za automatsko otvaranje i povezivanje sa Amethyst. Ako postoji, kliknite to dugme, otvorite Amethyst i pritisnite sačuvaj na novom ekranu. -\n\t\t3.2 Ručna veza: URI veze koji možete kopirati i kliknuti ikonu za nalepljivanje na ovom ekranu da ga direktno unesete. -\n\t\t3.3 QR kod: Novčanik kreira QR kod koji možete očitati dugmetom za QR kod na ovom ekranu. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst nije mogao da pronađe nijednu aplikaciju novčanika koja podržava Nostr Wallet Connect (NWC). \n\nŠta možete da uradite: \n\t1. Proverite NWC podršku: Proverite da li vaša preferovana aplikacija novčanika podržava Nostr Wallet Connect. \n\t2. Kreirajte vezu: Idite na aplikaciju novčanika i kreirajte novu NWC vezu. \n\t3. Povežite sa Amethyst: Vaš novčanik će obično ponuditi tri opcije: \n\t\t3.1 Automatska veza: Dugme za automatsko otvaranje i povezivanje sa Amethyst. Ako postoji, kliknite to dugme, otvorite Amethyst i pritisnite sačuvaj na novom ekranu. \n\t\t3.2 Ručna veza: URI veze koji možete kopirati i kliknuti ikonu za nalepljivanje na ovom ekranu da ga direktno unesete. \n\t\t3.3 QR kod: Novčanik kreira QR kod koji možete očitati dugmetom za QR kod na ovom ekranu.</string> <string name="create">Napravi</string> <string name="danger_zone">Opasna zona</string> <string name="dark">Tamno</string> @@ -2703,11 +2686,8 @@ <string name="proxy_section">Proxy Relay-i</string> <string name="proxy_section_explainer">Agregatorni relay-i koje aplikacija mora koristiti za preuzimanje vaših feedova, poput filter.nostr.wine. Ovo zamenjuje outbox model i čini da se aplikacija povezuje samo na relay-e u vašim listama.</string> <string name="public_chat">Javni čet</string> - <string name="public_chat_explainer">Javni četovi vidljivi su svima na Nostr-u i svako - može da učestvuje. Odlični su za otvorene zajednice oko specifičnih tema. - Moderacija se može kontrolisati brisanjem objava na relay-ima</string> - <string name="public_chat_relays_explainer">Unesite između 1 i 3 relay-a koji hostuju ovu grupu. - Nostr klijenti koriste ovo podešavanje da znaju odakle da preuzmu poruke i kuda da ih šalju.</string> + <string name="public_chat_explainer">Javni četovi vidljivi su svima na Nostr-u i svako može da učestvuje. Odlični su za otvorene zajednice oko specifičnih tema. Moderacija se može kontrolisati brisanjem objava na relay-ima</string> + <string name="public_chat_relays_explainer">Unesite između 1 i 3 relay-a koji hostuju ovu grupu. Nostr klijenti koriste ovo podešavanje da znaju odakle da preuzmu poruke i kuda da ih šalju.</string> <string name="public_chat_relays_title">Relay-i</string> <string name="public_chat_title">Metapodaci javnog četa</string> <string name="public_chats">Javni razgovori</string> @@ -2732,10 +2712,7 @@ <string name="read_only_user">Korisnik samo za čitanje</string> <string name="record_a_message_description">Kliknite i držite za snimanje poruke</string> <string name="relay_chat">Relay čet</string> - <string name="relay_chat_explainer">Relay četovi su grupe za razgovor kojima upravlja njihov matični relay. - Vidljivi su svima na Nostr-u i svako može da učestvuje. - Odlični su za otvorene zajednice oko specifičnih tema. Neke od ovih grupa su efemeralne - i stoga poruke nestaju s vremenom</string> + <string name="relay_chat_explainer">Relay četovi su grupe za razgovor kojima upravlja njihov matični relay. Vidljivi su svima na Nostr-u i svako može da učestvuje. Odlični su za otvorene zajednice oko specifičnih tema. Neke od ovih grupa su efemeralne i stoga poruke nestaju s vremenom</string> <string name="relay_chat_title">Relay četovi</string> <string name="relay_management_tab_events">Događaji</string> <string name="relay_management_tab_ips">IP adrese</string> diff --git a/commonsUI/src/commonMain/composeResources/values-sv-rSE/strings.xml b/commonsUI/src/commonMain/composeResources/values-sv-rSE/strings.xml index f591cc0177..0b434776f0 100644 --- a/commonsUI/src/commonMain/composeResources/values-sv-rSE/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-sv-rSE/strings.xml @@ -361,7 +361,7 @@ <string name="copy_user_id">Kopiera Användarens ID</string> <string name="unblock_user">Sluta blockera Användare</string> <string name="user_is_blocked_hidden">Den här användaren är blockerad/tystad. Deras inlägg är dolda.</string> - <string name="npub_hex_username">npub, hex, användarnamn </string> + <string name="npub_hex_username">npub, hex, användarnamn</string> <string name="clear">Rensa</string> <string name="app_logo">Appens logo</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex privat nyckel</string> @@ -463,13 +463,8 @@ <string name="mark_all_known_as_read">Markera alla kända som lästa</string> <string name="mark_all_new_as_read">Markera alla nya som lästa</string> <string name="mark_all_as_read">Markera allt som läst</string> - <string name="account_backup_tips2_md"> ## Nyckelsäkerhetsråd - \n\nDitt konto är säkrat med en hemlig nyckel. Nyckeln är en lång följd av tecken som börjar med **nsec1**. Den som har tillgång till denna hemliga nyckel kan posta och ändra din identitet. - \n\n- **Lägg inte** din hemliga nyckel på någon webbplats eller i någon mjukvara som du inte litar på. - \n- Utvecklarna av Amethyst kommer **aldrig** att be om din hemliga nyckel. - \n- **Spara** en säkerhetskopia av din hemliga nyckel för återställning av kontot. Vi rekommenderar att du använder en lösenordshanterare.</string> - <string name="account_backup_tips3_md"> För extra säkerhet kan du kryptera din nyckel med ett lösenord. Denna nyckel börjar med **ncryptsec1** och kan inte användas utan ditt lösenord. - \n\nOm du tappar bort ditt lösenord kommer du inte att kunna återställa din nyckel.</string> + <string name="account_backup_tips2_md">## Nyckelsäkerhetsråd \n\nDitt konto är säkrat med en hemlig nyckel. Nyckeln är en lång följd av tecken som börjar med **nsec1**. Den som har tillgång till denna hemliga nyckel kan posta och ändra din identitet. \n\n- **Lägg inte** din hemliga nyckel på någon webbplats eller i någon mjukvara som du inte litar på. \n- Utvecklarna av Amethyst kommer **aldrig** att be om din hemliga nyckel. \n- **Spara** en säkerhetskopia av din hemliga nyckel för återställning av kontot. Vi rekommenderar att du använder en lösenordshanterare.</string> + <string name="account_backup_tips3_md">För extra säkerhet kan du kryptera din nyckel med ett lösenord. Denna nyckel börjar med **ncryptsec1** och kan inte användas utan ditt lösenord. \n\nOm du tappar bort ditt lösenord kommer du inte att kunna återställa din nyckel.</string> <string name="backup_keys_nudge_title">Säkerhetskopiera dina nycklar</string> <string name="backup_keys_nudge_body">Din hemliga nyckel är enda sättet att komma åt det här kontot. Om du förlorar den kan den aldrig återskapas. Spara den på ett säkert ställe nu.</string> <string name="backup_keys_nudge_backup_now">Säkerhetskopiera nu</string> @@ -478,7 +473,7 @@ <string name="encrypt_and_copy_my_secret_key">Kryptera och kopiera min hemliga nyckel</string> <string name="badge_award_image_for">Tilldelad Badge för %1$s</string> <string name="badge_award_image">Bild på utmärkelse</string> - <string name="new_badge_award_notif">Du har blivit tilldelad en ny Badge </string> + <string name="new_badge_award_notif">Du har blivit tilldelad en ny Badge</string> <string name="award_granted_to">Badge utmärkelse tilldelas</string> <string name="account_switch_add_account_dialog_title">Lägg till nytt konto</string> <string name="account_switch_select_account">Välj konto</string> @@ -1584,9 +1579,7 @@ <string name="push_server_none_explainer">Inaktivera Push-meddelande</string> <string name="push_server_uses_app_explainer">Använder appen %1$s</string> <string name="push_server_install_app">Inställning av Push-aviseringar</string> - <string name="push_server_install_app_description"> För att ta emot push-aviseringar, installera vilken app som helst som stöder [Unified Push](https://unifiedpush.org), till exempel [Ntfy](https://ntfy.sh/). - Efter installationen väljer du den app du vill använda i inställningarna. - </string> + <string name="push_server_install_app_description">För att ta emot push-aviseringar, installera vilken app som helst som stöder [Unified Push](https://unifiedpush.org), till exempel [Ntfy](https://ntfy.sh/). Efter installationen väljer du den app du vill använda i inställningarna.</string> <string name="thread_title">Tråd</string> <string name="send_the_seller_a_message">Skicka ett meddelande till säljaren</string> <string name="hi_there_is_this_still_available">Hallå där, är detta fortfarande tillgängligt?</string> @@ -3323,14 +3316,7 @@ <string name="could_not_fetch_invoice_from_details">Kunde inte hämta faktura från %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Kunde inte öppna den komprimerade filen</string> <string name="couldnt_find_nwc_wallets">Plånbok hittades inte</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst kunde inte hitta några plånboksappar som stöder Nostr Wallet Connect (NWC). -\n\nVad du kan göra: -\n\t1. Verifiera NWC-stöd: Kontrollera att din föredragna plånbok stöder Nostr Wallet Connect. -\n\t2. Skapa anslutning: Gå till din plånbok och skapa en ny NWC-anslutning. -\n\t3. Länka till Amethyst: Din plånbok erbjuder vanligtvis tre alternativ: -\n\t\t3.1 Automatisk länk: En knapp för att automatiskt öppna och ansluta till Amethyst. Klicka på den, öppna Amethyst och spara på den nya skärmen. -\n\t\t3.2 Manuell länk: En anslutnings-URI som du kan kopiera och klistra in via klistra-ikonen på den här skärmen. -\n\t\t3.3 QR-kod: Plånboken skapar en QR-kod som du kan skanna med QR-knappens funktion på den här skärmen.</string> + <string name="couldnt_find_nwc_wallets_description">Amethyst kunde inte hitta några plånboksappar som stöder Nostr Wallet Connect (NWC). \n\nVad du kan göra: \n\t1. Verifiera NWC-stöd: Kontrollera att din föredragna plånbok stöder Nostr Wallet Connect. \n\t2. Skapa anslutning: Gå till din plånbok och skapa en ny NWC-anslutning. \n\t3. Länka till Amethyst: Din plånbok erbjuder vanligtvis tre alternativ: \n\t\t3.1 Automatisk länk: En knapp för att automatiskt öppna och ansluta till Amethyst. Klicka på den, öppna Amethyst och spara på den nya skärmen. \n\t\t3.2 Manuell länk: En anslutnings-URI som du kan kopiera och klistra in via klistra-ikonen på den här skärmen. \n\t\t3.3 QR-kod: Plånboken skapar en QR-kod som du kan skanna med QR-knappens funktion på den här skärmen.</string> <string name="create">Skapa</string> <string name="d">d</string> <string name="danger_zone">Riskzon</string> @@ -4427,11 +4413,8 @@ <string name="proxy_section">Proxyreläer</string> <string name="proxy_section_explainer">Aggregeringsreläer som används för att hämta flöden, t.ex. filter.nostr.wine</string> <string name="public_chat">Publik Chat</string> - <string name="public_chat_explainer">Offentliga chattar är synliga för alla på Nostr och alla - kan delta på dem. De är bra för öppna samhällen kring specifika ämnen. - Moderation kan kontrolleras genom att ta bort inlägg på reläerna</string> - <string name="public_chat_relays_explainer">Infoga mellan 1–3 reläer som är värd för denna grupp. - Nostr klienter använder denna inställning för att veta var du kan ladda ner meddelanden från och skicka dina meddelanden till.</string> + <string name="public_chat_explainer">Offentliga chattar är synliga för alla på Nostr och alla kan delta på dem. De är bra för öppna samhällen kring specifika ämnen. Moderation kan kontrolleras genom att ta bort inlägg på reläerna</string> + <string name="public_chat_relays_explainer">Infoga mellan 1–3 reläer som är värd för denna grupp. Nostr klienter använder denna inställning för att veta var du kan ladda ner meddelanden från och skicka dina meddelanden till.</string> <string name="public_chat_relays_title">Reläer</string> <string name="public_chat_title">Metadata för offentlig chatt</string> <string name="public_chats">Offentliga chattar</string> @@ -4496,10 +4479,7 @@ <string name="relay_auth_search_keywords">auth autentisering relä signera verifiera nip-42 identitet</string> <string name="relay_auth_settings_title">Reläautentisering</string> <string name="relay_chat">Relä Chatt</string> - <string name="relay_chat_explainer">Relä chattar är chattgrupper som kontrolleras av deras hem relä. - De är synliga för alla på Nostr och vem som helst kan delta på dem. - De är bra för öppna gemenskaper kring specifika ämnen. Några av dessa grupper är kortlivade - och därmed försvinner chattmeddelanden över tiden</string> + <string name="relay_chat_explainer">Relä chattar är chattgrupper som kontrolleras av deras hem relä. De är synliga för alla på Nostr och vem som helst kan delta på dem. De är bra för öppna gemenskaper kring specifika ämnen. Några av dessa grupper är kortlivade och därmed försvinner chattmeddelanden över tiden</string> <string name="relay_chat_title">Relä Chattar</string> <string name="relay_explain_account_data">Din egen profil, dina inställningar och utkast, på dina hemreläer.</string> <string name="relay_explain_community_chats">Reläerna som varje gemenskap publicerar sina plan till.</string> diff --git a/commonsUI/src/commonMain/composeResources/values-sw/strings.xml b/commonsUI/src/commonMain/composeResources/values-sw/strings.xml index 9c24ec5784..439b9c7be0 100644 --- a/commonsUI/src/commonMain/composeResources/values-sw/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-sw/strings.xml @@ -268,15 +268,8 @@ <string name="mark_all_known_as_read">Funga kama Zimejulikana</string> <string name="mark_all_new_as_read">Funga kama Mpya</string> <string name="mark_all_as_read">Funga kama Zimejulikana</string> - <string name="account_backup_tips2_md"> ## Vidokezo vya Nakala Rudufu ya Ufunguo na Usalama - \n\nAkaunti yako inalindwa na ufunguo wa siri. Ufunguo ni mfululizo mrefu wa herufi unaoanza na **nsec1**. Mtu yeyote anayepata ufunguo huu wa siri anaweza kuchapisha na kubadilisha utambulisho wako. - \n\n- **Usiweke** ufunguo wako wa siri katika tovuti yoyote au programu unayoitembelewa. - \n- Watengenezaji wa Amethyst **hawatawahi** kuomba ufunguo wako wa siri. - \n- **Hifadhi** nakala salama ya ufunguo wako wa siri kwa ajili ya kurejesha akaunti. Tunapendekeza kutumia kidhibiti cha nenosiri. - </string> - <string name="account_backup_tips3_md"> Kwa usalama zaidi, unaweza kusimba ufunguo wako kwa nenosiri. Ufunguo huu unaanza na **ncryptsec1** na hauwezi kutumika bila nenosiri lako. - \n\nUkipoteza nenosiri lako, hutaweza kurejesha ufunguo wako. - </string> + <string name="account_backup_tips2_md">## Vidokezo vya Nakala Rudufu ya Ufunguo na Usalama \n\nAkaunti yako inalindwa na ufunguo wa siri. Ufunguo ni mfululizo mrefu wa herufi unaoanza na **nsec1**. Mtu yeyote anayepata ufunguo huu wa siri anaweza kuchapisha na kubadilisha utambulisho wako. \n\n- **Usiweke** ufunguo wako wa siri katika tovuti yoyote au programu unayoitembelewa. \n- Watengenezaji wa Amethyst **hawatawahi** kuomba ufunguo wako wa siri. \n- **Hifadhi** nakala salama ya ufunguo wako wa siri kwa ajili ya kurejesha akaunti. Tunapendekeza kutumia kidhibiti cha nenosiri.</string> + <string name="account_backup_tips3_md">Kwa usalama zaidi, unaweza kusimba ufunguo wako kwa nenosiri. Ufunguo huu unaanza na **ncryptsec1** na hauwezi kutumika bila nenosiri lako. \n\nUkipoteza nenosiri lako, hutaweza kurejesha ufunguo wako.</string> <string name="encrypt_and_copy_my_secret_key">Simba na nakili ufunguo wangu wa siri</string> <string name="badge_award_image_for">Picha ya tuzo ya alama kwa %1$s</string> <string name="badge_award_image">"Picha ya tuzo ya beji</string> @@ -961,9 +954,7 @@ <string name="push_server_none_explainer">Inazima Arifa za Push</string> <string name="push_server_uses_app_explainer">Inatumia programu %1$s</string> <string name="push_server_install_app">Mpangilio wa Arifa za Push</string> - <string name="push_server_install_app_description"> Ili kupokea arifa za kusukuma, sakinisha programu yoyote inayounga mkono [Unified Push](https://unifiedpush.org/), kama vile [Ntfy](https://ntfy.sh/). - Baada ya kusakinisha, chagua programu unayotaka kutumia katika Mipangilio. - </string> + <string name="push_server_install_app_description">Ili kupokea arifa za kusukuma, sakinisha programu yoyote inayounga mkono [Unified Push](https://unifiedpush.org/), kama vile [Ntfy](https://ntfy.sh/). Baada ya kusakinisha, chagua programu unayotaka kutumia katika Mipangilio.</string> <string name="thread_title">Nyuzi</string> <string name="send_the_seller_a_message">Tuma ujumbe kwa muuzaji</string> <string name="hi_there_is_this_still_available">Habari, je, hii bado inapatikana?</string> @@ -2016,15 +2007,7 @@ <string name="could_not_fetch_invoice_from_details">Haikuweza kupata ankara kutoka kwa %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Haikuweza kufungua faili lililosinyazwa</string> <string name="couldnt_find_nwc_wallets">Mkoba haukupatikana</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst haikupata programu yoyote ya mkoba inayounga mkono Nostr Wallet Connect (NWC). -\n\nUnachoweza kufanya: -\n\t1. Thibitisha Usaidizi wa NWC: Hakikisha kuwa programu yako ya mkoba inaoana na Nostr Wallet Connect. -\n\t2. Unda Muunganisho: Nenda kwenye programu yako ya mkoba na unda muunganisho mpya wa NWC. -\n\t3. Unganisha na Amethyst: Mkoba wako kwa kawaida utakupa chaguo tatu: -\n\t\t3.1 Kiungo cha Kiotomatiki: Kitufe cha kufungua na kuunganisha moja kwa moja na Amethyst. Ikiwa ndivyo, bonyeza kitufe hicho, fungua Amethyst na bonyeza hifadhi kwenye skrini mpya. -\n\t\t3.2 Kiungo cha Mkono: URI ya Muunganisho unayoweza kunakili na kubonyeza ikoni ya kubandika kwenye skrini hii kuiingiza moja kwa moja. -\n\t\t3.3 Msimbo wa QR: Mkoba unaunda msimbo wa QR ambao unaweza kuusoma kutoka kwa kitufe cha msimbo wa QR kwenye skrini hii. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst haikupata programu yoyote ya mkoba inayounga mkono Nostr Wallet Connect (NWC). \n\nUnachoweza kufanya: \n\t1. Thibitisha Usaidizi wa NWC: Hakikisha kuwa programu yako ya mkoba inaoana na Nostr Wallet Connect. \n\t2. Unda Muunganisho: Nenda kwenye programu yako ya mkoba na unda muunganisho mpya wa NWC. \n\t3. Unganisha na Amethyst: Mkoba wako kwa kawaida utakupa chaguo tatu: \n\t\t3.1 Kiungo cha Kiotomatiki: Kitufe cha kufungua na kuunganisha moja kwa moja na Amethyst. Ikiwa ndivyo, bonyeza kitufe hicho, fungua Amethyst na bonyeza hifadhi kwenye skrini mpya. \n\t\t3.2 Kiungo cha Mkono: URI ya Muunganisho unayoweza kunakili na kubonyeza ikoni ya kubandika kwenye skrini hii kuiingiza moja kwa moja. \n\t\t3.3 Msimbo wa QR: Mkoba unaunda msimbo wa QR ambao unaweza kuusoma kutoka kwa kitufe cha msimbo wa QR kwenye skrini hii.</string> <string name="create">Unda</string> <string name="d">siku</string> <string name="danger_zone">Eneo Hatari</string> @@ -2686,11 +2669,8 @@ <string name="proxy_section">Relay za Wakala</string> <string name="proxy_section_explainer">Relay za mkusanyaji ambazo programu lazima itumie kupakua malisho yako, kama filter.nostr.wine. Hii inabadilisha mfano wa sanduku la nje na itafanya programu iunganike na relay zilizo kwenye orodha zako tu.</string> <string name="public_chat">Mazungumzo ya Umma</string> - <string name="public_chat_explainer">Mazungumzo ya umma yanaweza kuonekana na kila mtu kwenye Nostr na mtu yeyote - anaweza kushiriki. Ni mazuri kwa jamii wazi kuhusu mada maalum. - Udhibiti unaweza kufanywa kwa kufuta machapisho kwenye relay zake</string> - <string name="public_chat_relays_explainer">Ingiza kati ya relay 1–3 zinazohifadhi kikundi hiki. - Wateja wa Nostr hutumia mipangilio hii kujua mahali pa kupakua ujumbe na kutuma ujumbe wako.</string> + <string name="public_chat_explainer">Mazungumzo ya umma yanaweza kuonekana na kila mtu kwenye Nostr na mtu yeyote anaweza kushiriki. Ni mazuri kwa jamii wazi kuhusu mada maalum. Udhibiti unaweza kufanywa kwa kufuta machapisho kwenye relay zake</string> + <string name="public_chat_relays_explainer">Ingiza kati ya relay 1–3 zinazohifadhi kikundi hiki. Wateja wa Nostr hutumia mipangilio hii kujua mahali pa kupakua ujumbe na kutuma ujumbe wako.</string> <string name="public_chat_title">Metadata ya Mazungumzo ya Umma</string> <string name="public_chats">Mazungumzo ya Umma</string> <string name="public_home_section">Relay za Sanduku la Nje/Nyumbani za Umma</string> @@ -2714,10 +2694,7 @@ <string name="read_only_user">Mtumiaji wa kusoma tu</string> <string name="record_a_message_description">Bonyeza na ushikilie kurekodi ujumbe</string> <string name="relay_chat">Mazungumzo ya Relay</string> - <string name="relay_chat_explainer">Mazungumzo ya relay ni vikundi vya mazungumzo vinavyodhibitiwa na relay yao ya nyumbani. - Yanaweza kuonekana na kila mtu kwenye Nostr na mtu yeyote anaweza kushiriki. - Ni mazuri kwa jamii wazi kuhusu mada maalum. Baadhi ya vikundi hivi ni vya muda mfupi - na hivyo ujumbe wa mazungumzo huisha baada ya muda</string> + <string name="relay_chat_explainer">Mazungumzo ya relay ni vikundi vya mazungumzo vinavyodhibitiwa na relay yao ya nyumbani. Yanaweza kuonekana na kila mtu kwenye Nostr na mtu yeyote anaweza kushiriki. Ni mazuri kwa jamii wazi kuhusu mada maalum. Baadhi ya vikundi hivi ni vya muda mfupi na hivyo ujumbe wa mazungumzo huisha baada ya muda</string> <string name="relay_chat_title">Mazungumzo ya Relay</string> <string name="relay_management_tab_events">Matukio</string> <string name="relay_management_tab_kinds">Aina</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ta-rIN/strings.xml b/commonsUI/src/commonMain/composeResources/values-ta-rIN/strings.xml index 3b46dde816..106be142e3 100644 --- a/commonsUI/src/commonMain/composeResources/values-ta-rIN/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ta-rIN/strings.xml @@ -224,7 +224,7 @@ <string name="copy_user_id">பயனர் IDயை நகலெடுக்கவும்</string> <string name="unblock_user">பயனரைத் தடைநீக்கு</string> <string name="user_is_blocked_hidden">இந்த பயனர் தடுக்கப்பட்டு/முடக்கப்பட்டுள்ளார். அவர்களின் இடுகைகள் மறைக்கப்பட்டுள்ளன.</string> - <string name="npub_hex_username">npub, hex, பயனர்பெயர் </string> + <string name="npub_hex_username">npub, hex, பயனர்பெயர்</string> <string name="clear">அழி</string> <string name="app_logo">பயன்பாட்டு இலச்சினை</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex தனிப்பட்ட சாவி</string> @@ -272,17 +272,10 @@ <string name="mark_all_known_as_read">தெரிந்தவற்றைப் படித்ததாகக் குறி</string> <string name="mark_all_new_as_read">புதியனவற்றைப் படித்ததாகக் குறி</string> <string name="mark_all_as_read">அனைத்தையும் படித்ததாகக் குறி</string> - <string name="account_backup_tips2_md"> ## திறவுகோல் காப்புப்பிரதி மற்றும் பாதுகாப்பு குறிப்புகள் - \n\nஉங்கள் கணக்கு ஒரு இரகசிய திறவுகோலால் பாதுகாக்கப்படுகிறது. இந்த திறவுகோல் **nsec1** என்று தொடங்கும் நீண்ட எழுத்துத் தொடராகும். இந்த இரகசிய திறவுகோலை யாராவது பெற்றால் அவர்கள் உங்கள் அடையாளத்தை பயன்படுத்தி இடுகையிடலாம் மற்றும் மாற்றலாம். - \n\n- உங்கள் இரகசிய திறவுகோலை நீங்கள் நம்பாத எந்த வலைத்தளத்திலும் அல்லது மென்பொருளிலும் வைக்க **வேண்டாம்**. - \n- Amethyst டெவலப்பர்கள் உங்கள் இரகசிய திறவுகோலை **ஒருபோதும்** கேட்கமாட்டார்கள். - \n- கணக்கு மீட்டெடுப்புக்காக உங்கள் இரகசிய திறவுகோலை பாதுகாப்பாக காப்புப்பிரதி எடுங்கள். கடவுச்சொல் மேலாளரை பயன்படுத்த பரிந்துரைக்கிறோம். - </string> - <string name="account_backup_tips3_md"> கூடுதல் பாதுகாப்புக்காக, உங்கள் திறவுகோலை கடவுச்சொல்லால் குறியாக்கலாம். இந்த திறவுகோல் **ncryptsec1** என்று தொடங்கும் மற்றும் உங்கள் கடவுச்சொல்லின்றி பயன்படுத்த முடியாது. - \n\nகடவுச்சொல்லை மறந்தால், உங்கள் திறவுகோலை மீட்டெடுக்க முடியாது. - </string> + <string name="account_backup_tips2_md">## திறவுகோல் காப்புப்பிரதி மற்றும் பாதுகாப்பு குறிப்புகள் \n\nஉங்கள் கணக்கு ஒரு இரகசிய திறவுகோலால் பாதுகாக்கப்படுகிறது. இந்த திறவுகோல் **nsec1** என்று தொடங்கும் நீண்ட எழுத்துத் தொடராகும். இந்த இரகசிய திறவுகோலை யாராவது பெற்றால் அவர்கள் உங்கள் அடையாளத்தை பயன்படுத்தி இடுகையிடலாம் மற்றும் மாற்றலாம். \n\n- உங்கள் இரகசிய திறவுகோலை நீங்கள் நம்பாத எந்த வலைத்தளத்திலும் அல்லது மென்பொருளிலும் வைக்க **வேண்டாம்**. \n- Amethyst டெவலப்பர்கள் உங்கள் இரகசிய திறவுகோலை **ஒருபோதும்** கேட்கமாட்டார்கள். \n- கணக்கு மீட்டெடுப்புக்காக உங்கள் இரகசிய திறவுகோலை பாதுகாப்பாக காப்புப்பிரதி எடுங்கள். கடவுச்சொல் மேலாளரை பயன்படுத்த பரிந்துரைக்கிறோம்.</string> + <string name="account_backup_tips3_md">கூடுதல் பாதுகாப்புக்காக, உங்கள் திறவுகோலை கடவுச்சொல்லால் குறியாக்கலாம். இந்த திறவுகோல் **ncryptsec1** என்று தொடங்கும் மற்றும் உங்கள் கடவுச்சொல்லின்றி பயன்படுத்த முடியாது. \n\nகடவுச்சொல்லை மறந்தால், உங்கள் திறவுகோலை மீட்டெடுக்க முடியாது.</string> <string name="encrypt_and_copy_my_secret_key">என் இரகசிய விசையை மறைகுறியாக்கி நகல் எடுக்கவும்</string> - <string name="badge_award_image_for"> %1$s க்கான பேட்ஜ் விருது படம்</string> + <string name="badge_award_image_for">%1$s க்கான பேட்ஜ் விருது படம்</string> <string name="badge_award_image">"பேட்ஜ் விருது படம்</string> <string name="new_badge_award_notif">நீங்கள் ஒரு புதிய பேட்ஜ் விருதைப் பெற்றீர்கள்</string> <string name="award_granted_to">பேட்ஜ் விருது வழங்கப்பட்டது. பெறுநர்:</string> @@ -304,7 +297,7 @@ <string name="quick_action_block_dialog_btn">தடைசெய்</string> <string name="quick_action_delete_dialog_btn">அழி</string> <string name="quick_action_block">தடைசெய்</string> - <string name="quick_action_report">புகார் </string> + <string name="quick_action_report">புகார்</string> <string name="quick_action_dont_show_again_button">மீண்டும் காட்டாதே</string> <string name="report_dialog_spam">எரிதம் அல்லது மோசடிகள்</string> <string name="report_dialog_profanity">அவதூறு அல்லது வெறுக்கத்தக்க நடத்தை</string> @@ -871,7 +864,7 @@ <string name="followed_tags">பின்பற்றப்படும் சிட்டைகள்</string> <string name="discover_follows_explainer">இவை நீங்கள் மற்றவர்களுக்கு பரிந்துரைக்கும் பயனர்களின் பட்டியல்கள். பொது பயனர்கள் மட்டுமே அனுமதிக்கப்படுவர்.</string> <string name="community_approved_posts">அங்கீகரிக்கப்பட்ட குறிப்பு</string> - <string name="groups_no_descriptor">இந்த அரட்டைக் குழுவின் விளக்கமும் விதிகளும் இன்னும் சேர்க்கபடவில்லை. உரிமையாளரை அணுகி அவற்றை சேர்க்க கோரவும் </string> + <string name="groups_no_descriptor">இந்த அரட்டைக் குழுவின் விளக்கமும் விதிகளும் இன்னும் சேர்க்கபடவில்லை. உரிமையாளரை அணுகி அவற்றை சேர்க்க கோரவும்</string> <string name="community_no_descriptor">இந்த சமூகத்தின் விளக்கமும் விதிகளும் இன்னும் சேர்க்கபடவில்லை. உரிமையாளரை அணுகி அவற்றை சேர்க்க கோரவும்</string> <string name="user_preferences">பயனர் விருப்பங்கள்</string> <string name="settings_search_placeholder">அமைப்புகளை தேடு</string> @@ -965,9 +958,7 @@ <string name="push_server_none_explainer">புஷ் அறிவிப்புகளை முடக்கும்</string> <string name="push_server_uses_app_explainer">%1$s ஆப்பை பயன்படுத்துகிறது</string> <string name="push_server_install_app">புஷ் அறிவிப்பு அமைவு</string> - <string name="push_server_install_app_description"> Push அறிவிப்புகளை பெற, [Unified Push](https://unifiedpush.org/) ஆதரிக்கும் எந்த பயன்பாட்டையும் நிறுவுங்கள், எடுத்துக்காட்டாக [Ntfy](https://ntfy.sh/). - நிறுவிய பின், அமைப்புகளில் நீங்கள் பயன்படுத்த விரும்பும் பயன்பாட்டை தேர்ந்தெடுங்கள். - </string> + <string name="push_server_install_app_description">Push அறிவிப்புகளை பெற, [Unified Push](https://unifiedpush.org/) ஆதரிக்கும் எந்த பயன்பாட்டையும் நிறுவுங்கள், எடுத்துக்காட்டாக [Ntfy](https://ntfy.sh/). நிறுவிய பின், அமைப்புகளில் நீங்கள் பயன்படுத்த விரும்பும் பயன்பாட்டை தேர்ந்தெடுங்கள்.</string> <string name="thread_title">நூல்</string> <string name="send_the_seller_a_message">விற்பனையாளருக்கு ஒரு செய்தி அனுப்பவும்</string> <string name="hi_there_is_this_still_available">வணக்கம், இது இன்னும் கிடைக்கிறதா?</string> @@ -2016,15 +2007,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s இலிருந்து இன்வாய்ஸை பெற முடியவில்லை: %2$s</string> <string name="could_not_open_the_compressed_file">சுருக்கப்பட்ட கோப்பை திறக்க முடியவில்லை</string> <string name="couldnt_find_nwc_wallets">வாலட் கிடைக்கவில்லை</string> - <string name="couldnt_find_nwc_wallets_description">Nostr Wallet Connect (NWC)-ஐ ஆதரிக்கும் எந்த பணப்பை பயன்பாடுகளையும் Amethyst கண்டுபிடிக்கவில்லை. -\n\nநீங்கள் செய்யக்கூடியவை: -\n\t1. NWC ஆதரவை சரிபாருங்கள்: உங்கள் விருப்பமான பணப்பை பயன்பாடு Nostr Wallet Connect-உடன் இணக்கமானதா என இரட்டிப்பு சரிபாருங்கள். -\n\t2. இணைப்பை உருவாக்குங்கள்: உங்கள் பணப்பை பயன்பாட்டிற்கு சென்று புதிய NWC இணைப்பை உருவாக்குங்கள். -\n\t3. Amethyst-உடன் இணைக்குங்கள்: உங்கள் பணப்பை பொதுவாக மூன்று விருப்பங்களை வழங்கும்: -\n\t\t3.1 தானியங்கி இணைப்பு: Amethyst-ஐ தானாக திறந்து இணைக்க ஒரு பொத்தான். அவ்வாறிருந்தால், அந்த பொத்தானை அழுத்தி Amethyst-ஐ திறந்து புதிய திரையில் சேமி அழுத்துங்கள். -\n\t\t3.2 கைமுறை இணைப்பு: நீங்கள் நகலெடுக்கக்கூடிய Connection URI, இந்த திரையில் ஒட்டு ஐகானை அழுத்தி நேரடியாக உள்ளிடலாம். -\n\t\t3.3 QR குறியீடு: பணப்பை ஒரு QR குறியீட்டை உருவாக்கும், இந்த திரையில் QR குறியீடு பொத்தானிலிருந்து படிக்கலாம். - </string> + <string name="couldnt_find_nwc_wallets_description">Nostr Wallet Connect (NWC)-ஐ ஆதரிக்கும் எந்த பணப்பை பயன்பாடுகளையும் Amethyst கண்டுபிடிக்கவில்லை. \n\nநீங்கள் செய்யக்கூடியவை: \n\t1. NWC ஆதரவை சரிபாருங்கள்: உங்கள் விருப்பமான பணப்பை பயன்பாடு Nostr Wallet Connect-உடன் இணக்கமானதா என இரட்டிப்பு சரிபாருங்கள். \n\t2. இணைப்பை உருவாக்குங்கள்: உங்கள் பணப்பை பயன்பாட்டிற்கு சென்று புதிய NWC இணைப்பை உருவாக்குங்கள். \n\t3. Amethyst-உடன் இணைக்குங்கள்: உங்கள் பணப்பை பொதுவாக மூன்று விருப்பங்களை வழங்கும்: \n\t\t3.1 தானியங்கி இணைப்பு: Amethyst-ஐ தானாக திறந்து இணைக்க ஒரு பொத்தான். அவ்வாறிருந்தால், அந்த பொத்தானை அழுத்தி Amethyst-ஐ திறந்து புதிய திரையில் சேமி அழுத்துங்கள். \n\t\t3.2 கைமுறை இணைப்பு: நீங்கள் நகலெடுக்கக்கூடிய Connection URI, இந்த திரையில் ஒட்டு ஐகானை அழுத்தி நேரடியாக உள்ளிடலாம். \n\t\t3.3 QR குறியீடு: பணப்பை ஒரு QR குறியீட்டை உருவாக்கும், இந்த திரையில் QR குறியீடு பொத்தானிலிருந்து படிக்கலாம்.</string> <string name="create">உருவாக்கு</string> <string name="d">நா</string> <string name="danger_zone">ஆபத்து மண்டலம்</string> @@ -2416,7 +2399,7 @@ <string name="metadata_strip_failed_upload_cancelled">மீடியாவிலிருந்து தனிப்பட்ட மெட்டாடேட்டாவை நீக்கத் தோல்வியடைந்தது. பதிவேற்றம் ரத்துசெய்யப்பட்டது.</string> <string name="migrate_bookmarks_success">புக்மார்க்குகள் வெற்றிகரமாக இடம்பெயர்க்கப்பட்டன</string> <string name="missing_lud16">Lightning அமைப்பு இல்லை</string> - <string name="more_options">மேலும் </string> + <string name="more_options">மேலும்</string> <string name="move_bookmark_to_private_label">தனிப்பட்டதிற்கு நகர்த்து</string> <string name="move_bookmark_to_public_label">பொதுவிற்கு நகர்த்து</string> <string name="music_playlist_cover_upload_cta">அட்டை படத்தை பதிவேற்று</string> @@ -2648,7 +2631,7 @@ <item quantity="one">இந்த இடுகையில் %1$d hashtag-ஐ விட அதிகம் உள்ளது</item> <item quantity="other">இந்த இடுகையில் %1$d hashtags-ஐ விட அதிகம் உள்ளது</item> </plurals> - <string name="preview_card_image_for"> %1$s க்கான முன்னோட்ட அட்டைப் படம்</string> + <string name="preview_card_image_for">%1$s க்கான முன்னோட்ட அட்டைப் படம்</string> <string name="privacy_options">தனியுரிமை விருப்பங்கள்</string> <string name="privacy_policy">தனியுரிமைக் கொள்கை</string> <string name="private_conversation_notification">தனிப்பட்ட செய்தியை மறைக்குறியாக்க இயலவில்லை \n \n %1$s மற்றும் %2$s க்கு இடையே தனிப்பட்ட/ குறியாக்கப்பட்ட உரையாடலில் நீங்கள் மேற்கோள் காட்டப்பட்டீர்கள்.</string> @@ -2673,11 +2656,8 @@ <string name="propose_an_edit">திருத்தத்தை முன்மொழிக</string> <string name="proxy_section_explainer">filter.nostr.wine போன்ற ஒருங்கிணைப்பு relays, பயன்பாடு உங்கள் ஊட்டங்களை பதிவிறக்க பயன்படுத்த வேண்டும். இது அவுட்பாக்ஸ் மாதிரியை மாற்றுகிறது, பயன்பாட்டை உங்கள் பட்டியல்களில் உள்ள relays மட்டுமே இணைக்கும்.</string> <string name="public_chat">பொது அரட்டை</string> - <string name="public_chat_explainer">பொது அரட்டைகள் Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் - அவற்றில் பங்கேற்கலாம். அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. - அதன் relays-ல் இடுகைகளை நீக்குவதன் மூலம் மிதவாண்மையை கட்டுப்படுத்தலாம்</string> - <string name="public_chat_relays_explainer">இந்த குழுவை ஹோஸ்ட் செய்யும் 1–3 relays-ஐ உள்ளிடவும். - Nostr கிளையன்கள் செய்திகளை எங்கிருந்து பதிவிறக்கம் செய்வது மற்றும் உங்கள் செய்திகளை எங்கே அனுப்புவது என்பதை அறிய இந்த அமைப்பை பயன்படுத்துகின்றன.</string> + <string name="public_chat_explainer">பொது அரட்டைகள் Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் அவற்றில் பங்கேற்கலாம். அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. அதன் relays-ல் இடுகைகளை நீக்குவதன் மூலம் மிதவாண்மையை கட்டுப்படுத்தலாம்</string> + <string name="public_chat_relays_explainer">இந்த குழுவை ஹோஸ்ட் செய்யும் 1–3 relays-ஐ உள்ளிடவும். Nostr கிளையன்கள் செய்திகளை எங்கிருந்து பதிவிறக்கம் செய்வது மற்றும் உங்கள் செய்திகளை எங்கே அனுப்புவது என்பதை அறிய இந்த அமைப்பை பயன்படுத்துகின்றன.</string> <string name="public_chat_relays_title">Relay கள்</string> <string name="public_chat_title">பொது அரட்டை மெட்டாடேட்டா</string> <string name="public_chats">பொது அரட்டைகள்</string> @@ -2702,10 +2682,7 @@ <string name="read_only_user">படிக்க மட்டும் பயனர்</string> <string name="record_a_message_description">செய்தி பதிவு செய்ய கிளிக் செய்து பிடிக்கவும்</string> <string name="relay_chat">Relay அரட்டை</string> - <string name="relay_chat_explainer">Relay அரட்டைகள் என்பவை அவற்றின் முகப்பு relay-ஆல் கட்டுப்படுத்தப்படும் அரட்டை குழுக்கள். - அவை Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் அவற்றில் பங்கேற்கலாம். - அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. இந்த குழுக்களில் சில தற்காலிகமானவை - எனவே அரட்டை செய்திகள் காலப்போக்கில் மறைந்துவிடும்</string> + <string name="relay_chat_explainer">Relay அரட்டைகள் என்பவை அவற்றின் முகப்பு relay-ஆல் கட்டுப்படுத்தப்படும் அரட்டை குழுக்கள். அவை Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் அவற்றில் பங்கேற்கலாம். அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. இந்த குழுக்களில் சில தற்காலிகமானவை எனவே அரட்டை செய்திகள் காலப்போக்கில் மறைந்துவிடும்</string> <string name="relay_chat_title">Relay அரட்டைகள்</string> <string name="relay_management_tab_events">நிகழ்வுகள்</string> <string name="relay_management_tab_kinds">வகைகள்</string> diff --git a/commonsUI/src/commonMain/composeResources/values-ta/strings.xml b/commonsUI/src/commonMain/composeResources/values-ta/strings.xml index 18a9e71315..210f73485f 100644 --- a/commonsUI/src/commonMain/composeResources/values-ta/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-ta/strings.xml @@ -211,7 +211,7 @@ <string name="copy_user_id">பயனர் IDயை நகலெடுக்கவும்</string> <string name="unblock_user">பயனரைத் தடைநீக்கு</string> <string name="user_is_blocked_hidden">இந்த பயனர் தடுக்கப்பட்டு/முடக்கப்பட்டுள்ளார். அவர்களின் இடுகைகள் மறைக்கப்பட்டுள்ளன.</string> - <string name="npub_hex_username">npub, hex, பயனர்பெயர் </string> + <string name="npub_hex_username">npub, hex, பயனர்பெயர்</string> <string name="clear">அழி</string> <string name="app_logo">பயன்பாட்டு இலச்சினை</string> <string name="nsec_npub_hex_private_key">nsec / npub / hex தனிப்பட்ட சாவி</string> @@ -259,19 +259,10 @@ <string name="mark_all_known_as_read">தெரிந்தவற்றைப் படித்ததாகக் குறி</string> <string name="mark_all_new_as_read">புதியனவற்றைப் படித்ததாகக் குறி</string> <string name="mark_all_as_read">அனைத்தையும் படித்ததாகக் குறி</string> - <string name="account_backup_tips2_md"> - ## திறவுகோல் காப்புப்பிரதி மற்றும் பாதுகாப்பு குறிப்புகள் - \n\nஉங்கள் கணக்கு ஒரு இரகசிய திறவுகோலால் பாதுகாக்கப்படுகிறது. இந்த திறவுகோல் **nsec1** என்று தொடங்கும் நீண்ட எழுத்துத் தொடராகும். இந்த இரகசிய திறவுகோலை யாராவது பெற்றால் அவர்கள் உங்கள் அடையாளத்தை பயன்படுத்தி இடுகையிடலாம் மற்றும் மாற்றலாம். - \n\n- உங்கள் இரகசிய திறவுகோலை நீங்கள் நம்பாத எந்த வலைத்தளத்திலும் அல்லது மென்பொருளிலும் வைக்க **வேண்டாம்**. - \n- Amethyst டெவலப்பர்கள் உங்கள் இரகசிய திறவுகோலை **ஒருபோதும்** கேட்கமாட்டார்கள். - \n- கணக்கு மீட்டெடுப்புக்காக உங்கள் இரகசிய திறவுகோலை பாதுகாப்பாக காப்புப்பிரதி எடுங்கள். கடவுச்சொல் மேலாளரை பயன்படுத்த பரிந்துரைக்கிறோம். - </string> - <string name="account_backup_tips3_md"> - கூடுதல் பாதுகாப்புக்காக, உங்கள் திறவுகோலை கடவுச்சொல்லால் குறியாக்கலாம். இந்த திறவுகோல் **ncryptsec1** என்று தொடங்கும் மற்றும் உங்கள் கடவுச்சொல்லின்றி பயன்படுத்த முடியாது. - \n\nகடவுச்சொல்லை மறந்தால், உங்கள் திறவுகோலை மீட்டெடுக்க முடியாது. - </string> + <string name="account_backup_tips2_md">## திறவுகோல் காப்புப்பிரதி மற்றும் பாதுகாப்பு குறிப்புகள் \n\nஉங்கள் கணக்கு ஒரு இரகசிய திறவுகோலால் பாதுகாக்கப்படுகிறது. இந்த திறவுகோல் **nsec1** என்று தொடங்கும் நீண்ட எழுத்துத் தொடராகும். இந்த இரகசிய திறவுகோலை யாராவது பெற்றால் அவர்கள் உங்கள் அடையாளத்தை பயன்படுத்தி இடுகையிடலாம் மற்றும் மாற்றலாம். \n\n- உங்கள் இரகசிய திறவுகோலை நீங்கள் நம்பாத எந்த வலைத்தளத்திலும் அல்லது மென்பொருளிலும் வைக்க **வேண்டாம்**. \n- Amethyst டெவலப்பர்கள் உங்கள் இரகசிய திறவுகோலை **ஒருபோதும்** கேட்கமாட்டார்கள். \n- கணக்கு மீட்டெடுப்புக்காக உங்கள் இரகசிய திறவுகோலை பாதுகாப்பாக காப்புப்பிரதி எடுங்கள். கடவுச்சொல் மேலாளரை பயன்படுத்த பரிந்துரைக்கிறோம்.</string> + <string name="account_backup_tips3_md">கூடுதல் பாதுகாப்புக்காக, உங்கள் திறவுகோலை கடவுச்சொல்லால் குறியாக்கலாம். இந்த திறவுகோல் **ncryptsec1** என்று தொடங்கும் மற்றும் உங்கள் கடவுச்சொல்லின்றி பயன்படுத்த முடியாது. \n\nகடவுச்சொல்லை மறந்தால், உங்கள் திறவுகோலை மீட்டெடுக்க முடியாது.</string> <string name="encrypt_and_copy_my_secret_key">என் இரகசிய விசையை மறைகுறியாக்கி நகல் எடுக்கவும்</string> - <string name="badge_award_image_for"> %1$s க்கான பேட்ஜ் விருது படம்</string> + <string name="badge_award_image_for">%1$s க்கான பேட்ஜ் விருது படம்</string> <string name="badge_award_image">"பேட்ஜ் விருது படம்</string> <string name="new_badge_award_notif">நீங்கள் ஒரு புதிய பேட்ஜ் விருதைப் பெற்றீர்கள்</string> <string name="award_granted_to">பேட்ஜ் விருது வழங்கப்பட்டது. பெறுநர்:</string> @@ -293,7 +284,7 @@ <string name="quick_action_block_dialog_btn">தடைசெய்</string> <string name="quick_action_delete_dialog_btn">அழி</string> <string name="quick_action_block">தடைசெய்</string> - <string name="quick_action_report">புகார் </string> + <string name="quick_action_report">புகார்</string> <string name="quick_action_dont_show_again_button">மீண்டும் காட்டாதே</string> <string name="report_dialog_spam">எரிதம் அல்லது மோசடிகள்</string> <string name="report_dialog_profanity">அவதூறு அல்லது வெறுக்கத்தக்க நடத்தை</string> @@ -867,7 +858,7 @@ <string name="followed_tags">பின்பற்றப்படும் சிட்டைகள்</string> <string name="discover_follows_explainer">இவை நீங்கள் மற்றவர்களுக்கு பரிந்துரைக்கும் பயனர்களின் பட்டியல்கள். பொது பயனர்கள் மட்டுமே அனுமதிக்கப்படுவர்.</string> <string name="community_approved_posts">அங்கீகரிக்கப்பட்ட குறிப்பு</string> - <string name="groups_no_descriptor">இந்த அரட்டைக் குழுவின் விளக்கமும் விதிகளும் இன்னும் சேர்க்கபடவில்லை. உரிமையாளரை அணுகி அவற்றை சேர்க்க கோரவும் </string> + <string name="groups_no_descriptor">இந்த அரட்டைக் குழுவின் விளக்கமும் விதிகளும் இன்னும் சேர்க்கபடவில்லை. உரிமையாளரை அணுகி அவற்றை சேர்க்க கோரவும்</string> <string name="community_no_descriptor">இந்த சமூகத்தின் விளக்கமும் விதிகளும் இன்னும் சேர்க்கபடவில்லை. உரிமையாளரை அணுகி அவற்றை சேர்க்க கோரவும்</string> <string name="user_preferences">பயனர் விருப்பங்கள்</string> <string name="settings_search_placeholder">அமைப்புகளை தேடு</string> @@ -962,10 +953,7 @@ <string name="push_server_none_explainer">புஷ் அறிவிப்புகளை முடக்கும்</string> <string name="push_server_uses_app_explainer">%1$s ஆப்பை பயன்படுத்துகிறது</string> <string name="push_server_install_app">புஷ் அறிவிப்பு அமைவு</string> - <string name="push_server_install_app_description"> - Push அறிவிப்புகளை பெற, [Unified Push](https://unifiedpush.org/) ஆதரிக்கும் எந்த பயன்பாட்டையும் நிறுவுங்கள், எடுத்துக்காட்டாக [Ntfy](https://ntfy.sh/). - நிறுவிய பின், அமைப்புகளில் நீங்கள் பயன்படுத்த விரும்பும் பயன்பாட்டை தேர்ந்தெடுங்கள். - </string> + <string name="push_server_install_app_description">Push அறிவிப்புகளை பெற, [Unified Push](https://unifiedpush.org/) ஆதரிக்கும் எந்த பயன்பாட்டையும் நிறுவுங்கள், எடுத்துக்காட்டாக [Ntfy](https://ntfy.sh/). நிறுவிய பின், அமைப்புகளில் நீங்கள் பயன்படுத்த விரும்பும் பயன்பாட்டை தேர்ந்தெடுங்கள்.</string> <string name="thread_title">நூல்</string> <string name="send_the_seller_a_message">விற்பனையாளருக்கு ஒரு செய்தி அனுப்பவும்</string> <string name="hi_there_is_this_still_available">வணக்கம், இது இன்னும் கிடைக்கிறதா?</string> @@ -2058,15 +2046,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s இலிருந்து இன்வாய்ஸை பெற முடியவில்லை: %2$s</string> <string name="could_not_open_the_compressed_file">சுருக்கப்பட்ட கோப்பை திறக்க முடியவில்லை</string> <string name="couldnt_find_nwc_wallets">வாலட் கிடைக்கவில்லை</string> - <string name="couldnt_find_nwc_wallets_description">Nostr Wallet Connect (NWC)-ஐ ஆதரிக்கும் எந்த பணப்பை பயன்பாடுகளையும் Amethyst கண்டுபிடிக்கவில்லை. -\n\nநீங்கள் செய்யக்கூடியவை: -\n\t1. NWC ஆதரவை சரிபாருங்கள்: உங்கள் விருப்பமான பணப்பை பயன்பாடு Nostr Wallet Connect-உடன் இணக்கமானதா என இரட்டிப்பு சரிபாருங்கள். -\n\t2. இணைப்பை உருவாக்குங்கள்: உங்கள் பணப்பை பயன்பாட்டிற்கு சென்று புதிய NWC இணைப்பை உருவாக்குங்கள். -\n\t3. Amethyst-உடன் இணைக்குங்கள்: உங்கள் பணப்பை பொதுவாக மூன்று விருப்பங்களை வழங்கும்: -\n\t\t3.1 தானியங்கி இணைப்பு: Amethyst-ஐ தானாக திறந்து இணைக்க ஒரு பொத்தான். அவ்வாறிருந்தால், அந்த பொத்தானை அழுத்தி Amethyst-ஐ திறந்து புதிய திரையில் சேமி அழுத்துங்கள். -\n\t\t3.2 கைமுறை இணைப்பு: நீங்கள் நகலெடுக்கக்கூடிய Connection URI, இந்த திரையில் ஒட்டு ஐகானை அழுத்தி நேரடியாக உள்ளிடலாம். -\n\t\t3.3 QR குறியீடு: பணப்பை ஒரு QR குறியீட்டை உருவாக்கும், இந்த திரையில் QR குறியீடு பொத்தானிலிருந்து படிக்கலாம். - </string> + <string name="couldnt_find_nwc_wallets_description">Nostr Wallet Connect (NWC)-ஐ ஆதரிக்கும் எந்த பணப்பை பயன்பாடுகளையும் Amethyst கண்டுபிடிக்கவில்லை. \n\nநீங்கள் செய்யக்கூடியவை: \n\t1. NWC ஆதரவை சரிபாருங்கள்: உங்கள் விருப்பமான பணப்பை பயன்பாடு Nostr Wallet Connect-உடன் இணக்கமானதா என இரட்டிப்பு சரிபாருங்கள். \n\t2. இணைப்பை உருவாக்குங்கள்: உங்கள் பணப்பை பயன்பாட்டிற்கு சென்று புதிய NWC இணைப்பை உருவாக்குங்கள். \n\t3. Amethyst-உடன் இணைக்குங்கள்: உங்கள் பணப்பை பொதுவாக மூன்று விருப்பங்களை வழங்கும்: \n\t\t3.1 தானியங்கி இணைப்பு: Amethyst-ஐ தானாக திறந்து இணைக்க ஒரு பொத்தான். அவ்வாறிருந்தால், அந்த பொத்தானை அழுத்தி Amethyst-ஐ திறந்து புதிய திரையில் சேமி அழுத்துங்கள். \n\t\t3.2 கைமுறை இணைப்பு: நீங்கள் நகலெடுக்கக்கூடிய Connection URI, இந்த திரையில் ஒட்டு ஐகானை அழுத்தி நேரடியாக உள்ளிடலாம். \n\t\t3.3 QR குறியீடு: பணப்பை ஒரு QR குறியீட்டை உருவாக்கும், இந்த திரையில் QR குறியீடு பொத்தானிலிருந்து படிக்கலாம்.</string> <string name="create">உருவாக்கு</string> <string name="d">நா</string> <string name="danger_zone">ஆபத்து மண்டலம்</string> @@ -2486,7 +2466,7 @@ <string name="metadata_strip_failed_upload_cancelled">மீடியாவிலிருந்து தனிப்பட்ட மெட்டாடேட்டாவை நீக்கத் தோல்வியடைந்தது. பதிவேற்றம் ரத்துசெய்யப்பட்டது.</string> <string name="migrate_bookmarks_success">புக்மார்க்குகள் வெற்றிகரமாக இடம்பெயர்க்கப்பட்டன</string> <string name="missing_lud16">Lightning அமைப்பு இல்லை</string> - <string name="more_options">மேலும் </string> + <string name="more_options">மேலும்</string> <string name="move_bookmark_to_private_label">தனிப்பட்டதிற்கு நகர்த்து</string> <string name="move_bookmark_to_public_label">பொதுவிற்கு நகர்த்து</string> <string name="music_playlist_cover_upload_cta">அட்டை படத்தை பதிவேற்று</string> @@ -2728,7 +2708,7 @@ <item quantity="one">இந்த இடுகையில் %1$d hashtag-ஐ விட அதிகம் உள்ளது</item> <item quantity="other">இந்த இடுகையில் %1$d hashtags-ஐ விட அதிகம் உள்ளது</item> </plurals> - <string name="preview_card_image_for"> %1$s க்கான முன்னோட்ட அட்டைப் படம்</string> + <string name="preview_card_image_for">%1$s க்கான முன்னோட்ட அட்டைப் படம்</string> <string name="privacy_options">தனியுரிமை விருப்பங்கள்</string> <string name="privacy_policy">தனியுரிமைக் கொள்கை</string> <string name="private_conversation_notification">தனிப்பட்ட செய்தியை மறைக்குறியாக்க இயலவில்லை \n \n %1$s மற்றும் %2$s க்கு இடையே தனிப்பட்ட/ குறியாக்கப்பட்ட உரையாடலில் நீங்கள் மேற்கோள் காட்டப்பட்டீர்கள்.</string> @@ -2754,11 +2734,8 @@ <string name="proxy_section">Proxy Relays</string> <string name="proxy_section_explainer">filter.nostr.wine போன்ற ஒருங்கிணைப்பு relays, பயன்பாடு உங்கள் ஊட்டங்களை பதிவிறக்க பயன்படுத்த வேண்டும். இது அவுட்பாக்ஸ் மாதிரியை மாற்றுகிறது, பயன்பாட்டை உங்கள் பட்டியல்களில் உள்ள relays மட்டுமே இணைக்கும்.</string> <string name="public_chat">பொது அரட்டை</string> - <string name="public_chat_explainer">பொது அரட்டைகள் Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் - அவற்றில் பங்கேற்கலாம். அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. - அதன் relays-ல் இடுகைகளை நீக்குவதன் மூலம் மிதவாண்மையை கட்டுப்படுத்தலாம்</string> - <string name="public_chat_relays_explainer">இந்த குழுவை ஹோஸ்ட் செய்யும் 1–3 relays-ஐ உள்ளிடவும். - Nostr கிளையன்கள் செய்திகளை எங்கிருந்து பதிவிறக்கம் செய்வது மற்றும் உங்கள் செய்திகளை எங்கே அனுப்புவது என்பதை அறிய இந்த அமைப்பை பயன்படுத்துகின்றன.</string> + <string name="public_chat_explainer">பொது அரட்டைகள் Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் அவற்றில் பங்கேற்கலாம். அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. அதன் relays-ல் இடுகைகளை நீக்குவதன் மூலம் மிதவாண்மையை கட்டுப்படுத்தலாம்</string> + <string name="public_chat_relays_explainer">இந்த குழுவை ஹோஸ்ட் செய்யும் 1–3 relays-ஐ உள்ளிடவும். Nostr கிளையன்கள் செய்திகளை எங்கிருந்து பதிவிறக்கம் செய்வது மற்றும் உங்கள் செய்திகளை எங்கே அனுப்புவது என்பதை அறிய இந்த அமைப்பை பயன்படுத்துகின்றன.</string> <string name="public_chat_relays_title">Relay கள்</string> <string name="public_chat_title">பொது அரட்டை மெட்டாடேட்டா</string> <string name="public_chats">பொது அரட்டைகள்</string> @@ -2783,10 +2760,7 @@ <string name="read_only_user">படிக்க மட்டும் பயனர்</string> <string name="record_a_message_description">செய்தி பதிவு செய்ய கிளிக் செய்து பிடிக்கவும்</string> <string name="relay_chat">Relay அரட்டை</string> - <string name="relay_chat_explainer">Relay அரட்டைகள் என்பவை அவற்றின் முகப்பு relay-ஆல் கட்டுப்படுத்தப்படும் அரட்டை குழுக்கள். - அவை Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் அவற்றில் பங்கேற்கலாம். - அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. இந்த குழுக்களில் சில தற்காலிகமானவை - எனவே அரட்டை செய்திகள் காலப்போக்கில் மறைந்துவிடும்</string> + <string name="relay_chat_explainer">Relay அரட்டைகள் என்பவை அவற்றின் முகப்பு relay-ஆல் கட்டுப்படுத்தப்படும் அரட்டை குழுக்கள். அவை Nostr-ல் அனைவருக்கும் தெரியும் மற்றும் யாரும் அவற்றில் பங்கேற்கலாம். அவை குறிப்பிட்ட தலைப்புகளை சுற்றிய திறந்த சமூகங்களுக்கு மிகவும் ஏற்றவை. இந்த குழுக்களில் சில தற்காலிகமானவை எனவே அரட்டை செய்திகள் காலப்போக்கில் மறைந்துவிடும்</string> <string name="relay_chat_title">Relay அரட்டைகள்</string> <string name="relay_management_tab_events">நிகழ்வுகள்</string> <string name="relay_management_tab_ips">IPs</string> diff --git a/commonsUI/src/commonMain/composeResources/values-th-rTH/strings.xml b/commonsUI/src/commonMain/composeResources/values-th-rTH/strings.xml index 79bd7785d6..ae6a8e1778 100644 --- a/commonsUI/src/commonMain/composeResources/values-th-rTH/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-th-rTH/strings.xml @@ -158,7 +158,7 @@ <string name="send_payment_min_onchain">การ zap แบบ on-chain ต้องใช้อย่างน้อย %1$s sats</string> <string name="send_payment_cashu_insufficient">ยอดคงเหลือใน mint ที่ผู้รับยอมรับไม่เพียงพอ เติมเงินในกระเป๋า Cashu ก่อน</string> <string name="send_payment_onchain_fee">ค่าธรรมเนียมเครือข่าย</string> - <string name="lightning_tips">ส่งทิปให้เบา ๆ </string> + <string name="lightning_tips">ส่งทิปให้เบา ๆ</string> <string name="note_to_receiver">โน้ตถึงผู้รับ</string> <string name="thank_you_so_much">ขอบคุณมาก!</string> <string name="amount_in_sats">จำนวนในหน่วย sat</string> @@ -269,14 +269,8 @@ <string name="mark_all_known_as_read">ทำเครื่องหมายอ่านแล้วในแชทที่รู้จักทั้งหมด</string> <string name="mark_all_new_as_read">ทำเครื่องหมายว่าอ่านแล้วทั้งหมดสำหรับข้อความใหม่</string> <string name="mark_all_as_read">ทพเครื่องหมายว่าอ่านแล้วทั้งหมด</string> - <string name="account_backup_tips2_md"> ## เคล็ดลับการสำรองข้อมูลและความปลอดภัยที่สำคัญ - \n\nบัญชีของคุณได้รับการรักษาความปลอดภัยด้วยคีย์ลับ คีย์เป็นรหัสชุดตัวอักษรยาวขึ้นต้นด้วย **nsec1** ใครก็ตามที่สามารถเข้าถึงรหัสชุดนี้ได้ จะสามารถโพสต์และเปลี่ยนแปลงข้อมูลประจำตัวของคุณได้ - - \n\n- **ห้าม** ใส่รหัสชุดนี้ในเว็บไซต์หรือซอฟต์แวร์ที่คุณไม่ไว้ใจ - \n- ทีมพัฒนา Amethyst **จะไม่มีวัน** ขอรหัสชุดนี้ของคุณ - \n- **ควร** สำรองข้อมูลรหัสชุดนี้ไว้เพื่อกู้คืนบัญชีของคุณ เราแนะนำให้ใช้โปรแกรมจัดการรหัสผ่าน</string> - <string name="account_backup_tips3_md"> สำหรับการรักษาความปลอดภัยเพิ่มเติม คุณสามารถเข้ารหัสคีย์ของคุณด้วยรหัสผ่าน คีย์นี้ขึ้นต้นด้วย **ncryptsec1** และไม่สามารถใช้งานได้หากไม่มีรหัสผ่านของคุณ - \n\n**แต่** หากคุณสูญหายรหัสผ่าน คุณจะไม่สามารถกู้คืนคีย์ของคุณได้ </string> + <string name="account_backup_tips2_md">## เคล็ดลับการสำรองข้อมูลและความปลอดภัยที่สำคัญ \n\nบัญชีของคุณได้รับการรักษาความปลอดภัยด้วยคีย์ลับ คีย์เป็นรหัสชุดตัวอักษรยาวขึ้นต้นด้วย **nsec1** ใครก็ตามที่สามารถเข้าถึงรหัสชุดนี้ได้ จะสามารถโพสต์และเปลี่ยนแปลงข้อมูลประจำตัวของคุณได้ \n\n- **ห้าม** ใส่รหัสชุดนี้ในเว็บไซต์หรือซอฟต์แวร์ที่คุณไม่ไว้ใจ \n- ทีมพัฒนา Amethyst **จะไม่มีวัน** ขอรหัสชุดนี้ของคุณ \n- **ควร** สำรองข้อมูลรหัสชุดนี้ไว้เพื่อกู้คืนบัญชีของคุณ เราแนะนำให้ใช้โปรแกรมจัดการรหัสผ่าน</string> + <string name="account_backup_tips3_md">สำหรับการรักษาความปลอดภัยเพิ่มเติม คุณสามารถเข้ารหัสคีย์ของคุณด้วยรหัสผ่าน คีย์นี้ขึ้นต้นด้วย **ncryptsec1** และไม่สามารถใช้งานได้หากไม่มีรหัสผ่านของคุณ \n\n**แต่** หากคุณสูญหายรหัสผ่าน คุณจะไม่สามารถกู้คืนคีย์ของคุณได้</string> <string name="encrypt_and_copy_my_secret_key">เข้ารหัสและคัดลอกคีย์ความปลอดภัยของฉัน</string> <string name="badge_award_image_for">ภาพเหรียญตราสําหรับ %1$s</string> <string name="badge_award_image">"รูปภาพรางวัลป้าย</string> @@ -1831,7 +1825,7 @@ <string name="back">ย้อนกลับ</string> <string name="backup_keys">สำรองข้อมูลรหัสลับ</string> <string name="badges">แบดจ์</string> - <string name="biometric_authentication_failed"> เกิดข้อผิดพลาดในการตรวจสอบ</string> + <string name="biometric_authentication_failed">เกิดข้อผิดพลาดในการตรวจสอบ</string> <string name="biometric_authentication_failed_explainer">เกิดข้อผิดพลาดจากการยืนยันตนด้วยชีวภาพ</string> <string name="biometric_authentication_failed_explainer_with_error">เกิดข้อผิดพลาดจากการยืนยันตนด้วยชีวภาพ: Error: %1$s</string> <string name="block_only">บล๊อก</string> @@ -1894,7 +1888,7 @@ <string name="cashu">โทเคน Cashu</string> <string name="cashu_checking_mint">กำลังตรวจสอบ mint…</string> <string name="cashu_failed_redemption">ไม่สามารถใช้งาน Cashu</string> - <string name="cashu_failed_redemption_explainer_error_msg">ผู้ให้บริการ Mint เกิดข้อผิดพลาด : %1$s </string> + <string name="cashu_failed_redemption_explainer_error_msg">ผู้ให้บริการ Mint เกิดข้อผิดพลาด : %1$s</string> <string name="cashu_history_incoming">รับแล้ว</string> <string name="cashu_history_outgoing">ส่งแล้ว</string> <string name="cashu_mint_matches_header">Mints ที่ตรงกัน</string> @@ -1986,15 +1980,7 @@ <string name="could_not_fetch_invoice_from_details">ไม่สามารถดึงใบแจ้งหนี้จาก %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">ไม่สามารถเปิดดูข้อมูลที่ถูกบีบอัดได้</string> <string name="couldnt_find_nwc_wallets">ไม่พบกระเป๋าเงิน</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst ไม่พบแอปกระเป๋าเงินที่รองรับ Nostr Wallet Connect (NWC) -\n\nสิ่งที่คุณทำได้: -\n\t1. ตรวจสอบการรองรับ NWC: ตรวจสอบอีกครั้งว่าแอปกระเป๋าเงินที่คุณต้องการใช้รองรับ Nostr Wallet Connect หรือไม่ -\n\t2. สร้างการเชื่อมต่อ: ไปที่แอปกระเป๋าเงินของคุณและสร้างการเชื่อมต่อ NWC ใหม่ -\n\t3. เชื่อมกับ Amethyst: กระเป๋าเงินของคุณมักจะให้ตัวเลือกสามแบบ: -\n\t\t3.1 ลิงก์อัตโนมัติ: ปุ่มเพื่อเปิดและเชื่อมต่อกับ Amethyst โดยอัตโนมัติ หากมี ให้กดปุ่มนั้น เปิด Amethyst และกดบันทึกที่หน้าจอใหม่ -\n\t\t3.2 ลิงก์ด้วยตนเอง: URI การเชื่อมต่อที่คุณสามารถคัดลอกและกดไอคอนวางบนหน้าจอนี้เพื่อป้อนโดยตรง -\n\t\t3.3 QR Code: กระเป๋าเงินสร้าง QR Code ที่คุณสามารถอ่านได้จากปุ่ม QR code ในหน้าจอนี้ - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst ไม่พบแอปกระเป๋าเงินที่รองรับ Nostr Wallet Connect (NWC) \n\nสิ่งที่คุณทำได้: \n\t1. ตรวจสอบการรองรับ NWC: ตรวจสอบอีกครั้งว่าแอปกระเป๋าเงินที่คุณต้องการใช้รองรับ Nostr Wallet Connect หรือไม่ \n\t2. สร้างการเชื่อมต่อ: ไปที่แอปกระเป๋าเงินของคุณและสร้างการเชื่อมต่อ NWC ใหม่ \n\t3. เชื่อมกับ Amethyst: กระเป๋าเงินของคุณมักจะให้ตัวเลือกสามแบบ: \n\t\t3.1 ลิงก์อัตโนมัติ: ปุ่มเพื่อเปิดและเชื่อมต่อกับ Amethyst โดยอัตโนมัติ หากมี ให้กดปุ่มนั้น เปิด Amethyst และกดบันทึกที่หน้าจอใหม่ \n\t\t3.2 ลิงก์ด้วยตนเอง: URI การเชื่อมต่อที่คุณสามารถคัดลอกและกดไอคอนวางบนหน้าจอนี้เพื่อป้อนโดยตรง \n\t\t3.3 QR Code: กระเป๋าเงินสร้าง QR Code ที่คุณสามารถอ่านได้จากปุ่ม QR code ในหน้าจอนี้</string> <string name="create">สร้าง</string> <string name="d">วัน</string> <string name="danger_zone">เขตอันตราย</string> diff --git a/commonsUI/src/commonMain/composeResources/values-th/strings.xml b/commonsUI/src/commonMain/composeResources/values-th/strings.xml index 60a0ddb5c5..a4d606f00b 100644 --- a/commonsUI/src/commonMain/composeResources/values-th/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-th/strings.xml @@ -144,7 +144,7 @@ <string name="send_payment_min_onchain">การ zap แบบ on-chain ต้องใช้อย่างน้อย %1$s sats</string> <string name="send_payment_cashu_insufficient">ยอดคงเหลือใน mint ที่ผู้รับยอมรับไม่เพียงพอ เติมเงินในกระเป๋า Cashu ก่อน</string> <string name="send_payment_onchain_fee">ค่าธรรมเนียมเครือข่าย</string> - <string name="lightning_tips">ส่งทิปให้เบา ๆ </string> + <string name="lightning_tips">ส่งทิปให้เบา ๆ</string> <string name="note_to_receiver">โน้ตถึงผู้รับ</string> <string name="thank_you_so_much">ขอบคุณมาก!</string> <string name="amount_in_sats">จำนวนในหน่วย sat</string> @@ -257,14 +257,8 @@ <string name="mark_all_known_as_read">ทำเครื่องหมายอ่านแล้วในแชทที่รู้จักทั้งหมด</string> <string name="mark_all_new_as_read">ทำเครื่องหมายว่าอ่านแล้วทั้งหมดสำหรับข้อความใหม่</string> <string name="mark_all_as_read">ทพเครื่องหมายว่าอ่านแล้วทั้งหมด</string> - <string name="account_backup_tips2_md"> ## เคล็ดลับการสำรองข้อมูลและความปลอดภัยที่สำคัญ - \n\nบัญชีของคุณได้รับการรักษาความปลอดภัยด้วยคีย์ลับ คีย์เป็นรหัสชุดตัวอักษรยาวขึ้นต้นด้วย **nsec1** ใครก็ตามที่สามารถเข้าถึงรหัสชุดนี้ได้ จะสามารถโพสต์และเปลี่ยนแปลงข้อมูลประจำตัวของคุณได้ - - \n\n- **ห้าม** ใส่รหัสชุดนี้ในเว็บไซต์หรือซอฟต์แวร์ที่คุณไม่ไว้ใจ - \n- ทีมพัฒนา Amethyst **จะไม่มีวัน** ขอรหัสชุดนี้ของคุณ - \n- **ควร** สำรองข้อมูลรหัสชุดนี้ไว้เพื่อกู้คืนบัญชีของคุณ เราแนะนำให้ใช้โปรแกรมจัดการรหัสผ่าน</string> - <string name="account_backup_tips3_md"> สำหรับการรักษาความปลอดภัยเพิ่มเติม คุณสามารถเข้ารหัสคีย์ของคุณด้วยรหัสผ่าน คีย์นี้ขึ้นต้นด้วย **ncryptsec1** และไม่สามารถใช้งานได้หากไม่มีรหัสผ่านของคุณ - \n\n**แต่** หากคุณสูญหายรหัสผ่าน คุณจะไม่สามารถกู้คืนคีย์ของคุณได้ </string> + <string name="account_backup_tips2_md">## เคล็ดลับการสำรองข้อมูลและความปลอดภัยที่สำคัญ \n\nบัญชีของคุณได้รับการรักษาความปลอดภัยด้วยคีย์ลับ คีย์เป็นรหัสชุดตัวอักษรยาวขึ้นต้นด้วย **nsec1** ใครก็ตามที่สามารถเข้าถึงรหัสชุดนี้ได้ จะสามารถโพสต์และเปลี่ยนแปลงข้อมูลประจำตัวของคุณได้ \n\n- **ห้าม** ใส่รหัสชุดนี้ในเว็บไซต์หรือซอฟต์แวร์ที่คุณไม่ไว้ใจ \n- ทีมพัฒนา Amethyst **จะไม่มีวัน** ขอรหัสชุดนี้ของคุณ \n- **ควร** สำรองข้อมูลรหัสชุดนี้ไว้เพื่อกู้คืนบัญชีของคุณ เราแนะนำให้ใช้โปรแกรมจัดการรหัสผ่าน</string> + <string name="account_backup_tips3_md">สำหรับการรักษาความปลอดภัยเพิ่มเติม คุณสามารถเข้ารหัสคีย์ของคุณด้วยรหัสผ่าน คีย์นี้ขึ้นต้นด้วย **ncryptsec1** และไม่สามารถใช้งานได้หากไม่มีรหัสผ่านของคุณ \n\n**แต่** หากคุณสูญหายรหัสผ่าน คุณจะไม่สามารถกู้คืนคีย์ของคุณได้</string> <string name="encrypt_and_copy_my_secret_key">เข้ารหัสและคัดลอกคีย์ความปลอดภัยของฉัน</string> <string name="badge_award_image_for">ภาพเหรียญตราสําหรับ %1$s</string> <string name="badge_award_image">"รูปภาพรางวัลป้าย</string> @@ -1883,7 +1877,7 @@ <string name="back">ย้อนกลับ</string> <string name="backup_keys">สำรองข้อมูลรหัสลับ</string> <string name="badges">แบดจ์</string> - <string name="biometric_authentication_failed"> เกิดข้อผิดพลาดในการตรวจสอบ</string> + <string name="biometric_authentication_failed">เกิดข้อผิดพลาดในการตรวจสอบ</string> <string name="biometric_authentication_failed_explainer">เกิดข้อผิดพลาดจากการยืนยันตนด้วยชีวภาพ</string> <string name="biometric_authentication_failed_explainer_with_error">เกิดข้อผิดพลาดจากการยืนยันตนด้วยชีวภาพ: Error: %1$s</string> <string name="block_only">บล๊อก</string> @@ -1950,7 +1944,7 @@ <string name="cashu">โทเคน Cashu</string> <string name="cashu_checking_mint">กำลังตรวจสอบ mint…</string> <string name="cashu_failed_redemption">ไม่สามารถใช้งาน Cashu</string> - <string name="cashu_failed_redemption_explainer_error_msg">ผู้ให้บริการ Mint เกิดข้อผิดพลาด : %1$s </string> + <string name="cashu_failed_redemption_explainer_error_msg">ผู้ให้บริการ Mint เกิดข้อผิดพลาด : %1$s</string> <string name="cashu_history_incoming">รับแล้ว</string> <string name="cashu_history_outgoing">ส่งแล้ว</string> <string name="cashu_mint_matches_header">Mints ที่ตรงกัน</string> @@ -2042,15 +2036,7 @@ <string name="could_not_fetch_invoice_from_details">ไม่สามารถดึงใบแจ้งหนี้จาก %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">ไม่สามารถเปิดดูข้อมูลที่ถูกบีบอัดได้</string> <string name="couldnt_find_nwc_wallets">ไม่พบกระเป๋าเงิน</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst ไม่พบแอปกระเป๋าเงินที่รองรับ Nostr Wallet Connect (NWC) -\n\nสิ่งที่คุณทำได้: -\n\t1. ตรวจสอบการรองรับ NWC: ตรวจสอบอีกครั้งว่าแอปกระเป๋าเงินที่คุณต้องการใช้รองรับ Nostr Wallet Connect หรือไม่ -\n\t2. สร้างการเชื่อมต่อ: ไปที่แอปกระเป๋าเงินของคุณและสร้างการเชื่อมต่อ NWC ใหม่ -\n\t3. เชื่อมกับ Amethyst: กระเป๋าเงินของคุณมักจะให้ตัวเลือกสามแบบ: -\n\t\t3.1 ลิงก์อัตโนมัติ: ปุ่มเพื่อเปิดและเชื่อมต่อกับ Amethyst โดยอัตโนมัติ หากมี ให้กดปุ่มนั้น เปิด Amethyst และกดบันทึกที่หน้าจอใหม่ -\n\t\t3.2 ลิงก์ด้วยตนเอง: URI การเชื่อมต่อที่คุณสามารถคัดลอกและกดไอคอนวางบนหน้าจอนี้เพื่อป้อนโดยตรง -\n\t\t3.3 QR Code: กระเป๋าเงินสร้าง QR Code ที่คุณสามารถอ่านได้จากปุ่ม QR code ในหน้าจอนี้ - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst ไม่พบแอปกระเป๋าเงินที่รองรับ Nostr Wallet Connect (NWC) \n\nสิ่งที่คุณทำได้: \n\t1. ตรวจสอบการรองรับ NWC: ตรวจสอบอีกครั้งว่าแอปกระเป๋าเงินที่คุณต้องการใช้รองรับ Nostr Wallet Connect หรือไม่ \n\t2. สร้างการเชื่อมต่อ: ไปที่แอปกระเป๋าเงินของคุณและสร้างการเชื่อมต่อ NWC ใหม่ \n\t3. เชื่อมกับ Amethyst: กระเป๋าเงินของคุณมักจะให้ตัวเลือกสามแบบ: \n\t\t3.1 ลิงก์อัตโนมัติ: ปุ่มเพื่อเปิดและเชื่อมต่อกับ Amethyst โดยอัตโนมัติ หากมี ให้กดปุ่มนั้น เปิด Amethyst และกดบันทึกที่หน้าจอใหม่ \n\t\t3.2 ลิงก์ด้วยตนเอง: URI การเชื่อมต่อที่คุณสามารถคัดลอกและกดไอคอนวางบนหน้าจอนี้เพื่อป้อนโดยตรง \n\t\t3.3 QR Code: กระเป๋าเงินสร้าง QR Code ที่คุณสามารถอ่านได้จากปุ่ม QR code ในหน้าจอนี้</string> <string name="create">สร้าง</string> <string name="d">วัน</string> <string name="danger_zone">เขตอันตราย</string> diff --git a/commonsUI/src/commonMain/composeResources/values-tr-rTR/strings.xml b/commonsUI/src/commonMain/composeResources/values-tr-rTR/strings.xml index ac074b789c..59fd97ae80 100644 --- a/commonsUI/src/commonMain/composeResources/values-tr-rTR/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-tr-rTR/strings.xml @@ -71,7 +71,7 @@ <string name="scan_qr">QR Tara</string> <string name="show_anyway">Yine De Göster</string> <string name="post_was_hidden">Bu gönderi, gizlediğiniz kullanıcıları veya kelimeleri içerdiği için gizlendi</string> - <string name="post_was_flagged_as_inappropriate_by">Gönderi uygun değil olarak işaretlendi tarafından: </string> + <string name="post_was_flagged_as_inappropriate_by">Gönderi uygun değil olarak işaretlendi tarafından:</string> <string name="post_not_found">Gönderi bulunamadı</string> <string name="channel_image">Kanal Resmi</string> <string name="referenced_event_not_found">Referanslı etkinlik bulunamadı</string> @@ -272,15 +272,8 @@ <string name="mark_all_known_as_read">Tüm bilinenleri okundu olarak işaretle</string> <string name="mark_all_new_as_read">Tüm yenileri okundu olarak işaretle</string> <string name="mark_all_as_read">Tümünü okundu olarak işaretle</string> - <string name="account_backup_tips2_md"> ## Anahtar Yedekleme ve Güvenlik İpuçları - \n\nHesabınız bir gizli anahtarla korunmaktadır. Anahtar, **nsec1** ile başlayan uzun bir karakter dizisidir. Bu gizli anahtara erişimi olan herkes kimliğiniz adına gönderi yapabilir ve kimliğinizi değiştirebilir. - \n\n- Gizli anahtarınızı güvenmediğiniz herhangi bir web sitesine veya yazılıma **koymayın**. - \n- Amethyst geliştiricileri gizli anahtarınızı **asla** istemez. - \n- Hesap kurtarma için gizli anahtarınızın güvenli bir yedeğini **alın**. Bir parola yöneticisi kullanmanızı öneririz. - </string> - <string name="account_backup_tips3_md"> Ek güvenlik için anahtarınızı bir parola ile şifreleyebilirsiniz. Bu anahtar **ncryptsec1** ile başlar ve parolanız olmadan kullanılamaz. - \n\nParolanızı kaybederseniz anahtarınızı kurtaramazsınız. - </string> + <string name="account_backup_tips2_md">## Anahtar Yedekleme ve Güvenlik İpuçları \n\nHesabınız bir gizli anahtarla korunmaktadır. Anahtar, **nsec1** ile başlayan uzun bir karakter dizisidir. Bu gizli anahtara erişimi olan herkes kimliğiniz adına gönderi yapabilir ve kimliğinizi değiştirebilir. \n\n- Gizli anahtarınızı güvenmediğiniz herhangi bir web sitesine veya yazılıma **koymayın**. \n- Amethyst geliştiricileri gizli anahtarınızı **asla** istemez. \n- Hesap kurtarma için gizli anahtarınızın güvenli bir yedeğini **alın**. Bir parola yöneticisi kullanmanızı öneririz.</string> + <string name="account_backup_tips3_md">Ek güvenlik için anahtarınızı bir parola ile şifreleyebilirsiniz. Bu anahtar **ncryptsec1** ile başlar ve parolanız olmadan kullanılamaz. \n\nParolanızı kaybederseniz anahtarınızı kurtaramazsınız.</string> <string name="encrypt_and_copy_my_secret_key">Gizli anahtarımı şifrele ve kopyala</string> <string name="badge_award_image_for">%1$s için rozet ödülü görseli</string> <string name="badge_award_image">"Rozet ödülü görseli</string> @@ -966,9 +959,7 @@ <string name="push_server_none_explainer">Push Bildirimlerini Devre Dışı Bırakır</string> <string name="push_server_uses_app_explainer">%1$s uygulamasını kullanır</string> <string name="push_server_install_app">Push Bildirim Kurulumu</string> - <string name="push_server_install_app_description"> Push bildirimleri almak için [Ntfy](https://ntfy.sh/) gibi [Unified Push](https://unifiedpush.org/) destekleyen herhangi bir uygulama yükleyin. - Yükledikten sonra, Ayarlar'da kullanmak istediğiniz uygulamayı seçin. - </string> + <string name="push_server_install_app_description">Push bildirimleri almak için [Ntfy](https://ntfy.sh/) gibi [Unified Push](https://unifiedpush.org/) destekleyen herhangi bir uygulama yükleyin. Yükledikten sonra, Ayarlar'da kullanmak istediğiniz uygulamayı seçin.</string> <string name="thread_title">Konu</string> <string name="send_the_seller_a_message">Satıcıya mesaj gönderin</string> <string name="hi_there_is_this_still_available">Merhaba, bu hâlâ mevcut mu?</string> @@ -2024,15 +2015,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s'den fatura alınamadı: %2$s</string> <string name="could_not_open_the_compressed_file">Sıkıştırılmış dosya açılamadı</string> <string name="couldnt_find_nwc_wallets">Cüzdan bulunamadı</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst, Nostr Wallet Connect (NWC) destekleyen herhangi bir cüzdan uygulaması bulamadı. -\n\nYapabilecekleriniz: -\n\t1. NWC Desteğini Doğrulayın: Tercih ettiğiniz cüzdan uygulamasının Nostr Wallet Connect ile uyumlu olup olmadığını iki kez kontrol edin. -\n\t2. Bağlantı Oluşturun: Cüzdan uygulamanıza gidin ve yeni bir NWC bağlantısı oluşturun. -\n\t3. Amethyst'e Bağlayın: Cüzdanınız genellikle size üç seçenek sunar: -\n\t\t3.1 Otomatik Bağlantı: Amethyst'i otomatik olarak açıp bağlamak için bir düğme. Öyleyse o düğmeye tıklayın, Amethyst'i açın ve yeni ekranda kaydet'e basın. -\n\t\t3.2 Manuel Bağlantı: Doğrudan girmek için bu ekrandaki yapıştır simgesine tıklayabileceğiniz bir Bağlantı URI'si kopyalayın. -\n\t\t3.3 QR Kodu: Cüzdan, bu ekrandaki QR kodu düğmesiyle okuyabileceğiniz bir QR kodu oluşturur. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst, Nostr Wallet Connect (NWC) destekleyen herhangi bir cüzdan uygulaması bulamadı. \n\nYapabilecekleriniz: \n\t1. NWC Desteğini Doğrulayın: Tercih ettiğiniz cüzdan uygulamasının Nostr Wallet Connect ile uyumlu olup olmadığını iki kez kontrol edin. \n\t2. Bağlantı Oluşturun: Cüzdan uygulamanıza gidin ve yeni bir NWC bağlantısı oluşturun. \n\t3. Amethyst'e Bağlayın: Cüzdanınız genellikle size üç seçenek sunar: \n\t\t3.1 Otomatik Bağlantı: Amethyst'i otomatik olarak açıp bağlamak için bir düğme. Öyleyse o düğmeye tıklayın, Amethyst'i açın ve yeni ekranda kaydet'e basın. \n\t\t3.2 Manuel Bağlantı: Doğrudan girmek için bu ekrandaki yapıştır simgesine tıklayabileceğiniz bir Bağlantı URI'si kopyalayın. \n\t\t3.3 QR Kodu: Cüzdan, bu ekrandaki QR kodu düğmesiyle okuyabileceğiniz bir QR kodu oluşturur.</string> <string name="create">Oluştur</string> <string name="d">g</string> <string name="danger_zone">Tehlike Bölgesi</string> @@ -2677,11 +2660,8 @@ <string name="proxy_section">Proxy Relay'leri</string> <string name="proxy_section_explainer">Uygulamanın akışlarınızı indirmek için kullanması gereken filter.nostr.wine gibi toplayıcı relay'ler. Bu, giden kutusu modelinin yerini alır ve uygulamanın yalnızca listelerinizdeki relay'lere bağlanmasını sağlar.</string> <string name="public_chat">Herkese Açık Chat</string> - <string name="public_chat_explainer">Genel sohbetler Nostr'daki herkese görünürdür ve herkes - katılabilir. Belirli konular etrafında açık topluluklar için idealdirler. - Moderasyon, relay'lerindeki gönderilerin silinmesiyle kontrol edilebilir</string> - <string name="public_chat_relays_explainer">Bu grubu barındıran 1–3 relay ekleyin. - Nostr istemcileri mesajları nereden indireceğini ve mesajlarınızı nereye göndereceğini öğrenmek için bu ayarı kullanır.</string> + <string name="public_chat_explainer">Genel sohbetler Nostr'daki herkese görünürdür ve herkes katılabilir. Belirli konular etrafında açık topluluklar için idealdirler. Moderasyon, relay'lerindeki gönderilerin silinmesiyle kontrol edilebilir</string> + <string name="public_chat_relays_explainer">Bu grubu barındıran 1–3 relay ekleyin. Nostr istemcileri mesajları nereden indireceğini ve mesajlarınızı nereye göndereceğini öğrenmek için bu ayarı kullanır.</string> <string name="public_chat_relays_title">relay'ler</string> <string name="public_chat_title">Genel Sohbet Meta Verisi</string> <string name="public_chats">Genel Sohbetler</string> @@ -2706,10 +2686,7 @@ <string name="read_only_user">Salt okunur kullanıcı</string> <string name="record_a_message_description">Sesli mesaj kaydetmek için tıklayıp basılı tutun</string> <string name="relay_chat">relay Sohbeti</string> - <string name="relay_chat_explainer">relay sohbetleri, ana relay'leri tarafından kontrol edilen sohbet gruplarıdır. - Nostr'daki herkese görünürdür ve herkes katılabilir. - Belirli konular etrafında açık topluluklar için idealdirler. Bu grupların bir kısmı geçici niteliktedir - ve bu nedenle sohbet mesajları zamanla silinir</string> + <string name="relay_chat_explainer">relay sohbetleri, ana relay'leri tarafından kontrol edilen sohbet gruplarıdır. Nostr'daki herkese görünürdür ve herkes katılabilir. Belirli konular etrafında açık topluluklar için idealdirler. Bu grupların bir kısmı geçici niteliktedir ve bu nedenle sohbet mesajları zamanla silinir</string> <string name="relay_chat_title">relay Sohbetleri</string> <string name="relay_management_tab_events">Etkinlikler</string> <string name="relay_management_tab_ips">IP'ler</string> diff --git a/commonsUI/src/commonMain/composeResources/values-tr/strings.xml b/commonsUI/src/commonMain/composeResources/values-tr/strings.xml index 989465fdb4..7716fa9b4b 100644 --- a/commonsUI/src/commonMain/composeResources/values-tr/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-tr/strings.xml @@ -51,7 +51,7 @@ <string name="scan_qr">QR Tara</string> <string name="show_anyway">Yine De Göster</string> <string name="post_was_hidden">Bu gönderi, gizlediğiniz kullanıcıları veya kelimeleri içerdiği için gizlendi</string> - <string name="post_was_flagged_as_inappropriate_by">Gönderi uygun değil olarak işaretlendi tarafından: </string> + <string name="post_was_flagged_as_inappropriate_by">Gönderi uygun değil olarak işaretlendi tarafından:</string> <string name="post_not_found">Gönderi bulunamadı</string> <string name="post_not_found_short">👀</string> <string name="channel_image">Kanal Resmi</string> @@ -259,17 +259,8 @@ <string name="mark_all_known_as_read">Tüm bilinenleri okundu olarak işaretle</string> <string name="mark_all_new_as_read">Tüm yenileri okundu olarak işaretle</string> <string name="mark_all_as_read">Tümünü okundu olarak işaretle</string> - <string name="account_backup_tips2_md"> - ## Anahtar Yedekleme ve Güvenlik İpuçları - \n\nHesabınız bir gizli anahtarla korunmaktadır. Anahtar, **nsec1** ile başlayan uzun bir karakter dizisidir. Bu gizli anahtara erişimi olan herkes kimliğiniz adına gönderi yapabilir ve kimliğinizi değiştirebilir. - \n\n- Gizli anahtarınızı güvenmediğiniz herhangi bir web sitesine veya yazılıma **koymayın**. - \n- Amethyst geliştiricileri gizli anahtarınızı **asla** istemez. - \n- Hesap kurtarma için gizli anahtarınızın güvenli bir yedeğini **alın**. Bir parola yöneticisi kullanmanızı öneririz. - </string> - <string name="account_backup_tips3_md"> - Ek güvenlik için anahtarınızı bir parola ile şifreleyebilirsiniz. Bu anahtar **ncryptsec1** ile başlar ve parolanız olmadan kullanılamaz. - \n\nParolanızı kaybederseniz anahtarınızı kurtaramazsınız. - </string> + <string name="account_backup_tips2_md">## Anahtar Yedekleme ve Güvenlik İpuçları \n\nHesabınız bir gizli anahtarla korunmaktadır. Anahtar, **nsec1** ile başlayan uzun bir karakter dizisidir. Bu gizli anahtara erişimi olan herkes kimliğiniz adına gönderi yapabilir ve kimliğinizi değiştirebilir. \n\n- Gizli anahtarınızı güvenmediğiniz herhangi bir web sitesine veya yazılıma **koymayın**. \n- Amethyst geliştiricileri gizli anahtarınızı **asla** istemez. \n- Hesap kurtarma için gizli anahtarınızın güvenli bir yedeğini **alın**. Bir parola yöneticisi kullanmanızı öneririz.</string> + <string name="account_backup_tips3_md">Ek güvenlik için anahtarınızı bir parola ile şifreleyebilirsiniz. Bu anahtar **ncryptsec1** ile başlar ve parolanız olmadan kullanılamaz. \n\nParolanızı kaybederseniz anahtarınızı kurtaramazsınız.</string> <string name="encrypt_and_copy_my_secret_key">Gizli anahtarımı şifrele ve kopyala</string> <string name="badge_award_image_for">%1$s için rozet ödülü görseli</string> <string name="badge_award_image">"Rozet ödülü görseli</string> @@ -962,10 +953,7 @@ <string name="push_server_none_explainer">Push Bildirimlerini Devre Dışı Bırakır</string> <string name="push_server_uses_app_explainer">%1$s uygulamasını kullanır</string> <string name="push_server_install_app">Push Bildirim Kurulumu</string> - <string name="push_server_install_app_description"> - Push bildirimleri almak için [Ntfy](https://ntfy.sh/) gibi [Unified Push](https://unifiedpush.org/) destekleyen herhangi bir uygulama yükleyin. - Yükledikten sonra, Ayarlar'da kullanmak istediğiniz uygulamayı seçin. - </string> + <string name="push_server_install_app_description">Push bildirimleri almak için [Ntfy](https://ntfy.sh/) gibi [Unified Push](https://unifiedpush.org/) destekleyen herhangi bir uygulama yükleyin. Yükledikten sonra, Ayarlar'da kullanmak istediğiniz uygulamayı seçin.</string> <string name="thread_title">Konu</string> <string name="send_the_seller_a_message">Satıcıya mesaj gönderin</string> <string name="hi_there_is_this_still_available">Merhaba, bu hâlâ mevcut mu?</string> @@ -2058,15 +2046,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s'den fatura alınamadı: %2$s</string> <string name="could_not_open_the_compressed_file">Sıkıştırılmış dosya açılamadı</string> <string name="couldnt_find_nwc_wallets">Cüzdan bulunamadı</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst, Nostr Wallet Connect (NWC) destekleyen herhangi bir cüzdan uygulaması bulamadı. -\n\nYapabilecekleriniz: -\n\t1. NWC Desteğini Doğrulayın: Tercih ettiğiniz cüzdan uygulamasının Nostr Wallet Connect ile uyumlu olup olmadığını iki kez kontrol edin. -\n\t2. Bağlantı Oluşturun: Cüzdan uygulamanıza gidin ve yeni bir NWC bağlantısı oluşturun. -\n\t3. Amethyst'e Bağlayın: Cüzdanınız genellikle size üç seçenek sunar: -\n\t\t3.1 Otomatik Bağlantı: Amethyst'i otomatik olarak açıp bağlamak için bir düğme. Öyleyse o düğmeye tıklayın, Amethyst'i açın ve yeni ekranda kaydet'e basın. -\n\t\t3.2 Manuel Bağlantı: Doğrudan girmek için bu ekrandaki yapıştır simgesine tıklayabileceğiniz bir Bağlantı URI'si kopyalayın. -\n\t\t3.3 QR Kodu: Cüzdan, bu ekrandaki QR kodu düğmesiyle okuyabileceğiniz bir QR kodu oluşturur. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst, Nostr Wallet Connect (NWC) destekleyen herhangi bir cüzdan uygulaması bulamadı. \n\nYapabilecekleriniz: \n\t1. NWC Desteğini Doğrulayın: Tercih ettiğiniz cüzdan uygulamasının Nostr Wallet Connect ile uyumlu olup olmadığını iki kez kontrol edin. \n\t2. Bağlantı Oluşturun: Cüzdan uygulamanıza gidin ve yeni bir NWC bağlantısı oluşturun. \n\t3. Amethyst'e Bağlayın: Cüzdanınız genellikle size üç seçenek sunar: \n\t\t3.1 Otomatik Bağlantı: Amethyst'i otomatik olarak açıp bağlamak için bir düğme. Öyleyse o düğmeye tıklayın, Amethyst'i açın ve yeni ekranda kaydet'e basın. \n\t\t3.2 Manuel Bağlantı: Doğrudan girmek için bu ekrandaki yapıştır simgesine tıklayabileceğiniz bir Bağlantı URI'si kopyalayın. \n\t\t3.3 QR Kodu: Cüzdan, bu ekrandaki QR kodu düğmesiyle okuyabileceğiniz bir QR kodu oluşturur.</string> <string name="create">Oluştur</string> <string name="d">g</string> <string name="danger_zone">Tehlike Bölgesi</string> @@ -2754,11 +2734,8 @@ <string name="proxy_section">Proxy Relay'leri</string> <string name="proxy_section_explainer">Uygulamanın akışlarınızı indirmek için kullanması gereken filter.nostr.wine gibi toplayıcı relay'ler. Bu, giden kutusu modelinin yerini alır ve uygulamanın yalnızca listelerinizdeki relay'lere bağlanmasını sağlar.</string> <string name="public_chat">Herkese Açık Chat</string> - <string name="public_chat_explainer">Genel sohbetler Nostr'daki herkese görünürdür ve herkes - katılabilir. Belirli konular etrafında açık topluluklar için idealdirler. - Moderasyon, relay'lerindeki gönderilerin silinmesiyle kontrol edilebilir</string> - <string name="public_chat_relays_explainer">Bu grubu barındıran 1–3 relay ekleyin. - Nostr istemcileri mesajları nereden indireceğini ve mesajlarınızı nereye göndereceğini öğrenmek için bu ayarı kullanır.</string> + <string name="public_chat_explainer">Genel sohbetler Nostr'daki herkese görünürdür ve herkes katılabilir. Belirli konular etrafında açık topluluklar için idealdirler. Moderasyon, relay'lerindeki gönderilerin silinmesiyle kontrol edilebilir</string> + <string name="public_chat_relays_explainer">Bu grubu barındıran 1–3 relay ekleyin. Nostr istemcileri mesajları nereden indireceğini ve mesajlarınızı nereye göndereceğini öğrenmek için bu ayarı kullanır.</string> <string name="public_chat_relays_title">relay'ler</string> <string name="public_chat_title">Genel Sohbet Meta Verisi</string> <string name="public_chats">Genel Sohbetler</string> @@ -2783,10 +2760,7 @@ <string name="read_only_user">Salt okunur kullanıcı</string> <string name="record_a_message_description">Sesli mesaj kaydetmek için tıklayıp basılı tutun</string> <string name="relay_chat">relay Sohbeti</string> - <string name="relay_chat_explainer">relay sohbetleri, ana relay'leri tarafından kontrol edilen sohbet gruplarıdır. - Nostr'daki herkese görünürdür ve herkes katılabilir. - Belirli konular etrafında açık topluluklar için idealdirler. Bu grupların bir kısmı geçici niteliktedir - ve bu nedenle sohbet mesajları zamanla silinir</string> + <string name="relay_chat_explainer">relay sohbetleri, ana relay'leri tarafından kontrol edilen sohbet gruplarıdır. Nostr'daki herkese görünürdür ve herkes katılabilir. Belirli konular etrafında açık topluluklar için idealdirler. Bu grupların bir kısmı geçici niteliktedir ve bu nedenle sohbet mesajları zamanla silinir</string> <string name="relay_chat_title">relay Sohbetleri</string> <string name="relay_management_tab_events">Etkinlikler</string> <string name="relay_management_tab_ips">IP'ler</string> diff --git a/commonsUI/src/commonMain/composeResources/values-uk-rUA/strings.xml b/commonsUI/src/commonMain/composeResources/values-uk-rUA/strings.xml index a6e1bee6c5..5e60c8e1da 100644 --- a/commonsUI/src/commonMain/composeResources/values-uk-rUA/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-uk-rUA/strings.xml @@ -225,7 +225,7 @@ <string name="copy_user_id">Скопіювати ID користувача</string> <string name="unblock_user">Розблокувати користувача</string> <string name="user_is_blocked_hidden">Цього користувача заблоковано/заглушено. Їхні публікації приховано.</string> - <string name="npub_hex_username">npub, hex, нікнейм </string> + <string name="npub_hex_username">npub, hex, нікнейм</string> <string name="clear">Очистити</string> <string name="app_logo">Логотип додатка</string> <string name="nsec_npub_hex_private_key">nsec / npub / приватний ключ в hex</string> @@ -273,15 +273,8 @@ <string name="mark_all_known_as_read">Позначити всі відомі прочитаними</string> <string name="mark_all_new_as_read">Позначити всі нові прочитаними</string> <string name="mark_all_as_read">Позначити все прочитаним</string> - <string name="account_backup_tips2_md"> ## Поради щодо резервного копіювання та безпеки ключа - \n\nВаш обліковий запис захищений секретним ключем. Ключ — це довга послідовність символів, що починається з **nsec1**. Будь-хто, хто має доступ до цього секретного ключа, може публікувати та змінювати вашу особу. - \n\n- **Не** вводьте свій секретний ключ на жодному сайті чи в програмі, якій ви не довіряєте. - \n- Розробники Amethyst **ніколи** не запитуватимуть ваш секретний ключ. - \n- **Зробіть** надійне резервне копіювання секретного ключа для відновлення облікового запису. Рекомендуємо використовувати менеджер паролів. - </string> - <string name="account_backup_tips3_md"> Для додаткової безпеки ви можете зашифрувати ключ паролем. Цей ключ починається з **ncryptsec1** і не може бути використаний без вашого пароля. - \n\nЯкщо ви забудете пароль, ви не зможете відновити ключ. - </string> + <string name="account_backup_tips2_md">## Поради щодо резервного копіювання та безпеки ключа \n\nВаш обліковий запис захищений секретним ключем. Ключ — це довга послідовність символів, що починається з **nsec1**. Будь-хто, хто має доступ до цього секретного ключа, може публікувати та змінювати вашу особу. \n\n- **Не** вводьте свій секретний ключ на жодному сайті чи в програмі, якій ви не довіряєте. \n- Розробники Amethyst **ніколи** не запитуватимуть ваш секретний ключ. \n- **Зробіть** надійне резервне копіювання секретного ключа для відновлення облікового запису. Рекомендуємо використовувати менеджер паролів.</string> + <string name="account_backup_tips3_md">Для додаткової безпеки ви можете зашифрувати ключ паролем. Цей ключ починається з **ncryptsec1** і не може бути використаний без вашого пароля. \n\nЯкщо ви забудете пароль, ви не зможете відновити ключ.</string> <string name="encrypt_and_copy_my_secret_key">Зашифрувати та скопіювати мій секретний ключ</string> <string name="badge_award_image_for">Картинка значка-нагороди %1$s</string> <string name="badge_award_image">"Зображення нагороди значком</string> @@ -970,9 +963,7 @@ <string name="push_server_none_explainer">Вимикає push-сповіщення</string> <string name="push_server_uses_app_explainer">Використовує додаток %1$s</string> <string name="push_server_install_app">Налаштування push-сповіщень</string> - <string name="push_server_install_app_description"> Щоб отримувати push-сповіщення, встановіть будь-який додаток з підтримкою [Unified Push](https://unifiedpush.org/), наприклад [Ntfy](https://ntfy.sh/). - Після встановлення виберіть потрібний додаток у налаштуваннях. - </string> + <string name="push_server_install_app_description">Щоб отримувати push-сповіщення, встановіть будь-який додаток з підтримкою [Unified Push](https://unifiedpush.org/), наприклад [Ntfy](https://ntfy.sh/). Після встановлення виберіть потрібний додаток у налаштуваннях.</string> <string name="thread_title">Тема</string> <string name="send_the_seller_a_message">Надіслати продавцю повідомлення</string> <string name="hi_there_is_this_still_available">Привіт, це ще доступно?</string> @@ -2037,15 +2028,7 @@ <string name="could_not_fetch_invoice_from_details">Не вдалося отримати інвойс від %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Не вдалося відкрити стиснутий файл</string> <string name="couldnt_find_nwc_wallets">Гаманець не знайдено</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst не знайшов жодного гаманця, який підтримує Nostr Wallet Connect (NWC). -\n\nЩо можна зробити: -\n\t1. Перевірте підтримку NWC: переконайтеся, що ваш гаманець сумісний з Nostr Wallet Connect. -\n\t2. Створіть підключення: відкрийте гаманець і створіть нове NWC-підключення. -\n\t3. Прив'яжіть до Amethyst: зазвичай гаманець надає три варіанти: -\n\t\t3.1 Автоматичне підключення: кнопка для автоматичного відкриття та підключення до Amethyst. Якщо так — натисніть її, відкрийте Amethyst і збережіть налаштування на новому екрані. -\n\t\t3.2 Ручне підключення: URI підключення, який можна скопіювати та вставити за допомогою значка вставки на цьому екрані. -\n\t\t3.3 QR-код: гаманець створює QR-код, який можна зчитати за допомогою кнопки QR-коду на цьому екрані. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst не знайшов жодного гаманця, який підтримує Nostr Wallet Connect (NWC). \n\nЩо можна зробити: \n\t1. Перевірте підтримку NWC: переконайтеся, що ваш гаманець сумісний з Nostr Wallet Connect. \n\t2. Створіть підключення: відкрийте гаманець і створіть нове NWC-підключення. \n\t3. Прив'яжіть до Amethyst: зазвичай гаманець надає три варіанти: \n\t\t3.1 Автоматичне підключення: кнопка для автоматичного відкриття та підключення до Amethyst. Якщо так — натисніть її, відкрийте Amethyst і збережіть налаштування на новому екрані. \n\t\t3.2 Ручне підключення: URI підключення, який можна скопіювати та вставити за допомогою значка вставки на цьому екрані. \n\t\t3.3 QR-код: гаманець створює QR-код, який можна зчитати за допомогою кнопки QR-коду на цьому екрані.</string> <string name="create">Створити</string> <string name="d">дн</string> <string name="danger_zone">Небезпечна зона</string> @@ -2726,11 +2709,8 @@ <string name="proxy_section">Proxy relay-сервери</string> <string name="proxy_section_explainer">Агрегаторні relay-сервери, які застосунок має використовувати для завантаження ваших стрічок, наприклад filter.nostr.wine. Це замінює модель outbox і змусить застосунок підключатися лише до relay-серверів у ваших списках.</string> <string name="public_chat">Публічний чат</string> - <string name="public_chat_explainer">Публічні чати видимі всім у Nostr, і кожен - може брати в них участь. Вони чудово підходять для відкритих спільнот за певними темами. - Модерацію можна здійснювати, видаляючи публікації на відповідних relay</string> - <string name="public_chat_relays_explainer">Вкажіть від 1 до 3 relay, що розміщують цю групу. - Клієнти Nostr використовують це налаштування, щоб знати, звідки завантажувати повідомлення та куди їх надсилати.</string> + <string name="public_chat_explainer">Публічні чати видимі всім у Nostr, і кожен може брати в них участь. Вони чудово підходять для відкритих спільнот за певними темами. Модерацію можна здійснювати, видаляючи публікації на відповідних relay</string> + <string name="public_chat_relays_explainer">Вкажіть від 1 до 3 relay, що розміщують цю групу. Клієнти Nostr використовують це налаштування, щоб знати, звідки завантажувати повідомлення та куди їх надсилати.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Метадані публічного чату</string> <string name="public_chats">Публічні чати</string> @@ -2755,10 +2735,7 @@ <string name="read_only_user">Користувач лише для читання</string> <string name="record_a_message_description">Натисніть і утримуйте, щоб записати повідомлення</string> <string name="relay_chat">Чат relay</string> - <string name="relay_chat_explainer">Чати relay — це групи чатів, керовані їхнім домашнім relay. - Вони видимі всім у Nostr, і кожен може брати в них участь. - Вони чудово підходять для відкритих спільнот за певними темами. Деякі з цих груп є тимчасовими, - і тому повідомлення чату зникають з часом</string> + <string name="relay_chat_explainer">Чати relay — це групи чатів, керовані їхнім домашнім relay. Вони видимі всім у Nostr, і кожен може брати в них участь. Вони чудово підходять для відкритих спільнот за певними темами. Деякі з цих груп є тимчасовими, і тому повідомлення чату зникають з часом</string> <string name="relay_chat_title">Чати relay</string> <string name="relay_management_tab_events">Події</string> <string name="relay_management_tab_ips">IP-адреси</string> diff --git a/commonsUI/src/commonMain/composeResources/values-uk/strings.xml b/commonsUI/src/commonMain/composeResources/values-uk/strings.xml index 53159e447e..bc7b9935b3 100644 --- a/commonsUI/src/commonMain/composeResources/values-uk/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-uk/strings.xml @@ -215,7 +215,7 @@ <string name="copy_user_id">Скопіювати ID користувача</string> <string name="unblock_user">Розблокувати користувача</string> <string name="user_is_blocked_hidden">Цього користувача заблоковано/заглушено. Їхні публікації приховано.</string> - <string name="npub_hex_username">npub, hex, нікнейм </string> + <string name="npub_hex_username">npub, hex, нікнейм</string> <string name="clear">Очистити</string> <string name="app_logo">Логотип додатка</string> <string name="nsec_npub_hex_private_key">nsec / npub / приватний ключ в hex</string> @@ -263,17 +263,8 @@ <string name="mark_all_known_as_read">Позначити всі відомі прочитаними</string> <string name="mark_all_new_as_read">Позначити всі нові прочитаними</string> <string name="mark_all_as_read">Позначити все прочитаним</string> - <string name="account_backup_tips2_md"> - ## Поради щодо резервного копіювання та безпеки ключа - \n\nВаш обліковий запис захищений секретним ключем. Ключ — це довга послідовність символів, що починається з **nsec1**. Будь-хто, хто має доступ до цього секретного ключа, може публікувати та змінювати вашу особу. - \n\n- **Не** вводьте свій секретний ключ на жодному сайті чи в програмі, якій ви не довіряєте. - \n- Розробники Amethyst **ніколи** не запитуватимуть ваш секретний ключ. - \n- **Зробіть** надійне резервне копіювання секретного ключа для відновлення облікового запису. Рекомендуємо використовувати менеджер паролів. - </string> - <string name="account_backup_tips3_md"> - Для додаткової безпеки ви можете зашифрувати ключ паролем. Цей ключ починається з **ncryptsec1** і не може бути використаний без вашого пароля. - \n\nЯкщо ви забудете пароль, ви не зможете відновити ключ. - </string> + <string name="account_backup_tips2_md">## Поради щодо резервного копіювання та безпеки ключа \n\nВаш обліковий запис захищений секретним ключем. Ключ — це довга послідовність символів, що починається з **nsec1**. Будь-хто, хто має доступ до цього секретного ключа, може публікувати та змінювати вашу особу. \n\n- **Не** вводьте свій секретний ключ на жодному сайті чи в програмі, якій ви не довіряєте. \n- Розробники Amethyst **ніколи** не запитуватимуть ваш секретний ключ. \n- **Зробіть** надійне резервне копіювання секретного ключа для відновлення облікового запису. Рекомендуємо використовувати менеджер паролів.</string> + <string name="account_backup_tips3_md">Для додаткової безпеки ви можете зашифрувати ключ паролем. Цей ключ починається з **ncryptsec1** і не може бути використаний без вашого пароля. \n\nЯкщо ви забудете пароль, ви не зможете відновити ключ.</string> <string name="encrypt_and_copy_my_secret_key">Зашифрувати та скопіювати мій секретний ключ</string> <string name="badge_award_image_for">Картинка значка-нагороди %1$s</string> <string name="badge_award_image">"Зображення нагороди значком</string> @@ -966,10 +957,7 @@ <string name="push_server_none_explainer">Вимикає push-сповіщення</string> <string name="push_server_uses_app_explainer">Використовує додаток %1$s</string> <string name="push_server_install_app">Налаштування push-сповіщень</string> - <string name="push_server_install_app_description"> - Щоб отримувати push-сповіщення, встановіть будь-який додаток з підтримкою [Unified Push](https://unifiedpush.org/), наприклад [Ntfy](https://ntfy.sh/). - Після встановлення виберіть потрібний додаток у налаштуваннях. - </string> + <string name="push_server_install_app_description">Щоб отримувати push-сповіщення, встановіть будь-який додаток з підтримкою [Unified Push](https://unifiedpush.org/), наприклад [Ntfy](https://ntfy.sh/). Після встановлення виберіть потрібний додаток у налаштуваннях.</string> <string name="thread_title">Тема</string> <string name="send_the_seller_a_message">Надіслати продавцю повідомлення</string> <string name="hi_there_is_this_still_available">Привіт, це ще доступно?</string> @@ -2078,15 +2066,7 @@ <string name="could_not_fetch_invoice_from_details">Не вдалося отримати інвойс від %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Не вдалося відкрити стиснутий файл</string> <string name="couldnt_find_nwc_wallets">Гаманець не знайдено</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst не знайшов жодного гаманця, який підтримує Nostr Wallet Connect (NWC). -\n\nЩо можна зробити: -\n\t1. Перевірте підтримку NWC: переконайтеся, що ваш гаманець сумісний з Nostr Wallet Connect. -\n\t2. Створіть підключення: відкрийте гаманець і створіть нове NWC-підключення. -\n\t3. Прив'яжіть до Amethyst: зазвичай гаманець надає три варіанти: -\n\t\t3.1 Автоматичне підключення: кнопка для автоматичного відкриття та підключення до Amethyst. Якщо так — натисніть її, відкрийте Amethyst і збережіть налаштування на новому екрані. -\n\t\t3.2 Ручне підключення: URI підключення, який можна скопіювати та вставити за допомогою значка вставки на цьому екрані. -\n\t\t3.3 QR-код: гаманець створює QR-код, який можна зчитати за допомогою кнопки QR-коду на цьому екрані. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst не знайшов жодного гаманця, який підтримує Nostr Wallet Connect (NWC). \n\nЩо можна зробити: \n\t1. Перевірте підтримку NWC: переконайтеся, що ваш гаманець сумісний з Nostr Wallet Connect. \n\t2. Створіть підключення: відкрийте гаманець і створіть нове NWC-підключення. \n\t3. Прив'яжіть до Amethyst: зазвичай гаманець надає три варіанти: \n\t\t3.1 Автоматичне підключення: кнопка для автоматичного відкриття та підключення до Amethyst. Якщо так — натисніть її, відкрийте Amethyst і збережіть налаштування на новому екрані. \n\t\t3.2 Ручне підключення: URI підключення, який можна скопіювати та вставити за допомогою значка вставки на цьому екрані. \n\t\t3.3 QR-код: гаманець створює QR-код, який можна зчитати за допомогою кнопки QR-коду на цьому екрані.</string> <string name="create">Створити</string> <string name="d">дн</string> <string name="danger_zone">Небезпечна зона</string> @@ -2816,11 +2796,8 @@ <string name="proxy_section">Proxy relay-сервери</string> <string name="proxy_section_explainer">Агрегаторні relay-сервери, які застосунок має використовувати для завантаження ваших стрічок, наприклад filter.nostr.wine. Це замінює модель outbox і змусить застосунок підключатися лише до relay-серверів у ваших списках.</string> <string name="public_chat">Публічний чат</string> - <string name="public_chat_explainer">Публічні чати видимі всім у Nostr, і кожен - може брати в них участь. Вони чудово підходять для відкритих спільнот за певними темами. - Модерацію можна здійснювати, видаляючи публікації на відповідних relay</string> - <string name="public_chat_relays_explainer">Вкажіть від 1 до 3 relay, що розміщують цю групу. - Клієнти Nostr використовують це налаштування, щоб знати, звідки завантажувати повідомлення та куди їх надсилати.</string> + <string name="public_chat_explainer">Публічні чати видимі всім у Nostr, і кожен може брати в них участь. Вони чудово підходять для відкритих спільнот за певними темами. Модерацію можна здійснювати, видаляючи публікації на відповідних relay</string> + <string name="public_chat_relays_explainer">Вкажіть від 1 до 3 relay, що розміщують цю групу. Клієнти Nostr використовують це налаштування, щоб знати, звідки завантажувати повідомлення та куди їх надсилати.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Метадані публічного чату</string> <string name="public_chats">Публічні чати</string> @@ -2845,10 +2822,7 @@ <string name="read_only_user">Користувач лише для читання</string> <string name="record_a_message_description">Натисніть і утримуйте, щоб записати повідомлення</string> <string name="relay_chat">Чат relay</string> - <string name="relay_chat_explainer">Чати relay — це групи чатів, керовані їхнім домашнім relay. - Вони видимі всім у Nostr, і кожен може брати в них участь. - Вони чудово підходять для відкритих спільнот за певними темами. Деякі з цих груп є тимчасовими, - і тому повідомлення чату зникають з часом</string> + <string name="relay_chat_explainer">Чати relay — це групи чатів, керовані їхнім домашнім relay. Вони видимі всім у Nostr, і кожен може брати в них участь. Вони чудово підходять для відкритих спільнот за певними темами. Деякі з цих груп є тимчасовими, і тому повідомлення чату зникають з часом</string> <string name="relay_chat_title">Чати relay</string> <string name="relay_management_tab_events">Події</string> <string name="relay_management_tab_ips">IP-адреси</string> diff --git a/commonsUI/src/commonMain/composeResources/values-uz-rUZ/strings.xml b/commonsUI/src/commonMain/composeResources/values-uz-rUZ/strings.xml index 332e2bae8f..3c8e9daa2a 100644 --- a/commonsUI/src/commonMain/composeResources/values-uz-rUZ/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-uz-rUZ/strings.xml @@ -273,15 +273,8 @@ <string name="mark_all_known_as_read">Barcha ma'lumlarni o'qilgan deb belgilash</string> <string name="mark_all_new_as_read">Barcha yangilarni o'qilgan deb belgilash</string> <string name="mark_all_as_read">Barchasini o'qilgan deb belgilash</string> - <string name="account_backup_tips2_md"> ## Kalit zaxiralash va xavfsizlik maslahatlari - \n\nHisobingiz maxfiy kalit bilan himoyalangan. Kalit **nsec1** bilan boshlanadigan uzun belgilar ketma-ketligidir. Ushbu maxfiy kalitga kirish huquqiga ega bo'lgan har kim sizning nomingizdan post qo'yishi va identifikatoringizni o'zgartirishi mumkin. - \n\n- Maxfiy kalitingizni ishonmagan veb-sayt yoki dasturga **kiritmang**. - \n- Amethyst ishlab chiquvchilari maxfiy kalitingizni hech **qachon** so'ramaydi. - \n- Hisob tiklash uchun maxfiy kalitingizning xavfsiz zaxira nusxasini saqlang. Parol menejeridan foydalanishni tavsiya qilamiz. - </string> - <string name="account_backup_tips3_md"> Qo'shimcha xavfsizlik uchun kalitingizni parol bilan shifrlashingiz mumkin. Bu kalit **ncryptsec1** bilan boshlanadi va parolsiz ishlatib bo'lmaydi. - \n\nParolingizni unutsangiz, kalitingizni tiklay olmaysiz. - </string> + <string name="account_backup_tips2_md">## Kalit zaxiralash va xavfsizlik maslahatlari \n\nHisobingiz maxfiy kalit bilan himoyalangan. Kalit **nsec1** bilan boshlanadigan uzun belgilar ketma-ketligidir. Ushbu maxfiy kalitga kirish huquqiga ega bo'lgan har kim sizning nomingizdan post qo'yishi va identifikatoringizni o'zgartirishi mumkin. \n\n- Maxfiy kalitingizni ishonmagan veb-sayt yoki dasturga **kiritmang**. \n- Amethyst ishlab chiquvchilari maxfiy kalitingizni hech **qachon** so'ramaydi. \n- Hisob tiklash uchun maxfiy kalitingizning xavfsiz zaxira nusxasini saqlang. Parol menejeridan foydalanishni tavsiya qilamiz.</string> + <string name="account_backup_tips3_md">Qo'shimcha xavfsizlik uchun kalitingizni parol bilan shifrlashingiz mumkin. Bu kalit **ncryptsec1** bilan boshlanadi va parolsiz ishlatib bo'lmaydi. \n\nParolingizni unutsangiz, kalitingizni tiklay olmaysiz.</string> <string name="encrypt_and_copy_my_secret_key">Maxfiy kalitni shifrlash va nusxalash</string> <string name="badge_award_image_for">%1$s uchun nishon mukofoti rasmi</string> <string name="badge_award_image">"Nishon mukofoti rasmi</string> @@ -962,9 +955,7 @@ <string name="push_server_none_explainer">Push bildirishnomalarini o'chiradi</string> <string name="push_server_uses_app_explainer">%1$s ilovasidan foydalanadi</string> <string name="push_server_install_app">Push bildirishnoma sozlamasi</string> - <string name="push_server_install_app_description"> Push bildirishnomalarni olish uchun [Ntfy](https://ntfy.sh/) kabi [Unified Push](https://unifiedpush.org/) ni qo'llab-quvvatlaydigan ilovani o'rnating. - O'rnatgandan so'ng, Sozlamalarda foydalanmoqchi bo'lgan ilovani tanlang. - </string> + <string name="push_server_install_app_description">Push bildirishnomalarni olish uchun [Ntfy](https://ntfy.sh/) kabi [Unified Push](https://unifiedpush.org/) ni qo'llab-quvvatlaydigan ilovani o'rnating. O'rnatgandan so'ng, Sozlamalarda foydalanmoqchi bo'lgan ilovani tanlang.</string> <string name="thread_title">Ip</string> <string name="send_the_seller_a_message">Sotuvchiga xabar yuborish</string> <string name="hi_there_is_this_still_available">Salom, bu hali ham mavjudmi?</string> @@ -2012,15 +2003,7 @@ <string name="could_not_fetch_invoice_from_details">%1$s dan hisob-faktura olishda xato: %2$s</string> <string name="could_not_open_the_compressed_file">Siqilgan faylni ochib bo'lmadi</string> <string name="couldnt_find_nwc_wallets">Hamyon topilmadi</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst Nostr Wallet Connect (NWC) ni qo'llab-quvvatlaydigan hech qanday hamyon ilovasini topa olmadi. -\n\nNima qilishingiz mumkin: -\n\t1. NWC qo'llab-quvvatlashini tekshirish: Tanlagan hamyon ilovangiz Nostr Wallet Connect bilan mos kelishini ikki marta tekshiring. -\n\t2. Ulanish yaratish: Hamyon ilovangizga o'ting va yangi NWC ulanishini yarating. -\n\t3. Amethyst ga bog'lash: Hamyoningiz odatda uchta variant taqdim etadi: -\n\t\t3.1 Avtomatik bog'lash: Amethyst ni avtomatik ochish va ulash tugmasi. Agar shunday bo'lsa, ushbu tugmani bosing, Amethyst ni oching va yangi ekranda saqlash tugmasini bosing. -\n\t\t3.2 Qo'lda bog'lash: Nusxa olishingiz va to'g'ridan-to'g'ri kiritish uchun ushbu ekrandagi joylashtirish belgisini bosishingiz mumkin bo'lgan Ulanish URI si. -\n\t\t3.3 QR kod: Hamyon ushbu ekrandagi QR kod tugmasidan o'qishingiz mumkin bo'lgan QR kod yaratadi. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst Nostr Wallet Connect (NWC) ni qo'llab-quvvatlaydigan hech qanday hamyon ilovasini topa olmadi. \n\nNima qilishingiz mumkin: \n\t1. NWC qo'llab-quvvatlashini tekshirish: Tanlagan hamyon ilovangiz Nostr Wallet Connect bilan mos kelishini ikki marta tekshiring. \n\t2. Ulanish yaratish: Hamyon ilovangizga o'ting va yangi NWC ulanishini yarating. \n\t3. Amethyst ga bog'lash: Hamyoningiz odatda uchta variant taqdim etadi: \n\t\t3.1 Avtomatik bog'lash: Amethyst ni avtomatik ochish va ulash tugmasi. Agar shunday bo'lsa, ushbu tugmani bosing, Amethyst ni oching va yangi ekranda saqlash tugmasini bosing. \n\t\t3.2 Qo'lda bog'lash: Nusxa olishingiz va to'g'ridan-to'g'ri kiritish uchun ushbu ekrandagi joylashtirish belgisini bosishingiz mumkin bo'lgan Ulanish URI si. \n\t\t3.3 QR kod: Hamyon ushbu ekrandagi QR kod tugmasidan o'qishingiz mumkin bo'lgan QR kod yaratadi.</string> <string name="create">Yaratish</string> <string name="d">k</string> <string name="danger_zone">Xavfli zona</string> @@ -2686,11 +2669,8 @@ <string name="proxy_section">Proksi Relay lar</string> <string name="proxy_section_explainer">Ilovaning tasmalangizni yuklab olish uchun foydalanishi kerak bo'lgan agregator relay lar, masalan filter.nostr.wine. Bu chiqib ketish modelini almashtiradi va ilovani faqat ro'yxatlaringizdagi relay larga ulanishga majbur qiladi.</string> <string name="public_chat">Ommaviy chat</string> - <string name="public_chat_explainer">Ommaviy chatlar Nostr dagi hamma uchun ko'rinadi va har kim - ularda ishtirok eta oladi. Ular muayyan mavzular bo'yicha ochiq jamoalar uchun juda mos keladi. - Moderatsiya relay'larida postlarni o'chirish orqali boshqarilishi mumkin</string> - <string name="public_chat_relays_explainer">Ushbu guruhni joylashtiradigan 1-3 ta relay kiriting. - Nostr klientlari xabarlarni qayerdan yuklab olishini va xabarlaringizni qayerga yuborishini bilish uchun ushbu sozlamadan foydalanadi.</string> + <string name="public_chat_explainer">Ommaviy chatlar Nostr dagi hamma uchun ko'rinadi va har kim ularda ishtirok eta oladi. Ular muayyan mavzular bo'yicha ochiq jamoalar uchun juda mos keladi. Moderatsiya relay'larida postlarni o'chirish orqali boshqarilishi mumkin</string> + <string name="public_chat_relays_explainer">Ushbu guruhni joylashtiradigan 1-3 ta relay kiriting. Nostr klientlari xabarlarni qayerdan yuklab olishini va xabarlaringizni qayerga yuborishini bilish uchun ushbu sozlamadan foydalanadi.</string> <string name="public_chat_relays_title">Relay lar</string> <string name="public_chat_title">Ommaviy chat metama'lumotlari</string> <string name="public_chats">Ommaviy chatlar</string> @@ -2715,10 +2695,7 @@ <string name="read_only_user">Faqat o'qish foydalanuvchisi</string> <string name="record_a_message_description">Xabar yozib olish uchun bosib ushlab turing</string> <string name="relay_chat">Relay chati</string> - <string name="relay_chat_explainer">Relay chatlari o'z uy relay'lari tomonidan boshqariladigan chat guruhlaridir. - Ular Nostr dagi hamma uchun ko'rinadi va har kim ularda ishtirok eta oladi. - Ular muayyan mavzular bo'yicha ochiq jamoalar uchun juda mos keladi. Bu guruhlarning bir qismi vaqtinchalik bo'lib, - shuning uchun chat xabarlari vaqt o'tishi bilan yo'qoladi</string> + <string name="relay_chat_explainer">Relay chatlari o'z uy relay'lari tomonidan boshqariladigan chat guruhlaridir. Ular Nostr dagi hamma uchun ko'rinadi va har kim ularda ishtirok eta oladi. Ular muayyan mavzular bo'yicha ochiq jamoalar uchun juda mos keladi. Bu guruhlarning bir qismi vaqtinchalik bo'lib, shuning uchun chat xabarlari vaqt o'tishi bilan yo'qoladi</string> <string name="relay_chat_title">Relay chatlari</string> <string name="relay_management_tab_events">Hodisalar</string> <string name="relay_management_tab_ips">IP lar</string> diff --git a/commonsUI/src/commonMain/composeResources/values-vi-rVN/strings.xml b/commonsUI/src/commonMain/composeResources/values-vi-rVN/strings.xml index a875b48f0e..e39e556680 100644 --- a/commonsUI/src/commonMain/composeResources/values-vi-rVN/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-vi-rVN/strings.xml @@ -267,15 +267,8 @@ <string name="mark_all_known_as_read">Đánh dấu tất cả đã biết là đã đọc</string> <string name="mark_all_new_as_read">Đánh dấu tất cả mới là đã đọc</string> <string name="mark_all_as_read">Đánh dấu tất cả là đã đọc</string> - <string name="account_backup_tips2_md"> ## Mẹo sao lưu khóa và bảo mật - \n\nTài khoản của bạn được bảo mật bằng một khóa bí mật. Khóa là một chuỗi ký tự dài bắt đầu bằng **nsec1**. Bất kỳ ai có quyền truy cập vào khóa bí mật này đều có thể đăng bài và thay đổi danh tính của bạn. - \n\n- **Không** đưa khóa bí mật của bạn vào bất kỳ trang web hoặc phần mềm nào mà bạn không tin tưởng. - \n- Các nhà phát triển Amethyst sẽ **không bao giờ** yêu cầu khóa bí mật của bạn. - \n- **Hãy** giữ bản sao lưu an toàn của khóa bí mật để khôi phục tài khoản. Chúng tôi khuyến nghị sử dụng trình quản lý mật khẩu. - </string> - <string name="account_backup_tips3_md"> Để bảo mật thêm, bạn có thể mã hóa khóa của mình bằng mật khẩu. Khóa này bắt đầu bằng **ncryptsec1** và không thể sử dụng nếu không có mật khẩu của bạn. - \n\nNếu bạn mất mật khẩu, bạn sẽ không thể khôi phục khóa của mình. - </string> + <string name="account_backup_tips2_md">## Mẹo sao lưu khóa và bảo mật \n\nTài khoản của bạn được bảo mật bằng một khóa bí mật. Khóa là một chuỗi ký tự dài bắt đầu bằng **nsec1**. Bất kỳ ai có quyền truy cập vào khóa bí mật này đều có thể đăng bài và thay đổi danh tính của bạn. \n\n- **Không** đưa khóa bí mật của bạn vào bất kỳ trang web hoặc phần mềm nào mà bạn không tin tưởng. \n- Các nhà phát triển Amethyst sẽ **không bao giờ** yêu cầu khóa bí mật của bạn. \n- **Hãy** giữ bản sao lưu an toàn của khóa bí mật để khôi phục tài khoản. Chúng tôi khuyến nghị sử dụng trình quản lý mật khẩu.</string> + <string name="account_backup_tips3_md">Để bảo mật thêm, bạn có thể mã hóa khóa của mình bằng mật khẩu. Khóa này bắt đầu bằng **ncryptsec1** và không thể sử dụng nếu không có mật khẩu của bạn. \n\nNếu bạn mất mật khẩu, bạn sẽ không thể khôi phục khóa của mình.</string> <string name="encrypt_and_copy_my_secret_key">Mã hóa và sao chép khóa bí mật của tôi</string> <string name="badge_award_image_for">Hình ảnh huy hiệu được trao cho %1$s</string> <string name="badge_award_image">"Hình ảnh huy hiệu được trao</string> @@ -954,9 +947,7 @@ <string name="push_server_none_explainer">Tắt thông báo Push</string> <string name="push_server_uses_app_explainer">Sử dụng ứng dụng %1$s</string> <string name="push_server_install_app">Cài đặt thông báo Push</string> - <string name="push_server_install_app_description"> Để nhận thông báo push, hãy cài đặt ứng dụng hỗ trợ [Unified Push](https://unifiedpush.org/), chẳng hạn như [Ntfy](https://ntfy.sh/). - Sau khi cài đặt, hãy chọn ứng dụng bạn muốn sử dụng trong Cài đặt. - </string> + <string name="push_server_install_app_description">Để nhận thông báo push, hãy cài đặt ứng dụng hỗ trợ [Unified Push](https://unifiedpush.org/), chẳng hạn như [Ntfy](https://ntfy.sh/). Sau khi cài đặt, hãy chọn ứng dụng bạn muốn sử dụng trong Cài đặt.</string> <string name="thread_title">Luồng</string> <string name="send_the_seller_a_message">Gửi tin nhắn cho người bán</string> <string name="hi_there_is_this_still_available">Xin chào, mặt hàng này còn không?</string> @@ -2000,15 +1991,7 @@ <string name="could_not_fetch_invoice_from_details">Không thể tải hóa đơn từ %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Không thể mở tệp nén</string> <string name="couldnt_find_nwc_wallets">Không tìm thấy ví</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst không tìm thấy ứng dụng ví nào hỗ trợ Nostr Wallet Connect (NWC). -\n\nBạn có thể thực hiện: -\n\t1. Xác minh hỗ trợ NWC: Kiểm tra lại xem ứng dụng ví của bạn có tương thích với Nostr Wallet Connect không. -\n\t2. Tạo kết nối: Vào ứng dụng ví của bạn và tạo kết nối NWC mới. -\n\t3. Liên kết với Amethyst: Ví của bạn thường cung cấp ba tùy chọn: -\n\t\t3.1 Liên kết tự động: Nút để tự động mở và kết nối với Amethyst. Nếu có, nhấn nút đó, mở Amethyst và nhấn lưu trên màn hình mới. -\n\t\t3.2 Liên kết thủ công: URI kết nối mà bạn có thể sao chép và nhấn biểu tượng dán trên màn hình này để nhập trực tiếp. -\n\t\t3.3 Mã QR: Ví tạo mã QR mà bạn có thể đọc bằng nút mã QR trên màn hình này. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst không tìm thấy ứng dụng ví nào hỗ trợ Nostr Wallet Connect (NWC). \n\nBạn có thể thực hiện: \n\t1. Xác minh hỗ trợ NWC: Kiểm tra lại xem ứng dụng ví của bạn có tương thích với Nostr Wallet Connect không. \n\t2. Tạo kết nối: Vào ứng dụng ví của bạn và tạo kết nối NWC mới. \n\t3. Liên kết với Amethyst: Ví của bạn thường cung cấp ba tùy chọn: \n\t\t3.1 Liên kết tự động: Nút để tự động mở và kết nối với Amethyst. Nếu có, nhấn nút đó, mở Amethyst và nhấn lưu trên màn hình mới. \n\t\t3.2 Liên kết thủ công: URI kết nối mà bạn có thể sao chép và nhấn biểu tượng dán trên màn hình này để nhập trực tiếp. \n\t\t3.3 Mã QR: Ví tạo mã QR mà bạn có thể đọc bằng nút mã QR trên màn hình này.</string> <string name="create">Tạo</string> <string name="d">n</string> <string name="danger_zone">Vùng nguy hiểm</string> @@ -2642,11 +2625,8 @@ <string name="proxy_section">Relay Proxy</string> <string name="proxy_section_explainer">Các relay tổng hợp mà ứng dụng phải sử dụng để tải feed của bạn, như filter.nostr.wine. Tùy chọn này thay thế mô hình outbox và sẽ khiến ứng dụng chỉ kết nối đến các relay trong danh sách của bạn.</string> <string name="public_chat">Trò chuyện công khai</string> - <string name="public_chat_explainer">Trò chuyện công khai hiển thị với mọi người trên Nostr và bất kỳ ai - cũng có thể tham gia. Chúng rất phù hợp cho các cộng đồng mở xung quanh các chủ đề cụ thể. - Kiểm duyệt có thể được kiểm soát bằng cách xóa bài đăng trên các relay của nó</string> - <string name="public_chat_relays_explainer">Nhập từ 1–3 relay lưu trữ nhóm này. - Các ứng dụng Nostr sử dụng cài đặt này để biết nơi tải xuống tin nhắn và gửi tin nhắn của bạn.</string> + <string name="public_chat_explainer">Trò chuyện công khai hiển thị với mọi người trên Nostr và bất kỳ ai cũng có thể tham gia. Chúng rất phù hợp cho các cộng đồng mở xung quanh các chủ đề cụ thể. Kiểm duyệt có thể được kiểm soát bằng cách xóa bài đăng trên các relay của nó</string> + <string name="public_chat_relays_explainer">Nhập từ 1–3 relay lưu trữ nhóm này. Các ứng dụng Nostr sử dụng cài đặt này để biết nơi tải xuống tin nhắn và gửi tin nhắn của bạn.</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">Siêu dữ liệu trò chuyện công khai</string> <string name="public_chats">Trò chuyện công khai</string> @@ -2670,10 +2650,7 @@ <string name="read_from_relay_description">Lượng dữ liệu tính bằng byte đã nhận được từ relay này, bao gồm các bộ lọc và sự kiện</string> <string name="read_only_user">Người dùng chỉ đọc</string> <string name="record_a_message_description">Nhấn và giữ để ghi âm tin nhắn</string> - <string name="relay_chat_explainer">Relay chat là các nhóm trò chuyện được kiểm soát bởi relay chủ quản. - Chúng hiển thị với mọi người trên Nostr và bất kỳ ai cũng có thể tham gia. - Chúng rất phù hợp cho các cộng đồng mở xung quanh các chủ đề cụ thể. Một số nhóm này là tạm thời - và do đó tin nhắn trò chuyện sẽ biến mất theo thời gian</string> + <string name="relay_chat_explainer">Relay chat là các nhóm trò chuyện được kiểm soát bởi relay chủ quản. Chúng hiển thị với mọi người trên Nostr và bất kỳ ai cũng có thể tham gia. Chúng rất phù hợp cho các cộng đồng mở xung quanh các chủ đề cụ thể. Một số nhóm này là tạm thời và do đó tin nhắn trò chuyện sẽ biến mất theo thời gian</string> <string name="relay_chat_title">Relay Chat</string> <string name="relay_management_tab_events">Sự kiện</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-zh-rCN/strings.xml b/commonsUI/src/commonMain/composeResources/values-zh-rCN/strings.xml index d16f98dff4..36527eeeaf 100644 --- a/commonsUI/src/commonMain/composeResources/values-zh-rCN/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-zh-rCN/strings.xml @@ -389,15 +389,8 @@ <string name="mark_all_known_as_read">将所有已知内容标记为已读</string> <string name="mark_all_new_as_read">将所有新内容标记为已读</string> <string name="mark_all_as_read">将所有内容标记为已读</string> - <string name="account_backup_tips2_md">## 备份与安全提示 - \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 - \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 - \n- Amethyst 开发人员**永远不会**要求你提供私钥。 - \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。 - </string> - <string name="account_backup_tips3_md"> 为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 - \n\n如果你丢失密码, 你将无法恢复你的密钥。 - </string> + <string name="account_backup_tips2_md">## 备份与安全提示 \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 \n- Amethyst 开发人员**永远不会**要求你提供私钥。 \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。</string> + <string name="account_backup_tips3_md">为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 \n\n如果你丢失密码, 你将无法恢复你的密钥。</string> <string name="encrypt_and_copy_my_secret_key">加密并复制我的密钥。</string> <string name="badge_award_image_for">颁发给 %1$s 的徽章图片</string> <string name="badge_award_image">"徽章图片</string> @@ -478,7 +471,7 @@ <string name="new_community_rules_kinds_hint">轻触以允许一种类型。长按一种类型来设置每个事件的大小或每日帖子的限制。</string> <string name="new_community_rules_kind_custom_label">自定义类型</string> <string name="new_community_rules_kind_add">添加类型</string> - <string name="new_community_rules_limits_title"> %1$d 类型的限制</string> + <string name="new_community_rules_limits_title">%1$d 类型的限制</string> <string name="new_community_rules_limits_max_bytes">最大事件大小(字节)</string> <string name="new_community_rules_limits_max_per_day">每位作者每天最多发帖数</string> <string name="new_community_rules_limits_unlimited">留空为无限制</string> @@ -1356,9 +1349,7 @@ <string name="push_server_none_explainer">关闭推送通知</string> <string name="push_server_uses_app_explainer">使用应用 %1$s</string> <string name="push_server_install_app">推送通知设置</string> - <string name="push_server_install_app_description"> 若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 - 安装后,请在设置中选择你想要使用的应用程序。 - </string> + <string name="push_server_install_app_description">若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 安装后,请在设置中选择你想要使用的应用程序。</string> <string name="thread_title">主题帖</string> <string name="send_the_seller_a_message">向卖方发送消息</string> <string name="hi_there_is_this_still_available">你好,这个还能买到吗?</string> @@ -2640,15 +2631,7 @@ <string name="could_not_fetch_invoice_from_details">无法从 %1$s 获取发票:%2$s</string> <string name="could_not_open_the_compressed_file">无法打开压缩文件</string> <string name="couldnt_find_nwc_wallets">未找到钱包</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. -\n\n你可以做的事情: -\n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 -\n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 -\n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: -\n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 -\n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 -\n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。 - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. \n\n你可以做的事情: \n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 \n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 \n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: \n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 \n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 \n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。</string> <string name="create">创建</string> <string name="d">天</string> <string name="danger_zone">危险区</string> @@ -3552,11 +3535,8 @@ <string name="proxy_section">代理中继</string> <string name="proxy_section_explainer">聚合器中继是应用获取资讯源时使用的中继(例如:filter.nostr.wine),设置这个列表将覆盖信箱模型的行为,使得应用只会连接到这个列表中的中继以获取内容。</string> <string name="public_chat">公共聊天</string> - <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: - 参与这些聊天。这对特定话题建立的开放式社区来说很重要 - 通过删除中继上的帖子实现内容审核控制</string> - <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 - 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> + <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: 参与这些聊天。这对特定话题建立的开放式社区来说很重要 通过删除中继上的帖子实现内容审核控制</string> + <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> <string name="public_chat_relays_title">中继器</string> <string name="public_chat_title">公开聊天元数据</string> <string name="public_chats">公共聊天</string> @@ -3589,10 +3569,7 @@ <string name="relay_auth_search_keywords">auth authentication relay sign verify nip-42 identity</string> <string name="relay_auth_settings_title">中继身份认证</string> <string name="relay_chat">中继聊天</string> - <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 - Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 - 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, - 因此聊天信息会随着时间的推移而消失。</string> + <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, 因此聊天信息会随着时间的推移而消失。</string> <string name="relay_chat_title">中继聊天</string> <string name="relay_group_create_title">建群</string> <string name="relay_group_edit_title">编辑群</string> diff --git a/commonsUI/src/commonMain/composeResources/values-zh-rHK/strings.xml b/commonsUI/src/commonMain/composeResources/values-zh-rHK/strings.xml index 9eb6ba5bc8..4ee4682e0a 100644 --- a/commonsUI/src/commonMain/composeResources/values-zh-rHK/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-zh-rHK/strings.xml @@ -228,7 +228,7 @@ <string name="copy_user_id">複製用户ID</string> <string name="unblock_user">隱藏該用户</string> <string name="user_is_blocked_hidden">此用户被屏蔽/静音。他们的帖子被隐藏。</string> - <string name="npub_hex_username">npub,hex,用户名 </string> + <string name="npub_hex_username">npub,hex,用户名</string> <string name="clear">清除</string> <string name="app_logo">應用標誌</string> <string name="nsec_npub_hex_private_key">nsec/ npub/ hex 私鑰</string> @@ -276,15 +276,8 @@ <string name="mark_all_known_as_read">將所有已知內容標記為已讀</string> <string name="mark_all_new_as_read">將所有新內容標記為已讀</string> <string name="mark_all_as_read">將所有內容標記為已讀</string> - <string name="account_backup_tips2_md">## 备份与安全提示 - \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 - \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 - \n- Amethyst 开发人员**永远不会**要求你提供私钥。 - \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。 - </string> - <string name="account_backup_tips3_md"> 为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 - \n\n如果你丢失密码, 你将无法恢复你的密钥。 - </string> + <string name="account_backup_tips2_md">## 备份与安全提示 \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 \n- Amethyst 开发人员**永远不会**要求你提供私钥。 \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。</string> + <string name="account_backup_tips3_md">为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 \n\n如果你丢失密码, 你将无法恢复你的密钥。</string> <string name="encrypt_and_copy_my_secret_key">加密并复制我的密钥。</string> <string name="badge_award_image_for">頒發給 %1$s 的徽章圖片</string> <string name="badge_award_image">"徽章图片</string> @@ -365,7 +358,7 @@ <string name="new_community_rules_kinds_hint">轻触以允许一种类型。长按一种类型来设置每个事件的大小或每日帖子的限制。</string> <string name="new_community_rules_kind_custom_label">自定义类型</string> <string name="new_community_rules_kind_add">添加类型</string> - <string name="new_community_rules_limits_title"> %1$d 类型的限制</string> + <string name="new_community_rules_limits_title">%1$d 类型的限制</string> <string name="new_community_rules_limits_max_bytes">最大事件大小(字节)</string> <string name="new_community_rules_limits_max_per_day">每位作者每天最多发帖数</string> <string name="new_community_rules_limits_unlimited">留空为无限制</string> @@ -976,9 +969,7 @@ <string name="push_server_none_explainer">关闭推送通知</string> <string name="push_server_uses_app_explainer">使用应用 %1$s</string> <string name="push_server_install_app">推送通知设置</string> - <string name="push_server_install_app_description"> 若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 - 安装后,请在设置中选择你想要使用的应用程序。 - </string> + <string name="push_server_install_app_description">若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 安装后,请在设置中选择你想要使用的应用程序。</string> <string name="thread_title">主题帖</string> <string name="send_the_seller_a_message">向卖方发送消息</string> <string name="hi_there_is_this_still_available">你好,这个还能买到吗?</string> @@ -2037,15 +2028,7 @@ <string name="could_not_fetch_invoice_from_details">无法从 %1$s 获取发票:%2$s</string> <string name="could_not_open_the_compressed_file">无法打开压缩文件</string> <string name="couldnt_find_nwc_wallets">未找到钱包</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. -\n\n你可以做的事情: -\n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 -\n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 -\n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: -\n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 -\n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 -\n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。 - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. \n\n你可以做的事情: \n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 \n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 \n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: \n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 \n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 \n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。</string> <string name="create">創建</string> <string name="d">天</string> <string name="danger_zone">危险区</string> @@ -2700,11 +2683,8 @@ <string name="proxy_section">代理中继</string> <string name="proxy_section_explainer">聚合器中继是应用获取资讯源时使用的中继(例如:filter.nostr.wine),设置这个列表将覆盖信箱模型的行为,使得应用只会连接到这个列表中的中继以获取内容。</string> <string name="public_chat">公共聊天</string> - <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: - 参与这些聊天。这对特定话题建立的开放式社区来说很重要 - 通过删除中继上的帖子实现内容审核控制</string> - <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 - 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> + <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: 参与这些聊天。这对特定话题建立的开放式社区来说很重要 通过删除中继上的帖子实现内容审核控制</string> + <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> <string name="public_chat_relays_title">中继器</string> <string name="public_chat_title">公开聊天元数据</string> <string name="public_chats">公共聊天</string> @@ -2729,10 +2709,7 @@ <string name="read_only_user">仅读用户</string> <string name="record_a_message_description">点按以录制消息</string> <string name="relay_chat">中继聊天</string> - <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 - Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 - 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, - 因此聊天信息会随着时间的推移而消失。</string> + <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, 因此聊天信息会随着时间的推移而消失。</string> <string name="relay_chat_title">中继聊天</string> <string name="relay_management_tab_events">事件</string> <string name="relay_management_tab_ips">IP地址</string> diff --git a/commonsUI/src/commonMain/composeResources/values-zh-rSG/strings.xml b/commonsUI/src/commonMain/composeResources/values-zh-rSG/strings.xml index 4649ff00d5..0d0a9f7f9e 100644 --- a/commonsUI/src/commonMain/composeResources/values-zh-rSG/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-zh-rSG/strings.xml @@ -276,15 +276,8 @@ <string name="mark_all_known_as_read">将所有已知内容标记为已读</string> <string name="mark_all_new_as_read">将所有新内容标记为已读</string> <string name="mark_all_as_read">将所有内容标记为已读</string> - <string name="account_backup_tips2_md">## 备份与安全提示 - \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 - \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 - \n- Amethyst 开发人员**永远不会**要求你提供私钥。 - \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。 - </string> - <string name="account_backup_tips3_md"> 为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 - \n\n如果你丢失密码, 你将无法恢复你的密钥。 - </string> + <string name="account_backup_tips2_md">## 备份与安全提示 \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 \n- Amethyst 开发人员**永远不会**要求你提供私钥。 \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。</string> + <string name="account_backup_tips3_md">为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 \n\n如果你丢失密码, 你将无法恢复你的密钥。</string> <string name="encrypt_and_copy_my_secret_key">加密并复制我的密钥。</string> <string name="badge_award_image_for">颁发给 %1$s 的徽章图片</string> <string name="badge_award_image">"徽章图片</string> @@ -365,7 +358,7 @@ <string name="new_community_rules_kinds_hint">轻触以允许一种类型。长按一种类型来设置每个事件的大小或每日帖子的限制。</string> <string name="new_community_rules_kind_custom_label">自定义类型</string> <string name="new_community_rules_kind_add">添加类型</string> - <string name="new_community_rules_limits_title"> %1$d 类型的限制</string> + <string name="new_community_rules_limits_title">%1$d 类型的限制</string> <string name="new_community_rules_limits_max_bytes">最大事件大小(字节)</string> <string name="new_community_rules_limits_max_per_day">每位作者每天最多发帖数</string> <string name="new_community_rules_limits_unlimited">留空为无限制</string> @@ -976,9 +969,7 @@ <string name="push_server_none_explainer">关闭推送通知</string> <string name="push_server_uses_app_explainer">使用应用 %1$s</string> <string name="push_server_install_app">推送通知设置</string> - <string name="push_server_install_app_description"> 若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 - 安装后,请在设置中选择你想要使用的应用程序。 - </string> + <string name="push_server_install_app_description">若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 安装后,请在设置中选择你想要使用的应用程序。</string> <string name="thread_title">主题帖</string> <string name="send_the_seller_a_message">向卖方发送消息</string> <string name="hi_there_is_this_still_available">你好,这个还能买到吗?</string> @@ -2037,15 +2028,7 @@ <string name="could_not_fetch_invoice_from_details">无法从 %1$s 获取发票:%2$s</string> <string name="could_not_open_the_compressed_file">无法打开压缩文件</string> <string name="couldnt_find_nwc_wallets">未找到钱包</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. -\n\n你可以做的事情: -\n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 -\n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 -\n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: -\n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 -\n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 -\n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。 - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. \n\n你可以做的事情: \n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 \n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 \n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: \n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 \n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 \n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。</string> <string name="create">创建</string> <string name="d">天</string> <string name="danger_zone">危险区</string> @@ -2700,11 +2683,8 @@ <string name="proxy_section">代理中继</string> <string name="proxy_section_explainer">聚合器中继是应用获取资讯源时使用的中继(例如:filter.nostr.wine),设置这个列表将覆盖信箱模型的行为,使得应用只会连接到这个列表中的中继以获取内容。</string> <string name="public_chat">公共聊天</string> - <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: - 参与这些聊天。这对特定话题建立的开放式社区来说很重要 - 通过删除中继上的帖子实现内容审核控制</string> - <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 - 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> + <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: 参与这些聊天。这对特定话题建立的开放式社区来说很重要 通过删除中继上的帖子实现内容审核控制</string> + <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> <string name="public_chat_relays_title">中继器</string> <string name="public_chat_title">公开聊天元数据</string> <string name="public_chats">公共聊天</string> @@ -2729,10 +2709,7 @@ <string name="read_only_user">仅读用户</string> <string name="record_a_message_description">点按以录制消息</string> <string name="relay_chat">中继聊天</string> - <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 - Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 - 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, - 因此聊天信息会随着时间的推移而消失。</string> + <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, 因此聊天信息会随着时间的推移而消失。</string> <string name="relay_chat_title">中继聊天</string> <string name="relay_management_tab_events">事件</string> <string name="relay_management_tab_ips">IP地址</string> diff --git a/commonsUI/src/commonMain/composeResources/values-zh-rTW/strings.xml b/commonsUI/src/commonMain/composeResources/values-zh-rTW/strings.xml index 6bd229d72c..65c10efd5d 100644 --- a/commonsUI/src/commonMain/composeResources/values-zh-rTW/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-zh-rTW/strings.xml @@ -223,7 +223,7 @@ <string name="copy_user_id">複製用户ID</string> <string name="unblock_user">隱藏該用户</string> <string name="user_is_blocked_hidden">此使用者已被封鎖/靜音。其貼文已隱藏。</string> - <string name="npub_hex_username">npub,hex,用户名 </string> + <string name="npub_hex_username">npub,hex,用户名</string> <string name="clear">清除</string> <string name="app_logo">應用標誌</string> <string name="nsec_npub_hex_private_key">nsec/ npub/ hex 私鑰</string> @@ -271,15 +271,8 @@ <string name="mark_all_known_as_read">將所有已知內容標記為已讀</string> <string name="mark_all_new_as_read">將所有新內容標記為已讀</string> <string name="mark_all_as_read">將所有內容標記為已讀</string> - <string name="account_backup_tips2_md">## 備份與安全提示 - \n\n你的帳戶由一個私鑰保護。私鑰是以 **nsec1** 開頭的隨機字符串。任何擁有你的私鑰的人都可以使用你的身份發佈內容。 - \n\n- **不要**將你的私鑰添加到任何你不信任的網站或軟件,亦不要在網上公開。 - \n- Amethyst 開發人員**永遠不會**要求你提供私鑰。 - \n- **請**保留你的私鑰的安全備份,以備帳戶恢復。我們建議使用密碼管理器。 - </string> - <string name="account_backup_tips3_md"> 爲了額外的安全性,你可以用密碼加密你的密鑰。此密鑰以 **ncryptsec1** 開頭,沒有密碼就不能使用。 - \n\n如果你丟失密碼,你將無法恢復你的密鑰。 - </string> + <string name="account_backup_tips2_md">## 備份與安全提示 \n\n你的帳戶由一個私鑰保護。私鑰是以 **nsec1** 開頭的隨機字符串。任何擁有你的私鑰的人都可以使用你的身份發佈內容。 \n\n- **不要**將你的私鑰添加到任何你不信任的網站或軟件,亦不要在網上公開。 \n- Amethyst 開發人員**永遠不會**要求你提供私鑰。 \n- **請**保留你的私鑰的安全備份,以備帳戶恢復。我們建議使用密碼管理器。</string> + <string name="account_backup_tips3_md">爲了額外的安全性,你可以用密碼加密你的密鑰。此密鑰以 **ncryptsec1** 開頭,沒有密碼就不能使用。 \n\n如果你丟失密碼,你將無法恢復你的密鑰。</string> <string name="encrypt_and_copy_my_secret_key">加密並複製我的密鑰</string> <string name="badge_award_image_for">頒發給 %1$s 的徽章圖片</string> <string name="badge_award_image">"徽章獎勵圖片</string> @@ -968,9 +961,7 @@ <string name="push_server_none_explainer">關閉推送通知</string> <string name="push_server_uses_app_explainer">使用應用 %1$s</string> <string name="push_server_install_app">推送通知設置</string> - <string name="push_server_install_app_description"> 若要接收推送通知,請安裝任何支持 [Unified Push](https://unifiedpush.org/)的應用,例如 [Ntfy](https://ntfy.sh/)。 - 安裝後,請在設備中選擇你想要使用的應用程式。 - </string> + <string name="push_server_install_app_description">若要接收推送通知,請安裝任何支持 [Unified Push](https://unifiedpush.org/)的應用,例如 [Ntfy](https://ntfy.sh/)。 安裝後,請在設備中選擇你想要使用的應用程式。</string> <string name="thread_title">主題帖</string> <string name="send_the_seller_a_message">向賣方發送消息</string> <string name="hi_there_is_this_still_available">你好,這個還能買到嗎?</string> @@ -2022,7 +2013,7 @@ <string name="could_not_fetch_invoice_from_details">無法從 %1$s 取得發票:%2$s</string> <string name="could_not_open_the_compressed_file">無法打開壓縮文件</string> <string name="couldnt_find_nwc_wallets">找不到錢包</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支援 Nostr Wallet Connect (NWC) 的錢包應用程式。\n\n您可以這樣做:\n\t1. 確認 NWC 支援:請再次確認您偏好的錢包應用程式是否與 Nostr Wallet Connect 相容。\n\t2. 建立連線:前往您的錢包應用程式並建立新的 NWC 連線。\n\t3. 連結至 Amethyst:您的錢包通常會提供三種選項:\n\t\t3.1 自動連結:點擊按鈕自動開啟並連接到 Amethyst。若有此選項,請點擊該按鈕,開啟 Amethyst 並在新畫面上點擊儲存。\n\t\t3.2 手動連結:複製連線 URI,然後點擊此畫面上的貼上圖示直接輸入。\n\t\t3.3 QR 碼:錢包會產生 QR 碼,您可透過此畫面上的 QR 碼按鈕掃描。\n </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支援 Nostr Wallet Connect (NWC) 的錢包應用程式。\n\n您可以這樣做:\n\t1. 確認 NWC 支援:請再次確認您偏好的錢包應用程式是否與 Nostr Wallet Connect 相容。\n\t2. 建立連線:前往您的錢包應用程式並建立新的 NWC 連線。\n\t3. 連結至 Amethyst:您的錢包通常會提供三種選項:\n\t\t3.1 自動連結:點擊按鈕自動開啟並連接到 Amethyst。若有此選項,請點擊該按鈕,開啟 Amethyst 並在新畫面上點擊儲存。\n\t\t3.2 手動連結:複製連線 URI,然後點擊此畫面上的貼上圖示直接輸入。\n\t\t3.3 QR 碼:錢包會產生 QR 碼,您可透過此畫面上的 QR 碼按鈕掃描。\n</string> <string name="create">創建</string> <string name="d">天</string> <string name="danger_zone">危險區域</string> @@ -2664,11 +2655,8 @@ <string name="proxy_section">代理 Relay</string> <string name="proxy_section_explainer">應用程式必須用來下載您的動態的聚合器 relay,例如 filter.nostr.wine。這將取代發件匣模式,使應用程式僅連線至您清單中的 relay。</string> <string name="public_chat">公共聊天</string> - <string name="public_chat_explainer">公開聊天室對所有 Nostr 使用者可見, - 任何人皆可參與。非常適合圍繞特定主題的開放社群。 - 可透過在其 relay 上刪除貼文來進行內容管理</string> - <string name="public_chat_relays_explainer">請輸入 1–3 個託管此群組的 relay。 - Nostr 客戶端使用此設定來確認下載訊息及傳送訊息的位置。</string> + <string name="public_chat_explainer">公開聊天室對所有 Nostr 使用者可見, 任何人皆可參與。非常適合圍繞特定主題的開放社群。 可透過在其 relay 上刪除貼文來進行內容管理</string> + <string name="public_chat_relays_explainer">請輸入 1–3 個託管此群組的 relay。 Nostr 客戶端使用此設定來確認下載訊息及傳送訊息的位置。</string> <string name="public_chat_relays_title">Relay</string> <string name="public_chat_title">公開聊天室元資料</string> <string name="public_chats">公開聊天室</string> @@ -2693,10 +2681,7 @@ <string name="read_only_user">只讀用戶</string> <string name="record_a_message_description">按住以錄製訊息</string> <string name="relay_chat">Relay 聊天</string> - <string name="relay_chat_explainer">Relay 聊天室是由其所屬 relay 管控的聊天群組。 - 所有 Nostr 使用者均可看見,任何人皆可參與。 - 非常適合圍繞特定主題的開放社群。部分群組為臨時性質, - 因此聊天訊息會隨時間消失</string> + <string name="relay_chat_explainer">Relay 聊天室是由其所屬 relay 管控的聊天群組。 所有 Nostr 使用者均可看見,任何人皆可參與。 非常適合圍繞特定主題的開放社群。部分群組為臨時性質, 因此聊天訊息會隨時間消失</string> <string name="relay_chat_title">Relay 聊天室</string> <string name="relay_management_tab_events">事件</string> <string name="relay_management_tab_ips">IP</string> diff --git a/commonsUI/src/commonMain/composeResources/values-zh/strings.xml b/commonsUI/src/commonMain/composeResources/values-zh/strings.xml index 643d37c01f..17be4c460b 100644 --- a/commonsUI/src/commonMain/composeResources/values-zh/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values-zh/strings.xml @@ -337,7 +337,7 @@ <string name="new_community_rules_kinds_hint">轻触以允许一种类型。长按一种类型来设置每个事件的大小或每日帖子的限制。</string> <string name="new_community_rules_kind_custom_label">自定义类型</string> <string name="new_community_rules_kind_add">添加类型</string> - <string name="new_community_rules_limits_title"> %1$d 类型的限制</string> + <string name="new_community_rules_limits_title">%1$d 类型的限制</string> <string name="new_community_rules_limits_max_bytes">最大事件大小(字节)</string> <string name="new_community_rules_limits_max_per_day">每位作者每天最多发帖数</string> <string name="new_community_rules_limits_unlimited">留空为无限制</string> @@ -949,9 +949,7 @@ <string name="push_server_none_explainer">关闭推送通知</string> <string name="push_server_uses_app_explainer">使用应用 %1$s</string> <string name="push_server_install_app">推送通知设置</string> - <string name="push_server_install_app_description"> 若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 - 安装后,请在设置中选择你想要使用的应用程序。 - </string> + <string name="push_server_install_app_description">若要接收推送通知,请安装任何支持 [Unified Push](https://unifiedpus)的应用, 例如 [Ntfy](https://ntfy.sh/)。 安装后,请在设置中选择你想要使用的应用程序。</string> <string name="thread_title">主题帖</string> <string name="send_the_seller_a_message">向卖方发送消息</string> <string name="hi_there_is_this_still_available">你好,这个还能买到吗?</string> @@ -1801,15 +1799,8 @@ <string name="ots_explorer_api_label">Explorer API 基础URL</string> <string name="dvm_pay_invoice_from_dvm">支付来自DVM的发票</string> <string name="dvm_pay_amount_to_dvm">支付 %1$s sats 到 DVM</string> - <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips2_md" ns0:ignore="Typos">## 备份与安全提示 - \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 - \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 - \n- Amethyst 开发人员**永远不会**要求你提供私钥。 - \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。 - </string> - <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips3_md" ns0:ignore="Typos"> 为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 - \n\n如果你丢失密码, 你将无法恢复你的密钥。 - </string> + <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips2_md" ns0:ignore="Typos">## 备份与安全提示 \n\n你的帐户由一个私钥保护。私钥是以**nsec1**开头的随机字符串。任何拥有你的私钥的人都可以使用你的身份发布内容。 \n\n- **不要**将你的私钥添加到任何你不信任的网站或软件,亦不要在网上公开。 \n- Amethyst 开发人员**永远不会**要求你提供私钥。 \n- **请**保留你的私钥的安全备份,以备帐户恢复。我们建议使用密码管理器。</string> + <string xmlns:ns0="http://schemas.android.com/tools" name="account_backup_tips3_md" ns0:ignore="Typos">为了额外的安全性,你可以用密码加密你的密钥。 此密钥以 **ncryptsec1** 开头,没有密码就不能使用。 \n\n如果你丢失密码, 你将无法恢复你的密钥。</string> <string name="use_direct_url">使用直接链接</string> <string name="nsite_title">静态网站: %1$s</string> <string name="napplet_card_title">nApple: %1$s</string> @@ -2054,15 +2045,7 @@ <string name="could_not_fetch_invoice_from_details">无法从 %1$s 获取发票:%2$s</string> <string name="could_not_open_the_compressed_file">无法打开压缩文件</string> <string name="couldnt_find_nwc_wallets">未找到钱包</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. -\n\n你可以做的事情: -\n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 -\n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 -\n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: -\n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 -\n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 -\n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。 - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst 找不到任何支持 Nostr Wallet Connect (NWC) 的钱包应用. \n\n你可以做的事情: \n\t1. 验证 NWC 支持:仔细确认偏好的钱包应用和 Nostr Wallet Connect 兼容。 \n\t2. 创建连接:前往钱包应用并创建新的 NWC 连接。 \n\t3.链接到 Amethyst: 你的钱包通常会给你三个选项: \n\t\t3.1 自动链接:自动打开并连接到 Amethyst 的按钮。如果是这样, 单击那个按钮,打开 Amethyst 并在新屏上按保存。 \n\t\t3.2 手动链接: 你可以复制的连接 URI,单击这个屏幕上的粘贴图标直接输入它。 \n\t\t3.3 二维码: 钱包会创建一个你可以从这个屏幕中的二维码按钮那里读取的二维码。</string> <string name="create">创建</string> <string name="d">天</string> <string name="danger_zone">危险区</string> @@ -2745,11 +2728,8 @@ <string name="proxy_section">代理中继</string> <string name="proxy_section_explainer">聚合器中继是应用获取资讯源时使用的中继(例如:filter.nostr.wine),设置这个列表将覆盖信箱模型的行为,使得应用只会连接到这个列表中的中继以获取内容。</string> <string name="public_chat">公共聊天</string> - <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: - 参与这些聊天。这对特定话题建立的开放式社区来说很重要 - 通过删除中继上的帖子实现内容审核控制</string> - <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 - 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> + <string name="public_chat_explainer">公开聊天对所有 Nostr 用户都是可见的,任何人都可以: 参与这些聊天。这对特定话题建立的开放式社区来说很重要 通过删除中继上的帖子实现内容审核控制</string> + <string name="public_chat_relays_explainer">使用 1~3 个中继托管这个群组。 让 Nostr 客户端知道应该使用这些中继配置来发送和下载消息。</string> <string name="public_chat_relays_title">中继器</string> <string name="public_chat_title">公开聊天元数据</string> <string name="public_chats">公共聊天</string> @@ -2776,10 +2756,7 @@ <string name="read_only_user">仅读用户</string> <string name="record_a_message_description">点按以录制消息</string> <string name="relay_chat">中继聊天</string> - <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 - Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 - 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, - 因此聊天信息会随着时间的推移而消失。</string> + <string name="relay_chat_explainer">中继聊天是由聊天所属中继控制的聊天群组。 Nostr 上的每个人都可以看到这些群组,任何人都可以加入群组。 这非常适合围绕特定主题而建立的开放社区。其中一些群组是临时的, 因此聊天信息会随着时间的推移而消失。</string> <string name="relay_chat_title">中继聊天</string> <string name="relay_management_tab_events">事件</string> <string name="relay_management_tab_ips">IP地址</string> diff --git a/commonsUI/src/commonMain/composeResources/values/strings.xml b/commonsUI/src/commonMain/composeResources/values/strings.xml index f8a7c986c4..8422630d31 100644 --- a/commonsUI/src/commonMain/composeResources/values/strings.xml +++ b/commonsUI/src/commonMain/composeResources/values/strings.xml @@ -660,17 +660,8 @@ <string name="mark_all_known_as_read">Mark all Known as read</string> <string name="mark_all_new_as_read">Mark all New as read</string> <string name="mark_all_as_read">Mark all as read</string> - <string name="account_backup_tips2_md"> - ## Key Backup and Safety Tips - \n\nYour account is secured by a secret key. The key is a long sequence of characters starting with **nsec1**. Anyone who has access to this secret key can post and change your identity. - \n\n- Do **not** put your secret key in any website or software you do not trust. - \n- Amethyst developers will **never** ask for your secret key. - \n- **Do** keep a secure backup of your secret key for account recovery. We recommend using a password manager. - </string> - <string name="account_backup_tips3_md"> - For additional security, you can encrypt your key with a password. This key starts with **ncryptsec1** and cannot be used without your password. - \n\nIf you lose your password, you will not be able to recover your key. - </string> + <string name="account_backup_tips2_md">## Key Backup and Safety Tips \n\nYour account is secured by a secret key. The key is a long sequence of characters starting with **nsec1**. Anyone who has access to this secret key can post and change your identity. \n\n- Do **not** put your secret key in any website or software you do not trust. \n- Amethyst developers will **never** ask for your secret key. \n- **Do** keep a secure backup of your secret key for account recovery. We recommend using a password manager.</string> + <string name="account_backup_tips3_md">For additional security, you can encrypt your key with a password. This key starts with **ncryptsec1** and cannot be used without your password. \n\nIf you lose your password, you will not be able to recover your key.</string> <string name="backup_keys_nudge_title">Back up your keys</string> <string name="backup_keys_nudge_body">Your secret key is the only way to access this account. If you lose it, it can never be recovered. Save it somewhere safe now.</string> <string name="backup_keys_nudge_backup_now">Back up now</string> @@ -1853,10 +1844,7 @@ <string name="push_server_none_explainer">Disables Push Notifications</string> <string name="push_server_uses_app_explainer">Uses app %1$s</string> <string name="push_server_install_app">Push Notification Setup</string> - <string name="push_server_install_app_description"> - To receive push notifications, install any app that supports [Unified Push](https://unifiedpush.org/), such as [Ntfy](https://ntfy.sh/). - After installing, select the app you want to use in the Settings. - </string> + <string name="push_server_install_app_description">To receive push notifications, install any app that supports [Unified Push](https://unifiedpush.org/), such as [Ntfy](https://ntfy.sh/). After installing, select the app you want to use in the Settings.</string> <string name="thread_title">Thread</string> <string name="send_the_seller_a_message">Send the seller a message</string> <string name="hi_there_is_this_still_available">Hi there, is this still available?</string> @@ -3629,15 +3617,7 @@ <string name="could_not_fetch_invoice_from_details">Could not fetch invoice from %1$s: %2$s</string> <string name="could_not_open_the_compressed_file">Could not open the compressed file</string> <string name="couldnt_find_nwc_wallets">Wallet not found</string> - <string name="couldnt_find_nwc_wallets_description">Amethyst couldn't find any wallet apps that support Nostr Wallet Connect (NWC). -\n\nWhat you can do: -\n\t1. Verify NWC Support: Double-check that your preferred wallet app is compatible with Nostr Wallet Connect. -\n\t2. Create Connection: Go to your wallet app and create a new NWC connection. -\n\t3. Link to Amethyst: Your wallet will usually give you three options: -\n\t\t3.1 Automatic Link: A button to automatically open and connect to Amethyst. If so, click that button, open Amethyst and hit save on the new screen. -\n\t\t3.2 Manual Link: A Connection URI you can copy and click the paste icon on this screen to directly input it. -\n\t\t3.3 QR Code: The wallet creates a QR code which you can read from the QR code button in this screen. - </string> + <string name="couldnt_find_nwc_wallets_description">Amethyst couldn't find any wallet apps that support Nostr Wallet Connect (NWC). \n\nWhat you can do: \n\t1. Verify NWC Support: Double-check that your preferred wallet app is compatible with Nostr Wallet Connect. \n\t2. Create Connection: Go to your wallet app and create a new NWC connection. \n\t3. Link to Amethyst: Your wallet will usually give you three options: \n\t\t3.1 Automatic Link: A button to automatically open and connect to Amethyst. If so, click that button, open Amethyst and hit save on the new screen. \n\t\t3.2 Manual Link: A Connection URI you can copy and click the paste icon on this screen to directly input it. \n\t\t3.3 QR Code: The wallet creates a QR code which you can read from the QR code button in this screen.</string> <string name="create">Create</string> <string name="d">d</string> <string name="danger_zone">Danger Zone</string> @@ -4773,11 +4753,8 @@ <string name="proxy_section">Proxy Relays</string> <string name="proxy_section_explainer">Aggregator relays the app must use to download your feeds from, like filter.nostr.wine. This replaces the outbox model and will make the app connect to only the relays in your lists.</string> <string name="public_chat">Public Chat</string> - <string name="public_chat_explainer">Public chats are visible to everyone on Nostr and anyone - can participate on them. They are great for open communities around specific topics. - Moderation can be controlled by deleting posts on its relays</string> - <string name="public_chat_relays_explainer">Insert between 1–3 relays that host this group. - Nostr clients use this setting to know where to download messages from and send your messages to.</string> + <string name="public_chat_explainer">Public chats are visible to everyone on Nostr and anyone can participate on them. They are great for open communities around specific topics. Moderation can be controlled by deleting posts on its relays</string> + <string name="public_chat_relays_explainer">Insert between 1–3 relays that host this group. Nostr clients use this setting to know where to download messages from and send your messages to.</string> <string name="public_chat_relays_title">Relays</string> <string name="public_chat_title">Public Chat Metadata</string> <string name="public_chats">Public Chats</string> @@ -4844,10 +4821,7 @@ <string name="relay_auth_search_keywords">auth authentication login relay sign verify nip-42 identity</string> <string name="relay_auth_settings_title">Relay login</string> <string name="relay_chat">Relay Chat</string> - <string name="relay_chat_explainer">Relay chats are chat groups controlled by their home relay. - They are visible to everyone on Nostr and anyone can participate on them. - They are great for open communities around specific topics. Some of these groups are ephemeral - and thus chat messages disappear over time</string> + <string name="relay_chat_explainer">Relay chats are chat groups controlled by their home relay. They are visible to everyone on Nostr and anyone can participate on them. They are great for open communities around specific topics. Some of these groups are ephemeral and thus chat messages disappear over time</string> <string name="relay_chat_title">Relay Chats</string> <string name="relay_explain_account_data">Your own profile, settings and drafts, on your home relays.</string> <string name="relay_explain_community_chats">The relays each community publishes its planes to.</string> diff --git a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt index 8a48da7f7d..c50279a930 100644 --- a/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt +++ b/commonsUI/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/ui/components/ClickableLinks.kt @@ -87,7 +87,8 @@ fun ClickableEmail( textDecoration = if (underline) TextDecoration.Underline else null, modifier = modifier.pointerHoverIcon(PointerIcon.Hand).clickable { - runCatching { uriHandler.openUri("mailto:$display") } + // '%' is legal in an address but starts an escape in a mailto: URI (RFC 6068). + runCatching { uriHandler.openUri("mailto:" + display.replace("%", "%25")) } }, ) } diff --git a/desktopApp/plans/2026-06-21-napplet-desktop-host.md b/desktopApp/plans/2026-06-21-napplet-desktop-host.md index b7b53f4ce8..03be3b0bc8 100644 --- a/desktopApp/plans/2026-06-21-napplet-desktop-host.md +++ b/desktopApp/plans/2026-06-21-napplet-desktop-host.md @@ -19,7 +19,7 @@ doc is the map: what already works for free, what desktop must build, and the de `NappletIdentity`, `NappletRequest`/`NappletResponse`, the permissions `Ledger`/`Store`/`GrantState`, and the gateway **interfaces** (`NappletRelayGateway`, `NappletStorage`, `NappletWalletGateway`, `NappletResourceGateway`, `NappletUploadGateway`, `NappletIdentityGateway`, `NappletConsentPrompt`). -- **`NappletProtocolJson`** (`commons/jvmAndroid`) — the wire codec. Desktop's host marshals through +- **`NappletProtocolJson`** (`commons/commonMain`) — the wire codec. Desktop's host marshals through the same object, so request/result/push shapes can never drift between platforms. **The web contract (`commons/commonMain/composeResources/files/napplet/` + `NappletWebContract`)** — diff --git a/tools/strings-migrate/fix_escapes.py b/tools/strings-migrate/fix_escapes.py index 34a48089f8..65c7a7c566 100755 --- a/tools/strings-migrate/fix_escapes.py +++ b/tools/strings-migrate/fix_escapes.py @@ -19,6 +19,17 @@ It does not handle these Android conventions, so this script applies them itself \\n, \\t, \\uXXXX and \\\\ are deliberately left alone -- Compose already resolves them, and converting them here would double-process. +Whitespace is the other half. aapt collapses every whitespace run in an unquoted +value to one space and trims the ends; Compose keeps the XML text verbatim. A value +wrapped over several indented lines therefore showed on Android as one line, and in +Compose as a leading line break plus eight spaces -- which CommonMark renders as a +code block (`account_backup_tips2_md`). This script applies aapt's rule to runs that +contain a line break or tab, which only XML layout produces (a deliberate newline is +written \\n). In a translation it also trims a leading/trailing space the source +string does not have: Crowdin exports a translator's stray edge space, aapt used to +drop it, Compose would draw it (" miejsca zniknęły" beside "tematy zniknęły"). +Deliberate edge spaces (" and ") exist in the source too, and are kept. + Usage: fix_escapes.py <file-or-dir> [...] (idempotent; safe to re-run) """ import re @@ -35,9 +46,28 @@ TOOLS_ATTR = re.compile(r'\s+tools:[\w.-]+="[^"]*"') TOOLS_NS = re.compile(r'\s+xmlns:tools="[^"]*"') # a backslash escape NOT itself preceded by a backslash ANDROID_ONLY = re.compile(r"(?<!\\)\\(['\"?@])") +# A whitespace run that holds a line break or a tab: XML layout, never content. +LAYOUT_WS = re.compile(r"[ \t]*[\r\n\t][ \t\r\n]*") +STRING_NAME = re.compile(r'<string\b[^>]*\bname="([^"]+)"') -def fix_text(text: str, unwrap_quotes: bool = True) -> str: +def normalize_whitespace(text: str, source: str = None) -> str: + """Apply the aapt whitespace handling that Compose lacks. Idempotent. + + [source] is the default-locale value of the same key when [text] is a translation. + """ + if "<![CDATA[" in text: + return text + text = LAYOUT_WS.sub(lambda m: "" if m.start() == 0 or m.end() == len(text) else " ", text) + if source is not None: + if not source[:1].isspace(): + text = text.lstrip(" ") + if not source[-1:].isspace(): + text = text.rstrip(" ") + return text + + +def fix_text(text: str, unwrap_quotes: bool = True, source: str = None) -> str: """Convert one element's text. NOTE: quote-unwrapping is NOT idempotent and must run exactly once per file, at @@ -47,8 +77,9 @@ def fix_text(text: str, unwrap_quotes: bool = True) -> str: already-migrated files must therefore pass unwrap_quotes=False. """ if unwrap_quotes and len(text) >= 2 and text.startswith('"') and text.endswith('"'): - text = text[1:-1] - return ANDROID_ONLY.sub(r"\1", text) + # Quoted: aapt kept this whitespace exactly, so Compose keeps it too. + return ANDROID_ONLY.sub(r"\1", text[1:-1]) + return normalize_whitespace(ANDROID_ONLY.sub(r"\1", text), source) def strip_android_only_attrs(src: str) -> tuple: @@ -58,13 +89,31 @@ def strip_android_only_attrs(src: str) -> tuple: return out, n + m +def source_values(path: str) -> dict: + """The default-locale values beside a `values-<locale>/strings.xml`, else {}.""" + parent = os.path.dirname(os.path.abspath(path)) + if not os.path.basename(parent).startswith("values-"): + return {} + default = os.path.join(os.path.dirname(parent), "values", os.path.basename(path)) + if not os.path.exists(default): + return {} + out = {} + for m in STRING_EL.finditer(open(default, encoding="utf-8").read()): + name = STRING_NAME.match(m.group(1)) + if name: + out[name.group(1)] = m.group(2) + return out + + def fix_file(path: str, unwrap_quotes: bool = True) -> int: src = open(path, encoding="utf-8").read() + sources = source_values(path) changed = 0 def repl(m): nonlocal changed - fixed = fix_text(m.group(2), unwrap_quotes) + name = STRING_NAME.match(m.group(1)) + fixed = fix_text(m.group(2), unwrap_quotes, sources.get(name.group(1)) if name else None) if fixed != m.group(2): changed += 1 return m.group(1) + fixed + m.group(3) From e76566fba2ba3a6cdc90fb2e85c0b341b12bae10 Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 22:14:38 +0000 Subject: [PATCH 55/57] fix: address review findings on the event rename branch - Deprecated aliases for merged classes now keep their old companion API: TokenEvent.build(encryptedContent), NutzapRedemptionEvent.build(nutzap, content), SoftwareReleaseEvent.build(appId, version, channel, assets) and buildDTag resolve to deprecated forwarders instead of an incompatible builder. Covered by DeprecatedMergedEventApiTest. - CashuWalletOps.redeemNutzap now tags the nutzap sender (NIP-61 ["p", sender]), using the notifySender helper from the merge. - TokenReference.parseFromTag requires a 64-char id, like ETag, so redeemedReferences() and redeemedNutzaps() agree; drop the per-tag list allocation. - Kind 30063 search: check content is non-blank before the two NIP-82 tag scans. - SoftwareApp: findAll/findLatest release lookups no longer re-run the NIP-82 and d-tag checks that the addressables scan already applied; cheap d-tag check first. - Deprecate asSoftwareRelease(): EventFactory already builds ReleaseArtifactSetEvent, and re-wrapping another kind breaks its id/sig. - Replace inline fully-qualified names touched by the rename with imports. - nostr-expert event-hierarchy doc: describe the real NIP-51 class hierarchy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015VvJ8XpeYqBe8bYT3bJ7UD --- .../references/event-hierarchy.md | 22 ++++-- .../amethyst/ui/note/types/SoftwareApp.kt | 22 +++--- .../create/NewCalendarCollectionViewModel.kt | 2 +- .../appfunctions/AmethystAppFunctions.kt | 3 +- .../commons/cashu/ops/CashuWalletOps.kt | 6 +- .../commons/viewmodels/NestViewModel.kt | 3 +- .../vitorpamplona/amethyst/desktop/Main.kt | 3 +- .../DesktopRelaySubscriptionsCoordinator.kt | 3 +- .../desktop/ui/note/DesktopRichText.kt | 3 +- .../release/Nip82ReleaseDetector.kt | 5 ++ .../release/SoftwareReleaseEvent.kt | 32 +++++++++ .../ReleaseArtifactSetEvent.kt | 5 +- .../nip60Cashu/history/TokenReference.kt | 6 +- .../redemption/NutzapRedemptionEvent.kt | 16 +++++ .../quartz/nip61Nutzaps/token/TokenEvent.kt | 16 +++++ .../SoftwareApplicationEventTest.kt | 9 +-- .../utils/DeprecatedMergedEventApiTest.kt | 68 +++++++++++++++++++ 17 files changed, 187 insertions(+), 37 deletions(-) create mode 100644 quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/DeprecatedMergedEventApiTest.kt diff --git a/.claude/skills/nostr-expert/references/event-hierarchy.md b/.claude/skills/nostr-expert/references/event-hierarchy.md index cf6f6dfd12..a2c288c9de 100644 --- a/.claude/skills/nostr-expert/references/event-hierarchy.md +++ b/.claude/skills/nostr-expert/references/event-hierarchy.md @@ -95,14 +95,22 @@ class LongFormContentEvent(...) : BaseAddressableEvent(...) // Addressable via kind:pubkey:d-tag ``` -### Lists (kinds 10000-30004) +### Lists (NIP-51) +Each list kind is its own class under `nip51Lists/`, not a subtype of a shared list event. +Lists with private (NIP-44 encrypted) items extend one of two bases: ```kotlin -sealed class FollowSetEvent : BaseAddressableEvent { - object MuteList : FollowSetEvent(10000) - object PinList : FollowSetEvent(10001) - object BookmarkList : FollowSetEvent(10003) - // ... 18 list types total -} +// Base for sets (kind 30000-39999); some replaceable lists use it too (MuteListEvent, InterestListEvent) +abstract class PrivateTagArrayEvent(...) : BaseAddressableEvent(...) +// Replaceable lists (kind 10000-19999) +abstract class PrivateReplaceableTagArrayEvent(...) : BaseReplaceableEvent(...) + +class MuteListEvent(...) : PrivateTagArrayEvent(...) // kind 10000 +class PinListEvent(...) : BaseReplaceableEvent(...) // kind 10001, public only +class BookmarkListEvent(...) : PrivateReplaceableTagArrayEvent(...) // kind 10003 +class InterestListEvent(...) : PrivateTagArrayEvent(...) // kind 10015 +class FollowSetEvent(...) : PrivateTagArrayEvent(...) // kind 30000 follow sets +class BookmarkSetEvent(...) : PrivateTagArrayEvent(...) // kind 30003 bookmark sets +class StarterPackEvent(...) : BaseAddressableEvent(...) // kind 39089 starter packs ``` ## Event Interfaces diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt index 8067e9db46..2caa900e85 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt @@ -242,7 +242,7 @@ fun produceLatestReleaseVersion(app: SoftwareApplicationEvent): State<String?> { return flow.collectAsStateWithLifecycle(initialValue = null) } -fun findLatestNip82Release(app: SoftwareApplicationEvent): ReleaseArtifactSetEvent? = latestNip82Release(nip82ReleaseNotesFor(app), app) +fun findLatestNip82Release(app: SoftwareApplicationEvent): ReleaseArtifactSetEvent? = nip82ReleasesFor(app).maxByOrNull { it.createdAt } /** Picks the newest NIP-82 release for [app] out of an already-narrowed [notes] collection. */ private fun latestNip82Release( @@ -256,12 +256,13 @@ private fun latestNip82Release( } /** kind-30063 addressables authored by [app] whose `d` tag is `<app-id>@<version>`. */ -private fun nip82ReleaseNotesFor(app: SoftwareApplicationEvent): Set<Note> { +private fun nip82ReleasesFor(app: SoftwareApplicationEvent): List<ReleaseArtifactSetEvent> { val prefix = "${app.dTag()}@" - return LocalCache.addressables.filterIntoSet(ReleaseArtifactSetEvent.KIND, app.pubKey) { _, addr -> - val ev = addr.event ?: return@filterIntoSet false - ev.isNip82SoftwareRelease() && ev.dTag().startsWith(prefix) - } + return LocalCache.addressables + .filterIntoSet(ReleaseArtifactSetEvent.KIND, app.pubKey) { _, addr -> + val ev = addr.event ?: return@filterIntoSet false + ev.dTag().startsWith(prefix) && ev.isNip82SoftwareRelease() + }.mapNotNull { it.event as? ReleaseArtifactSetEvent } } /** @@ -270,15 +271,10 @@ private fun nip82ReleaseNotesFor(app: SoftwareApplicationEvent): Set<Note> { */ private fun Note.asNip82ReleaseFor(prefix: String): ReleaseArtifactSetEvent? { val ev = event as? ReleaseArtifactSetEvent ?: return null - return ev.takeIf { it.isNip82SoftwareRelease() && it.dTag().startsWith(prefix) } + return ev.takeIf { it.dTag().startsWith(prefix) && it.isNip82SoftwareRelease() } } -fun findAllNip82Releases(app: SoftwareApplicationEvent): List<ReleaseArtifactSetEvent> { - val prefix = "${app.dTag()}@" - return nip82ReleaseNotesFor(app) - .mapNotNull { it.asNip82ReleaseFor(prefix) } - .sortedByDescending { it.createdAt } -} +fun findAllNip82Releases(app: SoftwareApplicationEvent): List<ReleaseArtifactSetEvent> = nip82ReleasesFor(app).sortedByDescending { it.createdAt } @Composable fun AppIcon( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt index f389c7a9c1..24dace858c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/calendars/create/NewCalendarCollectionViewModel.kt @@ -62,7 +62,7 @@ class NewCalendarCollectionViewModel : ViewModel() { private var dTag: String? = null /** The full original event in edit mode; needed to publish a NIP-09 deletion. */ - private var loadedEvent: com.vitorpamplona.quartz.nip52Calendar.calendar.CalendarCollectionEvent? = null + private var loadedEvent: CalendarCollectionEvent? = null val selectedAddresses = mutableStateListOf<Address>() val availableAppointments = mutableStateOf<List<OwnedAppointmentSummary>>(emptyList()) diff --git a/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt b/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt index f14ec732b7..c865137a76 100644 --- a/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt +++ b/amethyst/src/play/java/com/vitorpamplona/amethyst/appfunctions/AmethystAppFunctions.kt @@ -62,6 +62,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.rpc.Response import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent import com.vitorpamplona.quartz.nip55AndroidSigner.client.NostrSignerExternal import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.utils.TimeUtils @@ -1787,7 +1788,7 @@ class AmethystAppFunctions { lnAddress: String, sats: Long, comment: String, - zapRequest: com.vitorpamplona.quartz.nip57Zaps.ZapRequestEvent, + zapRequest: ZapRequestEvent, ): String { // Compute the LNURL-pay endpoint so we can ask the privacy-aware // HttpClient builder for the right OkHttpClient for that host. diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt index e26b1471d1..8262ec6188 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/cashu/ops/CashuWalletOps.kt @@ -57,6 +57,7 @@ import com.vitorpamplona.quartz.nip60Cashu.wallet.CashuWalletEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.NutzapInfoEvent import com.vitorpamplona.quartz.nip61Nutzaps.info.tags.NutzapMintTag import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent +import com.vitorpamplona.quartz.nip61Nutzaps.redemption.notifySender import com.vitorpamplona.quartz.nip87Ecash.cashu.CashuMintEvent import com.vitorpamplona.quartz.nip87Ecash.recommendation.MintRecommendationEvent import com.vitorpamplona.quartz.utils.Log @@ -914,7 +915,10 @@ class CashuWalletOps( TokenReference(nutzap.id, null, TokenReference.MARKER_REDEEMED), ), signer = signer, - ) + ) { + // NIP-61: tag the nutzap sender so their client learns it was redeemed. + notifySender(EventHintBundle(nutzap)) + } val historyEvent = signer.sign(historyTemplate) publish(historyEvent) diff --git a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt index faf5d970f1..e642ed3aa5 100644 --- a/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt +++ b/commons/src/jvmAndroid/kotlin/com/vitorpamplona/amethyst/commons/viewmodels/NestViewModel.kt @@ -45,6 +45,7 @@ import com.vitorpamplona.nestsclient.connectReconnectingNestsSpeaker import com.vitorpamplona.nestsclient.transport.WebTransportFactory import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nipB1Bolt12Zaps.zap.Bolt12ZapEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.collections.immutable.ImmutableSet @@ -629,7 +630,7 @@ class NestViewModel( * same window so the visual cadence matches the React button. */ fun onZapEvent( - event: com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent, + event: ZapReceiptEvent, nowSec: Long, windowSec: Long = REACTION_WINDOW_SEC, ) { diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt index a25cac2394..ce53aa2bde 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/Main.kt @@ -166,6 +166,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer import com.vitorpamplona.quartz.nip01Core.relay.sockets.okhttp.BasicOkHttpWebSocket +import com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKeyable import com.vitorpamplona.quartz.nip17Dm.settings.DmRelayListEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent @@ -1926,7 +1927,7 @@ fun MainContent( // Process into chatroomList based on event type when (event) { - is com.vitorpamplona.quartz.nip04Dm.messages.EncryptedDmEvent -> { + is EncryptedDmEvent -> { iAccount.chatroomList.addMessage( event.chatroomKey(iAccount.pubKey), note, diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt index d72846949e..140f96d844 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/subscriptions/DesktopRelaySubscriptionsCoordinator.kt @@ -39,6 +39,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.accessories.fetchAll import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.SubscriptionListener import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl +import com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent import com.vitorpamplona.quartz.utils.Log import kotlinx.coroutines.CancellationException @@ -310,7 +311,7 @@ class DesktopRelaySubscriptionsCoordinator( ), // Zap receipts (kind 9735) targeting these notes Filter( - kinds = listOf(com.vitorpamplona.quartz.nip57Zaps.ZapReceiptEvent.KIND), + kinds = listOf(ZapReceiptEvent.KIND), tags = mapOf("e" to noteIds), ), // Reposts (kind 6) targeting these notes diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt index 257baa799b..eb45da9db6 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/note/DesktopRichText.kt @@ -84,6 +84,7 @@ import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent import com.vitorpamplona.quartz.nip19Bech32.entities.NNote import com.vitorpamplona.quartz.nip19Bech32.entities.NProfile import com.vitorpamplona.quartz.nip19Bech32.entities.NPub +import com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent import java.awt.Toolkit import java.awt.datatransfer.StringSelection import java.net.URI @@ -376,7 +377,7 @@ private fun RenderBechSegment( .NAddress .parse(segment.segmentText) } - if (naddr != null && naddr.kind == com.vitorpamplona.quartz.nip51Lists.starterPack.StarterPackEvent.KIND) { + if (naddr != null && naddr.kind == StarterPackEvent.KIND) { val followPacks = com.vitorpamplona.amethyst.desktop.ui.deck.LocalFollowPacksState.current val relayManager = com.vitorpamplona.amethyst.desktop.ui.deck.LocalRelayManager.current if (localCache != null && relayManager != null && followPacks != null) { diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt index 088ad5934a..6ed0e63cf5 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/Nip82ReleaseDetector.kt @@ -44,4 +44,9 @@ fun Event.isNip82SoftwareRelease() = * Reinterprets `this` as a [ReleaseArtifactSetEvent]. Use [isNip82SoftwareRelease] * to gate the call. */ +@Deprecated( + "EventFactory already builds kind 30063 as ReleaseArtifactSetEvent, which exposes the NIP-82 fields. " + + "Re-wrapping an event of another kind yields one whose kind no longer matches its id and signature.", + ReplaceWith("this as ReleaseArtifactSetEvent", "com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent"), +) fun Event.asSoftwareRelease() = this as? ReleaseArtifactSetEvent ?: ReleaseArtifactSetEvent(id, pubKey, createdAt, tags, content, sig) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt index 86712d1400..872b86630e 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/release/SoftwareReleaseEvent.kt @@ -20,7 +20,11 @@ */ package com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.SoftwareAssetEvent +import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder +import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent +import com.vitorpamplona.quartz.utils.TimeUtils /** * NIP-82 software releases share kind 30063 with NIP-51 release artifact sets, and @@ -32,3 +36,31 @@ import com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSet ReplaceWith("ReleaseArtifactSetEvent", "com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent"), ) typealias SoftwareReleaseEvent = ReleaseArtifactSetEvent + +/** The old `SoftwareReleaseEvent.buildDTag`. */ +@Deprecated( + "Use ReleaseArtifactSetEvent.buildSoftwareReleaseDTag.", + ReplaceWith("ReleaseArtifactSetEvent.buildSoftwareReleaseDTag(appId, version)", "com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent"), +) +fun ReleaseArtifactSetEvent.Companion.buildDTag( + appId: String, + version: String, +) = buildSoftwareReleaseDTag(appId, version) + +/** The old `SoftwareReleaseEvent.build`: a NIP-82 release, not the NIP-51 set builder. */ +@Deprecated( + "Use ReleaseArtifactSetEvent.buildSoftwareRelease.", + ReplaceWith( + "ReleaseArtifactSetEvent.buildSoftwareRelease(appId, version, channel, assets, releaseNotes, createdAt, initializer)", + "com.vitorpamplona.quartz.nip51Lists.releaseArtifactSet.ReleaseArtifactSetEvent", + ), +) +fun ReleaseArtifactSetEvent.Companion.build( + appId: String, + version: String, + channel: String, + assets: List<EventHintBundle<SoftwareAssetEvent>>, + releaseNotes: String = "", + createdAt: Long = TimeUtils.now(), + initializer: TagArrayBuilder<ReleaseArtifactSetEvent>.() -> Unit = {}, +) = buildSoftwareRelease(appId, version, channel, assets, releaseNotes, createdAt, initializer) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt index 0e8a9db9ab..8926ed25cb 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip51Lists/releaseArtifactSet/ReleaseArtifactSetEvent.kt @@ -82,8 +82,9 @@ class ReleaseArtifactSetEvent( } // Only NIP-82 releases carry release notes in `content`. A NIP-51 set may keep - // encrypted private items there, which must never reach the index. - private fun searchableReleaseNotes() = if (isNip82SoftwareRelease()) content.ifBlank { null } else null + // encrypted private items there, which must never reach the index. The blank + // check runs first so empty sets skip the two tag scans on every search. + private fun searchableReleaseNotes() = if (content.isNotBlank() && isNip82SoftwareRelease()) content else null override fun eventHints() = tags.mapNotNull(EventBookmark::parseAsHint) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/TokenReference.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/TokenReference.kt index fe16e631f2..ca73026eca 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/TokenReference.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip60Cashu/history/TokenReference.kt @@ -43,9 +43,11 @@ data class TokenReference( const val MARKER_REDEEMED = "redeemed" fun parseFromTag(tag: Array<String>): TokenReference? { - if (tag.size < 4 || tag[0] != "e") return null + // Same id rule as ETag.parse, so redeemedReferences() and the NIP-61 + // redeemedNutzaps() agree on which tags are valid. + if (tag.size < 4 || tag[0] != "e" || tag[1].length != 64) return null val marker = tag[3] - if (marker !in listOf(MARKER_CREATED, MARKER_DESTROYED, MARKER_REDEEMED)) return null + if (marker != MARKER_CREATED && marker != MARKER_DESTROYED && marker != MARKER_REDEEMED) return null return TokenReference( eventId = tag[1], relay = tag.getOrNull(2)?.ifEmpty { null }, diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt index 1382f57b12..0b2897a1cf 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/redemption/NutzapRedemptionEvent.kt @@ -44,6 +44,22 @@ fun CashuSpendingHistoryEvent.Companion.buildNutzapRedemption( initializer() } +/** The old `NutzapRedemptionEvent.build`. */ +@Deprecated( + "Use CashuSpendingHistoryEvent.buildNutzapRedemption.", + ReplaceWith( + "CashuSpendingHistoryEvent.buildNutzapRedemption(nutzap, encryptedContent, createdAt, initializer)", + "com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent", + "com.vitorpamplona.quartz.nip61Nutzaps.redemption.buildNutzapRedemption", + ), +) +fun CashuSpendingHistoryEvent.Companion.build( + nutzap: EventHintBundle<NutzapEvent>, + encryptedContent: String, + createdAt: Long = TimeUtils.now(), + initializer: TagArrayBuilder<CashuSpendingHistoryEvent>.() -> Unit = {}, +) = buildNutzapRedemption(nutzap, encryptedContent, createdAt, initializer) + /** * NIP-61 redemptions are NIP-60 spending history events (kind 7376). This used to be a * second class for the same kind, which `EventFactory` could never instantiate because diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt index 0e72608c50..e48f186e62 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip61Nutzaps/token/TokenEvent.kt @@ -20,7 +20,10 @@ */ package com.vitorpamplona.quartz.nip61Nutzaps.token +import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder +import com.vitorpamplona.quartz.nip01Core.signers.eventTemplate import com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent +import com.vitorpamplona.quartz.utils.TimeUtils /** * NIP-61 does not define its own kind 7375: redeemed nutzap proofs are stored as @@ -32,3 +35,16 @@ import com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent ReplaceWith("CashuTokenEvent", "com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent"), ) typealias TokenEvent = CashuTokenEvent + +/** The old `TokenEvent.build` took content that was already encrypted. */ +@Deprecated( + "Use CashuTokenEvent.build(tokenContent, signer), which encrypts the token content.", + ReplaceWith("CashuTokenEvent.build(tokenContent, signer)", "com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent"), +) +fun CashuTokenEvent.Companion.build( + encryptedContent: String, + createdAt: Long = TimeUtils.now(), + initializer: TagArrayBuilder<CashuTokenEvent>.() -> Unit = {}, +) = eventTemplate(KIND, encryptedContent, createdAt) { + initializer() +} diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt index 6f5166d193..39bd9b45f4 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/nip82SoftwareApps/SoftwareApplicationEventTest.kt @@ -32,7 +32,6 @@ import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.SoftwareAss import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.apkCertificateHash import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.platform import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.asset.versionCode -import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.asSoftwareRelease import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.isNip82SoftwareRelease import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.shared.Platform import com.vitorpamplona.quartz.nip01Core.core.Event @@ -137,13 +136,12 @@ class SoftwareApplicationEventTest { } @Test - fun asSoftwareRelease_exposesParsedFields() { - val event = - Event( + fun releaseArtifactSet_exposesParsedNip82Fields() { + val release = + ReleaseArtifactSetEvent( id = "0".repeat(64), pubKey = "1".repeat(64), createdAt = 0, - kind = ReleaseArtifactSetEvent.KIND, tags = arrayOf( arrayOf("d", "com.example.app@1.0.0"), @@ -154,7 +152,6 @@ class SoftwareApplicationEventTest { content = "Initial release", sig = "", ) - val release = event.asSoftwareRelease() assertEquals("com.example.app", release.appId()) assertEquals("1.0.0", release.version()) assertEquals("main", release.channel()) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/DeprecatedMergedEventApiTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/DeprecatedMergedEventApiTest.kt new file mode 100644 index 0000000000..740e463ab3 --- /dev/null +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/DeprecatedMergedEventApiTest.kt @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +@file:Suppress("DEPRECATION") + +package com.vitorpamplona.quartz.utils + +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.SoftwareReleaseEvent +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.build +import com.vitorpamplona.quartz.experimental.nip82SoftwareApps.release.buildDTag +import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle +import com.vitorpamplona.quartz.nip60Cashu.history.CashuSpendingHistoryEvent +import com.vitorpamplona.quartz.nip60Cashu.token.CashuTokenEvent +import com.vitorpamplona.quartz.nip61Nutzaps.nutzap.NutzapEvent +import com.vitorpamplona.quartz.nip61Nutzaps.redemption.NutzapRedemptionEvent +import com.vitorpamplona.quartz.nip61Nutzaps.redemption.build +import com.vitorpamplona.quartz.nip61Nutzaps.token.TokenEvent +import com.vitorpamplona.quartz.nip61Nutzaps.token.build +import kotlin.test.Test +import kotlin.test.assertEquals + +/** + * The classes merged into another class keep their old companion calls compiling + * through the deprecated typealiases. If any of these stop resolving, external + * Quartz users break on upgrade. + */ +class DeprecatedMergedEventApiTest { + private val nutzap = NutzapEvent("a".repeat(64), "1".repeat(64), 1, emptyArray(), "", "b".repeat(128)) + + @Test + fun tokenEventBuildStillTakesEncryptedContent() { + val template = TokenEvent.build("encrypted") + assertEquals(CashuTokenEvent.KIND, template.kind) + assertEquals("encrypted", template.content) + } + + @Test + fun nutzapRedemptionBuildStillAddsRedeemedAndSenderTags() { + val template = NutzapRedemptionEvent.build(EventHintBundle(nutzap), "encrypted") + assertEquals(CashuSpendingHistoryEvent.KIND, template.kind) + assertEquals(listOf("e", "p"), template.tags.map { it[0] }) + } + + @Test + fun softwareReleaseBuildStillBuildsNip82Release() { + assertEquals("app@1.0", SoftwareReleaseEvent.buildDTag("app", "1.0")) + val template = SoftwareReleaseEvent.build("app", "1.0", "main", emptyList()) + assertEquals("app@1.0", template.tags.first { it[0] == "d" }[1]) + assertEquals("1.0", template.tags.first { it[0] == "version" }[1]) + } +} From 78986bd38c79f2b1aca2e882d255d7ada94650cb Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 22:23:27 +0000 Subject: [PATCH 56/57] fix(quartz): never cut an astral character in half in the tagging d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An audit pass over this branch found the `d16` truncation unpublishable for a target whose `d` has an astral character straddling the 16th UTF-16 code unit. Reproduced end to end before fixing: - the id is hashed from the in-memory string, lone high surrogate and all, giving 7f0bec88...; - UTF-8 has no encoding for half a character, so the bytes that reach the socket carry 0x3F ("?") in its place — not U+FFFD; - a relay parsing those bytes re-hashes a4bc430d... and rejects the event as id-mismatched. The first attempt to reproduce this compared string to string and came back clean; it only shows up once the comparison is at the byte level, which is where the relay reads. `d16` now drops a dangling high surrogate, giving 15 units instead of 16. The draft calls `d16` decoration that carries no uniqueness, and dropping half a character stays deterministic, so replaceability is unaffected and `hash8` still separates the targets. Pinned two ways: the `d` holds no unpaired surrogate, and it survives a UTF-8 round trip byte for byte. Also softens the KDoc on `prefix`, which claimed two targets can never collide. `hash8` is 32 bits by the draft's own widths, so what this actually removes is the old rule's *certain* collision between any two of an author's addressable events; a birthday-bound residue remains and is upstream's to widen, not ours. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXvKXakvup4inNFfAhhr4L --- .../taggings/EventTagging.kt | 28 ++++++++++++++++--- .../decentralizedLists/AuditRegressionTest.kt | 24 ++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt index 8a45a5ef82..69d42d9956 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/taggings/EventTagging.kt @@ -43,9 +43,13 @@ import com.vitorpamplona.quartz.utils.sha256.sha256 sealed interface TaggingTarget { /** * What stands for this target in the assertion `d`: `<id8>` for a plain event, - * `<author8>-<d16>-<hash8>` for an addressable one. Two distinct targets must never produce - * the same one — kind 39999 is addressable, so taggings sharing a `d` do not sit side by - * side: the later one replaces the earlier. + * `<author8>-<d16>-<hash8>` for an addressable one. Kind 39999 is addressable, so two + * taggings that share a `d` do not sit side by side — the later one replaces the earlier. + * + * The draft fixes these widths, so the separation is 32 bits of hash rather than a guarantee: + * it removes the old rule's *certain* collision between any two of an author's events, and + * leaves a birthday-bound residue that the draft accepts. Widening it is an upstream change, + * not ours. */ val prefix: String @@ -62,7 +66,23 @@ sealed interface TaggingTarget { * An empty `dTag` yields an empty `d16`, i.e. `<author8>--<hash8>`, which the draft spells * out. A plain event uses its own id (below): that already covers the whole event. */ - override val prefix get() = "${address.pubKeyHex.take(AUTHOR_CHARS)}-${address.dTag.take(D_TAG_CHARS)}-${hash8()}" + override val prefix get() = "${address.pubKeyHex.take(AUTHOR_CHARS)}-${d16()}-${hash8()}" + + /** + * The draft counts `d16` in UTF-16 code units, which can cut an astral character in half + * and leave a dangling high surrogate. That is not survivable: the id is hashed from the + * intact char, but UTF-8 encoding the event for the wire has no encoding for half a + * character and substitutes `?`, so the relay re-hashes different bytes, gets a different + * id, and rejects the event. Verified end to end — see the test. + * + * So the half character is dropped, giving 15 units instead of 16. `d16` is decoration + * the draft says carries no uniqueness, and dropping it stays deterministic, so nothing + * that matters is lost; `hash8` still separates the targets. + */ + private fun d16(): String { + val cut = address.dTag.take(D_TAG_CHARS) + return if (cut.lastOrNull()?.isHighSurrogate() == true) cut.dropLast(1) else cut + } // Lowercase hex of the UTF-8 coordinate exactly as the `a` tag carries it: no trimming, // no normalization, no reordering. Hex.encode already emits lower case. diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt index fbf7384959..08b44cca86 100644 --- a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/experimental/decentralizedLists/AuditRegressionTest.kt @@ -183,6 +183,30 @@ class AuditRegressionTest { ) } + // Truncating at 16 UTF-16 code units can cut an astral character in half. The id is hashed + // from the intact char while the wire bytes get `?` in its place, so the relay re-hashes + // different bytes and rejects the event. The half character is dropped instead. + @Test + fun aDTagCutMidAstralCharacterDoesNotLeaveHalfACharacterInTheD() { + // 15 ASCII then an emoji: the 16th code unit is the high surrogate of the pair. + val dTag = "a".repeat(15) + "\uD83D\uDE00" + "tail" + val d = EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, dTag)), alice) + + assertFalse(d.any { it.isHighSurrogate() || it.isLowSurrogate() }, "the `d` still carries half a character: $d") + // 15 units of decoration, not 16, and hash8 is over the untruncated coordinate. + assertEquals("event-tag-awesome-tag-bbbbbbbb-${"a".repeat(15)}-15c09d87-aaaaaaaa", d) + } + + // The property the above protects: what is hashed for the id must survive UTF-8 encoding, + // or the relay recomputes a different id. Pins the bytes, not just the string. + @Test + fun theDSurvivesAUtf8RoundTripByteForByte() { + val dTag = "a".repeat(15) + "\uD83D\uDE00" + "tail" + val d = EventTagging.dTag("awesome-tag", TaggingTarget.ByAddress(Address(39999, bob, dTag)), alice) + + assertEquals(d, d.encodeToByteArray().decodeToString(), "the `d` does not survive UTF-8 encoding") + } + // A plain event is still named by its own id: it already covers the whole event, and hashing // it would only cost a round of SHA-256 per assertion built. The `e` branch is unchanged. @Test From fa7e8dba7da5eb50775f9057dabba44be9f3bd5b Mon Sep 17 00:00:00 2001 From: Claude <noreply@anthropic.com> Date: Sat, 26 Sep 2026 23:54:56 +0000 Subject: [PATCH 57/57] fix(quartz): hash empty input on Apple without crashing sha256() and sha256Into() in Sha256.apple.kt pinned the input and took addressOf(0), which throws ArrayIndexOutOfBoundsException on Kotlin/Native when the array is empty. So sha256(ByteArray(0)) crashed on iOS/macOS, and test-quartz-ios failed 7 OversizedTransferTest cases that hash "" (red on main too). CommonCrypto's CC_SHA256 accepts a null data pointer for a zero-length input, so pass null when the array is empty. Adds Sha256Test with FIPS 180-2 vectors (empty, "abc", prefix hashing through sha256Into) so every platform's actual is checked, not only through CEP-22. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015VvJ8XpeYqBe8bYT3bJ7UD --- .../quartz/utils/sha256/Sha256.apple.kt | 6 +- .../quartz/utils/sha256/Sha256Test.kt | 58 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Test.kt diff --git a/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.apple.kt b/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.apple.kt index e21f31f86d..6d9058379a 100644 --- a/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.apple.kt +++ b/quartz/src/appleMain/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256.apple.kt @@ -34,7 +34,8 @@ actual fun sha256(data: ByteArray): ByteArray { data.usePinned { inputPinned -> digest.usePinned { digestPinned -> CC_SHA256( - inputPinned.addressOf(0), + // addressOf(0) throws on an empty array; CommonCrypto accepts null for a 0-byte input. + if (data.isEmpty()) null else inputPinned.addressOf(0), data.size.convert(), digestPinned.addressOf(0), ) @@ -53,7 +54,8 @@ actual fun sha256Into( data.usePinned { inputPinned -> out.asUByteArray().usePinned { digestPinned -> CC_SHA256( - inputPinned.addressOf(0), + // addressOf(0) throws on an empty array; CommonCrypto accepts null for a 0-byte input. + if (data.isEmpty()) null else inputPinned.addressOf(0), len.convert(), digestPinned.addressOf(0), ) diff --git a/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Test.kt b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Test.kt new file mode 100644 index 0000000000..d58c57ddb0 --- /dev/null +++ b/quartz/src/commonTest/kotlin/com/vitorpamplona/quartz/utils/sha256/Sha256Test.kt @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.quartz.utils.sha256 + +import kotlin.test.Test +import kotlin.test.assertEquals + +/** + * Known-answer vectors (FIPS 180-2) for every platform's sha256 actual. The empty + * input case guards the Apple actual, which used to pin `addressOf(0)` on a + * zero-length array and throw ArrayIndexOutOfBoundsException. + */ +class Sha256Test { + private val emptyDigest = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + private val abcDigest = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" + + private fun ByteArray.hex() = joinToString("") { (it.toInt() and 0xFF).toString(16).padStart(2, '0') } + + @Test + fun hashesEmptyInput() { + assertEquals(emptyDigest, sha256(ByteArray(0)).hex()) + } + + @Test + fun hashesAbc() { + assertEquals(abcDigest, sha256("abc".encodeToByteArray()).hex()) + } + + @Test + fun sha256IntoHashesEmptyInput() { + assertEquals(emptyDigest, sha256Into(ByteArray(32), ByteArray(0)).hex()) + } + + @Test + fun sha256IntoHashesOnlyThePrefix() { + val out = ByteArray(32) + assertEquals(abcDigest, sha256Into(out, "abcdef".encodeToByteArray(), 3).hex()) + assertEquals(emptyDigest, sha256Into(out, "abcdef".encodeToByteArray(), 0).hex()) + } +}