Merge branch 'mkirk/reject-unseen-id-calls'

pull/1/head
Michael Kirk 9 years ago
commit 05a96008e3

@ -40,6 +40,14 @@ extern NSString *const TSStorageManagerTrustedKeysCollection;
*/
- (nullable OWSRecipientIdentity *)unconfirmedIdentityThatShouldBlockSendingForRecipientId:(NSString *)recipientId;
/**
* @param recipientId unique stable identifier for the recipient, e.g. e164 phone number
* @returns nil if the recipient's current id has been seen, or if it's the users first key
* else returns the unseen identity
*
*/
- (nullable OWSRecipientIdentity *)unseenIdentityChangeForRecipientId:(NSString *)recipientId;
- (void)generateNewIdentityKey;
- (nullable NSData *)identityKeyForRecipientId:(NSString *)recipientId;
- (void)removeIdentityKeyForRecipient:(NSString *)receipientId;

@ -199,6 +199,31 @@ const NSTimeInterval kIdentityKeyStoreNonBlockingSecondsThreshold = 5.0;
}
}
- (nullable OWSRecipientIdentity *)unseenIdentityChangeForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId != nil);
@synchronized([[self class] sharedIdentityKeyLock])
{
OWSRecipientIdentity *currentIdentity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId];
if (currentIdentity == nil) {
// No preexisting key, Trust On First Use
return nil;
}
if (currentIdentity.isFirstKnownKey) {
return nil;
}
if (currentIdentity.wasSeen) {
return nil;
}
// identity not yet seen
return currentIdentity;
}
}
- (BOOL)isTrustedKey:(NSData *)identityKey forSendingToIdentity:(nullable OWSRecipientIdentity *)recipientIdentity
{
OWSAssert(identityKey != nil);

Loading…
Cancel
Save