Don't archive sessions when they are fresh.

This commit is contained in:
Nora Trapp 2021-01-16 17:41:58 -08:00
parent 9413e47751
commit 36601e4bbe
3 changed files with 11 additions and 0 deletions

View File

@ -86,6 +86,10 @@
}
- (void)archiveCurrentState{
if (self.sessionState.isFresh) {
OWSLogInfo(@"Skipping archive, current session state is fresh.");
return;
}
[self promoteState:[SessionState new]];
}

View File

@ -39,6 +39,8 @@
@property(nonatomic)int remoteRegistrationId;
@property(nonatomic)int localRegistrationId;
@property (nonatomic, readonly) BOOL isFresh;
- (NSData*)senderRatchetKey;
- (ECKeyPair*)senderRatchetKeyPair;

View File

@ -119,6 +119,11 @@ static NSString* const kCoderPendingPrekey = @"kCoderPendingPrekey";
[aCoder encodeObject:self.pendingPreKey forKey:kCoderPendingPrekey];
}
- (BOOL)isFresh
{
return self.remoteIdentityKey == nil && self.localIdentityKey == nil && self.sendingChain == nil && self.receivingChains.count == 0 && self.pendingPreKey == nil;
}
- (NSData*)senderRatchetKey{
return [[self senderRatchetKeyPair] publicKey];
}