In-memory store of Slack messages for the fake-Slack dev UI.
A GenServer that keeps an ordered list of entries (insertion order). Each
entry is a map: %{ts:, channel:, message:, raw:, at:}. On every put/1 and
clear/0 it broadcasts {:slackbox_store, op, entry_or_nil} on the
"slackbox" topic of the Slackbox.PubSub server — but only when that
PubSub server is actually running, so the store stays usable in plain tests.
Summary
Functions
Apply a Slack response payload to the message a token points at.
Returns a specification to start this module under a supervisor.
Drop every stored message.
Close the modal identified by view_id, broadcasting
{:slackbox_store, :view_close, view_id}.
List every channel that has at least one message, in insertion order.
List the entries for a channel, in insertion order.
List the currently open modal views, in insertion order (newest last).
Open a modal view for trigger_id. Generates a view_id, appends a view
entry, broadcasts {:slackbox_store, :view_open, entry}, and returns
%{view_id: view_id} — mirroring Slack's views.open response.
Store a message. Assigns a ts if the message has none, computes the raw
Slack payload, appends an entry, and returns %{ts:, channel:}.
Register a response_url callback token for the entry identified by
{channel, ts}. Returns an opaque random token; a later apply_response/2
with that token updates the corresponding message. Mirrors Slack's
response_url mechanism for the inbound simulation loop.
Start the store (registered under its module name by default).
Types
Functions
Apply a Slack response payload to the message a token points at.
response_map["text"] overrides the message text when present and
response_map["blocks"] overrides the blocks when present; the raw payload is
recomputed and a {:slackbox_store, :update, entry} broadcast is emitted.
Returns {:error, :not_found} for an unknown token.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec clear() :: :ok
Drop every stored message.
@spec close_view(String.t()) :: :ok
Close the modal identified by view_id, broadcasting
{:slackbox_store, :view_close, view_id}.
@spec list_channels() :: [String.t()]
List every channel that has at least one message, in insertion order.
List the entries for a channel, in insertion order.
@spec list_views() :: [view()]
List the currently open modal views, in insertion order (newest last).
Open a modal view for trigger_id. Generates a view_id, appends a view
entry, broadcasts {:slackbox_store, :view_open, entry}, and returns
%{view_id: view_id} — mirroring Slack's views.open response.
@spec put(Slackbox.Message.t()) :: %{ts: String.t(), channel: String.t() | nil}
Store a message. Assigns a ts if the message has none, computes the raw
Slack payload, appends an entry, and returns %{ts:, channel:}.
Register a response_url callback token for the entry identified by
{channel, ts}. Returns an opaque random token; a later apply_response/2
with that token updates the corresponding message. Mirrors Slack's
response_url mechanism for the inbound simulation loop.
@spec start_link(keyword()) :: GenServer.on_start()
Start the store (registered under its module name by default).