Skip to content

Commit

Permalink
feat/inline-attachments add contentDispositon field
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-schaber committed Jan 27, 2023
1 parent 6ba3559 commit e8a77a5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions config/mail/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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",
};
}
}

0 comments on commit e8a77a5

Please sign in to comment.