diff --git a/Signal/src/UserInterface/Strings.swift b/Signal/src/UserInterface/Strings.swift index b457b18ba..358a9314c 100644 --- a/Signal/src/UserInterface/Strings.swift +++ b/Signal/src/UserInterface/Strings.swift @@ -29,3 +29,8 @@ import Foundation 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}}") } + +@objc class SafetyNumberStrings: NSObject { + static let confirmSendButton = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_SEND_ACTION", + comment: "button title to confirm sending to a recipient whose safety number recently changed") +} diff --git a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m index ce78559e0..b744b7528 100644 --- a/Signal/src/ViewControllers/ConversationView/MessagesViewController.m +++ b/Signal/src/ViewControllers/ConversationView/MessagesViewController.m @@ -1167,8 +1167,7 @@ typedef enum : NSUInteger { * NO if there were no unconfirmed identities */ - (BOOL)showSafetyNumberConfirmationIfNecessaryWithConfirmationText:(NSString *)confirmationText - completion: - (void (^)(BOOL didConfirmedIdentity))completionHandler + completion:(void (^)(BOOL didConfirmIdentity))completionHandler { return [SafetyNumberConfirmationAlert presentAlertIfNecessaryWithRecipientIds:self.thread.recipientIdentifiers confirmationText:confirmationText @@ -1283,10 +1282,7 @@ typedef enum : NSUInteger { } BOOL didShowSNAlert = - [self showSafetyNumberConfirmationIfNecessaryWithConfirmationText: - NSLocalizedString(@"SAFETY_NUMBER_CHANGED_CONFIRM_SEND_ACTION", - @"button title to confirm sending to a recipient whose " - @"safety number recently changed") + [self showSafetyNumberConfirmationIfNecessaryWithConfirmationText:[SafetyNumberStrings confirmSendButton] completion:^(BOOL didConfirmIdentity) { if (didConfirmIdentity) { [weakSelf didPressSendButton:button @@ -3704,10 +3700,7 @@ typedef enum : NSUInteger { } BOOL didShowSNAlert = [self - showSafetyNumberConfirmationIfNecessaryWithConfirmationText: - NSLocalizedString(@"SAFETY_NUMBER_CHANGED_CONFIRM_SEND_ACTION", - @"button title to confirm sending to a recipient whose " - @"safety number recently changed") + showSafetyNumberConfirmationIfNecessaryWithConfirmationText:[SafetyNumberStrings confirmSendButton] completion:^(BOOL didConfirmIdentity) { if (didConfirmIdentity) { [weakSelf diff --git a/Signal/src/ViewControllers/SendExternalFileViewController.m b/Signal/src/ViewControllers/SendExternalFileViewController.m index d075d89cf..a1bf00c47 100644 --- a/Signal/src/ViewControllers/SendExternalFileViewController.m +++ b/Signal/src/ViewControllers/SendExternalFileViewController.m @@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SendExternalFileViewController () +@property (nonatomic, readonly) OWSContactsManager *contactsManager; @property (nonatomic, readonly) OWSMessageSender *messageSender; @end @@ -35,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN { [super loadView]; + _contactsManager = [Environment getCurrent].contactsManager; _messageSender = [Environment getCurrent].messageSender; self.title = NSLocalizedString(@"SEND_EXTERNAL_FILE_VIEW_TITLE", @"Title for the 'send external file' view."); @@ -47,6 +49,21 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.attachment); OWSAssert(thread); + __weak typeof(self) weakSelf = self; + + BOOL didShowSNAlert = + [SafetyNumberConfirmationAlert presentAlertIfNecessaryWithRecipientIds:thread.recipientIdentifiers + confirmationText:[SafetyNumberStrings confirmSendButton] + contactsManager:self.contactsManager + completion:^(BOOL didConfirm) { + if (didConfirm) { + [weakSelf threadWasSelected:thread]; + } + }]; + if (didShowSNAlert) { + return; + } + [ThreadUtil sendMessageWithAttachment:self.attachment inThread:thread messageSender:self.messageSender]; [Environment messageThreadId:thread.uniqueId];