Leave primary to upload profile key commitment.

This commit is contained in:
Matthew Chen 2020-02-24 16:24:24 -03:00
parent fc89afed20
commit ac59e34597
5 changed files with 35 additions and 0 deletions

View File

@ -430,6 +430,17 @@ const NSString *kNSNotificationKey_WasLocallyInitiated = @"kNSNotificationKey_Wa
[ProfileFetcherJob fetchAndUpdateProfileWithAddress:address ignoreThrottling:YES];
}
- (AnyPromise *)fetchLocalUsersProfilePromise
{
SignalServiceAddress *_Nullable localAddress = self.tsAccountManager.localAddress;
if (!localAddress.isValid) {
return [AnyPromise promiseWithValue:OWSErrorMakeAssertionError(@"Missing local address.")];
}
return [ProfileFetcherJob fetchAndUpdateProfilePromiseObjcWithAddress:localAddress
mainAppOnly:NO
ignoreThrottling:YES];
}
- (void)fetchAndUpdateProfileForUsername:(NSString *)username
success:(void (^)(SignalServiceAddress *))success
notFound:(void (^)(void))notFound

View File

@ -106,6 +106,15 @@ public class ProfileFetcherJob: NSObject {
private var backgroundTask: OWSBackgroundTask?
@objc
public class func fetchAndUpdateProfilePromiseObjc(address: SignalServiceAddress,
mainAppOnly: Bool,
ignoreThrottling: Bool) -> AnyPromise {
return AnyPromise(fetchAndUpdateProfilePromise(address: address,
mainAppOnly: mainAppOnly,
ignoreThrottling: ignoreThrottling))
}
public class func fetchAndUpdateProfilePromise(address: SignalServiceAddress,
mainAppOnly: Bool = true,
ignoreThrottling: Bool = false,

View File

@ -2,6 +2,7 @@
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
//
@class AnyPromise;
@class OWSAES256Key;
@class SDSAnyReadTransaction;
@class SDSAnyWriteTransaction;
@ -72,6 +73,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)fetchAndUpdateLocalUsersProfile;
- (AnyPromise *)fetchLocalUsersProfilePromise;
- (void)updateProfileForAddress:(SignalServiceAddress *)address;
- (BOOL)recipientAddressIsUuidCapable:(SignalServiceAddress *)address transaction:(SDSAnyReadTransaction *)transaction;

View File

@ -190,6 +190,12 @@ NS_ASSUME_NONNULL_BEGIN
// Do nothing.
}
- (AnyPromise *)fetchLocalUsersProfilePromise
{
// Do nothing.
return [AnyPromise promiseWithValue:nil];
}
- (void)updateProfileForAddress:(nonnull SignalServiceAddress *)address
{
// Do nothing.

View File

@ -1491,6 +1491,12 @@ public class GroupManager: NSObject {
guard !hasLocalCredential else {
return Promise.value(())
}
guard tsAccountManager.isRegisteredPrimaryDevice else {
// On secondary devices, just re-fetch the local
// profile.
return self.profileManager.fetchLocalUsersProfilePromise().asVoid()
}
// We (and other clients) need a profile key credential for
// all group members to use groups v2. Other clients can't
// request our profile key credential from the service until