more specific asserts, clean up logging

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent e408250ef2
commit 1603e8bfbf

@ -271,8 +271,8 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
if ([[self identityKeyPair].publicKey isEqualToData:identityKey]) { if ([[self identityKeyPair].publicKey isEqualToData:identityKey]) {
return YES; return YES;
} else { } else {
DDLogError(@"%s Wrong identity: %@ for local key: %@", DDLogError(@"%@ Wrong identity: %@ for local key: %@",
__PRETTY_FUNCTION__, self.tag,
identityKey, identityKey,
[self identityKeyPair].publicKey); [self identityKeyPair].publicKey);
OWSAssert(NO); OWSAssert(NO);
@ -289,7 +289,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
return [self isTrustedKey:identityKey forSendingToIdentity:existingIdentity]; return [self isTrustedKey:identityKey forSendingToIdentity:existingIdentity];
} }
default: { default: {
DDLogError(@"%s unexpected message direction: %ld", __PRETTY_FUNCTION__, (long)direction); DDLogError(@"%@ unexpected message direction: %ld", self.tag, (long)direction);
OWSAssert(NO); OWSAssert(NO);
return NO; return NO;
} }
@ -299,19 +299,18 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
- (BOOL)isTrustedKey:(NSData *)identityKey forSendingToIdentity:(nullable OWSRecipientIdentity *)recipientIdentity - (BOOL)isTrustedKey:(NSData *)identityKey forSendingToIdentity:(nullable OWSRecipientIdentity *)recipientIdentity
{ {
OWSAssert(identityKey != nil); OWSAssert(identityKey.length == 32);
@synchronized(self) @synchronized(self)
{ {
if (recipientIdentity == nil) { if (recipientIdentity == nil) {
DDLogDebug( DDLogDebug(@"%@ Trusting previously unknown recipient: %@", self.tag, recipientIdentity.recipientId);
@"%s Trusting on first use for recipient: %@", __PRETTY_FUNCTION__, recipientIdentity.recipientId);
return YES; return YES;
} }
OWSAssert(recipientIdentity.identityKey != nil); OWSAssert(recipientIdentity.identityKey.length == 32);
if (![recipientIdentity.identityKey isEqualToData:identityKey]) { if (![recipientIdentity.identityKey isEqualToData:identityKey]) {
DDLogWarn(@"%s key mismatch for recipient: %@", __PRETTY_FUNCTION__, recipientIdentity.recipientId); DDLogWarn(@"%@ key mismatch for recipient: %@", self.tag, recipientIdentity.recipientId);
return NO; return NO;
} }
@ -320,26 +319,18 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
BOOL isNew = (fabs([recipientIdentity.createdAt timeIntervalSinceNow]) BOOL isNew = (fabs([recipientIdentity.createdAt timeIntervalSinceNow])
< kIdentityKeyStoreNonBlockingSecondsThreshold); < kIdentityKeyStoreNonBlockingSecondsThreshold);
if (isNew) { if (isNew) {
DDLogWarn(@"%s not trusting new identity for recipient: %@", DDLogWarn(@"%@ not trusting new identity for recipient: %@", self.tag, recipientIdentity.recipientId);
__PRETTY_FUNCTION__,
recipientIdentity.recipientId);
return NO; return NO;
} else { } else {
DDLogWarn(@"%s trusting existing identity for recipient: %@", DDLogWarn(@"%@ trusting existing identity for recipient: %@", self.tag, recipientIdentity.recipientId);
__PRETTY_FUNCTION__,
recipientIdentity.recipientId);
return YES; return YES;
} }
} }
case OWSVerificationStateVerified: case OWSVerificationStateVerified:
DDLogWarn(@"%s trusting verified identity for recipient: %@", DDLogWarn(@"%@ trusting verified identity for recipient: %@", self.tag, recipientIdentity.recipientId);
__PRETTY_FUNCTION__,
recipientIdentity.recipientId);
return YES; return YES;
case OWSVerificationStateNoLongerVerified: case OWSVerificationStateNoLongerVerified:
DDLogWarn(@"%s not trusting no longer verified identity for recipient: %@", DDLogWarn(@"%@ not trusting no longer verified identity for recipient: %@", self.tag, recipientIdentity.recipientId);
__PRETTY_FUNCTION__,
recipientIdentity.recipientId);
return NO; return NO;
} }
} }

Loading…
Cancel
Save