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> {
let (promise, fulfill, reject) = Promise<Void>.pending()
tsAccountManager.setIsManualMessageFetchEnabled(true)
.then(execute: { (_) in
fulfill(())
}).catch(execute: { (error) in
reject(error)
})
return promise
return tsAccountManager.setIsManualMessageFetchEnabled(true).asPromise().asVoid()
}
// MARK: Turn Server

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

@ -632,6 +632,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
#pragma mark - Account Attributes
- (AnyPromise *)updateAccountAttributes {
// Enqueue a "account attribute update", recording the "request time".
[self.dbConnection setObject:[NSDate new]
forKey:TSAccountManager_NeedsAccountAttributesUpdateKey
inCollection:TSAccountManager_UserAccountCollection];
@ -647,10 +648,11 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
return [AnyPromise promiseWithValue:@(1)];
}
AnyPromise *promise = [[SignalServiceRestClient new] updateAccountAttributes];
AnyPromise *promise = [[SignalServiceRestClient new] updateAccountAttributesObjC];
promise = promise.then(^(id value) {
[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 =
[transaction objectForKey:TSAccountManager_NeedsAccountAttributesUpdateKey
inCollection:TSAccountManager_UserAccountCollection];

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

Loading…
Cancel
Save