A number of additional merging fixes

This commit is contained in:
Scott Nonnenberg 2022-08-10 11:39:04 -07:00 committed by GitHub
parent ccc89545c5
commit 269d170275
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 7 deletions

View file

@ -137,6 +137,10 @@ export async function toContactRecord(
if (e164) {
contactRecord.serviceE164 = e164;
}
const pni = conversation.get('pni');
if (pni) {
contactRecord.pni = pni;
}
const profileKey = conversation.get('profileKey');
if (profileKey) {
contactRecord.profileKey = Bytes.fromBase64(String(profileKey));
@ -849,6 +853,7 @@ export async function mergeContactRecord(
const e164 = dropNull(contactRecord.serviceE164);
const uuid = dropNull(contactRecord.serviceUuid);
const pni = dropNull(contactRecord.pni);
// All contacts must have UUID
if (!uuid) {
@ -866,6 +871,7 @@ export async function mergeContactRecord(
const conversation = window.ConversationController.maybeMergeContacts({
aci: uuid,
e164,
pni,
reason: 'mergeContactRecord',
});
@ -873,6 +879,20 @@ export async function mergeContactRecord(
throw new Error(`No conversation for ${storageID}`);
}
// We're going to ignore this; it's likely a PNI-only contact we've already merged
if (conversation.get('uuid') !== uuid) {
log.warn(
`mergeContactRecord: ${conversation.idForLogging()} ` +
`with storageId ${conversation.get('storageID')} ` +
`had uuid that didn't match provided uuid ${uuid}`
);
return {
hasConflict: false,
shouldDrop: true,
details: [],
};
}
let needsProfileFetch = false;
if (contactRecord.profileKey && contactRecord.profileKey.length > 0) {
needsProfileFetch = await conversation.setProfileKey(