diff --git a/Podfile.lock b/Podfile.lock index 8a23caa72..34424a452 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -263,7 +263,7 @@ CHECKOUT OPTIONS: :commit: 358ec16833d9b8b6e1410d83fa47c819c533fe91 :git: https://github.com/signalapp/SignalCoreKit.git SignalMetadataKit: - :commit: 0434fc7ade6e0eb27540291357a3382476dece52 + :commit: 954cbfa767e130626d2e87cc029769a1977c8edd :git: https://github.com/signalapp/SignalMetadataKit-Private SocketRocket: :commit: 9f9563a83cd8960503074aa8de72206f83fb7a69 diff --git a/Pods b/Pods index 4c450a8a1..536fb61dc 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 4c450a8a1702d3b00eaa476dbddff487d3a91c53 +Subproject commit 536fb61dc6b3b29db9ffe9210bbff1eefb75bef9 diff --git a/Signal/src/Models/AccountManager.swift b/Signal/src/Models/AccountManager.swift index 94e4132c3..7f134613e 100644 --- a/Signal/src/Models/AccountManager.swift +++ b/Signal/src/Models/AccountManager.swift @@ -107,9 +107,9 @@ public class AccountManager: NSObject { func updatePushTokens(pushToken: String, voipToken: String) -> Promise { return Promise { fulfill, reject in tsAccountManager.registerForPushNotifications(pushToken: pushToken, - voipToken: voipToken, - success: fulfill, - failure: reject) + voipToken: voipToken, + success: fulfill, + failure: reject) } } @@ -117,14 +117,7 @@ public class AccountManager: NSObject { tsAccountManager.setIsManualMessageFetchEnabled(true) // Try to update the account attributes to reflect this change. - let request = OWSRequestFactory.updateAttributesRequest() - let promise: Promise = self.networkManager.makePromise(request: request) - .then(execute: { (_, _) in - Logger.info("updated server with account attributes to enableManualFetching") - }).catch(execute: { (error) in - Logger.error("failed to update server with account attributes with error: \(error)") - }) - return promise + return SignalServiceRestClient().updateAcountAttributes() } // MARK: Turn Server diff --git a/SignalMessaging/environment/migrations/OWS111UDAttributesMigration.swift b/SignalMessaging/environment/migrations/OWS111UDAttributesMigration.swift index a9a0c99ba..bf0c43cc5 100644 --- a/SignalMessaging/environment/migrations/OWS111UDAttributesMigration.swift +++ b/SignalMessaging/environment/migrations/OWS111UDAttributesMigration.swift @@ -3,6 +3,7 @@ // import Foundation +import SignalServiceKit @objc public class OWS111UDAttributesMigration: OWSDatabaseMigration { @@ -32,8 +33,7 @@ public class OWS111UDAttributesMigration: OWSDatabaseMigration { } private func doMigration(completion: @escaping OWSDatabaseMigrationCompletion) { - let request = OWSRequestFactory.updateAttributesRequest() - self.networkManager.makePromise(request: request).then(execute: { (_, _) in + return SignalServiceRestClient().updateAcountAttributes().then(execute: { _ in self.dbReadWriteConnection().readWrite { transaction in self.save(with: transaction) } diff --git a/SignalServiceKit/src/Network/SignalServiceClient.swift b/SignalServiceKit/src/Network/SignalServiceClient.swift index a14ca48cc..96f4aab4f 100644 --- a/SignalServiceKit/src/Network/SignalServiceClient.swift +++ b/SignalServiceKit/src/Network/SignalServiceClient.swift @@ -10,10 +10,12 @@ protocol SignalServiceClient { func registerPreKeys(identityKey: IdentityKey, signedPreKeyRecord: SignedPreKeyRecord, preKeyRecords: [PreKeyRecord]) -> Promise func setCurrentSignedPreKey(_ signedPreKey: SignedPreKeyRecord) -> Promise func requestUDSenderCertificate() -> Promise + func updateAcountAttributes() -> Promise } /// Based on libsignal-service-java's PushServiceSocket class -class SignalServiceRestClient: SignalServiceClient { +@objc +public class SignalServiceRestClient: NSObject, SignalServiceClient { var networkManager: TSNetworkManager { return TSNetworkManager.shared() @@ -70,4 +72,15 @@ class SignalServiceRestClient: SignalServiceClient { return try parser.requiredBase64EncodedData(key: "certificate") } + + public func updateAcountAttributes() -> Promise { + let request = OWSRequestFactory.updateAttributesRequest() + let promise: Promise = networkManager.makePromise(request: request) + .then(execute: { (_, _) in + Logger.info("updated account attributes on server") + }).catch(execute: { (error) in + Logger.error("failed to update account attributes on server with error: \(error)") + }) + return promise + } }