]> nmode's Git Repositories - signal-cli/commitdiff
Fix npr when upgrading old accounts
authorAsamK <asamk@gmx.de>
Sun, 20 Aug 2023 20:37:25 +0000 (22:37 +0200)
committerAsamK <asamk@gmx.de>
Sun, 20 Aug 2023 20:37:25 +0000 (22:37 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java

index 6f1a00eee3be948923e3ad73345f707e6eedd5db..8d719ea33a28baa40d4fab9f4a5a5a9650eae020 100644 (file)
@@ -396,9 +396,7 @@ public class SignalAccount implements Closeable {
         this.setStorageManifest(null);
         this.storageKey = null;
         trustSelfIdentity(ServiceIdType.ACI);
         this.setStorageManifest(null);
         this.storageKey = null;
         trustSelfIdentity(ServiceIdType.ACI);
-        if (getPniIdentityKeyPair() != null) {
-            trustSelfIdentity(ServiceIdType.PNI);
-        }
+        trustSelfIdentity(ServiceIdType.PNI);
     }
 
     private void migrateLegacyConfigs() {
     }
 
     private void migrateLegacyConfigs() {
@@ -1373,6 +1371,7 @@ public class SignalAccount implements Closeable {
         }
 
         this.pni = updatedPni;
         }
 
         this.pni = updatedPni;
+        trustSelfIdentity(ServiceIdType.PNI);
         save();
     }
 
         save();
     }
 
@@ -1676,7 +1675,11 @@ public class SignalAccount implements Closeable {
     private void trustSelfIdentity(ServiceIdType serviceIdType) {
         final var accountData = getAccountData(serviceIdType);
         final var serviceId = accountData.getServiceId();
     private void trustSelfIdentity(ServiceIdType serviceIdType) {
         final var accountData = getAccountData(serviceIdType);
         final var serviceId = accountData.getServiceId();
-        final var publicKey = accountData.getIdentityKeyPair().getPublicKey();
+        final var identityKeyPair = accountData.getIdentityKeyPair();
+        if (serviceId == null || identityKeyPair == null) {
+            return;
+        }
+        final var publicKey = identityKeyPair.getPublicKey();
         getIdentityKeyStore().saveIdentity(serviceId, publicKey);
         getIdentityKeyStore().setIdentityTrustLevel(serviceId, publicKey, TrustLevel.TRUSTED_VERIFIED);
     }
         getIdentityKeyStore().saveIdentity(serviceId, publicKey);
         getIdentityKeyStore().setIdentityTrustLevel(serviceId, publicKey, TrustLevel.TRUSTED_VERIFIED);
     }