Introduce new urgent property for outgoing messages
This commit is contained in:
parent
6cd1e3fdfc
commit
06190b1434
25 changed files with 302 additions and 83 deletions
|
@ -100,6 +100,7 @@ export type SentProtoType = {
|
|||
contentHint: number;
|
||||
proto: Uint8Array;
|
||||
timestamp: number;
|
||||
urgent: boolean;
|
||||
};
|
||||
export type SentProtoWithMessageIdsType = SentProtoType & {
|
||||
messageIds: Array<string>;
|
||||
|
|
|
@ -820,14 +820,19 @@ async function insertSentProto(
|
|||
INSERT INTO sendLogPayloads (
|
||||
contentHint,
|
||||
proto,
|
||||
timestamp
|
||||
timestamp,
|
||||
urgent
|
||||
) VALUES (
|
||||
$contentHint,
|
||||
$proto,
|
||||
$timestamp
|
||||
$timestamp,
|
||||
$urgent
|
||||
);
|
||||
`
|
||||
).run(proto);
|
||||
).run({
|
||||
...proto,
|
||||
urgent: proto.urgent ? 1 : 0,
|
||||
});
|
||||
const id = parseIntOrThrow(
|
||||
info.lastInsertRowid,
|
||||
'insertSentProto/lastInsertRowid'
|
||||
|
@ -1082,6 +1087,7 @@ async function getSentProtoByRecipient({
|
|||
const { messageIds } = row;
|
||||
return {
|
||||
...row,
|
||||
urgent: isNumber(row.urgent) ? Boolean(row.urgent) : true,
|
||||
messageIds: messageIds ? messageIds.split(',') : [],
|
||||
};
|
||||
}
|
||||
|
@ -1093,7 +1099,10 @@ async function getAllSentProtos(): Promise<Array<SentProtoType>> {
|
|||
const db = getInstance();
|
||||
const rows = prepare<EmptyQuery>(db, 'SELECT * FROM sendLogPayloads;').all();
|
||||
|
||||
return rows;
|
||||
return rows.map(row => ({
|
||||
...row,
|
||||
urgent: isNumber(row.urgent) ? Boolean(row.urgent) : true,
|
||||
}));
|
||||
}
|
||||
async function _getAllSentProtoRecipients(): Promise<
|
||||
Array<SentRecipientsDBType>
|
||||
|
|
28
ts/sql/migrations/62-add-urgent-to-send-log.ts
Normal file
28
ts/sql/migrations/62-add-urgent-to-send-log.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2021-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Database } from 'better-sqlite3';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
|
||||
export default function updateToSchemaVersion62(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 62) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(
|
||||
`
|
||||
ALTER TABLE sendLogPayloads ADD COLUMN urgent INTEGER;
|
||||
`
|
||||
);
|
||||
|
||||
db.pragma('user_version = 62');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion62: success!');
|
||||
}
|
|
@ -37,6 +37,7 @@ import updateToSchemaVersion58 from './58-update-unread';
|
|||
import updateToSchemaVersion59 from './59-unprocessed-received-at-counter-index';
|
||||
import updateToSchemaVersion60 from './60-update-expiring-index';
|
||||
import updateToSchemaVersion61 from './61-distribution-list-storage';
|
||||
import updateToSchemaVersion62 from './62-add-urgent-to-send-log';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -1937,6 +1938,7 @@ export const SCHEMA_VERSIONS = [
|
|||
updateToSchemaVersion59,
|
||||
updateToSchemaVersion60,
|
||||
updateToSchemaVersion61,
|
||||
updateToSchemaVersion62,
|
||||
];
|
||||
|
||||
export function updateSchema(db: Database, logger: LoggerType): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue