Save group send endorsements
This commit is contained in:
parent
dea641bae4
commit
4253bed0bd
12 changed files with 583 additions and 91 deletions
50
ts/sql/migrations/1050-group-send-endorsements.ts
Normal file
50
ts/sql/migrations/1050-group-send-endorsements.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Database } from '@signalapp/better-sqlite3';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
import { sql } from '../util';
|
||||
|
||||
export const version = 1050;
|
||||
|
||||
export function updateToSchemaVersion1050(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 1050) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
const [createTables] = sql`
|
||||
DROP TABLE IF EXISTS groupSendCombinedEndorsement;
|
||||
DROP TABLE IF EXISTS groupSendMemberEndorsement;
|
||||
|
||||
-- From GroupSendEndorsementsResponse->ReceivedEndorsements in libsignal
|
||||
-- this is the combined endorsement for all group members
|
||||
CREATE TABLE groupSendCombinedEndorsement (
|
||||
groupId TEXT NOT NULL PRIMARY KEY, -- Only one endorsement per group
|
||||
expiration INTEGER NOT NULL, -- Unix timestamp in seconds
|
||||
endorsement BLOB NOT NULL
|
||||
) STRICT;
|
||||
|
||||
-- From GroupSendEndorsementsResponse->ReceivedEndorsements in libsignal
|
||||
-- these are the individual endorsements for each group member
|
||||
CREATE TABLE groupSendMemberEndorsement (
|
||||
groupId TEXT NOT NULL,
|
||||
memberAci TEXT NOT NULL,
|
||||
expiration INTEGER NOT NULL, -- Unix timestamp in seconds
|
||||
endorsement BLOB NOT NULL,
|
||||
PRIMARY KEY (groupId, memberAci) -- Only one endorsement per group member
|
||||
) STRICT;
|
||||
`;
|
||||
|
||||
db.exec(createTables);
|
||||
|
||||
db.pragma('user_version = 1050');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion1050: success!');
|
||||
}
|
|
@ -79,10 +79,11 @@ import { updateToSchemaVersion1000 } from './1000-mark-unread-call-history-messa
|
|||
import { updateToSchemaVersion1010 } from './1010-call-links-table';
|
||||
import { updateToSchemaVersion1020 } from './1020-self-merges';
|
||||
import { updateToSchemaVersion1030 } from './1030-unblock-event';
|
||||
import { updateToSchemaVersion1040 } from './1040-undownloaded-backed-up-media';
|
||||
import {
|
||||
updateToSchemaVersion1040,
|
||||
updateToSchemaVersion1050,
|
||||
version as MAX_VERSION,
|
||||
} from './1040-undownloaded-backed-up-media';
|
||||
} from './1050-group-send-endorsements';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -2029,6 +2030,7 @@ export const SCHEMA_VERSIONS = [
|
|||
updateToSchemaVersion1020,
|
||||
updateToSchemaVersion1030,
|
||||
updateToSchemaVersion1040,
|
||||
updateToSchemaVersion1050,
|
||||
];
|
||||
|
||||
export class DBVersionFromFutureError extends Error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue