Skip to content

Commit

Permalink
Merge pull request #1118 from nextcloud/fix/neon/push-notification-de…
Browse files Browse the repository at this point in the history
…cryption
  • Loading branch information
provokateurin authored Nov 6, 2023
2 parents c127cab + 39fc30e commit d446f99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/neon/neon/lib/src/models/push_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ class PushNotification {
/// Use [PushNotification.fromJson] when the [subject] is not encrypted.
factory PushNotification.fromEncrypted(
final Map<String, dynamic> 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,
Expand Down
6 changes: 5 additions & 1 deletion packages/neon/neon/lib/src/utils/push_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic>;
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));
Expand Down

0 comments on commit d446f99

Please sign in to comment.