|
|
|
@ -164,14 +164,15 @@ public final class SessionManagementProtocol : NSObject {
|
|
|
|
|
// MARK: - Receiving
|
|
|
|
|
|
|
|
|
|
@objc(handleDecryptionError:forPublicKey:transaction:)
|
|
|
|
|
public static func handleDecryptionError(_ rawValue: Int32, for publicKey: String, using transaction: YapDatabaseReadWriteTransaction) {
|
|
|
|
|
let type = TSErrorMessageType(rawValue: rawValue)
|
|
|
|
|
public static func handleDecryptionError(_ errorMessage: TSErrorMessage, for publicKey: String, using transaction: YapDatabaseReadWriteTransaction) {
|
|
|
|
|
let type = errorMessage.errorType
|
|
|
|
|
let masterPublicKey = storage.getMasterHexEncodedPublicKey(for: publicKey, in: transaction) ?? publicKey
|
|
|
|
|
let thread = TSContactThread.getOrCreateThread(withContactId: masterPublicKey, transaction: transaction)
|
|
|
|
|
let restorationTimeInMs = UInt64(storage.getRestorationTime() * 1000)
|
|
|
|
|
// Show the session reset prompt upon certain errors
|
|
|
|
|
switch type {
|
|
|
|
|
case .noSession, .invalidMessage, .invalidKeyException:
|
|
|
|
|
if storage.getRestorationTime() > 0 {
|
|
|
|
|
if restorationTimeInMs > errorMessage.timestamp {
|
|
|
|
|
// Automatically rebuild session after restoration
|
|
|
|
|
sendSessionRequestIfNeeded(to: publicKey, using: transaction)
|
|
|
|
|
} else {
|
|
|
|
|