Kantoor. Mime. Content
(Kantoor v1.0.0)
What the message view needs from a raw message: the plain text body, the HTML
body (still UNTRUSTED: it must go through Kantoor.Webmail.HtmlSanitizer),
the attachment list and the inline (cid:) images.
Parts are addressed by their position in the MIME tree ("1-0" is the first
child of the second top-level part); find_part/2 re-parses and returns the
decoded bytes for the download route. Nothing here trusts declared types or
names: callers must treat every string as hostile.
Summary
Types
@type attachment() :: %{ id: String.t(), name: String.t(), size: non_neg_integer(), content_type: String.t() }
@type t() :: %Kantoor.Mime.Content{ attachments: [attachment()], html: String.t() | nil, inline: %{required(String.t()) => {String.t(), binary()}}, seen: non_neg_integer(), text: String.t() | nil }
Functions
@spec attachments_with_data(binary()) :: [ %{name: String.t(), content_type: String.t(), data: binary()} ]
Every attachment of raw with its decoded bytes (for re-attaching a draft's files).
The decoded part with id part_id: {:ok, %{name:, content_type:, data:}} or
:error. Only parts parse/1 lists as attachments are addressable.
Extracts the displayable content of raw. Never raises.