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
|
@ -26,13 +26,16 @@ message Envelope {
|
||||||
optional string source = 2;
|
optional string source = 2;
|
||||||
optional string sourceUuid = 11;
|
optional string sourceUuid = 11;
|
||||||
optional uint32 sourceDevice = 7;
|
optional uint32 sourceDevice = 7;
|
||||||
|
optional string destinationUuid = 13;
|
||||||
// reserved 3; // formerly optional string relay = 3;
|
// reserved 3; // formerly optional string relay = 3;
|
||||||
optional uint64 timestamp = 5;
|
optional uint64 timestamp = 5;
|
||||||
// reserved 6; // formerly optional bytes legacyMessage = 6;
|
// reserved 6; // formerly optional bytes legacyMessage = 6;
|
||||||
optional bytes content = 8; // Contains an encrypted Content
|
optional bytes content = 8; // Contains an encrypted Content
|
||||||
optional string serverGuid = 9;
|
optional string serverGuid = 9;
|
||||||
optional uint64 serverTimestamp = 10;
|
optional uint64 serverTimestamp = 10;
|
||||||
optional string destinationUuid = 13;
|
optional bool ephemeral = 12; // indicates that the message should not be persisted if the recipient is offline
|
||||||
|
optional bool urgent = 14 [default=true]; // indicates that the content is considered timely by the sender; defaults to true so senders have to opt-out to say something isn't time critical
|
||||||
|
// next: 15
|
||||||
}
|
}
|
||||||
|
|
||||||
message Content {
|
message Content {
|
||||||
|
|
|
@ -130,6 +130,7 @@ export async function sendDeleteForEveryone(
|
||||||
expirationStartTimestamp: null,
|
expirationStartTimestamp: null,
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
{ messageIds, sendType }
|
{ messageIds, sendType }
|
||||||
);
|
);
|
||||||
|
@ -186,6 +187,7 @@ export async function sendDeleteForEveryone(
|
||||||
groupId: undefined,
|
groupId: undefined,
|
||||||
profileKey,
|
profileKey,
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
|
urgent: true,
|
||||||
}),
|
}),
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
@ -223,6 +225,7 @@ export async function sendDeleteForEveryone(
|
||||||
sendOptions,
|
sendOptions,
|
||||||
sendTarget: conversation.toSenderKeyTarget(),
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
sendType: 'deleteForEveryone',
|
sendType: 'deleteForEveryone',
|
||||||
|
urgent: true,
|
||||||
}),
|
}),
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
|
|
@ -105,6 +105,7 @@ export async function sendDirectExpirationTimerUpdate(
|
||||||
expirationStartTimestamp: null,
|
expirationStartTimestamp: null,
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
{ messageIds: [], sendType }
|
{ messageIds: [], sendType }
|
||||||
);
|
);
|
||||||
|
@ -139,6 +140,7 @@ export async function sendDirectExpirationTimerUpdate(
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
proto,
|
proto,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
|
|
@ -110,6 +110,7 @@ export async function sendGroupUpdate(
|
||||||
sendOptions,
|
sendOptions,
|
||||||
sendTarget: conversation.toSenderKeyTarget(),
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
sendType,
|
sendType,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
|
|
@ -232,6 +232,7 @@ export async function sendNormalMessage(
|
||||||
sendOptions,
|
sendOptions,
|
||||||
sendTarget: conversation.toSenderKeyTarget(),
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
sendType: 'message',
|
sendType: 'message',
|
||||||
|
urgent: true,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -279,6 +280,7 @@ export async function sendNormalMessage(
|
||||||
sticker,
|
sticker,
|
||||||
storyContext,
|
storyContext,
|
||||||
timestamp: messageTimestamp,
|
timestamp: messageTimestamp,
|
||||||
|
urgent: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ export async function sendProfileKey(
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
proto,
|
proto,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (isGroupV2(conversation.attributes) && !isNumber(revision)) {
|
if (isGroupV2(conversation.attributes) && !isNumber(revision)) {
|
||||||
|
@ -160,6 +161,7 @@ export async function sendProfileKey(
|
||||||
sendOptions,
|
sendOptions,
|
||||||
sendTarget: conversation.toSenderKeyTarget(),
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
sendType,
|
sendType,
|
||||||
|
urgent: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,7 @@ export async function sendReaction(
|
||||||
timestamp: message.get('sent_at'),
|
timestamp: message.get('sent_at'),
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
urgent: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.info('sending group reaction message');
|
log.info('sending group reaction message');
|
||||||
|
@ -280,6 +281,7 @@ export async function sendReaction(
|
||||||
sendOptions,
|
sendOptions,
|
||||||
sendTarget: conversation.toSenderKeyTarget(),
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
sendType: 'reaction',
|
sendType: 'reaction',
|
||||||
|
urgent: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
|
import { isBoolean } from 'lodash';
|
||||||
|
|
||||||
import * as Bytes from '../Bytes';
|
import * as Bytes from '../Bytes';
|
||||||
import type { LoggerType } from '../types/Logging';
|
import type { LoggerType } from '../types/Logging';
|
||||||
|
@ -67,6 +68,7 @@ export class SingleProtoJobQueue extends JobQueue<SingleProtoJobData> {
|
||||||
messageIds = [],
|
messageIds = [],
|
||||||
protoBase64,
|
protoBase64,
|
||||||
type,
|
type,
|
||||||
|
urgent,
|
||||||
} = data;
|
} = data;
|
||||||
log.info(
|
log.info(
|
||||||
`starting ${type} send to ${identifier} with timestamp ${timestamp}`
|
`starting ${type} send to ${identifier} with timestamp ${timestamp}`
|
||||||
|
@ -116,6 +118,7 @@ export class SingleProtoJobQueue extends JobQueue<SingleProtoJobData> {
|
||||||
options,
|
options,
|
||||||
proto,
|
proto,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: isBoolean(urgent) ? urgent : true,
|
||||||
}),
|
}),
|
||||||
{ messageIds, sendType: type }
|
{ messageIds, sendType: type }
|
||||||
);
|
);
|
||||||
|
|
|
@ -1313,12 +1313,13 @@ export class ConversationModel extends window.Backbone
|
||||||
if (isDirectConversation(this.attributes)) {
|
if (isDirectConversation(this.attributes)) {
|
||||||
await handleMessageSend(
|
await handleMessageSend(
|
||||||
messaging.sendMessageProtoAndWait({
|
messaging.sendMessageProtoAndWait({
|
||||||
timestamp,
|
|
||||||
recipients: groupMembers,
|
|
||||||
proto: contentMessage,
|
|
||||||
contentHint: ContentHint.IMPLICIT,
|
contentHint: ContentHint.IMPLICIT,
|
||||||
groupId: undefined,
|
groupId: undefined,
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
|
proto: contentMessage,
|
||||||
|
recipients: groupMembers,
|
||||||
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
{ messageIds: [], sendType: 'typing' }
|
{ messageIds: [], sendType: 'typing' }
|
||||||
);
|
);
|
||||||
|
@ -1334,6 +1335,7 @@ export class ConversationModel extends window.Backbone
|
||||||
sendTarget: this.toSenderKeyTarget(),
|
sendTarget: this.toSenderKeyTarget(),
|
||||||
sendType: 'typing',
|
sendType: 'typing',
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
{ messageIds: [], sendType: 'typing' }
|
{ messageIds: [], sendType: 'typing' }
|
||||||
);
|
);
|
||||||
|
|
|
@ -1698,6 +1698,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
conversationIdsWithSealedSender,
|
conversationIdsWithSealedSender,
|
||||||
isUpdate,
|
isUpdate,
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
// Note: in some situations, for doNotSave messages, the message has no
|
// Note: in some situations, for doNotSave messages, the message has no
|
||||||
// id, so we provide an empty array here.
|
// id, so we provide an empty array here.
|
||||||
|
|
|
@ -998,6 +998,7 @@ export class CallingClass {
|
||||||
sendOptions,
|
sendOptions,
|
||||||
sendTarget: conversation.toSenderKeyTarget(),
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
sendType: 'callingMessage',
|
sendType: 'callingMessage',
|
||||||
|
urgent: false,
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
sendType: 'callingMessage',
|
sendType: 'callingMessage',
|
||||||
|
@ -1621,6 +1622,7 @@ export class CallingClass {
|
||||||
sendTarget: conversation.toSenderKeyTarget(),
|
sendTarget: conversation.toSenderKeyTarget(),
|
||||||
sendType: 'callingMessage',
|
sendType: 'callingMessage',
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
{ messageIds: [], sendType: 'callingMessage' }
|
{ messageIds: [], sendType: 'callingMessage' }
|
||||||
)
|
)
|
||||||
|
|
|
@ -100,6 +100,7 @@ export type SentProtoType = {
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
proto: Uint8Array;
|
proto: Uint8Array;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
};
|
};
|
||||||
export type SentProtoWithMessageIdsType = SentProtoType & {
|
export type SentProtoWithMessageIdsType = SentProtoType & {
|
||||||
messageIds: Array<string>;
|
messageIds: Array<string>;
|
||||||
|
|
|
@ -820,14 +820,19 @@ async function insertSentProto(
|
||||||
INSERT INTO sendLogPayloads (
|
INSERT INTO sendLogPayloads (
|
||||||
contentHint,
|
contentHint,
|
||||||
proto,
|
proto,
|
||||||
timestamp
|
timestamp,
|
||||||
|
urgent
|
||||||
) VALUES (
|
) VALUES (
|
||||||
$contentHint,
|
$contentHint,
|
||||||
$proto,
|
$proto,
|
||||||
$timestamp
|
$timestamp,
|
||||||
|
$urgent
|
||||||
);
|
);
|
||||||
`
|
`
|
||||||
).run(proto);
|
).run({
|
||||||
|
...proto,
|
||||||
|
urgent: proto.urgent ? 1 : 0,
|
||||||
|
});
|
||||||
const id = parseIntOrThrow(
|
const id = parseIntOrThrow(
|
||||||
info.lastInsertRowid,
|
info.lastInsertRowid,
|
||||||
'insertSentProto/lastInsertRowid'
|
'insertSentProto/lastInsertRowid'
|
||||||
|
@ -1082,6 +1087,7 @@ async function getSentProtoByRecipient({
|
||||||
const { messageIds } = row;
|
const { messageIds } = row;
|
||||||
return {
|
return {
|
||||||
...row,
|
...row,
|
||||||
|
urgent: isNumber(row.urgent) ? Boolean(row.urgent) : true,
|
||||||
messageIds: messageIds ? messageIds.split(',') : [],
|
messageIds: messageIds ? messageIds.split(',') : [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1093,7 +1099,10 @@ async function getAllSentProtos(): Promise<Array<SentProtoType>> {
|
||||||
const db = getInstance();
|
const db = getInstance();
|
||||||
const rows = prepare<EmptyQuery>(db, 'SELECT * FROM sendLogPayloads;').all();
|
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<
|
async function _getAllSentProtoRecipients(): Promise<
|
||||||
Array<SentRecipientsDBType>
|
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 updateToSchemaVersion59 from './59-unprocessed-received-at-counter-index';
|
||||||
import updateToSchemaVersion60 from './60-update-expiring-index';
|
import updateToSchemaVersion60 from './60-update-expiring-index';
|
||||||
import updateToSchemaVersion61 from './61-distribution-list-storage';
|
import updateToSchemaVersion61 from './61-distribution-list-storage';
|
||||||
|
import updateToSchemaVersion62 from './62-add-urgent-to-send-log';
|
||||||
|
|
||||||
function updateToSchemaVersion1(
|
function updateToSchemaVersion1(
|
||||||
currentVersion: number,
|
currentVersion: number,
|
||||||
|
@ -1937,6 +1938,7 @@ export const SCHEMA_VERSIONS = [
|
||||||
updateToSchemaVersion59,
|
updateToSchemaVersion59,
|
||||||
updateToSchemaVersion60,
|
updateToSchemaVersion60,
|
||||||
updateToSchemaVersion61,
|
updateToSchemaVersion61,
|
||||||
|
updateToSchemaVersion62,
|
||||||
];
|
];
|
||||||
|
|
||||||
export function updateSchema(db: Database, logger: LoggerType): void {
|
export function updateSchema(db: Database, logger: LoggerType): void {
|
||||||
|
|
|
@ -39,6 +39,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: bytes,
|
proto: bytes,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
@ -54,6 +55,7 @@ describe('sql/sendLog', () => {
|
||||||
assert.strictEqual(actual.contentHint, proto.contentHint);
|
assert.strictEqual(actual.contentHint, proto.contentHint);
|
||||||
assert.isTrue(constantTimeEqual(actual.proto, proto.proto));
|
assert.isTrue(constantTimeEqual(actual.proto, proto.proto));
|
||||||
assert.strictEqual(actual.timestamp, proto.timestamp);
|
assert.strictEqual(actual.timestamp, proto.timestamp);
|
||||||
|
assert.strictEqual(actual.urgent, proto.urgent);
|
||||||
|
|
||||||
await removeAllSentProtos();
|
await removeAllSentProtos();
|
||||||
|
|
||||||
|
@ -71,6 +73,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: bytes,
|
proto: bytes,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid(), getUuid()],
|
messageIds: [getUuid(), getUuid()],
|
||||||
|
@ -80,7 +83,15 @@ describe('sql/sendLog', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.lengthOf(await getAllSentProtos(), 1);
|
const allProtos = await getAllSentProtos();
|
||||||
|
assert.lengthOf(allProtos, 1);
|
||||||
|
const actual = allProtos[0];
|
||||||
|
|
||||||
|
assert.strictEqual(actual.contentHint, proto.contentHint);
|
||||||
|
assert.isTrue(constantTimeEqual(actual.proto, proto.proto));
|
||||||
|
assert.strictEqual(actual.timestamp, proto.timestamp);
|
||||||
|
assert.strictEqual(actual.urgent, proto.urgent);
|
||||||
|
|
||||||
assert.lengthOf(await _getAllSentProtoMessageIds(), 2);
|
assert.lengthOf(await _getAllSentProtoMessageIds(), 2);
|
||||||
assert.lengthOf(await _getAllSentProtoRecipients(), 3);
|
assert.lengthOf(await _getAllSentProtoRecipients(), 3);
|
||||||
|
|
||||||
|
@ -115,6 +126,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: bytes,
|
proto: bytes,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [id],
|
messageIds: [id],
|
||||||
|
@ -146,11 +158,13 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 7,
|
contentHint: 7,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
const proto2 = {
|
const proto2 = {
|
||||||
contentHint: 9,
|
contentHint: 9,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.lengthOf(await getAllSentProtos(), 0);
|
assert.lengthOf(await getAllSentProtos(), 0);
|
||||||
|
@ -180,6 +194,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert.lengthOf(await getAllSentProtos(), 0);
|
assert.lengthOf(await getAllSentProtos(), 0);
|
||||||
|
@ -218,16 +233,19 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp: timestamp + 10,
|
timestamp: timestamp + 10,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
const proto2 = {
|
const proto2 = {
|
||||||
contentHint: 2,
|
contentHint: 2,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
const proto3 = {
|
const proto3 = {
|
||||||
contentHint: 0,
|
contentHint: 0,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp: timestamp - 15,
|
timestamp: timestamp - 15,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto1, {
|
await insertSentProto(proto1, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
@ -279,16 +297,19 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
const proto2 = {
|
const proto2 = {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp: timestamp - 10,
|
timestamp: timestamp - 10,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
const proto3 = {
|
const proto3 = {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp: timestamp - 20,
|
timestamp: timestamp - 20,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto1, {
|
await insertSentProto(proto1, {
|
||||||
messageIds: [messageId, getUuid()],
|
messageIds: [messageId, getUuid()],
|
||||||
|
@ -332,6 +353,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
@ -363,6 +385,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
@ -412,6 +435,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
@ -457,6 +481,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds,
|
messageIds,
|
||||||
|
@ -492,6 +517,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [],
|
messageIds: [],
|
||||||
|
@ -527,6 +553,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
@ -555,6 +582,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
@ -584,6 +612,7 @@ describe('sql/sendLog', () => {
|
||||||
contentHint: 1,
|
contentHint: 1,
|
||||||
proto: getRandomBytes(128),
|
proto: getRandomBytes(128),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
await insertSentProto(proto, {
|
await insertSentProto(proto, {
|
||||||
messageIds: [getUuid()],
|
messageIds: [getUuid()],
|
||||||
|
|
|
@ -2326,4 +2326,35 @@ describe('SQL migrations test', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateToSchemaVersion62', () => {
|
||||||
|
it('adds new urgent field to sendLogPayloads', () => {
|
||||||
|
updateToVersion(62);
|
||||||
|
|
||||||
|
const timestamp = Date.now();
|
||||||
|
db.exec(
|
||||||
|
`
|
||||||
|
INSERT INTO sendLogPayloads
|
||||||
|
(contentHint, timestamp, proto, urgent)
|
||||||
|
VALUES
|
||||||
|
(1, ${timestamp}, X'0123456789ABCDEF', 1);
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
db.prepare('SELECT COUNT(*) FROM sendLogPayloads;').pluck().get(),
|
||||||
|
1,
|
||||||
|
'starting total'
|
||||||
|
);
|
||||||
|
|
||||||
|
const payload = db
|
||||||
|
.prepare('SELECT * FROM sendLogPayloads LIMIT 1;')
|
||||||
|
.get();
|
||||||
|
|
||||||
|
assert.strictEqual(payload.contentHint, 1);
|
||||||
|
assert.strictEqual(payload.timestamp, timestamp);
|
||||||
|
assert.strictEqual(payload.proto.length, 8);
|
||||||
|
assert.strictEqual(payload.urgent, 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -132,6 +132,8 @@ export default class OutgoingMessage {
|
||||||
|
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
|
|
||||||
|
urgent: boolean;
|
||||||
|
|
||||||
recipients: Record<string, Array<number>>;
|
recipients: Record<string, Array<number>>;
|
||||||
|
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
|
@ -146,6 +148,7 @@ export default class OutgoingMessage {
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
server,
|
server,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
}: {
|
}: {
|
||||||
callback: (result: CallbackResultType) => void;
|
callback: (result: CallbackResultType) => void;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
|
@ -156,6 +159,7 @@ export default class OutgoingMessage {
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
server: WebAPIType;
|
server: WebAPIType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}) {
|
}) {
|
||||||
if (message instanceof Proto.DataMessage) {
|
if (message instanceof Proto.DataMessage) {
|
||||||
const content = new Proto.Content();
|
const content = new Proto.Content();
|
||||||
|
@ -171,6 +175,7 @@ export default class OutgoingMessage {
|
||||||
this.contentHint = contentHint;
|
this.contentHint = contentHint;
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
this.urgent = urgent;
|
||||||
|
|
||||||
this.identifiersCompleted = 0;
|
this.identifiersCompleted = 0;
|
||||||
this.errors = [];
|
this.errors = [];
|
||||||
|
@ -189,7 +194,7 @@ export default class OutgoingMessage {
|
||||||
if (this.identifiersCompleted >= this.identifiers.length) {
|
if (this.identifiersCompleted >= this.identifiers.length) {
|
||||||
const proto = this.message;
|
const proto = this.message;
|
||||||
const contentProto = this.getContentProtoBytes();
|
const contentProto = this.getContentProtoBytes();
|
||||||
const { timestamp, contentHint, recipients } = this;
|
const { timestamp, contentHint, recipients, urgent } = this;
|
||||||
let dataMessage: Uint8Array | undefined;
|
let dataMessage: Uint8Array | undefined;
|
||||||
|
|
||||||
if (proto instanceof Proto.Content && proto.dataMessage) {
|
if (proto instanceof Proto.Content && proto.dataMessage) {
|
||||||
|
@ -209,6 +214,7 @@ export default class OutgoingMessage {
|
||||||
recipients,
|
recipients,
|
||||||
contentProto,
|
contentProto,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,16 +305,13 @@ export default class OutgoingMessage {
|
||||||
identifier,
|
identifier,
|
||||||
jsonData,
|
jsonData,
|
||||||
timestamp,
|
timestamp,
|
||||||
this.online,
|
{ accessKey, online: this.online, urgent: this.urgent }
|
||||||
{ accessKey }
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
promise = this.server.sendMessages(
|
promise = this.server.sendMessages(identifier, jsonData, timestamp, {
|
||||||
identifier,
|
online: this.online,
|
||||||
jsonData,
|
urgent: this.urgent,
|
||||||
timestamp,
|
});
|
||||||
this.online
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise.catch(e => {
|
return promise.catch(e => {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import type {
|
||||||
GetProfileUnauthOptionsType,
|
GetProfileUnauthOptionsType,
|
||||||
GroupCredentialsType,
|
GroupCredentialsType,
|
||||||
GroupLogResponseType,
|
GroupLogResponseType,
|
||||||
MultiRecipient200ResponseType,
|
|
||||||
ProfileRequestDataType,
|
ProfileRequestDataType,
|
||||||
ProxiedRequestOptionsType,
|
ProxiedRequestOptionsType,
|
||||||
UploadAvatarHeadersType,
|
UploadAvatarHeadersType,
|
||||||
|
@ -150,6 +149,7 @@ export const singleProtoJobDataSchema = z.object({
|
||||||
messageIds: z.array(z.string()).optional(),
|
messageIds: z.array(z.string()).optional(),
|
||||||
protoBase64: z.string(),
|
protoBase64: z.string(),
|
||||||
type: sendTypesEnum,
|
type: sendTypesEnum,
|
||||||
|
urgent: z.boolean().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type SingleProtoJobData = z.infer<typeof singleProtoJobDataSchema>;
|
export type SingleProtoJobData = z.infer<typeof singleProtoJobDataSchema>;
|
||||||
|
@ -1006,11 +1006,13 @@ export default class MessageSender {
|
||||||
contentHint,
|
contentHint,
|
||||||
groupId,
|
groupId,
|
||||||
options,
|
options,
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
messageOptions: MessageOptionsType;
|
messageOptions: MessageOptionsType;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
|
urgent: boolean;
|
||||||
}>): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const message = await this.getHydratedMessage(messageOptions);
|
const message = await this.getHydratedMessage(messageOptions);
|
||||||
|
|
||||||
|
@ -1029,6 +1031,7 @@ export default class MessageSender {
|
||||||
proto: message.toProto(),
|
proto: message.toProto(),
|
||||||
recipients: message.recipients || [],
|
recipients: message.recipients || [],
|
||||||
timestamp: message.timestamp,
|
timestamp: message.timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1042,6 +1045,7 @@ export default class MessageSender {
|
||||||
recipients,
|
recipients,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
callback: (result: CallbackResultType) => void;
|
callback: (result: CallbackResultType) => void;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
|
@ -1051,6 +1055,7 @@ export default class MessageSender {
|
||||||
recipients: ReadonlyArray<string>;
|
recipients: ReadonlyArray<string>;
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}>): void {
|
}>): void {
|
||||||
const rejections = window.textsecure.storage.get(
|
const rejections = window.textsecure.storage.get(
|
||||||
'signedKeyRotationRejected',
|
'signedKeyRotationRejected',
|
||||||
|
@ -1070,6 +1075,7 @@ export default class MessageSender {
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
server: this.server,
|
server: this.server,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
|
|
||||||
recipients.forEach(identifier => {
|
recipients.forEach(identifier => {
|
||||||
|
@ -1086,6 +1092,7 @@ export default class MessageSender {
|
||||||
contentHint,
|
contentHint,
|
||||||
groupId,
|
groupId,
|
||||||
options,
|
options,
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
recipients: Array<string>;
|
recipients: Array<string>;
|
||||||
|
@ -1093,6 +1100,7 @@ export default class MessageSender {
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
|
urgent: boolean;
|
||||||
}>): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const callback = (result: CallbackResultType) => {
|
const callback = (result: CallbackResultType) => {
|
||||||
|
@ -1111,6 +1119,7 @@ export default class MessageSender {
|
||||||
proto,
|
proto,
|
||||||
recipients,
|
recipients,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1122,6 +1131,7 @@ export default class MessageSender {
|
||||||
options,
|
options,
|
||||||
proto,
|
proto,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
@ -1129,6 +1139,7 @@ export default class MessageSender {
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
proto: Proto.DataMessage | Proto.Content | PlaintextContent;
|
proto: Proto.DataMessage | Proto.Content | PlaintextContent;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}>): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
assert(identifier, "Identifier can't be undefined");
|
assert(identifier, "Identifier can't be undefined");
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -1147,6 +1158,7 @@ export default class MessageSender {
|
||||||
proto,
|
proto,
|
||||||
recipients: [identifier],
|
recipients: [identifier],
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1170,6 +1182,7 @@ export default class MessageSender {
|
||||||
sticker,
|
sticker,
|
||||||
storyContext,
|
storyContext,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
attachments: ReadonlyArray<AttachmentType> | undefined;
|
attachments: ReadonlyArray<AttachmentType> | undefined;
|
||||||
contact?: Array<ContactWithHydratedAvatar>;
|
contact?: Array<ContactWithHydratedAvatar>;
|
||||||
|
@ -1187,6 +1200,7 @@ export default class MessageSender {
|
||||||
sticker?: StickerType;
|
sticker?: StickerType;
|
||||||
storyContext?: StoryContextType;
|
storyContext?: StoryContextType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}>): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
return this.sendMessage({
|
return this.sendMessage({
|
||||||
messageOptions: {
|
messageOptions: {
|
||||||
|
@ -1207,6 +1221,7 @@ export default class MessageSender {
|
||||||
contentHint,
|
contentHint,
|
||||||
groupId,
|
groupId,
|
||||||
options,
|
options,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1223,6 +1238,7 @@ export default class MessageSender {
|
||||||
conversationIdsSentTo = [],
|
conversationIdsSentTo = [],
|
||||||
conversationIdsWithSealedSender = new Set(),
|
conversationIdsWithSealedSender = new Set(),
|
||||||
isUpdate,
|
isUpdate,
|
||||||
|
urgent,
|
||||||
options,
|
options,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
encodedDataMessage: Uint8Array;
|
encodedDataMessage: Uint8Array;
|
||||||
|
@ -1233,6 +1249,7 @@ export default class MessageSender {
|
||||||
conversationIdsSentTo?: Iterable<string>;
|
conversationIdsSentTo?: Iterable<string>;
|
||||||
conversationIdsWithSealedSender?: Set<string>;
|
conversationIdsWithSealedSender?: Set<string>;
|
||||||
isUpdate?: boolean;
|
isUpdate?: boolean;
|
||||||
|
urgent: boolean;
|
||||||
options?: SendOptionsType;
|
options?: SendOptionsType;
|
||||||
}>): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const myUuid = window.textsecure.storage.user.getCheckedUuid();
|
const myUuid = window.textsecure.storage.user.getCheckedUuid();
|
||||||
|
@ -1295,6 +1312,7 @@ export default class MessageSender {
|
||||||
timestamp,
|
timestamp,
|
||||||
contentHint: ContentHint.RESENDABLE,
|
contentHint: ContentHint.RESENDABLE,
|
||||||
options,
|
options,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1318,6 +1336,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'blockSyncRequest',
|
type: 'blockSyncRequest',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1341,6 +1360,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'configurationSyncRequest',
|
type: 'configurationSyncRequest',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1364,6 +1384,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'groupSyncRequest',
|
type: 'groupSyncRequest',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1387,6 +1408,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'contactSyncRequest',
|
type: 'contactSyncRequest',
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1410,6 +1432,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'pniIdentitySyncRequest',
|
type: 'pniIdentitySyncRequest',
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1434,6 +1457,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'fetchLatestManifestSync',
|
type: 'fetchLatestManifestSync',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1458,6 +1482,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'fetchLocalProfileSync',
|
type: 'fetchLocalProfileSync',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1482,6 +1507,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'keySyncRequest',
|
type: 'keySyncRequest',
|
||||||
|
urgent: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1516,6 +1542,7 @@ export default class MessageSender {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
contentHint: ContentHint.RESENDABLE,
|
contentHint: ContentHint.RESENDABLE,
|
||||||
options,
|
options,
|
||||||
|
urgent: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1548,6 +1575,7 @@ export default class MessageSender {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
contentHint: ContentHint.RESENDABLE,
|
contentHint: ContentHint.RESENDABLE,
|
||||||
options,
|
options,
|
||||||
|
urgent: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1593,6 +1621,7 @@ export default class MessageSender {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
contentHint: ContentHint.RESENDABLE,
|
contentHint: ContentHint.RESENDABLE,
|
||||||
options,
|
options,
|
||||||
|
urgent: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1634,6 +1663,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'messageRequestSync',
|
type: 'messageRequestSync',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1674,6 +1704,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'stickerPackSync',
|
type: 'stickerPackSync',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1718,6 +1749,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'verificationSync',
|
type: 'verificationSync',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1743,6 +1775,7 @@ export default class MessageSender {
|
||||||
contentHint: ContentHint.DEFAULT,
|
contentHint: ContentHint.DEFAULT,
|
||||||
groupId: undefined,
|
groupId: undefined,
|
||||||
options,
|
options,
|
||||||
|
urgent: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1824,6 +1857,7 @@ export default class MessageSender {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
contentHint: ContentHint.RESENDABLE,
|
contentHint: ContentHint.RESENDABLE,
|
||||||
options,
|
options,
|
||||||
|
urgent: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1858,6 +1892,7 @@ export default class MessageSender {
|
||||||
Proto.Content.encode(contentMessage).finish()
|
Proto.Content.encode(contentMessage).finish()
|
||||||
),
|
),
|
||||||
type: 'nullMessage',
|
type: 'nullMessage',
|
||||||
|
urgent: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1881,6 +1916,7 @@ export default class MessageSender {
|
||||||
contentHint: ContentHint.DEFAULT,
|
contentHint: ContentHint.DEFAULT,
|
||||||
groupId,
|
groupId,
|
||||||
options,
|
options,
|
||||||
|
urgent: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1895,12 +1931,14 @@ export default class MessageSender {
|
||||||
proto,
|
proto,
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
messageId?: string;
|
messageId?: string;
|
||||||
proto: Buffer;
|
proto: Buffer;
|
||||||
sendType: SendTypesType;
|
sendType: SendTypesType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}>): SendLogCallbackType {
|
}>): SendLogCallbackType {
|
||||||
let initialSavePromise: Promise<number>;
|
let initialSavePromise: Promise<number>;
|
||||||
|
|
||||||
|
@ -1933,9 +1971,10 @@ export default class MessageSender {
|
||||||
if (!initialSavePromise) {
|
if (!initialSavePromise) {
|
||||||
initialSavePromise = window.Signal.Data.insertSentProto(
|
initialSavePromise = window.Signal.Data.insertSentProto(
|
||||||
{
|
{
|
||||||
timestamp,
|
|
||||||
proto,
|
|
||||||
contentHint,
|
contentHint,
|
||||||
|
proto,
|
||||||
|
timestamp,
|
||||||
|
urgent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
recipients: { [recipientUuid]: deviceIds },
|
recipients: { [recipientUuid]: deviceIds },
|
||||||
|
@ -1963,6 +2002,7 @@ export default class MessageSender {
|
||||||
recipients,
|
recipients,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp = Date.now(),
|
timestamp = Date.now(),
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
|
@ -1971,6 +2011,7 @@ export default class MessageSender {
|
||||||
recipients: ReadonlyArray<string>;
|
recipients: ReadonlyArray<string>;
|
||||||
sendLogCallback?: SendLogCallbackType;
|
sendLogCallback?: SendLogCallbackType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}>): Promise<CallbackResultType> {
|
}>): Promise<CallbackResultType> {
|
||||||
const myE164 = window.textsecure.storage.user.getNumber();
|
const myE164 = window.textsecure.storage.user.getNumber();
|
||||||
const myUuid = window.textsecure.storage.user.getUuid()?.toString();
|
const myUuid = window.textsecure.storage.user.getUuid()?.toString();
|
||||||
|
@ -1987,6 +2028,8 @@ export default class MessageSender {
|
||||||
failoverIdentifiers: [],
|
failoverIdentifiers: [],
|
||||||
successfulIdentifiers: [],
|
successfulIdentifiers: [],
|
||||||
unidentifiedDeliveries: [],
|
unidentifiedDeliveries: [],
|
||||||
|
contentHint,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2008,6 +2051,7 @@ export default class MessageSender {
|
||||||
recipients: identifiers,
|
recipients: identifiers,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2078,12 +2122,14 @@ export default class MessageSender {
|
||||||
groupId,
|
groupId,
|
||||||
identifiers,
|
identifiers,
|
||||||
throwIfNotInDatabase,
|
throwIfNotInDatabase,
|
||||||
|
urgent,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
distributionId: string;
|
distributionId: string;
|
||||||
groupId: string | undefined;
|
groupId: string | undefined;
|
||||||
identifiers: ReadonlyArray<string>;
|
identifiers: ReadonlyArray<string>;
|
||||||
throwIfNotInDatabase?: boolean;
|
throwIfNotInDatabase?: boolean;
|
||||||
|
urgent: boolean;
|
||||||
}>,
|
}>,
|
||||||
options?: Readonly<SendOptionsType>
|
options?: Readonly<SendOptionsType>
|
||||||
): Promise<CallbackResultType> {
|
): Promise<CallbackResultType> {
|
||||||
|
@ -2103,6 +2149,7 @@ export default class MessageSender {
|
||||||
proto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
proto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
||||||
sendType: 'senderKeyDistributionMessage',
|
sendType: 'senderKeyDistributionMessage',
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
})
|
})
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
@ -2114,6 +2161,7 @@ export default class MessageSender {
|
||||||
recipients: identifiers,
|
recipients: identifiers,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2144,6 +2192,7 @@ export default class MessageSender {
|
||||||
proto: Buffer.from(Proto.Content.encode(proto).finish()),
|
proto: Buffer.from(Proto.Content.encode(proto).finish()),
|
||||||
sendType: 'legacyGroupChange',
|
sendType: 'legacyGroupChange',
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
})
|
})
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
@ -2155,11 +2204,15 @@ export default class MessageSender {
|
||||||
recipients: groupIdentifiers,
|
recipients: groupIdentifiers,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple pass-throughs
|
// Simple pass-throughs
|
||||||
|
|
||||||
|
// Note: instead of updating these functions, or adding new ones, remove these and go
|
||||||
|
// directly to window.textsecure.messaging.server.<function>
|
||||||
|
|
||||||
async getProfile(
|
async getProfile(
|
||||||
uuid: UUID,
|
uuid: UUID,
|
||||||
options: GetProfileOptionsType | GetProfileUnauthOptionsType
|
options: GetProfileOptionsType | GetProfileUnauthOptionsType
|
||||||
|
@ -2262,15 +2315,6 @@ export default class MessageSender {
|
||||||
return this.server.modifyGroup(changes, options, inviteLinkBase64);
|
return this.server.modifyGroup(changes, options, inviteLinkBase64);
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendWithSenderKey(
|
|
||||||
data: Readonly<Uint8Array>,
|
|
||||||
accessKeys: Readonly<Uint8Array>,
|
|
||||||
timestamp: number,
|
|
||||||
online?: boolean
|
|
||||||
): Promise<MultiRecipient200ResponseType> {
|
|
||||||
return this.server.sendWithSenderKey(data, accessKeys, timestamp, online);
|
|
||||||
}
|
|
||||||
|
|
||||||
async fetchLinkPreviewMetadata(
|
async fetchLinkPreviewMetadata(
|
||||||
href: string,
|
href: string,
|
||||||
abortSignal: AbortSignal
|
abortSignal: AbortSignal
|
||||||
|
|
1
ts/textsecure/Types.d.ts
vendored
1
ts/textsecure/Types.d.ts
vendored
|
@ -263,6 +263,7 @@ export interface CallbackResultType {
|
||||||
contentProto?: Uint8Array;
|
contentProto?: Uint8Array;
|
||||||
timestamp?: number;
|
timestamp?: number;
|
||||||
recipients?: Record<string, Array<number>>;
|
recipients?: Record<string, Array<number>>;
|
||||||
|
urgent?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRequestHandler {
|
export interface IRequestHandler {
|
||||||
|
|
|
@ -916,20 +916,22 @@ export type WebAPIType = {
|
||||||
destination: string,
|
destination: string,
|
||||||
messageArray: ReadonlyArray<MessageType>,
|
messageArray: ReadonlyArray<MessageType>,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
online?: boolean
|
options: { online?: boolean; urgent?: boolean }
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
sendMessagesUnauth: (
|
sendMessagesUnauth: (
|
||||||
destination: string,
|
destination: string,
|
||||||
messageArray: ReadonlyArray<MessageType>,
|
messageArray: ReadonlyArray<MessageType>,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
online?: boolean,
|
options: { accessKey?: string; online?: boolean; urgent?: boolean }
|
||||||
options?: { accessKey?: string }
|
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
sendWithSenderKey: (
|
sendWithSenderKey: (
|
||||||
payload: Uint8Array,
|
payload: Uint8Array,
|
||||||
accessKeys: Uint8Array,
|
accessKeys: Uint8Array,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
online?: boolean
|
options: {
|
||||||
|
online?: boolean;
|
||||||
|
urgent?: boolean;
|
||||||
|
}
|
||||||
) => Promise<MultiRecipient200ResponseType>;
|
) => Promise<MultiRecipient200ResponseType>;
|
||||||
setSignedPreKey: (
|
setSignedPreKey: (
|
||||||
signedPreKey: SignedPreKeyType,
|
signedPreKey: SignedPreKeyType,
|
||||||
|
@ -2078,15 +2080,18 @@ export function initialize({
|
||||||
destination: string,
|
destination: string,
|
||||||
messages: ReadonlyArray<MessageType>,
|
messages: ReadonlyArray<MessageType>,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
online?: boolean,
|
{
|
||||||
{ accessKey }: { accessKey?: string } = {}
|
accessKey,
|
||||||
|
online,
|
||||||
|
urgent = true,
|
||||||
|
}: { accessKey?: string; online?: boolean; urgent?: boolean }
|
||||||
) {
|
) {
|
||||||
let jsonData;
|
const jsonData = {
|
||||||
if (online) {
|
messages,
|
||||||
jsonData = { messages, timestamp, online: true };
|
timestamp,
|
||||||
} else {
|
online: Boolean(online),
|
||||||
jsonData = { messages, timestamp };
|
urgent,
|
||||||
}
|
};
|
||||||
|
|
||||||
await _ajax({
|
await _ajax({
|
||||||
call: 'messages',
|
call: 'messages',
|
||||||
|
@ -2103,14 +2108,14 @@ export function initialize({
|
||||||
destination: string,
|
destination: string,
|
||||||
messages: ReadonlyArray<MessageType>,
|
messages: ReadonlyArray<MessageType>,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
online?: boolean
|
{ online, urgent = true }: { online?: boolean; urgent?: boolean }
|
||||||
) {
|
) {
|
||||||
let jsonData;
|
const jsonData = {
|
||||||
if (online) {
|
messages,
|
||||||
jsonData = { messages, timestamp, online: true };
|
timestamp,
|
||||||
} else {
|
online: Boolean(online),
|
||||||
jsonData = { messages, timestamp };
|
urgent,
|
||||||
}
|
};
|
||||||
|
|
||||||
await _ajax({
|
await _ajax({
|
||||||
call: 'messages',
|
call: 'messages',
|
||||||
|
@ -2121,18 +2126,31 @@ export function initialize({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function booleanToString(value: boolean | undefined): string {
|
||||||
|
return value ? 'true' : 'false';
|
||||||
|
}
|
||||||
|
|
||||||
async function sendWithSenderKey(
|
async function sendWithSenderKey(
|
||||||
data: Uint8Array,
|
data: Uint8Array,
|
||||||
accessKeys: Uint8Array,
|
accessKeys: Uint8Array,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
online?: boolean
|
{
|
||||||
|
online,
|
||||||
|
urgent = true,
|
||||||
|
}: {
|
||||||
|
online?: boolean;
|
||||||
|
urgent?: boolean;
|
||||||
|
}
|
||||||
): Promise<MultiRecipient200ResponseType> {
|
): Promise<MultiRecipient200ResponseType> {
|
||||||
|
const onlineParam = `&online=${booleanToString(online)}`;
|
||||||
|
const urgentParam = `&urgent=${booleanToString(urgent)}`;
|
||||||
|
|
||||||
const response = await _ajax({
|
const response = await _ajax({
|
||||||
call: 'multiRecipient',
|
call: 'multiRecipient',
|
||||||
httpType: 'PUT',
|
httpType: 'PUT',
|
||||||
contentType: 'application/vnd.signal-messenger.mrm',
|
contentType: 'application/vnd.signal-messenger.mrm',
|
||||||
data,
|
data,
|
||||||
urlParameters: `?ts=${timestamp}&online=${online ? 'true' : 'false'}`,
|
urlParameters: `?ts=${timestamp}${onlineParam}${urgentParam}`,
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
unauthenticated: true,
|
unauthenticated: true,
|
||||||
accessKey: Bytes.toBase64(accessKeys),
|
accessKey: Bytes.toBase64(accessKeys),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { isNumber } from 'lodash';
|
import { isBoolean, isNumber } from 'lodash';
|
||||||
import type { CallbackResultType } from '../textsecure/Types.d';
|
import type { CallbackResultType } from '../textsecure/Types.d';
|
||||||
import dataInterface from '../sql/Client';
|
import dataInterface from '../sql/Client';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
@ -17,38 +17,49 @@ import { SEALED_SENDER } from '../types/SealedSender';
|
||||||
const { insertSentProto, updateConversation } = dataInterface;
|
const { insertSentProto, updateConversation } = dataInterface;
|
||||||
|
|
||||||
export const sendTypesEnum = z.enum([
|
export const sendTypesEnum = z.enum([
|
||||||
'blockSyncRequest',
|
// Core user interactions, default urgent
|
||||||
'pniIdentitySyncRequest',
|
|
||||||
'callingMessage', // excluded from send log
|
|
||||||
'configurationSyncRequest',
|
|
||||||
'contactSyncRequest',
|
|
||||||
'deleteForEveryone',
|
|
||||||
'deliveryReceipt',
|
|
||||||
'expirationTimerUpdate',
|
|
||||||
'fetchLatestManifestSync',
|
|
||||||
'fetchLocalProfileSync',
|
|
||||||
'groupChange',
|
|
||||||
'groupSyncRequest',
|
|
||||||
'keySyncRequest',
|
|
||||||
'legacyGroupChange',
|
|
||||||
'message',
|
'message',
|
||||||
'messageRequestSync',
|
'callingMessage', // excluded from send log; only call-initiation messages are urgent
|
||||||
|
'deleteForEveryone',
|
||||||
|
'expirationTimerUpdate', // non-urgent
|
||||||
|
'groupChange', // non-urgent
|
||||||
|
'reaction',
|
||||||
|
'typing', // excluded from send log; non-urgent
|
||||||
|
|
||||||
|
// Responding to incoming messages, all non-urgent
|
||||||
|
'deliveryReceipt',
|
||||||
|
'readReceipt',
|
||||||
|
'viewedReceipt',
|
||||||
|
|
||||||
|
// Encryption housekeeping, default non-urgent
|
||||||
'nullMessage',
|
'nullMessage',
|
||||||
'profileKeyUpdate',
|
'profileKeyUpdate',
|
||||||
'reaction',
|
'resendFromLog', // excluded from send log, only urgent if original message was urgent
|
||||||
'readReceipt',
|
|
||||||
'readSync',
|
|
||||||
'resendFromLog', // excluded from send log
|
|
||||||
'resetSession',
|
|
||||||
'retryRequest', // excluded from send log
|
'retryRequest', // excluded from send log
|
||||||
'senderKeyDistributionMessage',
|
'senderKeyDistributionMessage', // only urgent if associated message is
|
||||||
|
|
||||||
|
// Sync messages sent during link, default non-urgent
|
||||||
|
'blockSyncRequest',
|
||||||
|
'configurationSyncRequest',
|
||||||
|
'contactSyncRequest', // urgent because it blocks the link process
|
||||||
|
'groupSyncRequest',
|
||||||
|
'keySyncRequest', // urgent because it blocks the link process
|
||||||
|
'pniIdentitySyncRequest', // urgent because we need our PNI to be fully functional
|
||||||
|
|
||||||
|
// Syncs, default non-urgent
|
||||||
|
'fetchLatestManifestSync',
|
||||||
|
'fetchLocalProfileSync',
|
||||||
|
'messageRequestSync',
|
||||||
|
'readSync', // urgent
|
||||||
'sentSync',
|
'sentSync',
|
||||||
'stickerPackSync',
|
'stickerPackSync',
|
||||||
'typing', // excluded from send log
|
|
||||||
'verificationSync',
|
'verificationSync',
|
||||||
'viewOnceSync',
|
'viewOnceSync',
|
||||||
'viewSync',
|
'viewSync',
|
||||||
'viewedReceipt',
|
|
||||||
|
// No longer used, all non-urgent
|
||||||
|
'legacyGroupChange',
|
||||||
|
'resetSession',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export type SendTypesType = z.infer<typeof sendTypesEnum>;
|
export type SendTypesType = z.infer<typeof sendTypesEnum>;
|
||||||
|
@ -216,7 +227,7 @@ async function maybeSaveToSendLog(
|
||||||
sendType: SendTypesType;
|
sendType: SendTypesType;
|
||||||
}
|
}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { contentHint, contentProto, recipients, timestamp } = result;
|
const { contentHint, contentProto, recipients, timestamp, urgent } = result;
|
||||||
|
|
||||||
if (!shouldSaveProto(sendType)) {
|
if (!shouldSaveProto(sendType)) {
|
||||||
return;
|
return;
|
||||||
|
@ -247,6 +258,7 @@ async function maybeSaveToSendLog(
|
||||||
timestamp,
|
timestamp,
|
||||||
proto: Buffer.from(contentProto),
|
proto: Buffer.from(contentProto),
|
||||||
contentHint,
|
contentHint,
|
||||||
|
urgent: isBoolean(urgent) ? urgent : true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
messageIds,
|
messageIds,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
DecryptionErrorMessage,
|
DecryptionErrorMessage,
|
||||||
PlaintextContent,
|
PlaintextContent,
|
||||||
} from '@signalapp/libsignal-client';
|
} from '@signalapp/libsignal-client';
|
||||||
import { isNumber } from 'lodash';
|
import { isBoolean, isNumber } from 'lodash';
|
||||||
|
|
||||||
import * as Bytes from '../Bytes';
|
import * as Bytes from '../Bytes';
|
||||||
import { isProduction } from './version';
|
import { isProduction } from './version';
|
||||||
|
@ -131,7 +131,7 @@ export async function onRetryRequest(event: RetryRequestEvent): Promise<void> {
|
||||||
throw new Error(`onRetryRequest/${logId}: messaging is not available!`);
|
throw new Error(`onRetryRequest/${logId}: messaging is not available!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { contentHint, messageIds, proto, timestamp } = sentProto;
|
const { contentHint, messageIds, proto, timestamp, urgent } = sentProto;
|
||||||
|
|
||||||
const { contentProto, groupId } = await maybeAddSenderKeyDistributionMessage({
|
const { contentProto, groupId } = await maybeAddSenderKeyDistributionMessage({
|
||||||
contentProto: Proto.Content.decode(proto),
|
contentProto: Proto.Content.decode(proto),
|
||||||
|
@ -148,12 +148,13 @@ export async function onRetryRequest(event: RetryRequestEvent): Promise<void> {
|
||||||
);
|
);
|
||||||
const sendOptions = await getSendOptions(recipientConversation.attributes);
|
const sendOptions = await getSendOptions(recipientConversation.attributes);
|
||||||
const promise = messaging.sendMessageProtoAndWait({
|
const promise = messaging.sendMessageProtoAndWait({
|
||||||
timestamp,
|
|
||||||
recipients: [requesterUuid],
|
|
||||||
proto: new Proto.Content(contentProto),
|
|
||||||
contentHint,
|
contentHint,
|
||||||
groupId,
|
groupId,
|
||||||
options: sendOptions,
|
options: sendOptions,
|
||||||
|
proto: new Proto.Content(contentProto),
|
||||||
|
recipients: [requesterUuid],
|
||||||
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
|
|
||||||
await handleMessageSend(promise, {
|
await handleMessageSend(promise, {
|
||||||
|
@ -306,6 +307,7 @@ async function sendDistributionMessageOrNullMessage(
|
||||||
groupId,
|
groupId,
|
||||||
identifiers: [requesterUuid],
|
identifiers: [requesterUuid],
|
||||||
throwIfNotInDatabase: true,
|
throwIfNotInDatabase: true,
|
||||||
|
urgent: false,
|
||||||
},
|
},
|
||||||
sendOptions
|
sendOptions
|
||||||
),
|
),
|
||||||
|
@ -346,6 +348,7 @@ async function sendDistributionMessageOrNullMessage(
|
||||||
Bytes.fromBase64(nullMessage.protoBase64)
|
Bytes.fromBase64(nullMessage.protoBase64)
|
||||||
),
|
),
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
|
urgent: isBoolean(nullMessage.urgent) ? nullMessage.urgent : true,
|
||||||
}),
|
}),
|
||||||
{ messageIds: [], sendType: nullMessage.type }
|
{ messageIds: [], sendType: nullMessage.type }
|
||||||
);
|
);
|
||||||
|
|
|
@ -98,6 +98,7 @@ export async function sendToGroup({
|
||||||
sendOptions,
|
sendOptions,
|
||||||
sendTarget,
|
sendTarget,
|
||||||
sendType,
|
sendType,
|
||||||
|
urgent,
|
||||||
}: {
|
}: {
|
||||||
abortSignal?: AbortSignal;
|
abortSignal?: AbortSignal;
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
|
@ -107,6 +108,7 @@ export async function sendToGroup({
|
||||||
sendOptions?: SendOptionsType;
|
sendOptions?: SendOptionsType;
|
||||||
sendTarget: SenderKeyTargetType;
|
sendTarget: SenderKeyTargetType;
|
||||||
sendType: SendTypesType;
|
sendType: SendTypesType;
|
||||||
|
urgent: boolean;
|
||||||
}): Promise<CallbackResultType> {
|
}): Promise<CallbackResultType> {
|
||||||
strictAssert(
|
strictAssert(
|
||||||
window.textsecure.messaging,
|
window.textsecure.messaging,
|
||||||
|
@ -139,6 +141,7 @@ export async function sendToGroup({
|
||||||
sendTarget,
|
sendTarget,
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +156,7 @@ export async function sendContentMessageToGroup({
|
||||||
sendTarget,
|
sendTarget,
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
}: {
|
}: {
|
||||||
contentHint: number;
|
contentHint: number;
|
||||||
contentMessage: Proto.Content;
|
contentMessage: Proto.Content;
|
||||||
|
@ -164,6 +168,7 @@ export async function sendContentMessageToGroup({
|
||||||
sendTarget: SenderKeyTargetType;
|
sendTarget: SenderKeyTargetType;
|
||||||
sendType: SendTypesType;
|
sendType: SendTypesType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}): Promise<CallbackResultType> {
|
}): Promise<CallbackResultType> {
|
||||||
const logId = sendTarget.idForLogging();
|
const logId = sendTarget.idForLogging();
|
||||||
strictAssert(
|
strictAssert(
|
||||||
|
@ -194,6 +199,7 @@ export async function sendContentMessageToGroup({
|
||||||
sendTarget,
|
sendTarget,
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (!(error instanceof Error)) {
|
if (!(error instanceof Error)) {
|
||||||
|
@ -217,6 +223,7 @@ export async function sendContentMessageToGroup({
|
||||||
proto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
proto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
const groupId = sendTarget.isGroupV2() ? sendTarget.getGroupId() : undefined;
|
const groupId = sendTarget.isGroupV2() ? sendTarget.getGroupId() : undefined;
|
||||||
return window.textsecure.messaging.sendGroupProto({
|
return window.textsecure.messaging.sendGroupProto({
|
||||||
|
@ -227,6 +234,7 @@ export async function sendContentMessageToGroup({
|
||||||
recipients,
|
recipients,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,6 +252,7 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
sendTarget: SenderKeyTargetType;
|
sendTarget: SenderKeyTargetType;
|
||||||
sendType: SendTypesType;
|
sendType: SendTypesType;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
urgent: boolean;
|
||||||
}): Promise<CallbackResultType> {
|
}): Promise<CallbackResultType> {
|
||||||
const {
|
const {
|
||||||
contentHint,
|
contentHint,
|
||||||
|
@ -257,6 +266,7 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
sendTarget,
|
sendTarget,
|
||||||
sendType,
|
sendType,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
} = options;
|
} = options;
|
||||||
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
|
||||||
|
|
||||||
|
@ -421,6 +431,7 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
distributionId,
|
distributionId,
|
||||||
groupId,
|
groupId,
|
||||||
identifiers: newToMemberUuids,
|
identifiers: newToMemberUuids,
|
||||||
|
urgent,
|
||||||
},
|
},
|
||||||
sendOptions ? { ...sendOptions, online: false } : undefined
|
sendOptions ? { ...sendOptions, online: false } : undefined
|
||||||
),
|
),
|
||||||
|
@ -495,11 +506,11 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
});
|
});
|
||||||
const accessKeys = getXorOfAccessKeys(devicesForSenderKey);
|
const accessKeys = getXorOfAccessKeys(devicesForSenderKey);
|
||||||
|
|
||||||
const result = await window.textsecure.messaging.sendWithSenderKey(
|
const result = await window.textsecure.messaging.server.sendWithSenderKey(
|
||||||
messageBuffer,
|
messageBuffer,
|
||||||
accessKeys,
|
accessKeys,
|
||||||
timestamp,
|
timestamp,
|
||||||
online
|
{ online, urgent }
|
||||||
);
|
);
|
||||||
|
|
||||||
const parsed = multiRecipient200ResponseSchema.safeParse(result);
|
const parsed = multiRecipient200ResponseSchema.safeParse(result);
|
||||||
|
@ -531,6 +542,7 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
contentHint,
|
contentHint,
|
||||||
proto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
proto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
recipients: senderKeyRecipientsWithDevices,
|
recipients: senderKeyRecipientsWithDevices,
|
||||||
|
@ -598,6 +610,7 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
timestamp,
|
timestamp,
|
||||||
contentProto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
contentProto: Buffer.from(Proto.Content.encode(contentMessage).finish()),
|
||||||
recipients: senderKeyRecipientsWithDevices,
|
recipients: senderKeyRecipientsWithDevices,
|
||||||
|
urgent,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,6 +661,7 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
recipients: normalSendRecipients,
|
recipients: normalSendRecipients,
|
||||||
sendLogCallback,
|
sendLogCallback,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent,
|
||||||
});
|
});
|
||||||
|
|
||||||
return mergeSendResult({
|
return mergeSendResult({
|
||||||
|
|
|
@ -89,6 +89,7 @@ export async function wrapWithSyncMessageSend({
|
||||||
expirationStartTimestamp: null,
|
expirationStartTimestamp: null,
|
||||||
options,
|
options,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
urgent: false,
|
||||||
}),
|
}),
|
||||||
{ messageIds, sendType: sendType === 'message' ? 'sentSync' : sendType }
|
{ messageIds, sendType: sendType === 'message' ? 'sentSync' : sendType }
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue