]> nmode's Git Repositories - signal-cli/blobdiff - lib/src/main/java/org/asamk/signal/manager/helper/AccountHelper.java
Add fallback KBS and migrate to current version
[signal-cli] / lib / src / main / java / org / asamk / signal / manager / helper / AccountHelper.java
index 78cffa23e670fa0728a31817c958482c4514d0a7..99a0834e32b98674ee782f78fd099f3e062f846d 100644 (file)
@@ -60,6 +60,7 @@ public class AccountHelper {
             }
         }
         try {
+            updateAccountAttributes();
             context.getPreKeyHelper().refreshPreKeysIfNecessary();
             if (account.getAci() == null || account.getPni() == null) {
                 checkWhoAmiI();
@@ -67,7 +68,11 @@ public class AccountHelper {
             if (!account.isPrimaryDevice() && account.getPniIdentityKeyPair() == null) {
                 context.getSyncHelper().requestSyncPniIdentity();
             }
-            updateAccountAttributes();
+            if (account.getPreviousStorageVersion() < 4
+                    && account.isPrimaryDevice()
+                    && account.getRegistrationLockPin() != null) {
+                migrateRegistrationPin();
+            }
         } catch (AuthorizationFailedException e) {
             account.setRegistered(false);
             throw e;
@@ -171,6 +176,12 @@ public class AccountHelper {
         account.setMultiDevice(devices.size() > 1);
     }
 
+    public void migrateRegistrationPin() throws IOException {
+        var masterKey = account.getOrCreatePinMasterKey();
+
+        context.getPinHelper().migrateRegistrationLockPin(account.getRegistrationLockPin(), masterKey);
+    }
+
     public void setRegistrationPin(String pin) throws IOException {
         var masterKey = account.getOrCreatePinMasterKey();