Browse Source

Merge pull request #1118 from nextcloud/fix/neon/push-notification-decryption

pull/1120/head
Kate 1 year ago committed by GitHub
parent
commit
d446f99890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      packages/neon/neon/lib/src/models/push_notification.dart
  2. 6
      packages/neon/neon/lib/src/utils/push_utils.dart

3
packages/neon/neon/lib/src/models/push_notification.dart

@ -38,12 +38,13 @@ class PushNotification {
/// Use [PushNotification.fromJson] when the [subject] is not encrypted. /// Use [PushNotification.fromJson] when the [subject] is not encrypted.
factory PushNotification.fromEncrypted( factory PushNotification.fromEncrypted(
final Map<String, dynamic> json, final Map<String, dynamic> json,
final String accountID,
final RSAPrivateKey privateKey, final RSAPrivateKey privateKey,
) { ) {
final subject = decryptPushNotificationSubject(privateKey, json[_subjectKey] as String); final subject = decryptPushNotificationSubject(privateKey, json[_subjectKey] as String);
return PushNotification( return PushNotification(
accountID: json[_accountIDKey] as String, accountID: accountID,
priority: json[_priorityKey] as String, priority: json[_priorityKey] as String,
type: json[_typeKey] as String, type: json[_typeKey] as String,
subject: subject, subject: subject,

6
packages/neon/neon/lib/src/utils/push_utils.dart

@ -79,7 +79,11 @@ class PushUtils {
final keypair = loadRSAKeypair(); final keypair = loadRSAKeypair();
for (final message in Uri(query: utf8.decode(messages)).queryParameters.values) { for (final message in Uri(query: utf8.decode(messages)).queryParameters.values) {
final data = json.decode(message) as Map<String, dynamic>; 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) { if (pushNotification.subject.delete ?? false) {
await localNotificationsPlugin.cancel(_getNotificationID(instance, pushNotification)); await localNotificationsPlugin.cancel(_getNotificationID(instance, pushNotification));

Loading…
Cancel
Save