Don't assume all linked devices support UD.

pull/1/head
Matthew Chen 7 years ago
parent d9e5e9ddc5
commit 9322442881

@ -51,10 +51,6 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName;
// The local profile state can fall out of sync with the service
// (e.g. due to a botched profile update, for example).
- (void)fetchLocalUsersProfile;
#pragma mark - Profile Whitelist
// These methods are for debugging.

@ -10,6 +10,7 @@
#import "OWSError.h"
#import "OWSPrimaryStorage+SessionStore.h"
#import "OWSRequestFactory.h"
#import "ProfileManagerProtocol.h"
#import "SSKEnvironment.h"
#import "TSNetworkManager.h"
#import "TSPreKeyManager.h"
@ -117,6 +118,12 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
return SSKEnvironment.shared.networkManager;
}
- (id<ProfileManagerProtocol>)profileManager {
OWSAssertDebug(SSKEnvironment.shared.profileManager);
return SSKEnvironment.shared.profileManager;
}
#pragma mark -
- (void)setPhoneNumberAwaitingVerification:(NSString *_Nullable)phoneNumberAwaitingVerification
@ -661,6 +668,12 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
inCollection:TSAccountManager_UserAccountCollection];
}
}];
// Fetch the local profile, as we may have changed its
// account attributes. Specifically, we need to determine
// if all devices for our account now support UD for sync
// messages.
[self.profileManager fetchLocalUsersProfile];
});
[promise retainUntilComplete];
return promise;

@ -152,14 +152,6 @@ public class OWSUDManagerImpl: NSObject, OWSUDManager {
@objc
func unidentifiedAccessMode(recipientId: RecipientIdentifier) -> UnidentifiedAccessMode {
if tsAccountManager.localNumber() == recipientId {
if shouldAllowUnrestrictedAccessLocal() {
return .unrestricted
} else {
return .enabled
}
}
guard let existingRawValue = dbConnection.object(forKey: recipientId, inCollection: kUnidentifiedAccessCollection) as? Int else {
return .unknown
}

@ -1,9 +1,9 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
@class TSThread;
@class OWSAES256Key;
@class TSThread;
NS_ASSUME_NONNULL_BEGIN
@ -21,6 +21,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)addUserToProfileWhitelist:(NSString *)recipientId;
- (void)addGroupIdToProfileWhitelist:(NSData *)groupId;
- (void)fetchLocalUsersProfile;
@end
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save