mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-02 22:31:31 +01:00
Properly clean up story replies on expiration or delete
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user