mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-08-19 20:57:57 +01:00
Simplify story reply context
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
co-authored by
trevor-signal
parent
b8fc7ed66b
commit
1d83001d38
@@ -0,0 +1,79 @@
|
||||
// Copyright 2026 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import type { WritableDB } from '../../sql/Interface.std.ts';
|
||||
import { sql } from '../../sql/util.std.ts';
|
||||
import {
|
||||
createDB,
|
||||
updateToVersion,
|
||||
insertData,
|
||||
getTableData,
|
||||
explain,
|
||||
} from './helpers.node.ts';
|
||||
|
||||
describe('SQL/updateToSchemaVersion1760', () => {
|
||||
let db: WritableDB;
|
||||
|
||||
beforeEach(() => {
|
||||
db = createDB();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('removes the cached attachment but preserves the author', () => {
|
||||
updateToVersion(db, 1750);
|
||||
insertData(db, 'messages', [
|
||||
{
|
||||
id: 'story_reply',
|
||||
json: {
|
||||
id: 'story_reply',
|
||||
storyReplyContext: {
|
||||
attachment: {
|
||||
contentType: 'video/mp4',
|
||||
path: 'path',
|
||||
size: 100,
|
||||
},
|
||||
authorAci: 'author_aci',
|
||||
},
|
||||
},
|
||||
storyId: 'story_id',
|
||||
},
|
||||
]);
|
||||
|
||||
updateToVersion(db, 1760);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
getTableData(db, 'messages').map(msg => msg.json),
|
||||
[
|
||||
{
|
||||
id: 'story_reply',
|
||||
storyReplyContext: {
|
||||
authorAci: 'author_aci',
|
||||
},
|
||||
},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
it('should use storyId index', () => {
|
||||
updateToVersion(db, 1760);
|
||||
|
||||
const details = explain(
|
||||
db,
|
||||
sql`
|
||||
UPDATE messages
|
||||
SET json = json_remove(json, '$.storyReplyContext.attachment')
|
||||
WHERE isStory = 0
|
||||
AND storyId > '0'
|
||||
AND json->'$.storyReplyContext.attachment' IS NOT NULL;
|
||||
`
|
||||
);
|
||||
|
||||
assert.include(details, 'USING INDEX messages_by_storyId');
|
||||
assert.notInclude(details, 'SCAN');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user