sendNormalMessage: If no errors, still retry messages send if needed

This commit is contained in:
Scott Nonnenberg
2025-03-05 10:16:08 +10:00
committed by GitHub
parent b260c1e64c
commit 16d36053ea

View File

@@ -440,14 +440,18 @@ export async function sendNormalMessage(
await messageSendPromise; await messageSendPromise;
const didFullySend = const didFullySend = didSendToEveryone({
!messageSendErrors.length || isSendingInGroup: conversation.get('type') === 'group',
didSendToEveryone({ log,
log, message,
message, targetTimestamp: editedMessageTimestamp || messageTimestamp,
targetTimestamp: editedMessageTimestamp || messageTimestamp, });
});
if (!didFullySend) { if (!didFullySend) {
if (!messageSendErrors.length) {
log.warn(
'Did not send to everyone, but no errors returned - maybe all errors were UnregisteredUserErrors?'
);
}
throw new Error('message did not fully send'); throw new Error('message did not fully send');
} }
} catch (thrownError: unknown) { } catch (thrownError: unknown) {
@@ -1171,10 +1175,12 @@ async function markMessageFailed({
} }
function didSendToEveryone({ function didSendToEveryone({
isSendingInGroup,
log, log,
message, message,
targetTimestamp, targetTimestamp,
}: { }: {
isSendingInGroup: boolean;
log: LoggerType; log: LoggerType;
message: MessageModel; message: MessageModel;
targetTimestamp: number; targetTimestamp: number;
@@ -1186,7 +1192,19 @@ function didSendToEveryone({
prop: 'sendStateByConversationId', prop: 'sendStateByConversationId',
targetTimestamp, targetTimestamp,
}) || {}; }) || {};
return Object.values(sendStateByConversationId).every(sendState => return Object.entries(sendStateByConversationId).every(
isSent(sendState.status) ([conversationId, sendState]) => {
const conversation = window.ConversationController.get(conversationId);
if (isSendingInGroup) {
if (!conversation) {
return true;
}
if (conversation.isUnregistered()) {
return true;
}
}
return isSent(sendState.status);
}
); );
} }