]> nmode's Git Repositories - signal-cli/commitdiff
Only store our own profile key in contact list, if a contact entry already exists
authorAsamK <asamk@gmx.de>
Tue, 24 Mar 2020 13:27:12 +0000 (14:27 +0100)
committerAsamK <asamk@gmx.de>
Tue, 24 Mar 2020 13:36:12 +0000 (14:36 +0100)
src/main/java/org/asamk/signal/manager/Manager.java

index 0aada70364fa2802448136be4e12cfdd40886dae..90e981c244bfb28816f17403f4d3b75f250ee386 100644 (file)
@@ -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<SignalServiceDataMessage.Preview> previews = message.getPreviews().get();