Set Accept-Language header when requesting SMS code.

main
Greyson Parrelli 2023-01-10 17:24:35 -05:00 zatwierdzone przez Alex Hart
rodzic f2881843db
commit 40f9a25b87
3 zmienionych plików z 7 dodań i 6 usunięć

Wyświetl plik

@ -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())
}

Wyświetl plik

@ -239,9 +239,9 @@ public class SignalServiceAccountManager {
* @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);

Wyświetl plik

@ -320,8 +320,9 @@ public class PushServiceSocket {
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();
@ -329,7 +330,7 @@ public class PushServiceSocket {
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 {