From e8a77a5f89f1a4e66f84bab532a46950c3eb97b7 Mon Sep 17 00:00:00 2001 From: Benedikt Schaber Date: Fri, 27 Jan 2023 19:02:59 +0100 Subject: [PATCH] feat/inline-attachments add contentDispositon field --- config/mail/attachments.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/config/mail/attachments.ts b/config/mail/attachments.ts index 95c9ba3..0f488f7 100644 --- a/config/mail/attachments.ts +++ b/config/mail/attachments.ts @@ -12,14 +12,16 @@ export type Attachment = | base64Attachment | arrayBufferLikeAttachment ) - & baseAttachment; + & baseAttachment + & { contentDisposition?: "attachment" | "inline" }; export type ResolvedAttachment = & ( | textAttachment | base64Attachment ) - & baseAttachment; + & baseAttachment + & { contentDisposition: "attachment" | "inline" }; type textAttachment = { encoding: "text"; content: string }; type base64Attachment = { encoding: "base64"; content: string }; @@ -35,8 +37,15 @@ export function resolveAttachment(attachment: Attachment): ResolvedAttachment { contentType: attachment.contentType, encoding: "base64", content: base64Encode(attachment.content), + contentDisposition: attachment.contentDisposition ?? "attachment", }; } else { - return attachment; + return { + filename: attachment.filename, + contentType: attachment.contentType, + encoding: attachment.encoding, + content: attachment.content, + contentDisposition: attachment.contentDisposition ?? "attachment", + }; } }