Stories: Fix sender key persistence, pipe story: true into sends

This commit is contained in:
Scott Nonnenberg 2022-09-30 09:59:36 -07:00 committed by GitHub
parent 67c706a7ef
commit 2b2594c20a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 30 deletions

View file

@ -17,7 +17,6 @@ import {
conversationJobQueue,
conversationQueueJobEnum,
} from '../jobs/conversationJobQueue';
import { formatJobForInsert } from '../jobs/formatJobForInsert';
import { getRecipients } from './getRecipients';
import { getSignalConnections } from './getSignalConnections';
import { incrementMessageCounter } from './incrementMessageCounter';
@ -144,6 +143,8 @@ export async function sendStoryMessage(
);
}
// Note: we use the same sent_at for these messages because we want de-duplication
// on the receiver side.
return window.Signal.Migrations.upgradeMessageSchema({
attachments,
conversationId: ourConversation.id,
@ -247,7 +248,9 @@ export async function sendStoryMessage(
ourConversation.addSingleMessage(model, { isJustSent: true });
log.info(`stories.sendStoryMessage: saving message ${message.id}`);
log.info(
`stories.sendStoryMessage: saving message ${messageAttributes.timestamp}`
);
return dataInterface.saveMessage(message.attributes, {
forceSave: true,
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
@ -258,18 +261,12 @@ export async function sendStoryMessage(
// * Send to the distribution lists
// * Place into job queue
// * Save the job
await conversationJobQueue.add(
{
type: conversationQueueJobEnum.enum.Story,
conversationId: ourConversation.id,
messageIds: distributionListMessages.map(m => m.id),
timestamp,
},
async jobToInsert => {
log.info(`stories.sendStoryMessage: saving job ${jobToInsert.id}`);
await dataInterface.insertJob(formatJobForInsert(jobToInsert));
}
);
await conversationJobQueue.add({
type: conversationQueueJobEnum.enum.Story,
conversationId: ourConversation.id,
messageIds: distributionListMessages.map(m => m.id),
timestamp,
});
// * Send to groups
// * Save the message models
@ -301,7 +298,9 @@ export async function sendStoryMessage(
const conversation = message.getConversation();
conversation?.addSingleMessage(model, { isJustSent: true });
log.info(`stories.sendStoryMessage: saving message ${message.id}`);
log.info(
`stories.sendStoryMessage: saving message ${messageAttributes.timestamp}`
);
await dataInterface.saveMessage(message.attributes, {
forceSave: true,
jobToInsert,

View file

@ -156,6 +156,7 @@ export async function sendContentMessageToGroup({
sendOptions,
sendTarget,
sendType,
story,
timestamp,
urgent,
}: {
@ -168,6 +169,7 @@ export async function sendContentMessageToGroup({
sendOptions?: SendOptionsType;
sendTarget: SenderKeyTargetType;
sendType: SendTypesType;
story?: boolean;
timestamp: number;
urgent: boolean;
}): Promise<CallbackResultType> {
@ -199,6 +201,7 @@ export async function sendContentMessageToGroup({
sendOptions,
sendTarget,
sendType,
story,
timestamp,
urgent,
});
@ -235,6 +238,7 @@ export async function sendContentMessageToGroup({
proto: contentMessage,
recipients,
sendLogCallback,
story,
timestamp,
urgent,
});
@ -253,6 +257,7 @@ export async function sendToGroupViaSenderKey(options: {
sendOptions?: SendOptionsType;
sendTarget: SenderKeyTargetType;
sendType: SendTypesType;
story?: boolean;
timestamp: number;
urgent: boolean;
}): Promise<CallbackResultType> {
@ -267,6 +272,7 @@ export async function sendToGroupViaSenderKey(options: {
sendOptions,
sendTarget,
sendType,
story,
timestamp,
urgent,
} = options;
@ -433,6 +439,7 @@ export async function sendToGroupViaSenderKey(options: {
distributionId,
groupId,
identifiers: newToMemberUuids,
story,
urgent,
},
sendOptions ? { ...sendOptions, online: false } : undefined