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; return undefined;
} }
const uploadedAttachments = await uploadQueue.addAll( const attachmentsAfterThumbnailUpload = await uploadQueue.addAll(
loadedQuote.attachments loadedQuote.attachments.map(
.filter(attachment => attachment.thumbnail) attachment => async (): Promise<OutgoingQuoteAttachmentType> => {
.map(attachment => async (): Promise<OutgoingQuoteAttachmentType> => {
const { thumbnail } = attachment; const { thumbnail } = attachment;
strictAssert(thumbnail, 'Quote attachment must have a thumbnail'); if (!thumbnail) {
return {
contentType: attachment.contentType,
};
}
const uploaded = await uploadAttachment(thumbnail); const uploaded = await uploadAttachment(thumbnail);
@ -654,7 +657,8 @@ async function uploadMessageQuote(
fileName: attachment.fileName, fileName: attachment.fileName,
thumbnail: uploaded, thumbnail: uploaded,
}; };
}) }
)
); );
// Update message with attachment digests // Update message with attachment digests
@ -679,11 +683,16 @@ async function uploadMessageQuote(
`${logId}: Quote attachment ${index} no longer has a thumbnail` `${logId}: Quote attachment ${index} no longer has a thumbnail`
); );
const attachmentAfterThumbnailUpload =
attachmentsAfterThumbnailUpload[index];
const digest = attachmentAfterThumbnailUpload.thumbnail
? Bytes.toBase64(attachmentAfterThumbnailUpload.thumbnail.digest)
: undefined;
return { return {
...attachment, ...attachment,
thumbnail: { thumbnail: {
...attachment.thumbnail, ...attachment.thumbnail,
digest: Bytes.toBase64(uploadedAttachments[index].thumbnail.digest), digest,
}, },
}; };
}), }),
@ -696,7 +705,7 @@ async function uploadMessageQuote(
authorUuid: loadedQuote.authorUuid, authorUuid: loadedQuote.authorUuid,
text: loadedQuote.text, text: loadedQuote.text,
bodyRanges: loadedQuote.bodyRanges, bodyRanges: loadedQuote.bodyRanges,
attachments: uploadedAttachments, attachments: attachmentsAfterThumbnailUpload,
}; };
} }

View file

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