Fix handling attachment thumbnails using thumbnail key

This commit is contained in:
Scott Nonnenberg 2018-04-13 15:45:37 -07:00
parent 6413e75f82
commit 9ad55c803f
No known key found for this signature in database
GPG key ID: 5F82280C35134661
2 changed files with 32 additions and 4 deletions

View file

@ -157,8 +157,17 @@ exports._mapQuotedAttachments = upgradeAttachment => async (message, context) =>
return message;
}
const upgradeWithContext = attachment =>
upgradeAttachment(attachment, context);
const upgradeWithContext = async (attachment) => {
if (!attachment || !attachment.thumbnail) {
return attachment;
}
const thumbnail = await upgradeAttachment(attachment.thumbnail, context);
return Object.assign({}, attachment, {
thumbnail,
});
};
const quotedAttachments = (message.quote && message.quote.attachments) || [];
const attachments = await Promise.all(quotedAttachments.map(upgradeWithContext));