Fix contact sync for aci-less contacts
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
e43fccbaa4
commit
5594299524
2 changed files with 2 additions and 30 deletions
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import type { AciString } from '../types/ServiceId';
|
||||||
import { computeHash } from '../Crypto';
|
import { computeHash } from '../Crypto';
|
||||||
import { dropNull } from '../util/dropNull';
|
import { dropNull } from '../util/dropNull';
|
||||||
import { fromAciUuidBytesOrString } from '../util/ServiceId';
|
import { fromAciUuidBytesOrString } from '../util/ServiceId';
|
||||||
|
import * as Bytes from '../Bytes';
|
||||||
import { decryptAttachmentV2ToSink } from '../AttachmentCrypto';
|
import { decryptAttachmentV2ToSink } from '../AttachmentCrypto';
|
||||||
|
|
||||||
import Avatar = Proto.ContactDetails.IAvatar;
|
import Avatar = Proto.ContactDetails.IAvatar;
|
||||||
|
@ -204,7 +205,7 @@ function prepareContact(
|
||||||
|
|
||||||
const aci = fromAciUuidBytesOrString(aciBinary, rawAci, 'ContactBuffer.aci');
|
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');
|
log.warn('ParseContactsTransform: Dropping contact with invalid aci');
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue