Update Safety Number alerts to work with verification

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent c7c243cfed
commit 41a34e572b

@ -36,12 +36,12 @@ class SafetyNumberConfirmationAlert: NSObject {
*/ */
public func presentIfNecessary(recipientIds: [String], confirmationText: String, verifySeen: Bool, completion: @escaping (Bool) -> Void) -> Bool { public func presentIfNecessary(recipientIds: [String], confirmationText: String, verifySeen: Bool, completion: @escaping (Bool) -> Void) -> Bool {
guard let unverifiedIdentity = unverifiedIdentity(recipientIds: recipientIds) else { guard let noLongerVerifiedIdentity = noLongerVerifiedIdentity(recipientIds: recipientIds) else {
// No identities to confirm, no alert to present. // No identities to confirm, no alert to present.
return false return false
} }
let displayName = contactsManager.displayName(forPhoneIdentifier: unverifiedIdentity.recipientId) let displayName = contactsManager.displayName(forPhoneIdentifier: noLongerVerifiedIdentity.recipientId)
let titleFormat = NSLocalizedString("CONFIRM_SENDING_TO_CHANGED_IDENTITY_TITLE_FORMAT", let titleFormat = NSLocalizedString("CONFIRM_SENDING_TO_CHANGED_IDENTITY_TITLE_FORMAT",
comment: "Action sheet title presented when a users's SN have recently changed. Embeds {{contact's name or phone number}}") comment: "Action sheet title presented when a users's SN have recently changed. Embeds {{contact's name or phone number}}")
@ -54,10 +54,10 @@ class SafetyNumberConfirmationAlert: NSObject {
let actionSheetController = UIAlertController(title: title, message:body, preferredStyle: .actionSheet) let actionSheetController = UIAlertController(title: title, message:body, preferredStyle: .actionSheet)
let confirmAction = UIAlertAction(title: confirmationText, style: .default) { _ in let confirmAction = UIAlertAction(title: confirmationText, style: .default) { _ in
Logger.info("\(self.TAG) Confirmed identity: \(unverifiedIdentity)") Logger.info("\(self.TAG) Confirmed identity: \(noLongerVerifiedIdentity)")
OWSDispatch.sessionStoreQueue().async { OWSDispatch.sessionStoreQueue().async {
OWSIdentityManager.shared().setVerificationState(.default, identityKey: unverifiedIdentity.identityKey, recipientId: unverifiedIdentity.recipientId, sendSyncMessage: true) OWSIdentityManager.shared().setVerificationState(.default, identityKey: noLongerVerifiedIdentity.identityKey, recipientId: noLongerVerifiedIdentity.recipientId, sendSyncMessage: true)
DispatchQueue.main.async { DispatchQueue.main.async {
completion(true) completion(true)
} }
@ -66,10 +66,10 @@ class SafetyNumberConfirmationAlert: NSObject {
actionSheetController.addAction(confirmAction) actionSheetController.addAction(confirmAction)
let showSafetyNumberAction = UIAlertAction(title: NSLocalizedString("VERIFY_PRIVACY", comment: "Action sheet item"), style: .default) { _ in let showSafetyNumberAction = UIAlertAction(title: NSLocalizedString("VERIFY_PRIVACY", comment: "Action sheet item"), style: .default) { _ in
Logger.info("\(self.TAG) Opted to show Safety Number for identity: \(unverifiedIdentity)") Logger.info("\(self.TAG) Opted to show Safety Number for identity: \(noLongerVerifiedIdentity)")
self.presentSafetyNumberViewController(theirIdentityKey: unverifiedIdentity.identityKey, self.presentSafetyNumberViewController(theirIdentityKey: noLongerVerifiedIdentity.identityKey,
theirRecipientId: unverifiedIdentity.recipientId, theirRecipientId: noLongerVerifiedIdentity.recipientId,
theirDisplayName: displayName, theirDisplayName: displayName,
completion: { completion(false) }) completion: { completion(false) })
@ -94,20 +94,9 @@ class SafetyNumberConfirmationAlert: NSObject {
UIApplication.shared.frontmostViewController?.present(fingerprintViewController, animated: true, completion: completion) UIApplication.shared.frontmostViewController?.present(fingerprintViewController, animated: true, completion: completion)
} }
private func unconfirmedIdentities(recipientIds: [String]) -> [OWSRecipientIdentity] { private func noLongerVerifiedIdentity(recipientIds: [String]) -> OWSRecipientIdentity? {
// TODO: Return the _unverified_ identities. return recipientIds.flatMap {
return [] OWSIdentityManager.shared().noLongerVerifiedIdentity(recipientId: $0)
// return recipientIds.flatMap { }.first
// OWSIdentityManager.shared().unconfirmedIdentityThatShouldBlockSending(forRecipientId: $0)
// }
} }
private func unseenIdentities(recipientIds: [String]) -> [OWSRecipientIdentity] {
// TODO: Return the _unverified_ identities.
return []
// return recipientIds.flatMap {
// OWSIdentityManager.shared().unseenIdentityChange(forRecipientId: $0)
// }
}
} }

@ -470,7 +470,7 @@ protocol CallServiceObserver: class {
let newCall = SignalCall.incomingCall(localId: UUID(), remotePhoneNumber: thread.contactIdentifier(), signalingId: callId) let newCall = SignalCall.incomingCall(localId: UUID(), remotePhoneNumber: thread.contactIdentifier(), signalingId: callId)
guard OWSIdentityManager.shared().isCurrentIdentityTrustedForSending(withRecipientId: thread.contactIdentifier()) else { guard OWSIdentityManager.shared().isCurrentIdentityTrustedForSending(toRecipientId: thread.contactIdentifier()) else {
let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier()) let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier())
self.notificationsAdapter.presentRejectedCallWithUnseenIdentityChange(newCall, callerName: callerName) self.notificationsAdapter.presentRejectedCallWithUnseenIdentityChange(newCall, callerName: callerName)
return return

Loading…
Cancel
Save