diff --git a/SignalMessaging/profiles/OWSProfileManager.h b/SignalMessaging/profiles/OWSProfileManager.h index e0846acf6..9e917cc6d 100644 --- a/SignalMessaging/profiles/OWSProfileManager.h +++ b/SignalMessaging/profiles/OWSProfileManager.h @@ -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. diff --git a/SignalServiceKit/src/Account/TSAccountManager.m b/SignalServiceKit/src/Account/TSAccountManager.m index 3cb85c82e..b834085de 100644 --- a/SignalServiceKit/src/Account/TSAccountManager.m +++ b/SignalServiceKit/src/Account/TSAccountManager.m @@ -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)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; diff --git a/SignalServiceKit/src/Messages/UD/OWSUDManager.swift b/SignalServiceKit/src/Messages/UD/OWSUDManager.swift index 06dbb54aa..cb7dc7ce7 100644 --- a/SignalServiceKit/src/Messages/UD/OWSUDManager.swift +++ b/SignalServiceKit/src/Messages/UD/OWSUDManager.swift @@ -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 } diff --git a/SignalServiceKit/src/Protocols/ProfileManagerProtocol.h b/SignalServiceKit/src/Protocols/ProfileManagerProtocol.h index 1ab3dda0e..2537676f7 100644 --- a/SignalServiceKit/src/Protocols/ProfileManagerProtocol.h +++ b/SignalServiceKit/src/Protocols/ProfileManagerProtocol.h @@ -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