fix: processQuoteAttachments correctly updates attachment thumbnails when downloading them

pull/2806/head
William Grant 2 years ago committed by Audric Ackermann
parent 83a8adf033
commit 62c5ebb1fc

@ -218,17 +218,18 @@ async function processQuoteAttachments(
const isOpenGroupV2 = convo.isOpenGroupV2(); const isOpenGroupV2 = convo.isOpenGroupV2();
const openGroupV2Details = (isOpenGroupV2 && convo.toOpenGroupV2()) || undefined; const openGroupV2Details = (isOpenGroupV2 && convo.toOpenGroupV2()) || undefined;
quote.attachments = await Promise.all( for (let index = 0; index < quote.attachments.length - 1; index++) {
quote.attachments.map(async (item: any, index: any) => {
// If we already have a path, then we copied this image from the quoted // If we already have a path, then we copied this image from the quoted
// message and we don't need to download the attachment. // message and we don't need to download the attachment.
if (!item.thumbnail || item.thumbnail.path) { const attachment = quote.attachments[index];
return item;
if (!attachment.thumbnail || attachment.thumbnail.path) {
continue;
} }
addedCount += 1; addedCount += 1;
const thumbnail = await AttachmentDownloads.addJob(item.thumbnail, { const thumbnail = await AttachmentDownloads.addJob(attachment.thumbnail, {
messageId: message.id, messageId: message.id,
type: 'quote', type: 'quote',
index, index,
@ -236,9 +237,8 @@ async function processQuoteAttachments(
openGroupV2Details, openGroupV2Details,
}); });
return { ...item, thumbnail }; quote.attachments[index] = { ...attachment, thumbnail };
}) }
);
message.set({ quote }); message.set({ quote });

Loading…
Cancel
Save