From 6715e76c9919dda6bf6acca1dd01e5870e598d81 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 8 Jun 2017 08:37:28 -0400 Subject: [PATCH] Prefer archiving, to deleting old sessions for better handling of out of order decryption. // FREEBIE --- Podfile | 8 ++++---- Podfile.lock | 16 +++++----------- Signal/src/Jobs/SessionResetJob.swift | 2 +- Signal/src/ProfileFetcherJob.swift | 4 ++-- .../DebugUI/DebugUISessionState.m | 9 ++++++++- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Podfile b/Podfile index 55d7dcd08..4de5fa3a0 100644 --- a/Podfile +++ b/Podfile @@ -3,10 +3,10 @@ source 'https://github.com/CocoaPods/Specs.git' target 'Signal' do pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' - pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' - #pod 'AxolotlKit', path: '../SignalProtocolKit' - pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' - #pod 'SignalServiceKit', path: '../SignalServiceKit' + #pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' + pod 'AxolotlKit', path: '../SignalProtocolKit' + #pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' + pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL' pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu' #pod 'JSQMessagesViewController' path: '../JSQMessagesViewController' diff --git a/Podfile.lock b/Podfile.lock index cbacb03af..eb9ebbc47 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -109,35 +109,29 @@ PODS: - YapDatabase/SQLCipher/Core DEPENDENCIES: - - AxolotlKit (from `https://github.com/WhisperSystems/SignalProtocolKit.git`) + - AxolotlKit (from `../SignalProtocolKit`) - JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController.git`, branch `mkirk/position-edit-menu`) - OpenSSL - PureLayout - Reachability - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) + - SignalServiceKit (from `../SignalServiceKit`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) EXTERNAL SOURCES: AxolotlKit: - :git: https://github.com/WhisperSystems/SignalProtocolKit.git + :path: "../SignalProtocolKit" JSQMessagesViewController: :branch: mkirk/position-edit-menu :git: https://github.com/WhisperSystems/JSQMessagesViewController.git SignalServiceKit: - :git: https://github.com/WhisperSystems/SignalServiceKit.git + :path: "../SignalServiceKit" SocketRocket: :git: https://github.com/facebook/SocketRocket.git CHECKOUT OPTIONS: - AxolotlKit: - :commit: 9179d4e326df58185f35af45831e7a5d7250ab85 - :git: https://github.com/WhisperSystems/SignalProtocolKit.git JSQMessagesViewController: :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :git: https://github.com/WhisperSystems/JSQMessagesViewController.git - SignalServiceKit: - :commit: f2f654af194c9b232ccf2b3d382f8a096bffcd00 - :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf :git: https://github.com/facebook/SocketRocket.git @@ -164,6 +158,6 @@ SPEC CHECKSUMS: UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 -PODFILE CHECKSUM: 48e80d7f1e049bbf544a689fdfdf33e8196c640a +PODFILE CHECKSUM: dc5ed308ade575a81ccadf5c485990530353c4ee COCOAPODS: 1.2.1 diff --git a/Signal/src/Jobs/SessionResetJob.swift b/Signal/src/Jobs/SessionResetJob.swift index 3ccd9fad8..f105ca109 100644 --- a/Signal/src/Jobs/SessionResetJob.swift +++ b/Signal/src/Jobs/SessionResetJob.swift @@ -27,7 +27,7 @@ class SessionResetJob: NSObject { OWSDispatch.sessionStoreQueue().async { Logger.info("\(self.TAG) deleting sessions for recipient: \(self.recipientId)") - self.storageManager.deleteAllSessions(forContact: self.recipientId) + self.storageManager.archiveAllSessions(forContact: self.recipientId) DispatchQueue.main.async { let endSessionMessage = EndSessionMessage(timestamp:NSDate.ows_millisecondTimeStamp(), in: self.thread) diff --git a/Signal/src/ProfileFetcherJob.swift b/Signal/src/ProfileFetcherJob.swift index f80ddb517..76d00dbd4 100644 --- a/Signal/src/ProfileFetcherJob.swift +++ b/Signal/src/ProfileFetcherJob.swift @@ -68,8 +68,8 @@ class ProfileFetcherJob: NSObject { } if OWSIdentityManager.shared().saveRemoteIdentity(latestIdentityKey, recipientId: recipientId) { - Logger.info("\(self.TAG) updated identity key in fetched profile for recipient: \(recipientId)") - self.storageManager.deleteAllSessions(forContact: recipientId) + Logger.info("\(self.TAG) updated identity key with fetched profile for recipient: \(recipientId)") + self.storageManager.archiveAllSessions(forContact: recipientId) } else { // no change in identity. } diff --git a/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m b/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m index 5439fd363..6e19ae3ce 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUISessionState.m @@ -49,13 +49,20 @@ NS_ASSUME_NONNULL_BEGIN actionBlock:^{ [self presentVerificationStatePickerForContactThread:contactThread]; }], - [OWSTableItem itemWithTitle:@"Delete session" + [OWSTableItem itemWithTitle:@"Delete all sessions" actionBlock:^{ dispatch_async([OWSDispatch sessionStoreQueue], ^{ [[TSStorageManager sharedManager] deleteAllSessionsForContact:contactThread.contactIdentifier]; }); }], + [OWSTableItem itemWithTitle:@"Archive all sessions" + actionBlock:^{ + dispatch_async([OWSDispatch sessionStoreQueue], ^{ + [[TSStorageManager sharedManager] + archiveAllSessionsForContact:contactThread.contactIdentifier]; + }); + }], [OWSTableItem itemWithTitle:@"Send session reset" actionBlock:^{ [OWSSessionResetJob