Reset profile key credentials when new profile key is changed

This commit is contained in:
AsamK 2021-05-09 19:28:49 +02:00
parent ab95e635ce
commit 8217541d5e

View file

@ -226,7 +226,15 @@ public class RecipientStore implements ContactsStore, ProfileStore {
public void storeProfileKey(final RecipientId recipientId, final ProfileKey profileKey) { public void storeProfileKey(final RecipientId recipientId, final ProfileKey profileKey) {
synchronized (recipients) { synchronized (recipients) {
final var recipient = recipients.get(recipientId); 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);
} }
} }