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

authentication_retention_days()

@spec authentication_retention_days() :: pos_integer()

Days an authentication message (a sign-in code) is kept at most.

config()

@spec config() :: keyword()

The module's configuration (config :karta, :messaging).

default_retention_days()

@spec default_retention_days() :: pos_integer()

The instance's default retention in days.

enabled?()

@spec enabled?() :: boolean()

True when the messaging module is switched on (the flag, read at run time).

retention(organisation_id)

@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.

scopes()

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

The API key scopes the module adds.

server_settings(server_id)

The server's settings (defaults when none are stored yet).

settings(organisation_id)

The organisation's settings (defaults when none are stored yet).

update_server_settings(server, attrs)

@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.

update_settings(organisation, attrs)

@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.