Discard PreKeyBundle once session has been built.

This commit is contained in:
Mikunj 2019-05-13 11:40:33 +10:00 committed by Mikunj Varsani
parent 705e5f939d
commit ea7205ce76
3 changed files with 16 additions and 0 deletions

View file

@ -53,6 +53,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)setPreKeyBundle:(PreKeyBundle *)bundle forContact:(NSString *)pubKey;
/**
Remove the PreKeyBundle for the given contact.
@param pubKey The hex encoded public key of the contact.
*/
- (void)removePreKeyBundleForContact:(NSString *)pubKey;
@end
NS_ASSUME_NONNULL_END

View file

@ -91,4 +91,10 @@
inCollection:LokiPreKeyBundleCollection];
}
- (void)removePreKeyBundleForContact:(NSString *)pubKey
{
[self.dbReadWriteConnection removeObjectForKey:pubKey
inCollection:LokiPreKeyBundleCollection];
}
@end

View file

@ -1665,6 +1665,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
@try {
[builder throws_processPrekeyBundle:bundle protocolContext:transaction];
// Loki: Discard the prekey bundle here since the session is initiated
[[OWSPrimaryStorage sharedManager] removePreKeyBundleForContact:recipientId];
} @catch (NSException *caughtException) {
exception = caughtException;
}