WardrikChannel.Channel (wardrik_channel v0.1.0-rc.1)

Copy Markdown

One chat app Wardrik runs, under the name it's given.

Holds the adapter, the adapter's own options, and the installations that say where it's added. Wardrik passes it the rest:

  • :server - the Wardrik.Server that runs operations.
  • :wardrik - the instance.
  • :events - where events are followed and recorded.
  • :store - Wardrik's store.
  • :vault - where tokens are sealed. nil without Wardrik's :keys.

Summary

Functions

Saves installation, replacing any for the same workspace.

Returns the channel's installation in workspace, as the chat app names it.

Returns the installation nearest the owner of agent id.

Builds adapter's channel from the options Wardrik passes it. See WardrikChannel for the options.

Forgets the channel's installation in workspace.

Types

t()

@type t() :: %WardrikChannel.Channel{
  adapter: module(),
  approvers: [String.t()] | :anyone,
  deciding: String.t(),
  events: atom(),
  installations: {module(), term()},
  name: String.t(),
  offering: String.t(),
  options: keyword(),
  server: module(),
  store: WardrikStore.t(),
  vault: atom() | nil,
  wardrik: atom()
}

Functions

install(channel, installation)

@spec install(t(), Wardrik.Channel.Installation.t()) :: :ok | {:error, String.t()}

Saves installation, replacing any for the same workspace.

installation(channel, workspace)

@spec installation(t(), String.t()) ::
  {:ok, Wardrik.Channel.Installation.t()} | :error

Returns the channel's installation in workspace, as the chat app names it.

nearest(channel, id)

@spec nearest(t(), String.t()) :: {:ok, Wardrik.Channel.Installation.t()} | :error

Returns the installation nearest the owner of agent id.

Looks first for one owned by the user, as acme/@jon, then by the org, as acme. Returns :error if there's neither.

new(adapter, opts)

@spec new(module(), keyword()) :: t()

Builds adapter's channel from the options Wardrik passes it. See WardrikChannel for the options.

Raises ArgumentError if the name isn't lower-case letters, digits and -, starting with a letter, or if the options give neither or both of :token and :installations.

uninstall(channel, workspace)

@spec uninstall(t(), String.t()) :: :ok

Forgets the channel's installation in workspace.