Karta.Kantoor (Karta v1.0.0)

The optional mailbox interface (/kantoor/v1, see guides/operations/kantoor.md) for a webmail or mail store that keeps its own index and uses Karta as its mail store. Kantoor, a mail client, is its first user.

Everything here is off unless KARTA_KANTOOR is 1 or true (config :karta, :kantoor, enabled: true, read in config/runtime.exs). The /kantoor/v1 routes are always compiled, but while the switch is off KartaWeb.Kantoor.Gate answers every one of them as an unknown route does, no code path of the existing APIs changes, and the nullable columns this feature adds stay NULL.

A Kantoor key is an API key marked kantoor: true (Karta.Credentials.create_kantoor_key/2). It is accepted on /kantoor/v1 only, and no other key is accepted there (KartaWeb.APIAuth).

Summary

Functions

Karta's commit: KARTA_COMMIT from the environment, else the commit the code was compiled from, else nil.

The version of the Karta <-> Kantoor contract this Karta implements.

The scopes a new Kantoor key gets when none are given.

True when the Kantoor interface is switched on (the flag, read at run time).

Marks an HTTP endpoint as a Kantoor endpoint (true) or not (false). Only on a Kantoor endpoint does the answer to a push carry a retention (Karta.Kantoor.Response). With notify_only: true (only in the :karta format) the push carries the metadata without the message, so that messages of any size can be announced and Kantoor fetches the body (GET /kantoor/v1/messages/:id/raw). A mailbox sets both when it registers its endpoint (POST /kantoor/v1/endpoints, Karta.Kantoor.Attach); an operator may still set them by hand (IEx, bin/karta eval).

Gives the rows of new deliveries (Karta.Inbound) the retention policy of their route, when the flag is on and the route has one. Without the flag the rows are returned as they are, with no query.

The scopes the Kantoor interface added.

Functions

commit()

@spec commit() :: String.t() | nil

Karta's commit: KARTA_COMMIT from the environment, else the commit the code was compiled from, else nil.

contract_version()

@spec contract_version() :: String.t()

The version of the Karta <-> Kantoor contract this Karta implements.

default_scopes()

@spec default_scopes() :: [String.t()]

The scopes a new Kantoor key gets when none are given.

enabled?()

@spec enabled?() :: boolean()

True when the Kantoor interface is switched on (the flag, read at run time).

mark_endpoint(endpoint, kantoor?, opts \\ [])

@spec mark_endpoint(Karta.Inbound.Endpoint.t(), boolean(), keyword()) ::
  {:ok, Karta.Inbound.Endpoint.t()} | {:error, :not_http | :format}

Marks an HTTP endpoint as a Kantoor endpoint (true) or not (false). Only on a Kantoor endpoint does the answer to a push carry a retention (Karta.Kantoor.Response). With notify_only: true (only in the :karta format) the push carries the metadata without the message, so that messages of any size can be announced and Kantoor fetches the body (GET /kantoor/v1/messages/:id/raw). A mailbox sets both when it registers its endpoint (POST /kantoor/v1/endpoints, Karta.Kantoor.Attach); an operator may still set them by hand (IEx, bin/karta eval).

route_retention(rows)

@spec route_retention([map()]) :: [map()]

Gives the rows of new deliveries (Karta.Inbound) the retention policy of their route, when the flag is on and the route has one. Without the flag the rows are returned as they are, with no query.

scopes()

@spec scopes() :: [String.t()]

The scopes the Kantoor interface added.