Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent 4342b04bd3
commit 61ec865b6d

@ -35,7 +35,12 @@ NSString *const TSAccountManager_ServerSignalingKey = @"TSStorageServerSignaling
@interface TSAccountManager () @interface TSAccountManager ()
@property (nonatomic, readonly) BOOL isRegistered; @property (nonatomic, readonly) BOOL isRegistered;
// This property is exposed publicly for testing purposes only.
#ifndef DEBUG
@property (nonatomic, nullable) NSString *phoneNumberAwaitingVerification; @property (nonatomic, nullable) NSString *phoneNumberAwaitingVerification;
#endif
@property (nonatomic, nullable) NSString *cachedLocalNumber; @property (nonatomic, nullable) NSString *cachedLocalNumber;
@property (nonatomic, readonly) YapDatabaseConnection *dbConnection; @property (nonatomic, readonly) YapDatabaseConnection *dbConnection;

@ -985,7 +985,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
deviceMessages:deviceMessages deviceMessages:deviceMessages
success:successHandler]; success:successHandler];
} }
failure:^(NSInteger statusCode, NSData *_Nullable responseBody, NSError *error) { failure:^(NSInteger statusCode, NSData *_Nullable responseData, NSError *error) {
[self messageSendDidFail:message [self messageSendDidFail:message
recipient:recipient recipient:recipient
thread:thread thread:thread
@ -994,7 +994,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
remainingAttempts:remainingAttempts remainingAttempts:remainingAttempts
statusCode:statusCode statusCode:statusCode
error:error error:error
responseData:responseBody responseData:responseData
success:successHandler success:successHandler
failure:failureHandler]; failure:failureHandler];
}]; }];

@ -18,7 +18,7 @@ typedef NS_ENUM(NSUInteger, SocketManagerState) {
typedef void (^TSSocketMessageSuccess)(id _Nullable responseObject); typedef void (^TSSocketMessageSuccess)(id _Nullable responseObject);
// statusCode is zero by default, if request never made or failed. // statusCode is zero by default, if request never made or failed.
typedef void (^TSSocketMessageFailure)(NSInteger statusCode, NSData *_Nullable responseBody, NSError *error); typedef void (^TSSocketMessageFailure)(NSInteger statusCode, NSData *_Nullable responseData, NSError *error);
@class TSRequest; @class TSRequest;

@ -102,10 +102,10 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeMessageRequestFailed, NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeMessageRequestFailed,
NSLocalizedString(@"ERROR_DESCRIPTION_REQUEST_FAILED", @"Error indicating that a socket request failed.")); NSLocalizedString(@"ERROR_DESCRIPTION_REQUEST_FAILED", @"Error indicating that a socket request failed."));
[self didFailWithStatusCode:0 responseBody:nil error:error]; [self didFailWithStatusCode:0 responseData:nil error:error];
} }
- (void)didFailWithStatusCode:(NSInteger)statusCode responseBody:(nullable NSData *)responseBody error:(NSError *)error - (void)didFailWithStatusCode:(NSInteger)statusCode responseData:(nullable NSData *)responseData error:(NSError *)error
{ {
OWSAssert(error); OWSAssert(error);
@ -124,7 +124,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
TSSocketMessageFailure failure = self.failure; TSSocketMessageFailure failure = self.failure;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
failure(statusCode, responseBody, error); failure(statusCode, responseData, error);
}); });
self.success = nil; self.success = nil;
@ -570,18 +570,18 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
if (message.hasMessage) { if (message.hasMessage) {
responseMessage = message.message; responseMessage = message.message;
} }
NSData *_Nullable responseBody; NSData *_Nullable responseData;
if (message.hasBody) { if (message.hasBody) {
responseBody = message.body; responseData = message.body;
} }
NSArray<NSString *> *_Nullable responseHeaders = message.headers; NSArray<NSString *> *_Nullable responseHeaders = message.headers;
BOOL hasValidResponse = YES; BOOL hasValidResponse = YES;
id responseObject = responseBody; id responseObject = responseData;
if (responseBody) { if (responseData) {
NSError *error; NSError *error;
id _Nullable responseJson = id _Nullable responseJson =
[NSJSONSerialization JSONObjectWithData:responseBody options:(NSJSONReadingOptions)0 error:&error]; [NSJSONSerialization JSONObjectWithData:responseData options:(NSJSONReadingOptions)0 error:&error];
if (!responseJson || error) { if (!responseJson || error) {
OWSProdLogAndFail(@"%@ could not parse WebSocket response JSON: %@.", self.logTag, error); OWSProdLogAndFail(@"%@ could not parse WebSocket response JSON: %@.", self.logTag, error);
hasValidResponse = NO; hasValidResponse = NO;
@ -608,7 +608,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeMessageResponseFailed, NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeMessageResponseFailed,
NSLocalizedString( NSLocalizedString(
@"ERROR_DESCRIPTION_RESPONSE_FAILED", @"Error indicating that a socket response failed.")); @"ERROR_DESCRIPTION_RESPONSE_FAILED", @"Error indicating that a socket response failed."));
[socketMessage didFailWithStatusCode:(NSInteger)responseStatus responseBody:responseBody error:error]; [socketMessage didFailWithStatusCode:(NSInteger)responseStatus responseData:responseData error:error];
} }
} }
@ -617,7 +617,7 @@ NSString *const kNSNotification_SocketManagerStateDidChange = @"kNSNotification_
(unsigned long long)requestId, (unsigned long long)requestId,
(NSInteger)responseStatus, (NSInteger)responseStatus,
responseMessage, responseMessage,
responseBody.length, responseData.length,
responseHeaders, responseHeaders,
socketMessage != nil, socketMessage != nil,
responseObject); responseObject);

Loading…
Cancel
Save