diff --git a/src/Account/TSAccountManager.h b/src/Account/TSAccountManager.h index 9a7a63def..964f47442 100644 --- a/src/Account/TSAccountManager.h +++ b/src/Account/TSAccountManager.h @@ -64,6 +64,7 @@ static NSString *const TSRegistrationErrorUserInfoHTTPStatus = @"TSHTTPStatus"; + (void)rerequestVoiceWithSuccess:(void (^)())successBlock failure:(void (^)(NSError *error))failureBlock; - (void)verifyAccountWithCode:(NSString *)verificationCode + isWebRTCEnabled:(BOOL)isWebRTCEnabled success:(void (^)())successBlock failure:(void (^)(NSError *error))failureBlock; diff --git a/src/Account/TSAccountManager.m b/src/Account/TSAccountManager.m index b7a25bd08..cd4a0fdae 100644 --- a/src/Account/TSAccountManager.m +++ b/src/Account/TSAccountManager.m @@ -181,6 +181,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)verifyAccountWithCode:(NSString *)verificationCode + isWebRTCEnabled:(BOOL)isWebRTCEnabled success:(void (^)())successBlock failure:(void (^)(NSError *error))failureBlock { @@ -195,7 +196,8 @@ NS_ASSUME_NONNULL_BEGIN TSVerifyCodeRequest *request = [[TSVerifyCodeRequest alloc] initWithVerificationCode:verificationCode forNumber:phoneNumber signalingKey:signalingKey - authKey:authToken]; + authKey:authToken + isWebRTCEnabled:isWebRTCEnabled]; [self.networkManager makeRequest:request success:^(NSURLSessionDataTask *task, id responseObject) { diff --git a/src/Account/TSAttributes.h b/src/Account/TSAttributes.h index 0cd1faf1c..fea637831 100644 --- a/src/Account/TSAttributes.h +++ b/src/Account/TSAttributes.h @@ -10,9 +10,10 @@ @interface TSAttributes : NSObject -+ (NSDictionary *)attributesFromStorageWithVoiceSupport; ++ (NSDictionary *)attributesFromStorage:(BOOL)isWebRTCEnabled; + (NSDictionary *)attributesWithSignalingKey:(NSString *)signalingKey - serverAuthToken:(NSString *)authToken; + serverAuthToken:(NSString *)authToken + isWebRTCEnabled:(BOOL)isWebRTCEnabled; @end diff --git a/src/Account/TSAttributes.m b/src/Account/TSAttributes.m index c6fd9f651..340ef8c29 100644 --- a/src/Account/TSAttributes.m +++ b/src/Account/TSAttributes.m @@ -13,18 +13,21 @@ @implementation TSAttributes -+ (NSDictionary *)attributesFromStorageWithVoiceSupport { ++ (NSDictionary *)attributesFromStorage:(BOOL)isWebRTCEnabled { return [self attributesWithSignalingKey:[TSStorageManager signalingKey] - serverAuthToken:[TSStorageManager serverAuthToken]]; + serverAuthToken:[TSStorageManager serverAuthToken] + isWebRTCEnabled:isWebRTCEnabled]; } + (NSDictionary *)attributesWithSignalingKey:(NSString *)signalingKey serverAuthToken:(NSString *)authToken + isWebRTCEnabled:(BOOL)isWebRTCEnabled { return @{ @"signalingKey" : signalingKey, @"AuthKey" : authToken, - @"voice" : [NSNumber numberWithBool:YES], // all Signal-iOS clients support voice + @"voice" : @(YES), // all Signal-iOS clients support voice + @"video" : @(isWebRTCEnabled), @"registrationId" : [NSString stringWithFormat:@"%i", [TSAccountManager getOrGenerateRegistrationId]] }; } diff --git a/src/Network/API/Requests/TSUpdateAttributesRequest.h b/src/Network/API/Requests/TSUpdateAttributesRequest.h index 1347ef864..4398811c6 100644 --- a/src/Network/API/Requests/TSUpdateAttributesRequest.h +++ b/src/Network/API/Requests/TSUpdateAttributesRequest.h @@ -10,6 +10,6 @@ @interface TSUpdateAttributesRequest : TSRequest -- (instancetype)initWithUpdatedAttributesWithVoice; +- (instancetype)initWithUpdatedAttributes:(BOOL)isWebRTCEnabled; @end diff --git a/src/Network/API/Requests/TSUpdateAttributesRequest.m b/src/Network/API/Requests/TSUpdateAttributesRequest.m index c27b33457..f002fcf66 100644 --- a/src/Network/API/Requests/TSUpdateAttributesRequest.m +++ b/src/Network/API/Requests/TSUpdateAttributesRequest.m @@ -12,13 +12,13 @@ @implementation TSUpdateAttributesRequest -- (instancetype)initWithUpdatedAttributesWithVoice { +- (instancetype)initWithUpdatedAttributes:(BOOL)isWebRTCEnabled { NSString *endPoint = [textSecureAccountsAPI stringByAppendingString:textSecureAttributesAPI]; self = [super initWithURL:[NSURL URLWithString:endPoint]]; if (self) { [self setHTTPMethod:@"PUT"]; - [self.parameters addEntriesFromDictionary:[TSAttributes attributesFromStorageWithVoiceSupport]]; + [self.parameters addEntriesFromDictionary:[TSAttributes attributesFromStorage:isWebRTCEnabled]]; } return self; diff --git a/src/Network/API/Requests/TSVerifyCodeRequest.h b/src/Network/API/Requests/TSVerifyCodeRequest.h index 496777be9..60fd79cc4 100644 --- a/src/Network/API/Requests/TSVerifyCodeRequest.h +++ b/src/Network/API/Requests/TSVerifyCodeRequest.h @@ -13,7 +13,8 @@ - (TSRequest *)initWithVerificationCode:(NSString *)verificationCode forNumber:(NSString *)phoneNumber signalingKey:(NSString *)signalingKey - authKey:(NSString *)authKey; + authKey:(NSString *)authKey + isWebRTCEnabled:(BOOL)isWebRTCEnabled; @property (nonatomic, readonly) NSString *numberToValidate; diff --git a/src/Network/API/Requests/TSVerifyCodeRequest.m b/src/Network/API/Requests/TSVerifyCodeRequest.m index 5c67b2df0..e9f791ae7 100644 --- a/src/Network/API/Requests/TSVerifyCodeRequest.m +++ b/src/Network/API/Requests/TSVerifyCodeRequest.m @@ -16,13 +16,16 @@ - (TSRequest *)initWithVerificationCode:(NSString *)verificationCode forNumber:(NSString *)phoneNumber signalingKey:(NSString *)signalingKey - authKey:(NSString *)authKey { + authKey:(NSString *)authKey + isWebRTCEnabled:(BOOL)isWebRTCEnabled { self = [super initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/code/%@", textSecureAccountsAPI, verificationCode]]]; NSDictionary *attributes = - [TSAttributes attributesWithSignalingKey:signalingKey serverAuthToken:authKey]; + [TSAttributes attributesWithSignalingKey:signalingKey + serverAuthToken:authKey + isWebRTCEnabled:isWebRTCEnabled]; _numberToValidate = phoneNumber; [self.parameters addEntriesFromDictionary:attributes];