Add some basic prekey logging
This commit is contained in:
parent
29d2784eb8
commit
8220cd2bd1
@ -325,6 +325,7 @@ extension PreKeyTasks {
|
||||
)
|
||||
}
|
||||
}.map(on: context.scheduler) { targets in
|
||||
PreKey.logger.info("[\(identity)] Refresh(filtered): [\(targets)]")
|
||||
return try self.createPartialBundle(
|
||||
identity: identity,
|
||||
identityKeyPair: identityKeyPair,
|
||||
|
||||
@ -5,7 +5,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum PreKey {}
|
||||
public enum PreKey {
|
||||
static let logger = PrefixedLogger(prefix: "[PreKey]")
|
||||
}
|
||||
|
||||
extension PreKey {
|
||||
public enum Operation {
|
||||
@ -107,6 +109,7 @@ public class PreKeyOperation: OWSOperation {
|
||||
}
|
||||
|
||||
public override func run() {
|
||||
PreKey.logger.info("")
|
||||
firstly(on: context.schedulers.global()) {
|
||||
self.preKeyTask.runPreKeyTask()
|
||||
} .done(on: self.context.schedulers.global()) {
|
||||
@ -177,6 +180,7 @@ internal class PreKeyCreateForRegistrationOperation: OWSOperation {
|
||||
}
|
||||
|
||||
public override func run() {
|
||||
PreKey.logger.info("Create for registration")
|
||||
firstly(on: scheduler) { () -> RegistrationPreKeyUploadBundles in
|
||||
let aciBundle = try self.aciGenerateTask.runTask(identity: .aci)
|
||||
try self.aciPersistTask.runTask(bundle: aciBundle)
|
||||
@ -253,6 +257,7 @@ internal class PreKeyCreateForProvisioningOperation: OWSOperation {
|
||||
}
|
||||
|
||||
public override func run() {
|
||||
PreKey.logger.info("Create for provisioning")
|
||||
firstly(on: scheduler) { () -> RegistrationPreKeyUploadBundles in
|
||||
let aciBundle = try self.aciGenerateTask.runTask(identity: .aci, identityKeyPair: self.aciIdentityKeyPair)
|
||||
try self.aciPersistTask.runTask(bundle: aciBundle)
|
||||
@ -311,6 +316,7 @@ internal class PreKeyPersistAfterRegistrationOperation: OWSOperation {
|
||||
}
|
||||
|
||||
public override func run() {
|
||||
PreKey.logger.info("Persist after provisioning")
|
||||
firstly(on: scheduler) {
|
||||
try self.aciPersistTask.runTask(bundle: self.bundles.aci, uploadDidSucceed: self.uploadDidSucceed)
|
||||
try self.pniPersistTask.runTask(bundle: self.bundles.pni, uploadDidSucceed: self.uploadDidSucceed)
|
||||
|
||||
@ -98,7 +98,8 @@ extension PreKeyTasks {
|
||||
)
|
||||
|
||||
switch action {
|
||||
case .refresh(_, let targets):
|
||||
case .refresh(let identity, let targets):
|
||||
PreKey.logger.info("[\(identity)] Refresh [\(targets)]")
|
||||
bundlePromise = GenerateForRefresh
|
||||
.init(
|
||||
dateProvider: context.dateProvider,
|
||||
@ -111,7 +112,8 @@ extension PreKeyTasks {
|
||||
targets: targets
|
||||
)
|
||||
.map(on: SyncScheduler()) { $0 }
|
||||
case .rotate(_, let targets):
|
||||
case .rotate(let identity, let targets):
|
||||
PreKey.logger.info("[\(identity)] Rotate [\(targets)]")
|
||||
bundlePromise = GenerateForRotation
|
||||
.init(
|
||||
context: generateContext,
|
||||
@ -123,10 +125,12 @@ extension PreKeyTasks {
|
||||
)
|
||||
.map(on: SyncScheduler()) { $0 }
|
||||
case .createOneTimePreKeys:
|
||||
PreKey.logger.info("[\(action.identity)] Create one-time prekeys")
|
||||
bundlePromise = CreateOneTimePreKeys(context: generateContext)
|
||||
.runTask(identity: action.identity)
|
||||
.map(on: SyncScheduler()) { $0 }
|
||||
case .createOrRotatePniKeys(let targets):
|
||||
PreKey.logger.info("[PNI] Create or Rotate PNI [\(targets)]")
|
||||
bundlePromise = GenerateForPNIRotation
|
||||
.init(
|
||||
context: generateContext,
|
||||
@ -134,7 +138,8 @@ extension PreKeyTasks {
|
||||
)
|
||||
.runTask(targets: targets)
|
||||
.map(on: SyncScheduler()) { $0 }
|
||||
case .legacy_create(_, let targets):
|
||||
case .legacy_create(let identity, let targets):
|
||||
PreKey.logger.info("[\(identity)] Legacy prekey operation [\(targets)]")
|
||||
bundlePromise = Legacy_Generate
|
||||
.init(
|
||||
accountManager: context.accountManager,
|
||||
@ -155,7 +160,10 @@ extension PreKeyTasks {
|
||||
.runTask(bundle: bundle, auth: self.auth)
|
||||
.map(on: globalQueue()) { uploadResult throws in
|
||||
switch uploadResult {
|
||||
case .skipped:
|
||||
PreKey.logger.info("[\(self.action.identity)] No keys to upload")
|
||||
case .success:
|
||||
PreKey.logger.info("[\(self.action.identity)] Successfully uploaded prekeys")
|
||||
try PersistSuccesfulUpload(
|
||||
dateProvider: self.context.dateProvider,
|
||||
db: self.context.db,
|
||||
@ -178,6 +186,7 @@ extension PreKeyTasks {
|
||||
.recordSuspectedIssueWithPniIdentityKey(tx: tx)
|
||||
}
|
||||
case let .failure(error):
|
||||
PreKey.logger.info("[\(self.action.identity)] Failed to upload prekeys")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ extension PreKeyTasks {
|
||||
internal class Upload {
|
||||
enum UploadResult {
|
||||
case success
|
||||
case skipped
|
||||
/// An error in which we, a linked device, attempted an upload and
|
||||
/// were told by the server that the identity key in our bundle was
|
||||
/// incorrect.
|
||||
@ -35,7 +36,9 @@ extension PreKeyTasks {
|
||||
auth: ChatServiceAuth
|
||||
) -> Guarantee<UploadResult> {
|
||||
// If there is nothing to update, skip this step.
|
||||
guard !bundle.isEmpty() else { return .value(.success) }
|
||||
guard !bundle.isEmpty() else { return .value(.skipped) }
|
||||
|
||||
PreKey.logger.info("[\(bundle.identity)] uploading prekeys")
|
||||
|
||||
return self.serviceClient.setPreKeys(
|
||||
for: bundle.identity,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user