From 39fc30ec172f6cab430d4d1ac47ba949a57cfd70 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Mon, 6 Nov 2023 09:13:04 +0100 Subject: [PATCH] fix(neon): Fix push notification decryption Signed-off-by: jld3103 --- packages/neon/neon/lib/src/models/push_notification.dart | 3 ++- packages/neon/neon/lib/src/utils/push_utils.dart | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/neon/neon/lib/src/models/push_notification.dart b/packages/neon/neon/lib/src/models/push_notification.dart index 83dede8b..96d07497 100644 --- a/packages/neon/neon/lib/src/models/push_notification.dart +++ b/packages/neon/neon/lib/src/models/push_notification.dart @@ -38,12 +38,13 @@ class PushNotification { /// Use [PushNotification.fromJson] when the [subject] is not encrypted. factory PushNotification.fromEncrypted( final Map json, + final String accountID, final RSAPrivateKey privateKey, ) { final subject = decryptPushNotificationSubject(privateKey, json[_subjectKey] as String); return PushNotification( - accountID: json[_accountIDKey] as String, + accountID: accountID, priority: json[_priorityKey] as String, type: json[_typeKey] as String, subject: subject, diff --git a/packages/neon/neon/lib/src/utils/push_utils.dart b/packages/neon/neon/lib/src/utils/push_utils.dart index 2f71828f..3e8ba2d9 100644 --- a/packages/neon/neon/lib/src/utils/push_utils.dart +++ b/packages/neon/neon/lib/src/utils/push_utils.dart @@ -79,7 +79,11 @@ class PushUtils { final keypair = loadRSAKeypair(); for (final message in Uri(query: utf8.decode(messages)).queryParameters.values) { final data = json.decode(message) as Map; - final pushNotification = PushNotification.fromEncrypted(data, keypair.privateKey); + final pushNotification = PushNotification.fromEncrypted( + data, + instance, + keypair.privateKey, + ); if (pushNotification.subject.delete ?? false) { await localNotificationsPlugin.cancel(_getNotificationID(instance, pushNotification));