Support pollTerminateNotification in backups

This commit is contained in:
trevor-signal
2026-03-13 13:39:42 -07:00
committed by GitHub
parent 54053d7ff6
commit 5acdb2f287
16 changed files with 280 additions and 51 deletions

View File

@@ -0,0 +1,37 @@
// Copyright 2026 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { LoggerType } from '../../types/Logging.std.js';
import type { WritableDB } from '../Interface.std.js';
import { sql } from '../util.std.js';
export default function updateToSchemaVersion1690(
db: WritableDB,
logger: LoggerType
): void {
const [query, params] = sql`
UPDATE messages AS message
SET json = json_remove(
json_set(
message.json,
'$.pollTerminateNotification.pollTimestamp',
COALESCE(
(
SELECT poll.timestamp
FROM messages AS poll
WHERE poll.id = message.json ->> '$.pollTerminateNotification.pollMessageId'
),
0
)
),
'$.pollTerminateNotification.pollMessageId'
)
WHERE
message.type IS 'poll-terminate' AND
message.json -> '$.pollTerminateNotification' IS NOT NULL;
`;
const result = db.prepare(query).run(params);
logger.info(`Updated ${result.changes} poll terminate notifications`);
}

View File

@@ -145,6 +145,7 @@ import updateToSchemaVersion1650 from './1650-protected-attachments.std.js';
import updateToSchemaVersion1660 from './1660-protected-attachments-non-unique.std.js';
import updateToSchemaVersion1670 from './1670-drop-call-link-epoch.std.js';
import updateToSchemaVersion1680 from './1680-cleanup-empty-strings.std.js';
import updateToSchemaVersion1690 from './1690-poll-terminate-notification-timestamp.std.js';
import { DataWriter } from '../Server.node.js';
import { strictAssert } from '../../util/assert.std.js';
@@ -1652,6 +1653,7 @@ export const SCHEMA_VERSIONS: ReadonlyArray<SchemaUpdateType> = [
{ version: 1660, update: updateToSchemaVersion1660 },
{ version: 1670, update: updateToSchemaVersion1670 },
{ version: 1680, update: updateToSchemaVersion1680 },
{ version: 1690, update: updateToSchemaVersion1690 },
];
export class DBVersionFromFutureError extends Error {