Protocol stores use strongly typed signatures
This commit is contained in:
parent
11876a8f12
commit
bae00466aa
@ -111,7 +111,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
|
||||
if firstAttempt {
|
||||
self.dbConnection.readWrite { transaction in
|
||||
Logger.info("deleting sessions for recipient: \(self.recipientId)")
|
||||
self.primaryStorage.deleteAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
self.primaryStorage.deleteAllSessions(forContact: self.recipientId, transaction: transaction)
|
||||
}
|
||||
firstAttempt = false
|
||||
}
|
||||
@ -126,7 +126,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
|
||||
// Archive the just-created session since the recipient should delete their corresponding
|
||||
// session upon receiving and decrypting our EndSession message.
|
||||
// Otherwise if we send another message before them, they wont have the session to decrypt it.
|
||||
self.primaryStorage.archiveAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
self.primaryStorage.archiveAllSessions(forContact: self.recipientId, transaction: transaction)
|
||||
|
||||
let message = TSInfoMessage(timestamp: NSDate.ows_millisecondTimeStamp(),
|
||||
in: self.contactThread,
|
||||
@ -184,7 +184,7 @@ public class SessionResetOperation: OWSOperation, DurableOperation {
|
||||
// Archive the just-created session since the recipient should delete their corresponding
|
||||
// session upon receiving and decrypting our EndSession message.
|
||||
// Otherwise if we send another message before them, they wont have the session to decrypt it.
|
||||
self.primaryStorage.archiveAllSessions(forContact: self.recipientId, protocolContext: transaction)
|
||||
self.primaryStorage.archiveAllSessions(forContact: self.recipientId, transaction: transaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DebugUISessionState.h"
|
||||
@ -54,17 +54,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[[OWSPrimaryStorage sharedManager]
|
||||
deleteAllSessionsForContact:thread.contactIdentifier
|
||||
protocolContext:transaction];
|
||||
transaction:transaction];
|
||||
}];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Archive all sessions"
|
||||
actionBlock:^{
|
||||
[self.dbConnection
|
||||
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[[OWSPrimaryStorage sharedManager]
|
||||
archiveAllSessionsForContact:thread.contactIdentifier
|
||||
protocolContext:transaction];
|
||||
}];
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[[OWSPrimaryStorage sharedManager]
|
||||
archiveAllSessionsForContact:thread.contactIdentifier
|
||||
transaction:transaction];
|
||||
}];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Send session reset"
|
||||
actionBlock:^{
|
||||
|
||||
@ -569,8 +569,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
|
||||
}
|
||||
case OWSVerificationStateNoLongerVerified: {
|
||||
OWSLogInfo(@"marked recipient: %@ as default verification status.", recipientId);
|
||||
NSData *identityKey = [[OWSIdentityManager sharedManager] identityKeyForRecipientId:recipientId
|
||||
protocolContext:transaction];
|
||||
NSData *identityKey =
|
||||
[[OWSIdentityManager sharedManager] identityKeyForRecipientId:recipientId transaction:transaction];
|
||||
OWSAssertDebug(identityKey);
|
||||
[[OWSIdentityManager sharedManager] setVerificationState:OWSVerificationStateDefault
|
||||
identityKey:identityKey
|
||||
|
||||
@ -227,9 +227,9 @@ public class ProfileFetcherJob: NSObject {
|
||||
|
||||
private func verifyIdentityUpToDateAsync(recipientId: String, latestIdentityKey: Data) {
|
||||
primaryStorage.newDatabaseConnection().asyncReadWrite { (transaction) in
|
||||
if self.identityManager.saveRemoteIdentity(latestIdentityKey, recipientId: recipientId, protocolContext: transaction) {
|
||||
if self.identityManager.saveRemoteIdentity(latestIdentityKey, recipientId: recipientId, transaction: transaction) {
|
||||
Logger.info("updated identity key with fetched profile for recipient: \(recipientId)")
|
||||
self.primaryStorage.archiveAllSessions(forContact: recipientId, protocolContext: transaction)
|
||||
self.primaryStorage.archiveAllSessions(forContact: recipientId, transaction: transaction)
|
||||
} else {
|
||||
// no change in identity.
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
if (transcript.isEndSessionMessage) {
|
||||
OWSLogInfo(@"EndSession was sent to recipient: %@.", transcript.recipientId);
|
||||
[self.primaryStorage deleteAllSessionsForContact:transcript.recipientId protocolContext:transaction];
|
||||
[self.primaryStorage deleteAllSessionsForContact:transcript.recipientId transaction:transaction];
|
||||
|
||||
// MJK TODO - we don't use this timestamp, safe to remove
|
||||
[[[TSInfoMessage alloc] initWithTimestamp:transcript.timestamp
|
||||
|
||||
@ -200,7 +200,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||
|
||||
__block BOOL result;
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
result = [self saveRemoteIdentity:identityKey recipientId:recipientId protocolContext:transaction];
|
||||
result = [self saveRemoteIdentity:identityKey recipientId:recipientId transaction:transaction];
|
||||
}];
|
||||
|
||||
return result;
|
||||
@ -273,7 +273,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||
createdAt:[NSDate new]
|
||||
verificationState:verificationState] saveWithTransaction:transaction];
|
||||
|
||||
[self.primaryStorage archiveAllSessionsForContact:recipientId protocolContext:transaction];
|
||||
[self.primaryStorage archiveAllSessionsForContact:recipientId transaction:transaction];
|
||||
|
||||
// Cancel any pending verification state sync messages for this recipient.
|
||||
[self clearSyncMessageForRecipientId:recipientId transaction:transaction];
|
||||
@ -334,7 +334,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||
|
||||
// Ensure a remote identity exists for this key. We may be learning about
|
||||
// it for the first time.
|
||||
[self saveRemoteIdentity:identityKey recipientId:recipientId protocolContext:transaction];
|
||||
[self saveRemoteIdentity:identityKey recipientId:recipientId transaction:transaction];
|
||||
|
||||
OWSRecipientIdentity *recipientIdentity =
|
||||
[OWSRecipientIdentity fetchObjectWithUniqueID:recipientId transaction:transaction];
|
||||
@ -772,8 +772,8 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||
|
||||
// Ensure a remote identity exists for this key. We may be learning about
|
||||
// it for the first time.
|
||||
[self saveRemoteIdentity:identityKey recipientId:recipientId protocolContext:transaction];
|
||||
|
||||
[self saveRemoteIdentity:identityKey recipientId:recipientId transaction:transaction];
|
||||
|
||||
recipientIdentity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId
|
||||
transaction:transaction];
|
||||
|
||||
@ -824,8 +824,8 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||
}
|
||||
|
||||
OWSLogWarn(@"recipientIdentity has non-matching identityKey; overwriting: %@", recipientId);
|
||||
[self saveRemoteIdentity:identityKey recipientId:recipientId protocolContext:transaction];
|
||||
|
||||
[self saveRemoteIdentity:identityKey recipientId:recipientId transaction:transaction];
|
||||
|
||||
recipientIdentity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId
|
||||
transaction:transaction];
|
||||
|
||||
|
||||
@ -993,7 +993,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
inThread:thread
|
||||
messageType:TSInfoMessageTypeSessionDidEnd] saveWithTransaction:transaction];
|
||||
|
||||
[self.primaryStorage deleteAllSessionsForContact:envelope.source protocolContext:transaction];
|
||||
[self.primaryStorage deleteAllSessionsForContact:envelope.source transaction:transaction];
|
||||
}
|
||||
|
||||
- (void)handleExpirationTimerUpdateMessageWithEnvelope:(SSKProtoEnvelope *)envelope
|
||||
|
||||
@ -1349,7 +1349,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||
for (NSNumber *extraDeviceId in extraDevices) {
|
||||
[self.primaryStorage deleteSessionForContact:recipient.uniqueId
|
||||
deviceId:extraDeviceId.intValue
|
||||
protocolContext:transaction];
|
||||
transaction:transaction];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1530,7 +1530,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||
|
||||
__block BOOL hasSession;
|
||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
hasSession = [storage containsSession:recipientId deviceId:[deviceId intValue] protocolContext:transaction];
|
||||
hasSession = [storage containsSession:recipientId deviceId:[deviceId intValue] transaction:transaction];
|
||||
}];
|
||||
if (hasSession) {
|
||||
return;
|
||||
@ -1668,7 +1668,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||
OWSAssertDebug(recipientId.length > 0);
|
||||
|
||||
// This may throw an exception.
|
||||
if (![storage containsSession:recipientId deviceId:[deviceId intValue] protocolContext:transaction]) {
|
||||
if (![storage containsSession:recipientId deviceId:[deviceId intValue] transaction:transaction]) {
|
||||
NSString *missingSessionException = @"missingSessionException";
|
||||
OWSRaiseException(missingSessionException,
|
||||
@"Unexpectedly missing session for recipient: %@, device: %@",
|
||||
@ -1791,7 +1791,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||
int deviceNumber = [devices[i] intValue];
|
||||
[[OWSPrimaryStorage sharedManager] deleteSessionForContact:identifier
|
||||
deviceId:deviceNumber
|
||||
protocolContext:transaction];
|
||||
transaction:transaction];
|
||||
}
|
||||
}];
|
||||
completionHandler();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user