Properly clean up story replies on expiration or delete

This commit is contained in:
Scott Nonnenberg
2023-12-18 08:58:07 -08:00
committed by GitHub
parent 0918b3da7f
commit 8c71ed2590
3 changed files with 44 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import { MessageModel } from '../../models/messages';
import { strictAssert } from '../../util/assert';
import { MessageCache } from '../../services/MessageCache';
import { generateAci } from '../../types/ServiceId';
describe('MessageCache', () => {
describe('filterBySentAt', () => {
@@ -343,6 +344,47 @@ describe('MessageCache', () => {
});
});
describe('setAttributes', () => {
it('saves the new attributes to the database', async () => {
const mc = new MessageCache();
const ourAci = generateAci();
const id = uuid();
const messageAttributes: MessageAttributesType = {
conversationId: uuid(),
id,
received_at: 1,
sent_at: Date.now(),
timestamp: Date.now(),
type: 'incoming',
};
await window.Signal.Data.saveMessage(messageAttributes, {
forceSave: true,
ourAci,
});
const changes = {
received_at: 2,
};
const newAttributes = {
...messageAttributes,
...changes,
};
mc.toMessageAttributes(messageAttributes);
await mc.setAttributes({
messageId: id,
messageAttributes: changes,
skipSaveToDatabase: false,
});
const messageFromDatabase = await window.Signal.Data.getMessageById(id);
assert.deepEqual(newAttributes, messageFromDatabase);
});
});
describe('accessAttributesOrThrow', () => {
it('accesses the attributes or throws if they do not exist', () => {
const mc = new MessageCache();