Raxol.Gateway.Delivery (RaxolGateway v0.2.0)

Copy Markdown View Source

Sends a rendered outbound message to one of four destinations.

adapters is a map of platform => {adapter_module, conn}, so a single gateway delivers across every connected platform. A destination is one of:

  • {:direct, route} -- reply to the originating chat.
  • {:home, route} -- a configured home channel (cron and background results).
  • {:cross_platform, route} -- a different platform's chat.
  • {:target, "platform:chat_id"} -- an explicit target string, e.g. "telegram:-1001234567890".

All four resolve to a Raxol.Gateway.Route; delivery then sends through that route's platform adapter. A target string's platform must match a connected adapter (no String.to_atom/1 on the string).

Summary

Functions

Resolve a destination to a route and send rendered through its adapter.

Resolve a destination to the Route it delivers to.

Types

adapters()

@type adapters() :: %{required(atom()) => {module(), term()}}

destination()

@type destination() ::
  {:direct, Raxol.Gateway.Route.t()}
  | {:home, Raxol.Gateway.Route.t()}
  | {:cross_platform, Raxol.Gateway.Route.t()}
  | {:target, String.t()}

Functions

deliver(adapters, destination, rendered)

@spec deliver(adapters(), destination(), term()) :: :ok | {:error, term()}

Resolve a destination to a route and send rendered through its adapter.

resolve(arg1, adapters)

@spec resolve(destination(), adapters()) ::
  {:ok, Raxol.Gateway.Route.t()} | {:error, term()}

Resolve a destination to the Route it delivers to.