Show information when requesting voice verification without SMS verification

Fixes #1373
This commit is contained in:
AsamK 2024-02-20 17:37:31 +01:00
parent f1e3b5c9cc
commit 59c1f4eed2
10 changed files with 39 additions and 8 deletions

View file

@ -15,6 +15,7 @@ import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.output.JsonWriter;
import org.asamk.signal.util.CommandUtil;
@ -79,6 +80,12 @@ public class RegisterCommand implements RegistrationCommand, JsonRpcRegistration
} catch (IOException e) {
throw new IOErrorException("Failed to register: %s (%s)".formatted(e.getMessage(),
e.getClass().getSimpleName()), e);
} catch (VerificationMethoNotAvailableException e) {
throw new UserErrorException("Failed to register: " + e.getMessage() + (
voiceVerification
? ": Before requesting voice verification you need to request SMS verification and wait a minute."
: ""
), e);
}
}

View file

@ -13,6 +13,7 @@ import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
import org.asamk.signal.manager.api.RateLimitException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.asamk.signal.output.OutputWriter;
import org.asamk.signal.util.CommandUtil;
@ -59,6 +60,12 @@ public class StartChangeNumberCommand implements JsonRpcLocalCommand {
} catch (IOException e) {
throw new IOErrorException("Failed to change number: %s (%s)".formatted(e.getMessage(),
e.getClass().getSimpleName()), e);
} catch (VerificationMethoNotAvailableException e) {
throw new UserErrorException("Failed to register: " + e.getMessage() + (
voiceVerification
? ": Before requesting voice verification you need to request SMS verification and wait a minute."
: ""
), e);
}
}
}

View file

@ -13,6 +13,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.UserAlreadyExistsException;
import org.asamk.signal.manager.api.VerificationMethoNotAvailableException;
import org.freedesktop.dbus.DBusPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -73,7 +74,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
throw new Error.InvalidNumber(e.getMessage());
} catch (OverlappingFileLockException e) {
throw new SignalControl.Error.Failure("Account is already in use");
} catch (IOException e) {
} catch (IOException | VerificationMethoNotAvailableException e) {
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
}
}