BaileysEx.MessageRetryManager (baileys_ex v0.1.0-alpha.12)

Copy Markdown View Source

Opaque, connection-scoped facade for Baileys RC14 message retry state.

Obtain a value with BaileysEx.message_retry_manager/1. State-bearing operations are serialized by the owning connection and return {:ok, value} or {:error, reason}.

Summary

Functions

Cache a recent protocol message for retry handling.

Cancel a pending phone fallback callback.

Clear all message retry-manager state for the connection.

Delete a cached Signal base key.

Return a cached recent message and its insertion timestamp.

Return a message's current retry count.

Return whether a message has reached the connection's retry limit.

Return whether the cached and supplied Signal base keys match exactly.

Increment and return a message's retry count.

Return whether a retry reason represents a MAC failure.

Mark a retry failed and release its cached state.

Mark a retry successful and release its cached state.

Parse a retry error attribute into its idiomatic Elixir reason atom.

Cache a Signal base key for retry-collision detection.

Schedule a connection-owned phone fallback callback.

Determine whether retry handling should recreate a Signal session.

Types

t()

@opaque t()

Functions

add_recent_message(manager, to, id, message, opts \\ [])

@spec add_recent_message(t(), String.t(), String.t(), struct(), keyword()) ::
  :ok | {:error, term()}

Cache a recent protocol message for retry handling.

cancel_pending_phone_request(manager, message_id)

@spec cancel_pending_phone_request(t(), String.t()) :: :ok | {:error, term()}

Cancel a pending phone fallback callback.

clear(manager)

@spec clear(t()) :: :ok | {:error, term()}

Clear all message retry-manager state for the connection.

delete_base_key(manager, address, message_id)

@spec delete_base_key(t(), String.t(), String.t()) :: :ok | {:error, term()}

Delete a cached Signal base key.

get_recent_message(manager, to, id, opts \\ [])

@spec get_recent_message(t(), String.t(), String.t(), keyword()) ::
  {:ok, map() | nil} | {:error, term()}

Return a cached recent message and its insertion timestamp.

get_retry_count(manager, message_id)

@spec get_retry_count(t(), String.t()) :: {:ok, non_neg_integer()} | {:error, term()}

Return a message's current retry count.

has_exceeded_max_retries?(manager, message_id)

@spec has_exceeded_max_retries?(t(), String.t()) ::
  {:ok, boolean()} | {:error, term()}

Return whether a message has reached the connection's retry limit.

has_same_base_key?(manager, address, message_id, base_key, opts \\ [])

@spec has_same_base_key?(t(), String.t(), String.t(), binary(), keyword()) ::
  {:ok, boolean()} | {:error, term()}

Return whether the cached and supplied Signal base keys match exactly.

increment_retry_count(manager, message_id)

@spec increment_retry_count(t(), String.t()) ::
  {:ok, pos_integer()} | {:error, term()}

Increment and return a message's retry count.

mac_error?(message_retry_manager, error_code)

@spec mac_error?(t(), atom() | integer() | nil) :: boolean()

Return whether a retry reason represents a MAC failure.

mark_retry_failed(manager, message_id)

@spec mark_retry_failed(t(), String.t()) :: :ok | {:error, term()}

Mark a retry failed and release its cached state.

mark_retry_success(manager, message_id)

@spec mark_retry_success(t(), String.t()) :: :ok | {:error, term()}

Mark a retry successful and release its cached state.

parse_retry_error_code(message_retry_manager, error_attr)

@spec parse_retry_error_code(t(), String.t() | nil) :: atom() | nil

Parse a retry error attribute into its idiomatic Elixir reason atom.

save_base_key(manager, address, message_id, base_key, opts \\ [])

@spec save_base_key(t(), String.t(), String.t(), binary(), keyword()) ::
  :ok | {:error, term()}

Cache a Signal base key for retry-collision detection.

schedule_phone_request(manager, message_id, callback, opts \\ [])

@spec schedule_phone_request(t(), String.t(), (-> term()), keyword()) ::
  :ok | {:error, term()}

Schedule a connection-owned phone fallback callback.

should_recreate_session(manager, jid, has_session?, error_code \\ nil, opts \\ [])

@spec should_recreate_session(
  t(),
  String.t(),
  boolean(),
  atom() | integer() | nil,
  keyword()
) ::
  {:ok, %{reason: String.t(), recreate: boolean()}} | {:error, term()}

Determine whether retry handling should recreate a Signal session.