mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-05 20:32:35 +02:00
Don't try to decrypt appData unless it is a writeable account
This commit is contained in:
@@ -64,40 +64,42 @@ class AppSpecificState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
settings.backupAppSpecificData?.let { event ->
|
if (settings.isWriteable()) {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved app specific data ${event.toJson()}")
|
settings.backupAppSpecificData?.let { event ->
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
Log.d("AccountRegisterObservers", "Loading saved app specific data ${event.toJson()}")
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
LocalCache.justConsumeMyOwnEvent(event)
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
try {
|
LocalCache.justConsumeMyOwnEvent(event)
|
||||||
val decrypted = signer.decrypt(event.content, event.pubKey)
|
try {
|
||||||
val syncedSettings = JsonMapper.mapper.readValue<AccountSyncedSettingsInternal>(decrypted)
|
val decrypted = signer.decrypt(event.content, event.pubKey)
|
||||||
settings.syncedSettings.updateFrom(syncedSettings)
|
val syncedSettings = JsonMapper.mapper.readValue<AccountSyncedSettingsInternal>(decrypted)
|
||||||
} catch (e: Throwable) {
|
settings.syncedSettings.updateFrom(syncedSettings)
|
||||||
if (e is CancellationException) throw e
|
} catch (e: Throwable) {
|
||||||
Log.w("LocalPreferences", "Error Decoding latestAppSpecificData from Preferences with value", e)
|
if (e is CancellationException) throw e
|
||||||
|
Log.w("LocalPreferences", "Error Decoding latestAppSpecificData from Preferences with value", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
scope.launch(Dispatchers.Default) {
|
scope.launch(Dispatchers.Default) {
|
||||||
Log.d("AccountRegisterObservers", "AppSpecificData Collector Start")
|
Log.d("AccountRegisterObservers", "AppSpecificData Collector Start")
|
||||||
getAppSpecificDataFlow().collect {
|
getAppSpecificDataFlow().collect {
|
||||||
try {
|
try {
|
||||||
Log.d("AccountRegisterObservers", "Updating AppSpecificData for ${signer.pubKey}")
|
Log.d("AccountRegisterObservers", "Updating AppSpecificData for ${signer.pubKey}")
|
||||||
(it.note.event as? AppSpecificDataEvent)?.let {
|
(it.note.event as? AppSpecificDataEvent)?.let {
|
||||||
val decrypted = signer.decrypt(it.content, it.pubKey)
|
val decrypted = signer.decrypt(it.content, it.pubKey)
|
||||||
try {
|
try {
|
||||||
val syncedSettings = JsonMapper.mapper.readValue<AccountSyncedSettingsInternal>(decrypted)
|
val syncedSettings = JsonMapper.mapper.readValue<AccountSyncedSettingsInternal>(decrypted)
|
||||||
settings.updateAppSpecificData(it, syncedSettings)
|
settings.updateAppSpecificData(it, syncedSettings)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
if (e is CancellationException) throw e
|
if (e is CancellationException) throw e
|
||||||
Log.w("LocalPreferences", "Error Decoding latestAppSpecificData from Preferences with value $decrypted", e)
|
Log.w("LocalPreferences", "Error Decoding latestAppSpecificData from Preferences with value $decrypted", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
if (e is CancellationException) throw e
|
||||||
|
Log.w("LocalPreferences", "Error Decrypting latestAppSpecificData from Preferences", e)
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
|
||||||
if (e is CancellationException) throw e
|
|
||||||
Log.w("LocalPreferences", "Error Decrypting latestAppSpecificData from Preferences", e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user