Karta. Messaging
(Karta v1.0.0)
The optional messaging module (/messaging/v1, see
guides/operations/messaging.md): conversations with people over
channels such as WhatsApp and SMS, kept in Karta, sent and received
through plugs.
Everything here is off unless KARTA_MESSAGING is 1 or true
(config :karta, :messaging, enabled: true, read in
config/runtime.exs). The routes and pages are always compiled, but
while the switch is off KartaWeb.Messaging.Gate and the pages' mount
answer every one of them as an unknown route does, no job is scheduled
(see Karta.Application), no process is started, the navigation shows
nothing, no webhook is sent and no metric is emitted. Mail does not
change when it is on.
The words: a channel is a medium (whatsapp, sms); a plug
(Karta.Messaging.Plug) is the code of a kind of connector; a
connector (Karta.Messaging.Connector) is one configured instance
of a plug on a server; an address is where a person is reached on a
channel; a conversation is one thread between a connector and one
address; a message is one item in it, one attempt on one connector;
a send request is what an application asked for.
Row locks are taken in one order everywhere, Karta.Messaging.Locks
(connector, command, request, message).
Tenancy is Karta's own: a connector, conversation and message belong to a server (and so to its organisation), and every lookup goes through the server.
Retention, encryption and who can read the messages are in the
Messaging guide: the text of a message is encrypted in the database
column, media are encrypted blobs; both are removed after the
organisation's retention (default KARTA_MESSAGING_RETENTION_DAYS, 730
days; a sign-in code, category: "authentication", after 7 days at
most) by Karta.Messaging.Retention.
Summary
Functions
Days an authentication message (a sign-in code) is kept at most.
The module's configuration (config :karta, :messaging).
The instance's default retention in days.
True when the messaging module is switched on (the flag, read at run time).
The organisation's retention in days, or :keep when it keeps messages
forever.
The API key scopes the module adds.
The server's settings (defaults when none are stored yet).
The organisation's settings (defaults when none are stored yet).
Changes (or first stores) the server's settings.
Changes (or first stores) the organisation's settings.
Functions
@spec authentication_retention_days() :: pos_integer()
Days an authentication message (a sign-in code) is kept at most.
@spec config() :: keyword()
The module's configuration (config :karta, :messaging).
@spec default_retention_days() :: pos_integer()
The instance's default retention in days.
@spec enabled?() :: boolean()
True when the messaging module is switched on (the flag, read at run time).
@spec retention(Karta.Accounts.Organisation.t() | Ecto.UUID.t()) :: pos_integer() | :keep
The organisation's retention in days, or :keep when it keeps messages
forever.
@spec scopes() :: [String.t()]
The API key scopes the module adds.
@spec server_settings(Karta.Servers.Server.t() | Ecto.UUID.t()) :: Karta.Messaging.ServerSettings.t()
The server's settings (defaults when none are stored yet).
@spec settings(Karta.Accounts.Organisation.t() | Ecto.UUID.t()) :: Karta.Messaging.Settings.t()
The organisation's settings (defaults when none are stored yet).
@spec update_server_settings(Karta.Servers.Server.t(), map()) :: {:ok, Karta.Messaging.ServerSettings.t()} | {:error, Ecto.Changeset.t()}
Changes (or first stores) the server's settings.
@spec update_settings(Karta.Accounts.Organisation.t(), map()) :: {:ok, Karta.Messaging.Settings.t()} | {:error, Ecto.Changeset.t()}
Changes (or first stores) the organisation's settings.