From c3ff62e02dd3e1cf30a2b4aea71b464141d51b18 Mon Sep 17 00:00:00 2001 From: Madhav Dhuppe Date: Fri, 18 Jun 2021 15:05:33 +0530 Subject: [PATCH] PREAPPS-6138: Set the contentDisposition in the attachment item as per their classification while normalizing mime parts. --- src/utils/normalize-mime-parts.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/utils/normalize-mime-parts.ts b/src/utils/normalize-mime-parts.ts index d99f3265..eb92a1fd 100644 --- a/src/utils/normalize-mime-parts.ts +++ b/src/utils/normalize-mime-parts.ts @@ -77,9 +77,21 @@ export function normalizeMimeParts( isDesktop }: { isDesktop?: string; jwtToken?: string; origin?: string } ) { - const processAttachment = ({ ...attachment }) => { + const processAttachment = ( + { ...attachment }, + forcedContentDisposition?: string + ) => { attachment.messageId = attachment.messageId || message.id; attachment.url = getAttachmentUrl(attachment, { origin, jwtToken }); + + if (!attachment.contentDisposition) { + if (forcedContentDisposition === 'attachments') { + attachment.contentDisposition = 'attachment'; + } else if (forcedContentDisposition === 'inlineAttachments') { + attachment.contentDisposition === 'inline'; + } + } + attachment.contentId = attachment.contentId ? normalizeCid(attachment.contentId) : ~normalizeType(attachment.contentType).indexOf('image/') && @@ -156,7 +168,7 @@ export function normalizeMimeParts( part.contentType !== 'application/pkcs7-mime' && part.contentType !== 'application/pkcs7-signature' && part.contentType !== 'application/x-pkcs7-signature' && - (acc[mode] || (acc[mode] = [])).push(processAttachment(part)); + (acc[mode] || (acc[mode] = [])).push(processAttachment(part, mode)); if (isDesktop) { message.attributes = message.attributes || {};