Ensure that deleting sessions happens on session queue
// FREEBIE
This commit is contained in:
parent
2d93b8c6ec
commit
bb38fce54e
@ -1,5 +1,6 @@
|
||||
// Created by Frederic Jacobs on 31/12/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSInvalidIdentityKeyReceivingErrorMessage.h"
|
||||
#import "OWSFingerprint.h"
|
||||
@ -78,20 +79,25 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
return;
|
||||
}
|
||||
|
||||
[[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:self.envelope.source];
|
||||
// Saving a new identity mutates the session store so it must happen on the sessionStoreQueue
|
||||
dispatch_async([OWSDispatch sessionStoreQueue], ^{
|
||||
[[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:self.envelope.source];
|
||||
|
||||
// Decrypt this and any old messages for the newly accepted key
|
||||
NSArray<TSInvalidIdentityKeyReceivingErrorMessage *> *messagesToDecrypt =
|
||||
[self.thread receivedMessagesForInvalidKey:newKey];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Decrypt this and any old messages for the newly accepted key
|
||||
NSArray<TSInvalidIdentityKeyReceivingErrorMessage *> *messagesToDecrypt =
|
||||
[self.thread receivedMessagesForInvalidKey:newKey];
|
||||
|
||||
for (TSInvalidIdentityKeyReceivingErrorMessage *errorMessage in messagesToDecrypt) {
|
||||
[[TSMessagesManager sharedManager] handleReceivedEnvelope:errorMessage.envelope];
|
||||
for (TSInvalidIdentityKeyReceivingErrorMessage *errorMessage in messagesToDecrypt) {
|
||||
[[TSMessagesManager sharedManager] handleReceivedEnvelope:errorMessage.envelope];
|
||||
|
||||
// Here we remove the existing error message because handleReceivedEnvelope will either
|
||||
// 1.) succeed and create a new successful message in the thread or...
|
||||
// 2.) fail and create a new identical error message in the thread.
|
||||
[errorMessage remove];
|
||||
}
|
||||
// Here we remove the existing error message because handleReceivedEnvelope will either
|
||||
// 1.) succeed and create a new successful message in the thread or...
|
||||
// 2.) fail and create a new identical error message in the thread.
|
||||
[errorMessage remove];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
- (NSData *)newIdentityKey
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// Created by Frederic Jacobs on 15/02/15.
|
||||
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSInvalidIdentityKeySendingErrorMessage.h"
|
||||
#import "OWSFingerprint.h"
|
||||
@ -56,7 +57,10 @@ NSString *TSInvalidRecipientKey = @"TSInvalidRecipientKey";
|
||||
|
||||
- (void)acceptNewIdentityKey
|
||||
{
|
||||
[[TSStorageManager sharedManager] saveRemoteIdentity:self.newIdentityKey recipientId:self.recipientId];
|
||||
// Saving a new identity mutates the session store so it must happen on the sessionStoreQueue
|
||||
dispatch_async([OWSDispatch sessionStoreQueue], ^{
|
||||
[[TSStorageManager sharedManager] saveRemoteIdentity:self.newIdentityKey recipientId:self.recipientId];
|
||||
});
|
||||
}
|
||||
|
||||
- (NSData *)newIdentityKey
|
||||
|
||||
@ -581,7 +581,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
}
|
||||
}];
|
||||
|
||||
[[TSStorageManager sharedManager] deleteAllSessionsForContact:endSessionEnvelope.source];
|
||||
dispatch_async([OWSDispatch sessionStoreQueue], ^{
|
||||
[[TSStorageManager sharedManager] deleteAllSessionsForContact:endSessionEnvelope.source];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)handleExpirationTimerUpdateMessageWithEnvelope:(OWSSignalServiceProtosEnvelope *)envelope
|
||||
|
||||
Loading…
Reference in New Issue
Block a user