Skip to content

Commit

Permalink
Consistent scheduling of sendToGroup
Browse files Browse the repository at this point in the history
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
  • Loading branch information
automated-signal and indutny-signal committed Sep 27, 2021
1 parent 826306a commit 60b6285
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 50 deletions.
58 changes: 31 additions & 27 deletions ts/jobs/normalMessageSendJobQueue.ts
Expand Up @@ -260,33 +260,37 @@ export class NormalMessageSendJobQueue extends JobQueue<NormalMessageSendJobData
let innerPromise: Promise<CallbackResultType>;
if (conversationType === Message.GROUP) {
log.info('sending group message');
innerPromise = window.Signal.Util.sendToGroup({
groupSendOptions: {
attachments,
deletedForEveryoneTimestamp,
expireTimer,
groupV1: updateRecipients(
conversation.getGroupV1Info(),
recipientIdentifiersWithoutMe
),
groupV2: updateRecipients(
conversation.getGroupV2Info(),
recipientIdentifiersWithoutMe
),
messageText: body,
preview,
profileKey,
quote,
sticker,
timestamp: messageTimestamp,
mentions,
},
conversation,
contentHint: ContentHint.RESENDABLE,
messageId,
sendOptions,
sendType: 'message',
});
innerPromise = conversation.queueJob(
'normalMessageSendJobQueue',
() =>
window.Signal.Util.sendToGroup({
groupSendOptions: {
attachments,
deletedForEveryoneTimestamp,
expireTimer,
groupV1: updateRecipients(
conversation.getGroupV1Info(),
recipientIdentifiersWithoutMe
),
groupV2: updateRecipients(
conversation.getGroupV2Info(),
recipientIdentifiersWithoutMe
),
messageText: body,
preview,
profileKey,
quote,
sticker,
timestamp: messageTimestamp,
mentions,
},
conversation,
contentHint: ContentHint.RESENDABLE,
messageId,
sendOptions,
sendType: 'message',
})
);
} else {
log.info('sending direct message');
innerPromise = window.textsecure.messaging.sendMessageToIdentifier({
Expand Down
4 changes: 2 additions & 2 deletions ts/models/conversations.ts
Expand Up @@ -1222,7 +1222,7 @@ export class ConversationModel extends window.Backbone
online: true,
};
if (isDirectConversation(this.attributes)) {
handleMessageSend(
await handleMessageSend(
window.textsecure.messaging.sendMessageProtoAndWait({
timestamp,
recipients: groupMembers,
Expand All @@ -1234,7 +1234,7 @@ export class ConversationModel extends window.Backbone
{ messageIds: [], sendType: 'typing' }
);
} else {
handleMessageSend(
await handleMessageSend(
window.Signal.Util.sendContentMessageToGroup({
contentHint: ContentHint.IMPLICIT,
contentMessage,
Expand Down
50 changes: 29 additions & 21 deletions ts/services/calling.ts
Expand Up @@ -906,14 +906,20 @@ export class CallingClass {
logId: `sendToGroup/groupCallUpdate/${conversationId}-${eraId}`,
messageIds: [],
send: () =>
window.Signal.Util.sendToGroup({
groupSendOptions: { groupCallUpdate: { eraId }, groupV2, timestamp },
conversation,
contentHint: ContentHint.DEFAULT,
messageId: undefined,
sendOptions,
sendType: 'callingMessage',
}),
conversation.queueJob('sendGroupCallUpdateMessage', () =>
window.Signal.Util.sendToGroup({
groupSendOptions: {
groupCallUpdate: { eraId },
groupV2,
timestamp,
},
conversation,
contentHint: ContentHint.DEFAULT,
messageId: undefined,
sendOptions,
sendType: 'callingMessage',
})
),
sendType: 'callingMessage',
timestamp,
}).catch(err => {
Expand Down Expand Up @@ -1567,19 +1573,21 @@ export class CallingClass {
// We "fire and forget" because sending this message is non-essential.
// We also don't sync this message.
const { ContentHint } = Proto.UnidentifiedSenderMessage.Message;
await handleMessageSend(
window.Signal.Util.sendContentMessageToGroup({
contentHint: ContentHint.DEFAULT,
contentMessage,
conversation,
isPartialSend: false,
messageId: undefined,
recipients: conversation.getRecipients(),
sendOptions: await getSendOptions(conversation.attributes),
sendType: 'callingMessage',
timestamp,
}),
{ messageIds: [], sendType: 'callingMessage' }
await conversation.queueJob('handleSendCallMessageToGroup', async () =>
handleMessageSend(
window.Signal.Util.sendContentMessageToGroup({
contentHint: ContentHint.DEFAULT,
contentMessage,
conversation,
isPartialSend: false,
messageId: undefined,
recipients: conversation.getRecipients(),
sendOptions: await getSendOptions(conversation.attributes),
sendType: 'callingMessage',
timestamp,
}),
{ messageIds: [], sendType: 'callingMessage' }
)
);
}

Expand Down

0 comments on commit 60b6285

Please sign in to comment.