Batch deleteSentProtoRecipient queries

This commit is contained in:
Fedor Indutny 2021-08-31 14:35:01 -07:00 committed by GitHub
parent b71e4875e6
commit 6f3191117f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 151 additions and 81 deletions

View file

@ -416,6 +416,49 @@ describe('sendLog', () => {
assert.lengthOf(await getAllSentProtos(), 0);
assert.lengthOf(await _getAllSentProtoRecipients(), 0);
});
it('deletes multiple recipients in a single transaction', async () => {
const timestamp = Date.now();
const recipientUuid1 = getGuid();
const recipientUuid2 = getGuid();
const proto = {
contentHint: 1,
proto: Buffer.from(getRandomBytes(128)),
timestamp,
};
await insertSentProto(proto, {
messageIds: [getGuid()],
recipients: {
[recipientUuid1]: [1, 2],
[recipientUuid2]: [1],
},
});
assert.lengthOf(await getAllSentProtos(), 1);
assert.lengthOf(await _getAllSentProtoRecipients(), 3);
await deleteSentProtoRecipient([
{
timestamp,
recipientUuid: recipientUuid1,
deviceId: 1,
},
{
timestamp,
recipientUuid: recipientUuid1,
deviceId: 2,
},
{
timestamp,
recipientUuid: recipientUuid2,
deviceId: 1,
},
]);
assert.lengthOf(await getAllSentProtos(), 0);
assert.lengthOf(await _getAllSentProtoRecipients(), 0);
});
});
describe('#getSentProtoByRecipient', () => {