Attempt to repair session if needed

This commit is contained in:
nielsandriesse 2020-05-07 11:57:07 +10:00
parent 60cb5b6114
commit 807345868f
2 changed files with 14 additions and 0 deletions

View File

@ -139,6 +139,19 @@ public final class SessionManagementProtocol : NSObject {
return promise
}
@objc(repairSessionIfNeededForMessage:to:)
public static func repairSessionIfNeeded(for message: TSOutgoingMessage, to hexEncodedPublicKey: String) {
guard (message.thread as? TSGroupThread)?.groupModel.groupType == .closedGroup else { return }
DispatchQueue.main.async {
storage.dbReadWriteConnection.readWrite { transaction in
let thread = TSContactThread.getOrCreateThread(withContactId: hexEncodedPublicKey, transaction: transaction)
let sessionRequestMessage = SessionRequestMessage(thread: thread)
let messageSenderJobQueue = SSKEnvironment.shared.messageSenderJobQueue
messageSenderJobQueue.add(message: sessionRequestMessage, transaction: transaction)
}
}
}
// MARK: - Receiving
@objc(handleDecryptionError:forHexEncodedPublicKey:using:)
public static func handleDecryptionError(_ rawValue: Int32, for hexEncodedPublicKey: String, using transaction: YapDatabaseReadWriteTransaction) {

View File

@ -1705,6 +1705,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
*/
if (!bundle) {
[LKSessionManagementProtocol repairSessionIfNeededForMessage:messageSend.message to:recipientID];
NSString *missingPrekeyBundleException = @"missingPrekeyBundleException";
OWSRaiseException(missingPrekeyBundleException, @"Missing pre key bundle for: %@.", recipientID);
} else {