Fix contact sync for aci-less contacts

This commit is contained in:
Fedor Indutny 2025-07-09 09:14:25 -07:00 committed by GitHub
parent 6ec9dd60b1
commit 3063262730
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 30 deletions

View file

@ -127,35 +127,6 @@ describe('ContactsParser', () => {
}
}
});
it('parses an array buffer of contacts where contacts are dropped due to missing ACI', async () => {
let absolutePath: string | undefined;
try {
const avatarBuffer = generateAvatar();
const bytes = Bytes.concatenate([
generatePrefixedContact(avatarBuffer, null),
avatarBuffer,
generatePrefixedContact(undefined, null),
getTestBuffer(),
]);
const fileName = generateGuid();
absolutePath = join(tempDir, fileName);
writeFileSync(absolutePath, bytes);
const contacts = await parseContactsWithSmallChunkSize({
absolutePath,
});
assert.strictEqual(contacts.length, 3);
await Promise.all(contacts.map(contact => verifyContact(contact)));
} finally {
if (absolutePath) {
unlinkSync(absolutePath);
}
}
});
});
});

View file

@ -13,6 +13,7 @@ import type { AciString } from '../types/ServiceId';
import { computeHash } from '../Crypto';
import { dropNull } from '../util/dropNull';
import { fromAciUuidBytesOrString } from '../util/ServiceId';
import * as Bytes from '../Bytes';
import { decryptAttachmentV2ToSink } from '../AttachmentCrypto';
import Avatar = Proto.ContactDetails.IAvatar;
@ -204,7 +205,7 @@ function prepareContact(
const aci = fromAciUuidBytesOrString(aciBinary, rawAci, 'ContactBuffer.aci');
if (aci == null) {
if ((Bytes.isNotEmpty(aciBinary) || rawAci) && aci == null) {
log.warn('ParseContactsTransform: Dropping contact with invalid aci');
return undefined;
}