Merge branch 'mkirk/archive-not-delete'
This commit is contained in:
commit
8bd0281254
@ -336,19 +336,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
NSString *recipientId = messageEnvelope.source;
|
||||
int deviceId = messageEnvelope.sourceDevice;
|
||||
dispatch_async([OWSDispatch sessionStoreQueue], ^{
|
||||
if (![storageManager containsSession:recipientId deviceId:deviceId]) {
|
||||
__block TSErrorMessage *errorMessage;
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
errorMessage =
|
||||
[TSErrorMessage missingSessionWithEnvelope:messageEnvelope withTransaction:transaction];
|
||||
[errorMessage saveWithTransaction:transaction];
|
||||
}];
|
||||
[self notififyForErrorMessage:errorMessage withEnvelope:messageEnvelope];
|
||||
DDLogError(@"Skipping message envelope for unknown session.");
|
||||
completion(nil);
|
||||
return;
|
||||
}
|
||||
|
||||
// DEPRECATED - Remove after all clients have been upgraded.
|
||||
NSData *encryptedData
|
||||
= messageEnvelope.hasContent ? messageEnvelope.content : messageEnvelope.legacyMessage;
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
|
||||
@interface TSStorageManager (SessionStore) <SessionStore>
|
||||
|
||||
- (void)archiveAllSessionsForContact:(NSString *)contactIdentifier;
|
||||
|
||||
#pragma mark - debug
|
||||
|
||||
- (void)printAllSessions;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#import "TSStorageManager+SessionStore.h"
|
||||
#import <AxolotlKit/SessionRecord.h>
|
||||
|
||||
NSString *const TSStorageManagerSessionStoreCollection = @"TSStorageManagerSessionStoreCollection";
|
||||
NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey";
|
||||
@ -158,6 +159,35 @@ void AssertIsOnSessionStoreQueue()
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)archiveAllSessionsForContact:(NSString *)contactIdentifier
|
||||
{
|
||||
AssertIsOnSessionStoreQueue();
|
||||
|
||||
DDLogInfo(@"[TSStorageManager (SessionStore)] archiving all sessions for contact: %@", contactIdentifier);
|
||||
|
||||
__block NSDictionary<NSNumber *, SessionRecord *> *sessionRecords;
|
||||
[self.sessionDBConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
sessionRecords =
|
||||
[transaction objectForKey:contactIdentifier inCollection:TSStorageManagerSessionStoreCollection];
|
||||
|
||||
|
||||
for (id deviceId in sessionRecords) {
|
||||
id object = sessionRecords[deviceId];
|
||||
if (![object isKindOfClass:[SessionRecord class]]) {
|
||||
OWSFail(@"Unexpected object in session dict: %@", object);
|
||||
continue;
|
||||
}
|
||||
|
||||
SessionRecord *sessionRecord = (SessionRecord *)object;
|
||||
[sessionRecord archiveCurrentState];
|
||||
}
|
||||
|
||||
[transaction setObject:sessionRecords
|
||||
forKey:contactIdentifier
|
||||
inCollection:TSStorageManagerSessionStoreCollection];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - debug
|
||||
|
||||
- (void)printAllSessions
|
||||
|
||||
Loading…
Reference in New Issue
Block a user