mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Add register parameter to force reregistration
This commit is contained in:
parent
2e4cd0eddc
commit
2424fc1f53
6 changed files with 31 additions and 14 deletions
|
@ -13,7 +13,7 @@ import java.io.IOException;
|
|||
public interface RegistrationManager extends Closeable {
|
||||
|
||||
void register(
|
||||
boolean voiceVerification, String captcha
|
||||
boolean voiceVerification, String captcha, final boolean forceRegister
|
||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethoNotAvailableException;
|
||||
|
||||
void verifyAccount(
|
||||
|
|
|
@ -104,7 +104,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
@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
|
||||
|
@ -113,12 +113,18 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -128,6 +134,7 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
voiceVerification,
|
||||
captcha);
|
||||
NumberVerificationUtils.requestVerificationCode(accountManager, sessionId, voiceVerification);
|
||||
account.setRegistered(false);
|
||||
} catch (DeprecatedVersionException e) {
|
||||
logger.debug("Signal-Server returned deprecated version exception", e);
|
||||
throw e;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue