You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
//
|
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import PromiseKit
|
|
|
|
|
|
|
|
@objc(SSKCreatePreKeysOperation)
|
|
|
|
public class CreatePreKeysOperation: OWSOperation {
|
|
|
|
|
|
|
|
private var storage: OWSPrimaryStorage {
|
|
|
|
return OWSPrimaryStorage.shared()
|
|
|
|
}
|
|
|
|
|
|
|
|
private var identityKeyManager: OWSIdentityManager {
|
|
|
|
return OWSIdentityManager.shared()
|
|
|
|
}
|
|
|
|
|
|
|
|
public override func run() {
|
|
|
|
Logger.debug("")
|
|
|
|
|
|
|
|
if identityKeyManager.identityKeyPair() == nil {
|
|
|
|
identityKeyManager.generateNewIdentityKeyPair()
|
|
|
|
}
|
|
|
|
|
|
|
|
let signedPreKeyRecord = storage.generateRandomSignedRecord()
|
|
|
|
signedPreKeyRecord.markAsAcceptedByService()
|
|
|
|
storage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)
|
|
|
|
storage.setCurrentSignedPrekeyId(signedPreKeyRecord.id)
|
|
|
|
SNLog("Pre keys created successfully.")
|
|
|
|
reportSuccess()
|
|
|
|
}
|
|
|
|
}
|