diff --git a/SignalServiceKit/src/Account/TSAccountManager.h b/SignalServiceKit/src/Account/TSAccountManager.h index a60dc410f..a9e4ba626 100644 --- a/SignalServiceKit/src/Account/TSAccountManager.h +++ b/SignalServiceKit/src/Account/TSAccountManager.h @@ -18,7 +18,10 @@ extern NSString *const kNSNotificationName_LocalNumberDidChange; @interface TSAccountManager : NSObject -@property (nonatomic, nullable, readonly) NSString *phoneNumberAwaitingVerification; +// This property is exposed for testing purposes only. +#ifdef DEBUG +@property (nonatomic, nullable) NSString *phoneNumberAwaitingVerification; +#endif #pragma mark - Initializers @@ -116,8 +119,12 @@ extern NSString *const kNSNotificationName_LocalNumberDidChange; #pragma mark - De-Registration -// De-registration reflects whether or not the client has received -// a 403 from the service. +// De-registration reflects whether or not the "last known contact" +// with the service was: +// +// * A 403 from the service, indicating de-registration. +// * A successful auth'd request _or_ websocket connection indicating +// valid registration. - (BOOL)isDeregistered; - (void)setIsDeregistered:(BOOL)isDeregistered; diff --git a/SignalServiceKit/src/Account/TSAccountManager.m b/SignalServiceKit/src/Account/TSAccountManager.m index 09c0e19f7..0a5533296 100644 --- a/SignalServiceKit/src/Account/TSAccountManager.m +++ b/SignalServiceKit/src/Account/TSAccountManager.m @@ -40,7 +40,10 @@ NSString *const TSAccountManager_ServerSignalingKey = @"TSStorageServerSignaling @property (nonatomic, readonly) BOOL isRegistered; +// This property is exposed publicly for testing purposes only. +#ifndef DEBUG @property (nonatomic, nullable) NSString *phoneNumberAwaitingVerification; +#endif @property (nonatomic, nullable) NSString *cachedLocalNumber; @property (nonatomic, readonly) YapDatabaseConnection *dbConnection; @@ -73,10 +76,6 @@ NSString *const TSAccountManager_ServerSignalingKey = @"TSStorageServerSignaling selector:@selector(yapDatabaseModifiedExternally:) name:YapDatabaseModifiedExternallyNotification object:nil]; - - self.phoneNumberAwaitingVerification = - [self.dbConnection stringForKey:TSAccountManager_ReregisteringPhoneNumberKey - inCollection:TSAccountManager_UserAccountCollection]; } return self; @@ -189,6 +188,8 @@ NSString *const TSAccountManager_ServerSignalingKey = @"TSStorageServerSignaling inCollection:TSAccountManager_UserAccountCollection]; self.phoneNumberAwaitingVerification = nil; + + self.cachedLocalNumber = localNumber; } } diff --git a/SignalServiceKit/src/Network/API/TSNetworkManager.m b/SignalServiceKit/src/Network/API/TSNetworkManager.m index 6e00e038f..938f57fa7 100644 --- a/SignalServiceKit/src/Network/API/TSNetworkManager.m +++ b/SignalServiceKit/src/Network/API/TSNetworkManager.m @@ -88,7 +88,9 @@ typedef void (^failureBlock)(NSURLSessionDataTask *task, NSError *error); TSNetworkManagerSuccess success = ^(NSURLSessionDataTask *task, _Nullable id responseObject) { DDLogInfo(@"%@ request succeeded : %@", self.logTag, request); - [TSAccountManager.sharedInstance setIsDeregistered:NO]; + if (request.shouldHaveAuthorizationHeaders) { + [TSAccountManager.sharedInstance setIsDeregistered:NO]; + } successBlock(task, responseObject); };