|
|
@ -16,8 +16,8 @@ public class RefreshPreKeysOperation: OWSOperation {
|
|
|
|
return TSAccountManager.sharedInstance()
|
|
|
|
return TSAccountManager.sharedInstance()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var accountManager: AccountManager {
|
|
|
|
private var accountServiceClient: AccountServiceClient {
|
|
|
|
return AccountManager.shared
|
|
|
|
return AccountServiceClient.shared
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var primaryStorage: OWSPrimaryStorage {
|
|
|
|
private var primaryStorage: OWSPrimaryStorage {
|
|
|
@ -37,7 +37,7 @@ public class RefreshPreKeysOperation: OWSOperation {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
firstly {
|
|
|
|
firstly {
|
|
|
|
self.accountManager.getPreKeysCount()
|
|
|
|
self.accountServiceClient.getPreKeysCount()
|
|
|
|
}.then(on: DispatchQueue.global()) { preKeysCount -> Promise<Void> in
|
|
|
|
}.then(on: DispatchQueue.global()) { preKeysCount -> Promise<Void> in
|
|
|
|
Logger.debug("preKeysCount: \(preKeysCount)")
|
|
|
|
Logger.debug("preKeysCount: \(preKeysCount)")
|
|
|
|
guard preKeysCount < kEphemeralPreKeysMinimumCount || self.primaryStorage.currentSignedPrekeyId() == nil else {
|
|
|
|
guard preKeysCount < kEphemeralPreKeysMinimumCount || self.primaryStorage.currentSignedPrekeyId() == nil else {
|
|
|
@ -52,7 +52,7 @@ public class RefreshPreKeysOperation: OWSOperation {
|
|
|
|
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)
|
|
|
|
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)
|
|
|
|
self.primaryStorage.storePreKeyRecords(preKeyRecords)
|
|
|
|
self.primaryStorage.storePreKeyRecords(preKeyRecords)
|
|
|
|
|
|
|
|
|
|
|
|
return self.accountManager.setPreKeys(identityKey: identityKey, signedPreKeyRecord: signedPreKeyRecord, preKeyRecords: preKeyRecords).then { () -> Void in
|
|
|
|
return self.accountServiceClient.setPreKeys(identityKey: identityKey, signedPreKeyRecord: signedPreKeyRecord, preKeyRecords: preKeyRecords).then { () -> Void in
|
|
|
|
signedPreKeyRecord.markAsAcceptedByService()
|
|
|
|
signedPreKeyRecord.markAsAcceptedByService()
|
|
|
|
self.primaryStorage.setCurrentSignedPrekeyId(signedPreKeyRecord.id)
|
|
|
|
self.primaryStorage.setCurrentSignedPrekeyId(signedPreKeyRecord.id)
|
|
|
|
|
|
|
|
|
|
|
|