Skip to content

Commit

Permalink
PREAPPS-6138: Set the contentDisposition in the attachment item as pe…
Browse files Browse the repository at this point in the history
…r their classification while normalizing mime parts.
  • Loading branch information
Madhav Dhuppe authored and silentsakky committed Jun 23, 2021
1 parent c9618f3 commit c3ff62e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/utils/normalize-mime-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/') &&
Expand Down Expand Up @@ -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 || {};
Expand Down

0 comments on commit c3ff62e

Please sign in to comment.