Kantoor. Ingest
(Kantoor v1.0.0)
Turns a verified Karta push into an index record.
Order of work: look up the recipient (Kantoor.Routing: exact mailbox, alias,
catch-all), short-circuit on an already-ingested delivery, parse MIME (outside
the transaction), then in ONE transaction lock the mailbox row, re-check for
the delivery, apply quota, allocate the UID (visible mail only) and insert.
Callers must answer 2xx only after this returns.
Idempotency: karta_delivery_id is unique. Two concurrent calls for the same
delivery serialise on the mailbox lock; the second finds the first's row and
returns it as :duplicate. The unique index is the backstop.
Summary
Functions
Fills in the parsed fields of a :pending_fetch message once its raw body has
been fetched. Any other message is returned unchanged.
Ingests payload. Raw bytes come from payload.raw unless raw is given
explicitly (e.g. fetched for a notify-only push). Without any raw bytes the
record is stored as :pending_fetch with metadata from the push only.
Types
@type error() :: :unknown_recipient | :mailbox_disabled | :domain_disabled | :no_inbox | Ecto.Changeset.t()
Functions
@spec complete(Kantoor.Mailboxes.Message.t(), binary()) :: {:ok, Kantoor.Mailboxes.Message.t()} | {:error, Ecto.Changeset.t()}
Fills in the parsed fields of a :pending_fetch message once its raw body has
been fetched. Any other message is returned unchanged.
@spec ingest(Kantoor.Karta.InboundPayload.t(), binary() | nil, keyword()) :: {:ok, Kantoor.Ingest.Result.t()} | {:error, error()}
Ingests payload. Raw bytes come from payload.raw unless raw is given
explicitly (e.g. fetched for a notify-only push). Without any raw bytes the
record is stored as :pending_fetch with metadata from the push only.
Options: :retention (:keep default, or {:days, n}).