From 20bf605e36be0892d05b3ae11954aa7dd0784e23 Mon Sep 17 00:00:00 2001 From: AsamK Date: Tue, 24 Mar 2020 14:27:12 +0100 Subject: [PATCH] Only store our own profile key in contact list, if a contact entry already exists --- .../org/asamk/signal/manager/Manager.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/asamk/signal/manager/Manager.java b/src/main/java/org/asamk/signal/manager/Manager.java index 0aada703..90e981c2 100644 --- a/src/main/java/org/asamk/signal/manager/Manager.java +++ b/src/main/java/org/asamk/signal/manager/Manager.java @@ -1342,18 +1342,24 @@ public class Manager implements Signal { } } if (message.getProfileKey().isPresent() && message.getProfileKey().get().length == 32) { - if (source.equals(account.getSelfAddress())) { + if (source.matches(account.getSelfAddress())) { try { this.account.setProfileKey(new ProfileKey(message.getProfileKey().get())); } catch (InvalidInputException ignored) { } + ContactInfo contact = account.getContactStore().getContact(source); + if (contact != null) { + contact.profileKey = Base64.encodeBytes(message.getProfileKey().get()); + account.getContactStore().updateContact(contact); + } + } else { + ContactInfo contact = account.getContactStore().getContact(source); + if (contact == null) { + contact = new ContactInfo(source); + } + contact.profileKey = Base64.encodeBytes(message.getProfileKey().get()); + account.getContactStore().updateContact(contact); } - ContactInfo contact = account.getContactStore().getContact(source); - if (contact == null) { - contact = new ContactInfo(source); - } - contact.profileKey = Base64.encodeBytes(message.getProfileKey().get()); - account.getContactStore().updateContact(contact); } if (message.getPreviews().isPresent()) { final List previews = message.getPreviews().get();