diff --git a/server/presenters/document.js b/server/presenters/document.js index edfc4fa8..c98893d7 100644 --- a/server/presenters/document.js +++ b/server/presenters/document.js @@ -12,13 +12,15 @@ type Options = { async function replaceImageAttachments(text: string) { const attachmentIds = parseAttachmentIds(text); - for (const id of attachmentIds) { - const attachment = await Attachment.findByPk(id); - if (attachment) { - const accessUrl = await getSignedImageUrl(attachment.key); - text = text.replace(attachment.redirectUrl, accessUrl); - } - } + await Promise.all( + attachmentIds.map(async (id) => { + const attachment = await Attachment.findByPk(id); + if (attachment) { + const accessUrl = await getSignedImageUrl(attachment.key); + text = text.replace(attachment.redirectUrl, accessUrl); + } + }) + ); return text; }