]> nmode's Git Repositories - signal-cli/commitdiff
Reset profile key credentials when new profile key is changed
authorAsamK <asamk@gmx.de>
Sun, 9 May 2021 17:28:49 +0000 (19:28 +0200)
committerAsamK <asamk@gmx.de>
Sun, 9 May 2021 17:28:49 +0000 (19:28 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java

index 54f4af76da7c4b8a81820c8f0b7547a53a16ea5b..a323c6d99343b957ccc6e5afc3dcf620e86d2f1e 100644 (file)
@@ -226,7 +226,15 @@ public class RecipientStore implements ContactsStore, ProfileStore {
     public void storeProfileKey(final RecipientId recipientId, final ProfileKey profileKey) {
         synchronized (recipients) {
             final var recipient = recipients.get(recipientId);
     public void storeProfileKey(final RecipientId recipientId, final ProfileKey profileKey) {
         synchronized (recipients) {
             final var recipient = recipients.get(recipientId);
-            storeRecipientLocked(recipientId, Recipient.newBuilder(recipient).withProfileKey(profileKey).build());
+            if (profileKey.equals(recipient.getProfileKey())) {
+                return;
+            }
+
+            final var newRecipient = Recipient.newBuilder(recipient)
+                    .withProfileKey(profileKey)
+                    .withProfileKeyCredential(null)
+                    .build();
+            storeRecipientLocked(recipientId, newRecipient);
         }
     }
 
         }
     }