Early preparations for PNP Contact Merging

This commit is contained in:
Scott Nonnenberg 2022-08-09 14:39:00 -07:00 committed by GitHub
parent 2f5dd73e58
commit faf6c41332
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 1572 additions and 447 deletions

View file

@ -73,25 +73,24 @@ export async function lookupConversationWithoutUuid(
const serverLookup = await messaging.getUuidsForE164s([options.e164]);
if (serverLookup[options.e164]) {
conversationId = window.ConversationController.ensureContactIds({
const convo = window.ConversationController.maybeMergeContacts({
aci: serverLookup[options.e164] || undefined,
e164: options.e164,
uuid: serverLookup[options.e164],
highTrust: true,
reason: 'startNewConversationWithoutUuid(e164)',
});
conversationId = convo?.id;
}
} else {
const foundUsername = await checkForUsername(options.username);
if (foundUsername) {
conversationId = window.ConversationController.ensureContactIds({
const convo = window.ConversationController.lookupOrCreate({
uuid: foundUsername.uuid,
highTrust: true,
reason: 'startNewConversationWithoutUuid(username)',
});
const convo = window.ConversationController.get(conversationId);
strictAssert(convo, 'We just ensured conversation existence');
conversationId = convo.id;
convo.set({ username: foundUsername.username });
}
}