mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Show information when requesting voice verification without SMS verification
Fixes #1373
This commit is contained in:
parent
f1e3b5c9cc
commit
59c1f4eed2
10 changed files with 39 additions and 8 deletions
|
@ -43,6 +43,7 @@ import org.asamk.signal.manager.api.UpdateGroup;
|
|||
import org.asamk.signal.manager.api.UpdateProfile;
|
||||
import org.asamk.signal.manager.api.UserStatus;
|
||||
import org.asamk.signal.manager.api.UsernameLinkUrl;
|
||||
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||
|
@ -125,7 +126,7 @@ public interface Manager extends Closeable {
|
|||
|
||||
void startChangeNumber(
|
||||
String newNumber, boolean voiceVerification, String captcha
|
||||
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException;
|
||||
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethoNotAvailableException;
|
||||
|
||||
void finishChangeNumber(
|
||||
String newNumber, String verificationCode, String pin
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.asamk.signal.manager.api.IncorrectPinException;
|
|||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
@ -13,7 +14,7 @@ public interface RegistrationManager extends Closeable {
|
|||
|
||||
void register(
|
||||
boolean voiceVerification, String captcha
|
||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException;
|
||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException;
|
||||
|
||||
void verifyAccount(
|
||||
String verificationCode, String pin
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package org.asamk.signal.manager.api;
|
||||
|
||||
public class VerificationMethoNotAvailableException extends Exception {
|
||||
|
||||
public VerificationMethoNotAvailableException() {
|
||||
super("Invalid verification method");
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
|||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
|
||||
import org.asamk.signal.manager.internal.SignalDependencies;
|
||||
import org.asamk.signal.manager.jobs.SyncStorageJob;
|
||||
import org.asamk.signal.manager.storage.SignalAccount;
|
||||
|
@ -164,7 +165,7 @@ public class AccountHelper {
|
|||
|
||||
public void startChangeNumber(
|
||||
String newNumber, boolean voiceVerification, String captcha
|
||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException {
|
||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException {
|
||||
final var accountManager = dependencies.createUnauthenticatedAccountManager(newNumber, account.getPassword());
|
||||
String sessionId = NumberVerificationUtils.handleVerificationSession(accountManager,
|
||||
account.getSessionId(newNumber),
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.asamk.signal.manager.api.UpdateGroup;
|
|||
import org.asamk.signal.manager.api.UpdateProfile;
|
||||
import org.asamk.signal.manager.api.UserStatus;
|
||||
import org.asamk.signal.manager.api.UsernameLinkUrl;
|
||||
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
|
||||
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
||||
import org.asamk.signal.manager.helper.AccountFileUpdater;
|
||||
import org.asamk.signal.manager.helper.Context;
|
||||
|
@ -374,7 +375,7 @@ public class ManagerImpl implements Manager {
|
|||
@Override
|
||||
public void startChangeNumber(
|
||||
String newNumber, boolean voiceVerification, String captcha
|
||||
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException {
|
||||
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethoNotAvailableException {
|
||||
if (!account.isPrimaryDevice()) {
|
||||
throw new NotPrimaryDeviceException();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
|||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.UpdateProfile;
|
||||
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
|
||||
import org.asamk.signal.manager.config.ServiceConfig;
|
||||
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
||||
import org.asamk.signal.manager.helper.AccountFileUpdater;
|
||||
|
@ -104,7 +105,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
@Override
|
||||
public void register(
|
||||
boolean voiceVerification, String captcha
|
||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException {
|
||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException {
|
||||
if (account.isRegistered()
|
||||
&& account.getServiceEnvironment() != null
|
||||
&& account.getServiceEnvironment() != serviceEnvironmentConfig.type()) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
|||
import org.asamk.signal.manager.api.Pair;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
|
||||
import org.asamk.signal.manager.helper.PinHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,7 +35,7 @@ public class NumberVerificationUtils {
|
|||
Consumer<String> sessionIdSaver,
|
||||
boolean voiceVerification,
|
||||
String captcha
|
||||
) throws CaptchaRequiredException, IOException, RateLimitException {
|
||||
) throws CaptchaRequiredException, IOException, RateLimitException, VerificationMethoNotAvailableException {
|
||||
RegistrationSessionMetadataResponse sessionResponse;
|
||||
try {
|
||||
sessionResponse = getValidSession(accountManager, sessionId);
|
||||
|
@ -61,7 +62,9 @@ public class NumberVerificationUtils {
|
|||
final var nextAttempt = voiceVerification
|
||||
? sessionResponse.getBody().getNextCall()
|
||||
: sessionResponse.getBody().getNextSms();
|
||||
if (nextAttempt != null && nextAttempt > 0) {
|
||||
if (nextAttempt == null) {
|
||||
throw new VerificationMethoNotAvailableException();
|
||||
} else if (nextAttempt > 0) {
|
||||
final var timestamp = sessionResponse.getHeaders().getTimestamp() + nextAttempt * 1000;
|
||||
throw new RateLimitException(timestamp);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue