Only store our own profile key in contact list, if a contact entry already exists

This commit is contained in:
AsamK 2020-03-24 14:27:12 +01:00
parent 6665dc0e48
commit 20bf605e36

View file

@ -1342,18 +1342,24 @@ public class Manager implements Signal {
} }
} }
if (message.getProfileKey().isPresent() && message.getProfileKey().get().length == 32) { if (message.getProfileKey().isPresent() && message.getProfileKey().get().length == 32) {
if (source.equals(account.getSelfAddress())) { if (source.matches(account.getSelfAddress())) {
try { try {
this.account.setProfileKey(new ProfileKey(message.getProfileKey().get())); this.account.setProfileKey(new ProfileKey(message.getProfileKey().get()));
} catch (InvalidInputException ignored) { } 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()) { if (message.getPreviews().isPresent()) {
final List<SignalServiceDataMessage.Preview> previews = message.getPreviews().get(); final List<SignalServiceDataMessage.Preview> previews = message.getPreviews().get();