mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-06 18:22:55 +02:00
Adds a try/catch when receiving notifications to make sure it gets decrypted by the correct account.
This commit is contained in:
@@ -58,7 +58,11 @@ class EventNotificationConsumer(
|
|||||||
LocalPreferences.allSavedAccounts().forEach {
|
LocalPreferences.allSavedAccounts().forEach {
|
||||||
if (it.hasPrivKey || it.loggedInWithExternalSigner) {
|
if (it.hasPrivKey || it.loggedInWithExternalSigner) {
|
||||||
LocalPreferences.loadCurrentAccountFromEncryptedStorage(it.npub)?.let { acc ->
|
LocalPreferences.loadCurrentAccountFromEncryptedStorage(it.npub)?.let { acc ->
|
||||||
|
try {
|
||||||
consumeIfMatchesAccount(event, acc)
|
consumeIfMatchesAccount(event, acc)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Not for this account.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,7 +75,7 @@ class EventNotificationConsumer(
|
|||||||
pushWrappedEvent.cachedGift(account.signer) { notificationEvent ->
|
pushWrappedEvent.cachedGift(account.signer) { notificationEvent ->
|
||||||
val consumed = LocalCache.hasConsumed(notificationEvent)
|
val consumed = LocalCache.hasConsumed(notificationEvent)
|
||||||
val verified = LocalCache.justVerify(notificationEvent)
|
val verified = LocalCache.justVerify(notificationEvent)
|
||||||
Log.d("EventNotificationConsumer", "New Notification Arrived for ${account.userProfile().toBestDisplayName()} consumed= $consumed && verified= $verified")
|
Log.d("EventNotificationConsumer", "New Notification ${notificationEvent.kind} ${notificationEvent.id} Arrived for ${account.userProfile().toBestDisplayName()} consumed= $consumed && verified= $verified")
|
||||||
if (!consumed && verified) {
|
if (!consumed && verified) {
|
||||||
Log.d("EventNotificationConsumer", "New Notification was verified")
|
Log.d("EventNotificationConsumer", "New Notification was verified")
|
||||||
unwrapAndConsume(notificationEvent, account) { innerEvent ->
|
unwrapAndConsume(notificationEvent, account) { innerEvent ->
|
||||||
|
Reference in New Issue
Block a user