ExWapp.Session.Worker.OutboundConfirmation (ExWapp v0.1.2)

Copy Markdown View Source

Tracks outbound message delivery confirmation and handles the silent-drop fallback strategy for self-chat messages.

Summary

Functions

Handles the confirmation timeout: checks message status and optionally retries via fallback.

Schedules a confirmation timer for an outbound message when the destination is the user's own JID.

Functions

handle_timeout(state, message_id, confirmation, start_worker_fn, send_fn, register_fn)

Handles the confirmation timeout: checks message status and optionally retries via fallback.

start_worker_fn receives (state, jid, fun) and must return {:ok, worker, mon} | {:error, reason}.

send_fn receives (session_pid, state, jid, text, opts) and performs the actual send.

Returns the updated state.

handle_timeout(state, message_id, confirmation, start_worker_fn, send_fn, register_fn, opts)

@spec handle_timeout(
  map(),
  String.t(),
  map(),
  (map(), String.t(), (-> term()) ->
     {:ok, pid(), reference()} | {:error, term()}),
  (pid(), map(), String.t(), String.t(), keyword() -> term()),
  (map(), pid(), reference(), String.t() -> map()),
  keyword()
) :: map()

schedule(state, jid, text, message_id, strategy, attempt, opts \\ [])

@spec schedule(map(), String.t(), String.t(), String.t(), term(), non_neg_integer(), [
  {:timeout_ms, pos_integer()}
]) :: map()

Schedules a confirmation timer for an outbound message when the destination is the user's own JID.

Returns the updated state.