From 60f7308dc85cce12794a8356af07f4009bbda5d5 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Fri, 7 Jul 2023 16:34:23 -0400 Subject: [PATCH] Allow sends of quoted messages with attachments without thumbnails --- ts/jobs/helpers/sendNormalMessage.ts | 25 +++++++++++++++++-------- ts/textsecure/SendMessage.ts | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ts/jobs/helpers/sendNormalMessage.ts b/ts/jobs/helpers/sendNormalMessage.ts index 3b7b7cdfa117..c74ffae695d2 100644 --- a/ts/jobs/helpers/sendNormalMessage.ts +++ b/ts/jobs/helpers/sendNormalMessage.ts @@ -640,12 +640,15 @@ async function uploadMessageQuote( return undefined; } - const uploadedAttachments = await uploadQueue.addAll( - loadedQuote.attachments - .filter(attachment => attachment.thumbnail) - .map(attachment => async (): Promise => { + const attachmentsAfterThumbnailUpload = await uploadQueue.addAll( + loadedQuote.attachments.map( + attachment => async (): Promise => { const { thumbnail } = attachment; - strictAssert(thumbnail, 'Quote attachment must have a thumbnail'); + if (!thumbnail) { + return { + contentType: attachment.contentType, + }; + } const uploaded = await uploadAttachment(thumbnail); @@ -654,7 +657,8 @@ async function uploadMessageQuote( fileName: attachment.fileName, thumbnail: uploaded, }; - }) + } + ) ); // Update message with attachment digests @@ -679,11 +683,16 @@ async function uploadMessageQuote( `${logId}: Quote attachment ${index} no longer has a thumbnail` ); + const attachmentAfterThumbnailUpload = + attachmentsAfterThumbnailUpload[index]; + const digest = attachmentAfterThumbnailUpload.thumbnail + ? Bytes.toBase64(attachmentAfterThumbnailUpload.thumbnail.digest) + : undefined; return { ...attachment, thumbnail: { ...attachment.thumbnail, - digest: Bytes.toBase64(uploadedAttachments[index].thumbnail.digest), + digest, }, }; }), @@ -696,7 +705,7 @@ async function uploadMessageQuote( authorUuid: loadedQuote.authorUuid, text: loadedQuote.text, bodyRanges: loadedQuote.bodyRanges, - attachments: uploadedAttachments, + attachments: attachmentsAfterThumbnailUpload, }; } diff --git a/ts/textsecure/SendMessage.ts b/ts/textsecure/SendMessage.ts index 74af95402fba..6d06e200d271 100644 --- a/ts/textsecure/SendMessage.ts +++ b/ts/textsecure/SendMessage.ts @@ -95,7 +95,7 @@ export type SendOptionsType = { export type OutgoingQuoteAttachmentType = Readonly<{ contentType: string; fileName?: string; - thumbnail: UploadedAttachmentType; + thumbnail?: UploadedAttachmentType; }>; export type OutgoingQuoteType = Readonly<{