fix: Guard missing attachment, closes #1262

This commit is contained in:
Tom Moor
2020-05-07 20:37:36 -07:00
parent e1adb16c43
commit bd2837250b

View File

@ -18,8 +18,10 @@ async function replaceImageAttachments(text) {
for (const id of attachmentIds) { for (const id of attachmentIds) {
const attachment = await Attachment.findByPk(id); const attachment = await Attachment.findByPk(id);
const accessUrl = await getSignedImageUrl(attachment.key); if (attachment) {
text = text.replace(attachment.redirectUrl, accessUrl); const accessUrl = await getSignedImageUrl(attachment.key);
text = text.replace(attachment.redirectUrl, accessUrl);
}
} }
return text; return text;