diff --git a/Signal/src/UserInterface/Notifications/CallNotificationsAdapter.swift b/Signal/src/UserInterface/Notifications/CallNotificationsAdapter.swift index 8d0d95a40..f6e03dbbf 100644 --- a/Signal/src/UserInterface/Notifications/CallNotificationsAdapter.swift +++ b/Signal/src/UserInterface/Notifications/CallNotificationsAdapter.swift @@ -36,8 +36,8 @@ class CallNotificationsAdapter: NSObject { adaptee.presentMissedCall(call, callerName: callerName) } - func presentRejectedCallWithUnseenIdentityChange(_ call: SignalCall, callerName: String) { + func presentRejectedCallWithIdentityChange(_ call: SignalCall, callerName: String) { Logger.debug("\(TAG) in \(#function)") - adaptee.presentRejectedCallWithUnseenIdentityChange(call, callerName: callerName) + adaptee.presentRejectedCallWithIdentityChange(call, callerName: callerName) } } diff --git a/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift b/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift index 676a47179..66c9a1cbd 100644 --- a/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift +++ b/Signal/src/UserInterface/Notifications/UserNotificationsAdaptee.swift @@ -134,7 +134,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot center.add(request) } - func presentRejectedCallWithUnseenIdentityChange(_ call: SignalCall, callerName: String) { + func presentRejectedCallWithIdentityChange(_ call: SignalCall, callerName: String) { Logger.debug("\(TAG) \(#function)") let content = UNMutableNotificationContent() @@ -144,11 +144,11 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot let notificationBody = { () -> String in switch previewType { case .noNameNoPreview: - return CallStrings.rejectedCallWithUnseenIdentityChangeNotificationBody + return CallStrings.rejectedCallWithIdentityChangeNotificationBody case .nameNoPreview, .namePreview: return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled() - ? CallStrings.rejectedCallWithUnseenIdentityChangeNotificationBodyWithoutCallerName - : String(format: CallStrings.rejectedCallWithUnseenIdentityChangeNotificationBodyWithCallerName, callerName)) + ? CallStrings.rejectedCallWithIdentityChangeNotificationBodyWithoutCallerName + : String(format: CallStrings.rejectedCallWithIdentityChangeNotificationBodyWithCallerName, callerName)) }}() content.body = notificationBody diff --git a/Signal/src/UserInterface/Strings.swift b/Signal/src/UserInterface/Strings.swift index 60ef70c61..b457b18ba 100644 --- a/Signal/src/UserInterface/Strings.swift +++ b/Signal/src/UserInterface/Strings.swift @@ -13,22 +13,19 @@ import Foundation static let confirmAndCallButtonTitle = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION", comment: "alert button text to confirm placing an outgoing call after the recipients Safety Number has changed.") + static let callBackAlertTitle = NSLocalizedString("CALL_USER_ALERT_TITLE", comment: "Title for alert offering to call a user.") + static let callBackAlertMessageFormat = NSLocalizedString("CALL_USER_ALERT_MESSAGE_FORMAT", comment: "Message format for alert offering to call a user. Embeds {{the user's display name or phone number}}.") + static let callBackAlertCallButton = NSLocalizedString("CALL_USER_ALERT_CALL_BUTTON", comment: "Label for call button for alert offering to call a user.") + // MARK: Notification actions static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action") - static let confirmIdentityAndCallBackButtonTitle = NSLocalizedString("CONFIRM_IDENTITY_AND_CALLBACK_BUTTON_TITLE", comment: "notification action, confirming that it's OK to proceed calling after a caller's Safety Number has changed") static let showThreadButtonTitle = NSLocalizedString("SHOW_THREAD_BUTTON_TITLE", comment: "notification action") // MARK: Missed Call Notification - static let missedCallNotificationBody = NSLocalizedString("MISSED_CALL", comment: "notification title") - static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITH_NAME", comment: "notification title. Embeds {{Caller's Name}}") - static let missedCallNotificationBodyWithoutCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITHOUT_NAME", comment: "notification title.") + static let missedCallNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL", comment: "notification title") + static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITH_NAME", comment: "notification title. Embeds {{caller's name or phone number}}") - // MARK: Missed with Unseen identity Notification - static let rejectedCallWithUnseenIdentityChangeNotificationBody = NSLocalizedString("MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY", comment: "notification action") - static let rejectedCallWithUnseenIdentityChangeNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY_WITHOUT_CALLER_NAME", comment: "notification action") - static let rejectedCallWithUnseenIdentityChangeNotificationBodyWithCallerName = NSLocalizedString("MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY_WITH_CALLER_NAME", comment: "notification action") - - static let callBackAlertTitle = NSLocalizedString("CALL_USER_ALERT_TITLE", comment: "Title for alert offering to call a user.") - static let callBackAlertMessageFormat = NSLocalizedString("CALL_USER_ALERT_MESSAGE_FORMAT", comment: "Message format for alert offering to call a user. Embeds {{the user's display name or phone number}}.") - static let callBackAlertCallButton = NSLocalizedString("CALL_USER_ALERT_CALL_BUTTON", comment: "Label for call button for alert offering to call a user.") + // MARK: Missed with changed identity notification (for not previously verified identity) + static let missedCallWithIdentityChangeNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITHOUT_CALLER_NAME", comment: "notification title") + static let missedCallWithIdentityChangeNotificationBodyWithCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME", comment: "notification title. Embeds {{caller's name or phone number}}") } diff --git a/Signal/src/ViewControllers/DebugUI/DebugUITableViewController.m b/Signal/src/ViewControllers/DebugUI/DebugUITableViewController.m index 013f09cb6..2983f1d5b 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUITableViewController.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUITableViewController.m @@ -146,8 +146,8 @@ NS_ASSUME_NONNULL_BEGIN dispatch_get_main_queue(), ^{ [[Environment getCurrent].callService.notificationsAdapter - presentRejectedCallWithUnseenIdentityChange:call - callerName:thread.name]; + presentRejectedCallWithIdentityChange:call + callerName:thread.name]; }); }], ]]]; diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index 3d704da66..7d34663ff 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -472,7 +472,7 @@ protocol CallServiceObserver: class { guard OWSIdentityManager.shared().isCurrentIdentityTrustedForSending(toRecipientId: thread.contactIdentifier()) else { let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier()) - self.notificationsAdapter.presentRejectedCallWithUnseenIdentityChange(newCall, callerName: callerName) + self.notificationsAdapter.presentRejectedCallWithIdentityChange(newCall, callerName: callerName) return } diff --git a/Signal/src/call/UserInterface/OWSCallNotificationsAdaptee.h b/Signal/src/call/UserInterface/OWSCallNotificationsAdaptee.h index d80a09319..e63f4bb98 100644 --- a/Signal/src/call/UserInterface/OWSCallNotificationsAdaptee.h +++ b/Signal/src/call/UserInterface/OWSCallNotificationsAdaptee.h @@ -12,9 +12,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)presentMissedCall:(SignalCall *)call callerName:(NSString *)callerName; -- (void)presentRejectedCallWithUnseenIdentityChange:(SignalCall *)call - callerName:(NSString *)callerName - NS_SWIFT_NAME(presentRejectedCallWithUnseenIdentityChange(_:callerName:)); +- (void)presentRejectedCallWithIdentityChange:(SignalCall *)call + callerName:(NSString *)callerName + NS_SWIFT_NAME(presentRejectedCallWithIdentityChange(_:callerName +:)); @end diff --git a/Signal/src/environment/NotificationsManager.m b/Signal/src/environment/NotificationsManager.m index 2e72eadbc..040221bb2 100644 --- a/Signal/src/environment/NotificationsManager.m +++ b/Signal/src/environment/NotificationsManager.m @@ -113,13 +113,13 @@ [self presentNotification:notification identifier:localCallId]; } -- (void)presentRejectedCallWithUnseenIdentityChange:(SignalCall *)call callerName:(NSString *)callerName +- (void)presentRejectedCallWithIdentityChange:(SignalCall *)call callerName:(NSString *)callerName { TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber]; OWSAssert(thread != nil); UILocalNotification *notification = [UILocalNotification new]; - notification.category = PushManagerCategoriesRejectedCallFromUnseenIdentityChange; + notification.category = PushManagerCategoriesRejectedCallFromIdentityChange; NSString *localCallId = call.localId.UUIDString; notification.userInfo = @{ PushManagerUserInfoKeysLocalCallId : localCallId, @@ -130,17 +130,16 @@ NSString *alertMessage; switch (self.notificationPreviewType) { case NotificationNoNameNoPreview: { - alertMessage = [CallStrings rejectedCallWithUnseenIdentityChangeNotificationBody]; + alertMessage = [CallStrings rejectedCallWithIdentityChangeNotificationBody]; break; } case NotificationNameNoPreview: case NotificationNamePreview: { alertMessage = (([UIDevice currentDevice].supportsCallKit && [[Environment getCurrent].preferences isCallKitPrivacyEnabled]) - ? [CallStrings rejectedCallWithUnseenIdentityChangeNotificationBodyWithoutCallerName] + ? [CallStrings rejectedCallWithIdentityChangeNotificationBodyWithoutCallerName] : [NSString - stringWithFormat:[CallStrings - rejectedCallWithUnseenIdentityChangeNotificationBodyWithCallerName], + stringWithFormat:[CallStrings rejectedCallWithIdentityChangeNotificationBodyWithCallerName], callerName]); break; } diff --git a/Signal/src/network/PushManager.h b/Signal/src/network/PushManager.h index c3a93c33d..bb5fe32ba 100644 --- a/Signal/src/network/PushManager.h +++ b/Signal/src/network/PushManager.h @@ -22,12 +22,12 @@ extern NSString *const Signal_Message_MarkAsRead_Identifier; extern NSString *const PushManagerCategoriesIncomingCall; extern NSString *const PushManagerCategoriesMissedCall; -extern NSString *const PushManagerCategoriesRejectedCallFromUnseenIdentityChange; +extern NSString *const PushManagerCategoriesRejectedCallFromIdentityChange; extern NSString *const PushManagerActionsAcceptCall; extern NSString *const PushManagerActionsDeclineCall; extern NSString *const PushManagerActionsCallBack; -extern NSString *const PushManagerActionsConfirmIdentityAndCallBack; +extern NSString *const PushManagerActionsIgnoreIdentityChangeAndCallBack; extern NSString *const PushManagerActionsShowThread; extern NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId; diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index be5ffd931..390fe79c8 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -209,13 +209,23 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe [self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId]; completionHandler(); - } else if ([identifier isEqualToString:PushManagerActionsConfirmIdentityAndCallBack]) { + } else if ([identifier isEqualToString:PushManagerActionsIgnoreIdentityChangeAndCallBack]) { NSString *recipientId = notification.userInfo[PushManagerUserInfoKeysCallBackSignalRecipientId]; if (!recipientId) { DDLogError(@"%@ missing call back id", self.tag); return; } + NSData *currentIdentityKey = [[OWSIdentityManager sharedManager] identityKeyForRecipientId:recipientId]; + if (currentIdentityKey.length <= 0) { + OWSFail(@"%@ currentIdentityKey unexpectedly empty for recipient: %@", self.tag, recipientId); + completionHandler(); + return; + } + [[OWSIdentityManager sharedManager] setVerificationState:OWSVerificationStateDefault + identityKey:currentIdentityKey + recipientId:recipientId + sendSyncMessage:YES]; [self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId]; completionHandler(); } else if ([identifier isEqualToString:PushManagerActionsShowThread]) { @@ -354,13 +364,14 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe NSString *const PushManagerCategoriesIncomingCall = @"PushManagerCategoriesIncomingCall"; NSString *const PushManagerCategoriesMissedCall = @"PushManagerCategoriesMissedCall"; -NSString *const PushManagerCategoriesRejectedCallFromUnseenIdentityChange = - @"PushManagerCategoriesRejectedCallFromUnseenIdentityChange"; +NSString *const PushManagerCategoriesRejectedCallFromIdentityChange = + @"PushManagerCategoriesRejectedCallFromIdentityChange"; NSString *const PushManagerActionsAcceptCall = @"PushManagerActionsAcceptCall"; NSString *const PushManagerActionsDeclineCall = @"PushManagerActionsDeclineCall"; NSString *const PushManagerActionsCallBack = @"PushManagerActionsCallBack"; -NSString *const PushManagerActionsConfirmIdentityAndCallBack = @"PushManagerActionsConfirmIdentityAndCallBack"; +NSString *const PushManagerActionsIgnoreIdentityChangeAndCallBack = + @"PushManagerActionsIgnoreIdentityChangeAndCallBack"; NSString *const PushManagerActionsShowThread = @"PushManagerActionsShowThread"; NSString *const PushManagerUserInfoKeysLocalCallId = @"PushManagerUserInfoKeysLocalCallId"; @@ -410,7 +421,7 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager - (UIUserNotificationCategory *)signalRejectedCallWithUnseenIdentityChangeCategory { UIMutableUserNotificationAction *confirmAndCallBackAction = [UIMutableUserNotificationAction new]; - confirmAndCallBackAction.identifier = PushManagerActionsConfirmIdentityAndCallBack; + confirmAndCallBackAction.identifier = PushManagerActionsIgnoreIdentityChangeAndCallBack; confirmAndCallBackAction.title = [CallStrings confirmIdentityAndCallBackButtonTitle]; confirmAndCallBackAction.activationMode = UIUserNotificationActivationModeForeground; confirmAndCallBackAction.destructive = NO; @@ -424,7 +435,7 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager showThreadAction.authenticationRequired = YES; UIMutableUserNotificationCategory *rejectedCallCategory = [UIMutableUserNotificationCategory new]; - rejectedCallCategory.identifier = PushManagerCategoriesRejectedCallFromUnseenIdentityChange; + rejectedCallCategory.identifier = PushManagerCategoriesRejectedCallFromIdentityChange; [rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ] forContext:UIUserNotificationActionContextMinimal]; [rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ] diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index ae0c3bfb3..92b5fdb0c 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -241,9 +241,6 @@ /* No comment provided by engineer. */ "CONFIRM_ACCOUNT_DESTRUCTION_TITLE" = "Are you sure you want to delete your account?"; -/* notification action, confirming that it's OK to proceed calling after a caller's Safety Number has changed */ -"CONFIRM_IDENTITY_AND_CALLBACK_BUTTON_TITLE" = "Confirm and Call Back"; - /* Alert body */ "CONFIRM_LEAVE_GROUP_DESCRIPTION" = "You will no longer be able to send or receive messages in this group."; @@ -745,14 +742,11 @@ /* notification title */ "MISSED_CALL" = "Missed call"; -/* notification action */ -"MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY" = "Missed call because the caller's safety number changed."; - -/* notification action */ -"MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY_WITH_CALLER_NAME" = "Missed call from %@ because their safety number changed."; +/* notification title. Embeds {{caller's name or phone number}} */ +"MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME" = "Missed call because the caller's safety number changed."; -/* notification action */ -"MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY_WITHOUT_CALLER_NAME" = "Missed call because the caller's safety number changed."; +/* notification title */ +"MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITHOUT_CALLER_NAME" = "Missed call because the caller's safety number changed."; /* Alert body Alert body when camera is not authorized */ @@ -762,12 +756,9 @@ Alert title when camera is not authorized */ "MISSING_CAMERA_PERMISSION_TITLE" = "Signal needs to access your camera."; -/* notification title. Embeds {{Caller's Name}} */ +/* notification title. Embeds {{caller's name or phone number}} */ "MSGVIEW_MISSED_CALL_WITH_NAME" = "Missed call from %@."; -/* notification title. */ -"MSGVIEW_MISSED_CALL_WITHOUT_NAME" = "Missed call from Signal User."; - /* No comment provided by engineer. */ "MSGVIEW_RECEIVED_CALL" = "You received a call from %@."; @@ -1075,7 +1066,7 @@ /* button title to confirm adding a recipient to a group when their safety number has recently changed */ "SAFETY_NUMBER_CHANGED_CONFIRM_ADD_TO_GROUP_ACTION" = "Add to Group Anyway"; -/* button title to confirm calling a recipient whose safety number recently changed */ +/* alert button text to confirm placing an outgoing call after the recipients Safety Number has changed. */ "SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION" = "Call Anyway"; /* button title to confirm sending to a recipient whose safety number recently changed */