From fb919466de76fba09690a0472a8a36c6408a9578 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli <greyson@signal.org> Date: Wed, 20 Apr 2022 19:01:00 -0400 Subject: [PATCH] Enqueue a profile fetch to resolve identity key conflicts. --- .../securesms/storage/ContactRecordProcessor.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/storage/ContactRecordProcessor.java b/app/src/main/java/org/thoughtcrime/securesms/storage/ContactRecordProcessor.java index 214f20c1ca..117984b31b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/storage/ContactRecordProcessor.java +++ b/app/src/main/java/org/thoughtcrime/securesms/storage/ContactRecordProcessor.java @@ -9,6 +9,7 @@ import org.signal.core.util.logging.Log; import org.thoughtcrime.securesms.database.RecipientDatabase; import org.thoughtcrime.securesms.database.SignalDatabase; import org.thoughtcrime.securesms.database.model.RecipientRecord; +import org.thoughtcrime.securesms.jobs.RetrieveProfileJob; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.RecipientId; import org.whispersystems.signalservice.api.push.ServiceId; @@ -112,6 +113,11 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal identityKey = local.getIdentityKey().orElse(null); } + if (identityKey != null && remote.getIdentityKey().isPresent() && !Arrays.equals(identityKey, remote.getIdentityKey().get())) { + Log.w(TAG, "The local and remote identity keys do not match for " + local.getAddress().getIdentifier() + ". Enqueueing a profile fetch."); + RetrieveProfileJob.enqueue(Recipient.externalPush(local.getAddress()).getId()); + } + byte[] unknownFields = remote.serializeUnknownFields(); ServiceId serviceId = local.getAddress().getServiceId() == ServiceId.UNKNOWN ? remote.getAddress().getServiceId() : local.getAddress().getServiceId(); String e164 = OptionalUtil.or(remote.getAddress().getNumber(), local.getAddress().getNumber()).orElse(null); -- GitLab