From: AsamK Date: Tue, 24 Mar 2020 13:27:12 +0000 (+0100) Subject: Only store our own profile key in contact list, if a contact entry already exists X-Git-Tag: v0.6.6~12 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/20bf605e36be0892d05b3ae11954aa7dd0784e23?ds=sidebyside Only store our own profile key in contact list, if a contact entry already exists --- 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();