From: AsamK Date: Sun, 9 May 2021 17:28:49 +0000 (+0200) Subject: Reset profile key credentials when new profile key is changed X-Git-Tag: v0.8.2~10 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/8217541d5eff8d6a3b6a574573bd9604f2a70b00 Reset profile key credentials when new profile key is changed --- diff --git a/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java b/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java index 54f4af76..a323c6d9 100644 --- a/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java +++ b/lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java @@ -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); - 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); } }