Add logs when encrypt or decrypt fails

This commit is contained in:
greenart7c3
2025-02-19 11:13:31 -03:00
parent 25ff233dbd
commit 4b848a9d21
3 changed files with 51 additions and 0 deletions
@@ -7,6 +7,7 @@ import android.database.MatrixCursor
import android.net.Uri
import android.util.Log
import com.greenart7c3.nostrsigner.database.HistoryEntity
import com.greenart7c3.nostrsigner.database.LogEntity
import com.greenart7c3.nostrsigner.models.SignerType
import com.greenart7c3.nostrsigner.models.kindToNip
import com.greenart7c3.nostrsigner.service.AmberUtils
@@ -310,6 +311,17 @@ class SignerProvider : ContentProvider() {
pubkey,
) ?: "Could not decrypt the message"
} catch (e: Exception) {
scope.launch {
database.applicationDao().insertLog(
LogEntity(
0,
sortOrder ?: packageName,
uri.toString().replace("content://$appId.", ""),
e.message ?: "Could not decrypt the message",
System.currentTimeMillis(),
),
)
}
"Could not decrypt the message"
}
@@ -322,6 +322,18 @@ object BunkerRequestUtils {
pubKey,
) ?: "Could not decrypt the message"
} catch (e: Exception) {
NostrSigner.getInstance().applicationIOScope.launch {
val database = NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub())
database.applicationDao().insertLog(
LogEntity(
0,
bunkerRequest.localKey,
type.toString(),
e.message ?: "Could not decrypt the message",
System.currentTimeMillis(),
),
)
}
"Could not decrypt the message"
}
@@ -18,6 +18,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
import com.greenart7c3.nostrsigner.database.LogEntity
import com.greenart7c3.nostrsigner.models.Account
import com.greenart7c3.nostrsigner.models.BunkerRequest
import com.greenart7c3.nostrsigner.models.CompressionType
@@ -32,6 +34,7 @@ import com.vitorpamplona.quartz.encoders.toNpub
import com.vitorpamplona.quartz.events.Event
import fr.acinq.secp256k1.Hex
import java.net.URLDecoder
import kotlinx.coroutines.launch
data class BunkerMetadata(
val name: String,
@@ -199,6 +202,18 @@ object IntentUtils {
pubKey,
) ?: "Could not decrypt the message"
} catch (e: Exception) {
NostrSigner.getInstance().applicationIOScope.launch {
val database = NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub())
database.applicationDao().insertLog(
LogEntity(
0,
packageName ?: "",
type.toString(),
e.message ?: "Could not decrypt the message",
System.currentTimeMillis(),
),
)
}
"Could not decrypt the message"
}
@@ -376,6 +391,18 @@ object IntentUtils {
pubKey,
) ?: "Could not decrypt the message"
} catch (e: Exception) {
NostrSigner.getInstance().applicationIOScope.launch {
val database = NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub())
database.applicationDao().insertLog(
LogEntity(
0,
packageName ?: "",
type.toString(),
e.message ?: "Could not decrypt the message",
System.currentTimeMillis(),
),
)
}
"Could not decrypt the message"
}