Allow sends of quoted messages with attachments without thumbnails

This commit is contained in:
trevor-signal 2023-07-07 16:34:23 -04:00 committed by GitHub
parent cc6b299ab6
commit 60f7308dc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View file

@ -640,12 +640,15 @@ async function uploadMessageQuote(
return undefined;
}
const uploadedAttachments = await uploadQueue.addAll(
loadedQuote.attachments
.filter(attachment => attachment.thumbnail)
.map(attachment => async (): Promise<OutgoingQuoteAttachmentType> => {
const attachmentsAfterThumbnailUpload = await uploadQueue.addAll(
loadedQuote.attachments.map(
attachment => async (): Promise<OutgoingQuoteAttachmentType> => {
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,
};
}

View file

@ -95,7 +95,7 @@ export type SendOptionsType = {
export type OutgoingQuoteAttachmentType = Readonly<{
contentType: string;
fileName?: string;
thumbnail: UploadedAttachmentType;
thumbnail?: UploadedAttachmentType;
}>;
export type OutgoingQuoteType = Readonly<{