diff --git a/keyserver/src/push/crypto.js b/keyserver/src/push/crypto.js --- a/keyserver/src/push/crypto.js +++ b/keyserver/src/push/crypto.js @@ -44,7 +44,6 @@ encryptedNotification.payload.blobHolder = blobHolder; } - encryptedNotification.payload.keyserverID = notification.payload.keyserverID; encryptedNotification.topic = notification.topic; encryptedNotification.sound = notification.aps.sound; encryptedNotification.pushType = 'alert'; @@ -112,8 +111,10 @@ encryptedNotification.payload = { ...encryptedNotification.payload, ...notification.payload, - encryptionFailed: 1, + ...senderDeviceDescriptor, + encryptionFailed: '1', }; + return { notification: encryptedNotification, payloadSizeExceeded: notificationSizeValidator diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java --- a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java +++ b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java @@ -132,10 +132,17 @@ Log.w("COMM", "Notification decryption failure.", e); return; } - } else if ("1".equals(message.getData().get(ENCRYPTION_FAILED_KEY))) { - Log.w( - "COMM", - "Received unencrypted notification for client with existing olm session for notifications"); + } + + if (StaffUtils.isStaffRelease() && + "1".equals(message.getData().get(ENCRYPTION_FAILED_KEY))) { + displayErrorMessageNotification( + "Notification encryption failed on the keyserver. Please investigate", + "Unencrypted notification", + null); + } + if ("1".equals(message.getData().get(ENCRYPTION_FAILED_KEY))) { + Log.w("COMM", "Received erroneously unencrypted notification."); } String rescind = message.getData().get(RESCIND_KEY); diff --git a/native/ios/NotificationService/NotificationService.mm b/native/ios/NotificationService/NotificationService.mm --- a/native/ios/NotificationService/NotificationService.mm +++ b/native/ios/NotificationService/NotificationService.mm @@ -13,7 +13,7 @@ NSString *const backgroundNotificationTypeKey = @"backgroundNotifType"; NSString *const messageInfosKey = @"messageInfos"; NSString *const encryptedPayloadKey = @"encryptedPayload"; -NSString *const encryptionFailureKey = @"encryptionFailure"; +NSString *const encryptionFailedKey = @"encryptionFailed"; NSString *const collapseIDKey = @"collapseID"; NSString *const keyserverIDKey = @"keyserverID"; NSString *const blobHashKey = @"blobHash"; @@ -140,14 +140,20 @@ withPublicUserContent:[[UNNotificationContent alloc] init]]; return; } - } else if ([self shouldAlertUnencryptedNotification:content.userInfo]) { - // In future this will be replaced by notification content - // modification for DEV environment and staff members - comm::Logger::log("NSE: Received erroneously unencrypted notitication."); } NSMutableArray *errorMessages = [[NSMutableArray alloc] init]; + if (comm::StaffUtils::isStaffRelease() && + [self shouldAlertUnencryptedNotification:content.userInfo]) { + [errorMessages addObject: + @"Notification encryption failed on the keyserver. " + @"Please investigate!"]; + } + if ([self shouldAlertUnencryptedNotification:content.userInfo]) { + comm::Logger::log("NSE: Received erroneously unencrypted notification."); + } + // Step 2: notification persistence in a temporary storage std::string persistErrorMessage; try { @@ -594,8 +600,8 @@ } - (BOOL)shouldAlertUnencryptedNotification:(NSDictionary *)payload { - return payload[encryptionFailureKey] && - [payload[encryptionFailureKey] isEqualToNumber:@(1)]; + return payload[encryptionFailedKey] && + [payload[encryptionFailedKey] isEqualToString:@"1"]; } - (std::unique_ptr) diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp --- a/web/cpp/SQLiteQueryExecutorBindings.cpp +++ b/web/cpp/SQLiteQueryExecutorBindings.cpp @@ -312,8 +312,7 @@ "removeInboundP2PMessages", &SQLiteQueryExecutor::removeInboundP2PMessages) .function( - "getRelatedMessagesWeb", - &SQLiteQueryExecutor::getRelatedMessagesWeb); + "getRelatedMessagesWeb", &SQLiteQueryExecutor::getRelatedMessagesWeb); } } // namespace comm