From 2af0a897e177d5b79b9c6b2164b27271319fc163 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 20 Aug 2018 15:34:04 -0400 Subject: [PATCH 1/2] Disable CDS. --- .../OWSContactDiscoveryOperation.swift | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift b/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift index 459cba06c..6bf1465cd 100644 --- a/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift +++ b/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift @@ -7,6 +7,8 @@ import Foundation @objc(OWSLegacyContactDiscoveryOperation) class LegacyContactDiscoveryBatchOperation: OWSOperation { + private let isCDSEnabled = false + @objc var registeredRecipientIds: Set @@ -83,13 +85,15 @@ class LegacyContactDiscoveryBatchOperation: OWSOperation { // Called at most one time. override func didSucceed() { - // Compare against new CDS service - let modernCDSOperation = CDSOperation(recipientIdsToLookup: self.recipientIdsToLookup) - let cdsFeedbackOperation = CDSFeedbackOperation(legacyRegisteredRecipientIds: self.registeredRecipientIds) - cdsFeedbackOperation.addDependency(modernCDSOperation) - - let operations = modernCDSOperation.dependencies + [modernCDSOperation, cdsFeedbackOperation] - CDSOperation.operationQueue.addOperations(operations, waitUntilFinished: false) + if isCDSEnabled { + // Compare against new CDS service + let modernCDSOperation = CDSOperation(recipientIdsToLookup: self.recipientIdsToLookup) + let cdsFeedbackOperation = CDSFeedbackOperation(legacyRegisteredRecipientIds: self.registeredRecipientIds) + cdsFeedbackOperation.addDependency(modernCDSOperation) + + let operations = modernCDSOperation.dependencies + [modernCDSOperation, cdsFeedbackOperation] + CDSOperation.operationQueue.addOperations(operations, waitUntilFinished: false) + } } // MARK: Private Helpers @@ -362,7 +366,7 @@ class CDSBatchOperation: OWSOperation { } class func boolArray(data: Data) -> [Bool]? { - var bools: [Bool]? = nil + var bools: [Bool]? data.withUnsafeBytes { (bytes: UnsafePointer) -> Void in let buffer = UnsafeBufferPointer(start: bytes, count: data.count) bools = Array(buffer) From 2b8b688fb683b296c69670a4e0ee4516b96f78ea Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 20 Aug 2018 15:38:30 -0400 Subject: [PATCH 2/2] Disable CDS. --- .../Contacts/OWSContactDiscoveryOperation.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift b/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift index 6bf1465cd..24bb13a4f 100644 --- a/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift +++ b/SignalServiceKit/src/Contacts/OWSContactDiscoveryOperation.swift @@ -85,15 +85,16 @@ class LegacyContactDiscoveryBatchOperation: OWSOperation { // Called at most one time. override func didSucceed() { - if isCDSEnabled { - // Compare against new CDS service - let modernCDSOperation = CDSOperation(recipientIdsToLookup: self.recipientIdsToLookup) - let cdsFeedbackOperation = CDSFeedbackOperation(legacyRegisteredRecipientIds: self.registeredRecipientIds) - cdsFeedbackOperation.addDependency(modernCDSOperation) - - let operations = modernCDSOperation.dependencies + [modernCDSOperation, cdsFeedbackOperation] - CDSOperation.operationQueue.addOperations(operations, waitUntilFinished: false) + guard isCDSEnabled else { + return } + // Compare against new CDS service + let modernCDSOperation = CDSOperation(recipientIdsToLookup: self.recipientIdsToLookup) + let cdsFeedbackOperation = CDSFeedbackOperation(legacyRegisteredRecipientIds: self.registeredRecipientIds) + cdsFeedbackOperation.addDependency(modernCDSOperation) + + let operations = modernCDSOperation.dependencies + [modernCDSOperation, cdsFeedbackOperation] + CDSOperation.operationQueue.addOperations(operations, waitUntilFinished: false) } // MARK: Private Helpers