]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/helper/AccountHelper.java
Improve behavior when pin data doesn't exist on the server
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / helper / AccountHelper.java
index 7d40f99c41114386265e6914052e1cf388f7cee8..de3e2402c99c6f0eb2b957eb6d6e1d500d76a770 100644 (file)
@@ -4,6 +4,7 @@ import org.asamk.signal.manager.api.CaptchaRequiredException;
 import org.asamk.signal.manager.api.DeviceLinkUrl;
 import org.asamk.signal.manager.api.IncorrectPinException;
 import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
+import org.asamk.signal.manager.api.PinLockMissingException;
 import org.asamk.signal.manager.api.PinLockedException;
 import org.asamk.signal.manager.api.RateLimitException;
 import org.asamk.signal.manager.api.VerificationMethodNotAvailableException;
@@ -105,7 +106,7 @@ public class AccountHelper {
             if (!account.isPrimaryDevice() && account.getPniIdentityKeyPair() == null) {
                 throw new IOException("Missing PNI identity key, relinking required");
             }
-            if (account.getPreviousStorageVersion() < 4
+            if (account.getPreviousStorageVersion() < 10
                     && account.isPrimaryDevice()
                     && account.getRegistrationLockPin() != null) {
                 migrateRegistrationPin();
@@ -185,7 +186,7 @@ public class AccountHelper {
             String newNumber,
             String verificationCode,
             String pin
-    ) throws IncorrectPinException, PinLockedException, IOException {
+    ) throws IncorrectPinException, PinLockedException, IOException, PinLockMissingException {
         for (var attempts = 0; attempts < 5; attempts++) {
             try {
                 finishChangeNumberInternal(newNumber, verificationCode, pin);
@@ -205,7 +206,7 @@ public class AccountHelper {
             String newNumber,
             String verificationCode,
             String pin
-    ) throws IncorrectPinException, PinLockedException, IOException {
+    ) throws IncorrectPinException, PinLockedException, IOException, PinLockMissingException {
         final var pniIdentity = KeyUtils.generateIdentityKeyPair();
         final var encryptedDeviceMessages = new ArrayList<OutgoingPushMessage>();
         final var devicePniSignedPreKeys = new HashMap<Integer, SignedPreKeyEntity>();
@@ -535,9 +536,9 @@ public class AccountHelper {
                         account.getAciIdentityKeyPair(),
                         account.getPniIdentityKeyPair(),
                         account.getProfileKey(),
+                        account.getOrCreateAccountEntropyPool(),
                         account.getOrCreatePinMasterKey(),
                         account.getOrCreateMediaRootBackupKey(),
-                        account.getOrCreateAccountEntropyPool(),
                         verificationCode.getVerificationCode(),
                         null));
         account.setMultiDevice(true);
@@ -595,7 +596,7 @@ public class AccountHelper {
         }
         account.setRegistrationLockPin(null);
 
-        dependencies.getAccountManager().deleteAccount();
+        handleResponseException(dependencies.getAccountApi().deleteAccount());
 
         account.setRegistered(false);
         unregisteredListener.call();