Send just sync message if we've already sent to all recipients
This commit is contained in:
parent
a88560183b
commit
16d180efac
2 changed files with 16 additions and 6 deletions
|
@ -108,6 +108,7 @@ export async function sendNormalMessage(
|
||||||
const {
|
const {
|
||||||
allRecipientIdentifiers,
|
allRecipientIdentifiers,
|
||||||
recipientIdentifiersWithoutMe,
|
recipientIdentifiersWithoutMe,
|
||||||
|
sentRecipientIdentifiers,
|
||||||
untrustedUuids,
|
untrustedUuids,
|
||||||
} = getMessageRecipients({
|
} = getMessageRecipients({
|
||||||
log,
|
log,
|
||||||
|
@ -151,9 +152,13 @@ export async function sendNormalMessage(
|
||||||
let messageSendPromise: Promise<CallbackResultType | void>;
|
let messageSendPromise: Promise<CallbackResultType | void>;
|
||||||
|
|
||||||
if (recipientIdentifiersWithoutMe.length === 0) {
|
if (recipientIdentifiersWithoutMe.length === 0) {
|
||||||
if (!isMe(conversation.attributes) && !isGroup(conversation.attributes)) {
|
if (
|
||||||
|
!isMe(conversation.attributes) &&
|
||||||
|
!isGroup(conversation.attributes) &&
|
||||||
|
sentRecipientIdentifiers.length === 0
|
||||||
|
) {
|
||||||
log.info(
|
log.info(
|
||||||
'No recipients, but we are not sending to ourselves or to group. Failing job.'
|
'No recipients; not sending to ourselves or to group, and no successful sends. Failing job.'
|
||||||
);
|
);
|
||||||
markMessageFailed(message, [new Error('No valid recipients')]);
|
markMessageFailed(message, [new Error('No valid recipients')]);
|
||||||
return;
|
return;
|
||||||
|
@ -337,20 +342,18 @@ function getMessageRecipients({
|
||||||
}>): {
|
}>): {
|
||||||
allRecipientIdentifiers: Array<string>;
|
allRecipientIdentifiers: Array<string>;
|
||||||
recipientIdentifiersWithoutMe: Array<string>;
|
recipientIdentifiersWithoutMe: Array<string>;
|
||||||
|
sentRecipientIdentifiers: Array<string>;
|
||||||
untrustedUuids: Array<string>;
|
untrustedUuids: Array<string>;
|
||||||
} {
|
} {
|
||||||
const allRecipientIdentifiers: Array<string> = [];
|
const allRecipientIdentifiers: Array<string> = [];
|
||||||
const recipientIdentifiersWithoutMe: Array<string> = [];
|
const recipientIdentifiersWithoutMe: Array<string> = [];
|
||||||
const untrustedUuids: Array<string> = [];
|
const untrustedUuids: Array<string> = [];
|
||||||
|
const sentRecipientIdentifiers: Array<string> = [];
|
||||||
|
|
||||||
const currentConversationRecipients = conversation.getMemberConversationIds();
|
const currentConversationRecipients = conversation.getMemberConversationIds();
|
||||||
|
|
||||||
Object.entries(message.get('sendStateByConversationId') || {}).forEach(
|
Object.entries(message.get('sendStateByConversationId') || {}).forEach(
|
||||||
([recipientConversationId, sendState]) => {
|
([recipientConversationId, sendState]) => {
|
||||||
if (isSent(sendState.status)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const recipient = window.ConversationController.get(
|
const recipient = window.ConversationController.get(
|
||||||
recipientConversationId
|
recipientConversationId
|
||||||
);
|
);
|
||||||
|
@ -387,6 +390,11 @@ function getMessageRecipients({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSent(sendState.status)) {
|
||||||
|
sentRecipientIdentifiers.push(recipientIdentifier);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
allRecipientIdentifiers.push(recipientIdentifier);
|
allRecipientIdentifiers.push(recipientIdentifier);
|
||||||
if (!isRecipientMe) {
|
if (!isRecipientMe) {
|
||||||
recipientIdentifiersWithoutMe.push(recipientIdentifier);
|
recipientIdentifiersWithoutMe.push(recipientIdentifier);
|
||||||
|
@ -397,6 +405,7 @@ function getMessageRecipients({
|
||||||
return {
|
return {
|
||||||
allRecipientIdentifiers,
|
allRecipientIdentifiers,
|
||||||
recipientIdentifiersWithoutMe,
|
recipientIdentifiersWithoutMe,
|
||||||
|
sentRecipientIdentifiers,
|
||||||
untrustedUuids,
|
untrustedUuids,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1581,6 +1581,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
this.set({
|
this.set({
|
||||||
// This is the same as a normal send()
|
// This is the same as a normal send()
|
||||||
expirationStartTimestamp: Date.now(),
|
expirationStartTimestamp: Date.now(),
|
||||||
|
errors: [],
|
||||||
});
|
});
|
||||||
const result = await this.sendSyncMessage();
|
const result = await this.sendSyncMessage();
|
||||||
this.set({
|
this.set({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue