From 8217541d5eff8d6a3b6a574573bd9604f2a70b00 Mon Sep 17 00:00:00 2001 From: AsamK Date: Sun, 9 May 2021 19:28:49 +0200 Subject: [PATCH] Reset profile key credentials when new profile key is changed --- .../manager/storage/recipients/RecipientStore.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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); } }