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
1 changed files with 4 additions and 2 deletions

View File

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