restore "confirm and callback" functionality

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 146031e4d5
commit 1127553041

@ -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)
}
}

@ -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

@ -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}}")
}

@ -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];
});
}],
]]];

@ -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
}

@ -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

@ -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;
}

@ -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;

@ -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 ]

@ -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 */

Loading…
Cancel
Save