@Override
public void register(
- boolean voiceVerification, String captcha
+ boolean voiceVerification, String captcha, final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException {
if (account.isRegistered()
&& account.getServiceEnvironment() != null
}
try {
- final var recoveryPassword = account.getRecoveryPassword();
- if (recoveryPassword != null && account.isPrimaryDevice() && attemptReregisterAccount(recoveryPassword)) {
- return;
+ if (!forceRegister) {
+ if (account.isRegistered()) {
+ throw new IOException("Account is already registered");
+ }
+
+ if (account.getAci() != null && attemptReactivateAccount()) {
+ return;
+ }
}
- if (account.getAci() != null && attemptReactivateAccount()) {
+ final var recoveryPassword = account.getRecoveryPassword();
+ if (recoveryPassword != null && account.isPrimaryDevice() && attemptReregisterAccount(recoveryPassword)) {
return;
}
voiceVerification,
captcha);
NumberVerificationUtils.requestVerificationCode(accountManager, sessionId, voiceVerification);
+ account.setRegistered(false);
} catch (DeprecatedVersionException e) {
logger.debug("Signal-Server returned deprecated version exception", e);
throw e;