Simplify verification code request

This commit is contained in:
AsamK 2024-10-28 10:35:18 +01:00
parent acddef6e35
commit 1b959608c3
2 changed files with 5 additions and 14 deletions

View file

@ -10,7 +10,6 @@ import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
import org.asamk.signal.manager.helper.PinHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.signalservice.api.NetworkResult;
import org.whispersystems.signalservice.api.kbs.MasterKey;
import org.whispersystems.signalservice.api.push.exceptions.NoSuchSessionException;
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
@ -91,19 +90,11 @@ public class NumberVerificationUtils {
public static void requestVerificationCode(
RegistrationApi registrationApi, String sessionId, boolean voiceVerification
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException {
final NetworkResult<RegistrationSessionMetadataResponse> response;
final var locale = Utils.getDefaultLocale(Locale.US);
if (voiceVerification) {
response = registrationApi.requestSmsVerificationCode(sessionId,
locale,
false,
VerificationCodeTransport.VOICE);
} else {
response = registrationApi.requestSmsVerificationCode(sessionId,
locale,
false,
VerificationCodeTransport.SMS);
}
final var response = registrationApi.requestSmsVerificationCode(sessionId,
locale,
false,
voiceVerification ? VerificationCodeTransport.VOICE : VerificationCodeTransport.SMS);
try {
Utils.handleResponseException(response);
} catch (org.whispersystems.signalservice.api.push.exceptions.CaptchaRequiredException e) {