Skip to content

Commit

Permalink
Set Accept-Language header when requesting SMS code.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal authored and alex-signal committed Jan 11, 2023
1 parent f288184 commit 40f9a25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class VerifyAccountRepository(private val context: Application) {
if (mode == Mode.PHONE_CALL) {
accountManager.requestVoiceVerificationCode(Locale.getDefault(), Optional.ofNullable(captchaToken), pushChallenge, fcmToken)
} else {
accountManager.requestSmsVerificationCode(mode.isSmsRetrieverSupported, Optional.ofNullable(captchaToken), pushChallenge, fcmToken)
accountManager.requestSmsVerificationCode(Locale.getDefault(), mode.isSmsRetrieverSupported, Optional.ofNullable(captchaToken), pushChallenge, fcmToken)
}
}.subscribeOn(Schedulers.io())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ public void requestRegistrationPushChallenge(String gcmRegistrationId, String e1
* @param captchaToken If the user has done a CAPTCHA, include this.
* @param challenge If present, it can bypass the CAPTCHA.
*/
public ServiceResponse<RequestVerificationCodeResponse> requestSmsVerificationCode(boolean androidSmsRetrieverSupported, Optional<String> captchaToken, Optional<String> challenge, Optional<String> fcmToken) {
public ServiceResponse<RequestVerificationCodeResponse> requestSmsVerificationCode(Locale locale, boolean androidSmsRetrieverSupported, Optional<String> captchaToken, Optional<String> challenge, Optional<String> fcmToken) {
try {
this.pushServiceSocket.requestSmsVerificationCode(androidSmsRetrieverSupported, captchaToken, challenge);
this.pushServiceSocket.requestSmsVerificationCode(locale, androidSmsRetrieverSupported, captchaToken, challenge);
return ServiceResponse.forResult(new RequestVerificationCodeResponse(fcmToken), 200, null);
} catch (IOException e) {
return ServiceResponse.forUnknownError(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,17 @@ public PushServiceSocket(SignalServiceConfiguration configuration,
this.clientZkProfileOperations = clientZkProfileOperations;
}

public void requestSmsVerificationCode(boolean androidSmsRetriever, Optional<String> captchaToken, Optional<String> challenge) throws IOException {
String path = String.format(CREATE_ACCOUNT_SMS_PATH, credentialsProvider.getE164(), androidSmsRetriever ? "android-2021-03" : "android");
public void requestSmsVerificationCode(Locale locale, boolean androidSmsRetriever, Optional<String> captchaToken, Optional<String> challenge) throws IOException {
Map<String, String> headers = locale != null ? Collections.singletonMap("Accept-Language", locale.getLanguage() + "-" + locale.getCountry()) : NO_HEADERS;
String path = String.format(CREATE_ACCOUNT_SMS_PATH, credentialsProvider.getE164(), androidSmsRetriever ? "android-2021-03" : "android");

if (captchaToken.isPresent()) {
path += "&captcha=" + captchaToken.get();
} else if (challenge.isPresent()) {
path += "&challenge=" + challenge.get();
}

makeServiceRequest(path, "GET", null, NO_HEADERS, new VerificationCodeResponseHandler(), Optional.empty());
makeServiceRequest(path, "GET", null, headers, new VerificationCodeResponseHandler(), Optional.empty());
}

public void requestVoiceVerificationCode(Locale locale, Optional<String> captchaToken, Optional<String> challenge) throws IOException {
Expand Down

0 comments on commit 40f9a25

Please sign in to comment.