From 167961a45f42cbd3cf5427abeef84cdd0b56a492 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 6 Jun 2017 19:01:12 -0400 Subject: [PATCH] restore call-back for changed identities // FREEBIE --- src/Messages/OWSIdentityManager.h | 13 +++---------- src/Messages/OWSIdentityManager.m | 27 +++++++++------------------ src/Messages/TSMessagesManager.m | 2 +- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/Messages/OWSIdentityManager.h b/src/Messages/OWSIdentityManager.h index 547be0c6d..8ca138a33 100644 --- a/src/Messages/OWSIdentityManager.h +++ b/src/Messages/OWSIdentityManager.h @@ -22,12 +22,6 @@ extern NSString *const kNSNotificationName_IdentityStateDidChange; + (instancetype)sharedManager; -/** - * @param recipientId unique stable identifier for the recipient, e.g. e164 phone number - * @returns if the recipient's current identity is trusted. - */ -- (BOOL)isCurrentIdentityTrustedForSendingToRecipientId:(NSString *)recipientId; - - (void)generateNewIdentityKey; - (nullable NSData *)identityKeyForRecipientId:(NSString *)recipientId; @@ -41,11 +35,10 @@ extern NSString *const kNSNotificationName_IdentityStateDidChange; /** * @param recipientId unique stable identifier for the recipient, e.g. e164 phone number - * @returns nil if the recipient does not exist, or if the recipient exists and is OWSVerificationStateVerified or - * OWSVerificationStateDefault else return the no longer verified identity + * @returns nil if the recipient does not exist, or is trusted for sending + * else returns the untrusted recipient. */ -- (nullable OWSRecipientIdentity *)noLongerVerifiedIdentityForRecipientId:(NSString *)recipientId - NS_SWIFT_NAME(noLongerVerifiedIdentity(recipientId:)); +- (nullable OWSRecipientIdentity *)untrustedIdentityForSendingToRecipientId:(NSString *)recipientId; @end diff --git a/src/Messages/OWSIdentityManager.m b/src/Messages/OWSIdentityManager.m index 1496e8582..9bf7a2bd0 100644 --- a/src/Messages/OWSIdentityManager.m +++ b/src/Messages/OWSIdentityManager.m @@ -78,18 +78,6 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa return self; } -- (BOOL)isCurrentIdentityTrustedForSendingToRecipientId:(NSString *)recipientId -{ - OWSAssert(recipientId.length > 0); - - @synchronized(self) - { - OWSRecipientIdentity *currentIdentity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId]; - return [self isTrustedIdentityKey:currentIdentity.identityKey - recipientId:recipientId - direction:TSMessageDirectionOutgoing]; - } -} - (void)generateNewIdentityKey { @@ -236,19 +224,22 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa } } -- (nullable OWSRecipientIdentity *)noLongerVerifiedIdentityForRecipientId:(NSString *)recipientId +- (nullable OWSRecipientIdentity *)untrustedIdentityForSendingToRecipientId:(NSString *)recipientId { OWSAssert(recipientId.length > 0); @synchronized(self) { - OWSRecipientIdentity *_Nullable identity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId]; - - if (identity && identity.verificationState == OWSVerificationStateNoLongerVerified) { - return identity; + OWSRecipientIdentity *_Nullable recipientIdentity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId]; + BOOL isTrusted = [self isTrustedIdentityKey:recipientIdentity.identityKey + recipientId:recipientId + direction:TSMessageDirectionOutgoing]; + if (isTrusted) { + return nil; + } else { + return recipientIdentity; } } - return nil; } - (void)fireIdentityStateChangeNotification diff --git a/src/Messages/TSMessagesManager.m b/src/Messages/TSMessagesManager.m index c86177639..3c135c418 100644 --- a/src/Messages/TSMessagesManager.m +++ b/src/Messages/TSMessagesManager.m @@ -202,7 +202,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (NSString *)descriptionForSyncMessage:(OWSSignalServiceProtosSyncMessage *)syncMessage { - NSMutableString *description = [[NSMutableString alloc] initWithString:@"CallMessage: "]; + NSMutableString *description = [[NSMutableString alloc] initWithString:@""]; if (syncMessage.hasSent) { [description appendString:@"SentTranscript"]; } else if (syncMessage.hasRequest) {