maybeMergeContacts/create: Put PNI into UUID field if no ACI

This commit is contained in:
Scott Nonnenberg 2022-08-17 16:12:38 -07:00 committed by GitHub
parent 15714f35ef
commit 74374e4313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 3 deletions

View file

@ -451,9 +451,6 @@ export class ConversationController {
);
}
const identifier = aci || e164 || pni;
strictAssert(identifier, `${logId}: identifier must be truthy!`);
const matches: Array<ConvoMatchType> = [
{
key: 'uuid',
@ -591,6 +588,12 @@ export class ConversationController {
);
log.info(`${logId}: Creating a new conversation with all inputs`);
// This is not our precedence for lookup, but it ensures that the PNI gets into the
// uuid slot if we have no ACI.
const identifier = aci || pni || e164;
strictAssert(identifier, `${logId}: identifier must be truthy!`);
return this.getOrCreate(identifier, 'private', { e164, pni });
}

View file

@ -190,6 +190,35 @@ describe('ConversationController', () => {
assert.strictEqual(result?.id, second?.id, 'result and second match');
});
it('creates a new conversation with e164+PNI if no matches', () => {
const result = window.ConversationController.maybeMergeContacts({
mergeOldAndNew,
e164: E164_1,
pni: PNI_1,
reason,
});
expectPropsAndLookups(result, 'result', {
aci: PNI_1,
e164: E164_1,
pni: PNI_1,
});
const second = window.ConversationController.maybeMergeContacts({
mergeOldAndNew,
e164: E164_1,
pni: PNI_1,
reason,
});
expectPropsAndLookups(second, 'second', {
aci: PNI_1,
e164: E164_1,
pni: PNI_1,
});
assert.strictEqual(result?.id, second?.id, 'result and second match');
});
it('creates a new conversation with all data if no matches', () => {
const result = window.ConversationController.maybeMergeContacts({
mergeOldAndNew,