Merge branch 'charlesmchen/refineVerification'

pull/1/head
Matthew Chen 8 years ago
commit 13a119b4b6

@ -6,6 +6,7 @@
#import "OWSReadTracking.h"
#import "TSDatabaseView.h"
#import "TSIncomingMessage.h"
#import "TSInfoMessage.h"
#import "TSInteraction.h"
#import "TSInvalidIdentityKeyReceivingErrorMessage.h"
#import "TSOutgoingMessage.h"
@ -266,6 +267,17 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)updateWithLastMessage:(TSInteraction *)lastMessage transaction:(YapDatabaseReadWriteTransaction *)transaction {
OWSAssert(lastMessage);
OWSAssert(transaction);
if (lastMessage.isDynamicInteraction) {
DDLogDebug(@"%@ not updating lastMessage for thread: %@ dynamic interaction: %@",
self.tag,
self,
lastMessage.debugDescription);
return;
}
NSDate *lastMessageDate = [lastMessage dateForSorting];
if ([lastMessage isKindOfClass:[TSErrorMessage class]]) {
@ -273,12 +285,21 @@ NS_ASSUME_NONNULL_BEGIN
if (errorMessage.errorType == TSErrorMessageNonBlockingIdentityChange) {
// Otherwise all group threads with the recipient will percolate to the top of the inbox, even though
// there was no meaningful interaction.
DDLogDebug(@"%@ not updating lastMessage for thread:%@ nonblocking identity change: %@",
DDLogDebug(@"%@ not updating lastMessage for thread: %@ nonblocking identity change: %@",
self.tag,
self,
errorMessage.debugDescription);
return;
}
} else if ([lastMessage isKindOfClass:[TSInfoMessage class]]) {
TSInfoMessage *infoMessage = (TSInfoMessage *)lastMessage;
if (infoMessage.messageType == TSInfoMessageVerificationStateChange) {
DDLogDebug(@"%@ not updating lastMessage for thread: %@ verification state change: %@",
self.tag,
self,
infoMessage.debugDescription);
return;
}
}
if (!_lastMessageDate || [lastMessageDate timeIntervalSinceDate:self.lastMessageDate] > 0) {

@ -192,12 +192,6 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
// Cancel any pending verification state sync messages for this recipient.
[self clearSyncMessageForRecipientId:recipientId];
if (existingIdentity.verificationState != verificationState) {
[self saveChangeMessagesForRecipientId:recipientId
verificationState:verificationState
isLocalChange:YES];
}
[self fireIdentityStateChangeNotification];
return YES;
@ -245,12 +239,12 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
[self enqueueSyncMessageForVerificationState:verificationState
identityKey:identityKey
recipientId:recipientId];
[self saveChangeMessagesForRecipientId:recipientId verificationState:verificationState isLocalChange:YES];
} else {
// Cancel any pending verification state sync messages for this recipient.
[self clearSyncMessageForRecipientId:recipientId];
}
[self saveChangeMessagesForRecipientId:recipientId verificationState:verificationState isLocalChange:YES];
}
[self fireIdentityStateChangeNotification];
@ -712,6 +706,8 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
}
}
// We only want to create change messages in response to user activity,
// on any of their devices.
- (void)saveChangeMessagesForRecipientId:(NSString *)recipientId
verificationState:(OWSVerificationState)verificationState
isLocalChange:(BOOL)isLocalChange

Loading…
Cancel
Save