Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent 8fdf6009f9
commit c9922cda3e

@ -114,14 +114,7 @@ public class AccountManager: NSObject {
} }
func enableManualMessageFetching() -> Promise<Void> { func enableManualMessageFetching() -> Promise<Void> {
let (promise, fulfill, reject) = Promise<Void>.pending() return tsAccountManager.setIsManualMessageFetchEnabled(true).asPromise().asVoid()
tsAccountManager.setIsManualMessageFetchEnabled(true)
.then(execute: { (_) in
fulfill(())
}).catch(execute: { (error) in
reject(error)
})
return promise
} }
// MARK: Turn Server // MARK: Turn Server

@ -625,17 +625,17 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
// No need to rotate the profile key. // No need to rotate the profile key.
return success(); return success();
} }
[self rotateProfileKeyWithSuccess:success [self rotateProfileKeyWithIntersectingRecipientIds:intersectingRecipientIds
failure:failure intersectingGroupIds:intersectingGroupIds
intersectingRecipientIds:intersectingRecipientIds success:success
intersectingGroupIds:intersectingGroupIds]; failure:failure];
}); });
} }
- (void)rotateProfileKeyWithSuccess:(dispatch_block_t)success - (void)rotateProfileKeyWithIntersectingRecipientIds:(NSSet<NSString *> *)intersectingRecipientIds
failure:(ProfileManagerFailureBlock)failure intersectingGroupIds:(NSSet<NSData *> *)intersectingGroupIds
intersectingRecipientIds:(NSSet<NSString *> *)intersectingRecipientIds success:(dispatch_block_t)success
intersectingGroupIds:(NSSet<NSData *> *)intersectingGroupIds { failure:(ProfileManagerFailureBlock)failure {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Rotate the profile key // Rotate the profile key
OWSLogInfo(@"Rotating the profile key."); OWSLogInfo(@"Rotating the profile key.");

@ -632,6 +632,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
#pragma mark - Account Attributes #pragma mark - Account Attributes
- (AnyPromise *)updateAccountAttributes { - (AnyPromise *)updateAccountAttributes {
// Enqueue a "account attribute update", recording the "request time".
[self.dbConnection setObject:[NSDate new] [self.dbConnection setObject:[NSDate new]
forKey:TSAccountManager_NeedsAccountAttributesUpdateKey forKey:TSAccountManager_NeedsAccountAttributesUpdateKey
inCollection:TSAccountManager_UserAccountCollection]; inCollection:TSAccountManager_UserAccountCollection];
@ -647,10 +648,11 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
return [AnyPromise promiseWithValue:@(1)]; return [AnyPromise promiseWithValue:@(1)];
} }
AnyPromise *promise = [[SignalServiceRestClient new] updateAccountAttributes]; AnyPromise *promise = [[SignalServiceRestClient new] updateAccountAttributesObjC];
promise = promise.then(^(id value) { promise = promise.then(^(id value) {
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
// Clear the update request unless a new update has been requested. // Clear the update request unless a new update has been requested
// while this update was in flight.
NSDate *_Nullable latestUpdateRequestDate = NSDate *_Nullable latestUpdateRequestDate =
[transaction objectForKey:TSAccountManager_NeedsAccountAttributesUpdateKey [transaction objectForKey:TSAccountManager_NeedsAccountAttributesUpdateKey
inCollection:TSAccountManager_UserAccountCollection]; inCollection:TSAccountManager_UserAccountCollection];

@ -10,7 +10,7 @@ public typealias RecipientIdentifier = String
@objc @objc
public protocol SignalServiceClientObjC { public protocol SignalServiceClientObjC {
@objc func updateAccountAttributes() -> AnyPromise @objc func updateAccountAttributesObjC() -> AnyPromise
} }
public protocol SignalServiceClient: SignalServiceClientObjC { public protocol SignalServiceClient: SignalServiceClientObjC {
@ -18,6 +18,7 @@ public protocol SignalServiceClient: SignalServiceClientObjC {
func registerPreKeys(identityKey: IdentityKey, signedPreKeyRecord: SignedPreKeyRecord, preKeyRecords: [PreKeyRecord]) -> Promise<Void> func registerPreKeys(identityKey: IdentityKey, signedPreKeyRecord: SignedPreKeyRecord, preKeyRecords: [PreKeyRecord]) -> Promise<Void>
func setCurrentSignedPreKey(_ signedPreKey: SignedPreKeyRecord) -> Promise<Void> func setCurrentSignedPreKey(_ signedPreKey: SignedPreKeyRecord) -> Promise<Void>
func requestUDSenderCertificate() -> Promise<Data> func requestUDSenderCertificate() -> Promise<Data>
func updateAccountAttributes() -> Promise<Void>
func retrieveProfile(recipientId: RecipientIdentifier, unidentifiedAccess: SSKUnidentifiedAccess?) -> Promise<SignalServiceProfile> func retrieveProfile(recipientId: RecipientIdentifier, unidentifiedAccess: SSKUnidentifiedAccess?) -> Promise<SignalServiceProfile>
} }
@ -82,7 +83,11 @@ public class SignalServiceRestClient: NSObject, SignalServiceClient {
} }
@objc @objc
public func updateAccountAttributes() -> AnyPromise { public func updateAccountAttributesObjC() -> AnyPromise {
return AnyPromise(updateAccountAttributes())
}
public func updateAccountAttributes() -> Promise<Void> {
let request = OWSRequestFactory.updateAttributesRequest() let request = OWSRequestFactory.updateAttributesRequest()
let promise: Promise<Void> = networkManager.makePromise(request: request) let promise: Promise<Void> = networkManager.makePromise(request: request)
.then(execute: { (_, _) in .then(execute: { (_, _) in
@ -90,7 +95,7 @@ public class SignalServiceRestClient: NSObject, SignalServiceClient {
}).catch(execute: { (error) in }).catch(execute: { (error) in
Logger.error("failed to update account attributes on server with error: \(error)") Logger.error("failed to update account attributes on server with error: \(error)")
}) })
return AnyPromise(promise) return promise
} }
public func retrieveProfile(recipientId: RecipientIdentifier, unidentifiedAccess: SSKUnidentifiedAccess?) -> Promise<SignalServiceProfile> { public func retrieveProfile(recipientId: RecipientIdentifier, unidentifiedAccess: SSKUnidentifiedAccess?) -> Promise<SignalServiceProfile> {

Loading…
Cancel
Save