diff --git a/ts/jobs/helpers/sendNormalMessage.ts b/ts/jobs/helpers/sendNormalMessage.ts index 3b7b7cdfa..c74ffae69 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 74af95402..6d06e200d 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<{