Discard PreKeyBundle once session has been built.

pull/14/head
Mikunj 6 years ago committed by Mikunj Varsani
parent 705e5f939d
commit ea7205ce76

@ -53,6 +53,13 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (void)setPreKeyBundle:(PreKeyBundle *)bundle forContact:(NSString *)pubKey; - (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 @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

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

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

Loading…
Cancel
Save