Retry-state helpers modeled after Baileys' message retry manager.
Summary
Functions
Caches recently sent plaintext messages allowing retry requests to resend them.
Cancels a previously scheduled fallback request.
Deletes a cached retry base key once the collision check has completed.
Clears an expired placeholder timeout.
Looks up a placeholder that actively blocking resolution of a message.
Retrieves a cached sent message for a remote peer and message ID.
Yields the current retry iteration count.
Parses an incoming retry receipt and retrieves cached messages for re-encryption.
Checks if a message retry sequence has violated the configured limit loop.
Returns true when the cached base key exactly matches the current base key.
Bumps the volatile retry tally for a specific message tracking iteration count.
Indicates whether the parsed retry code suggests a fatal MAC/Signature error.
Parses stringified error codes from WhatsApp XML nodes.
Records an active placeholder awaiting server response.
Idempotently queues a placeholder resend command, stalling slightly to await in-flight messages.
Clears a resolved placeholder from state.
Executes a scheduled fallback phone request, immediately invoking the callback.
Saves the open Signal base key observed during the rc10 retry collision check.
Schedules an asynchronous fallback request for a retry sequence.
Constructs and formats a protocol retry receipt to request a sender re-encrypt a failed message.
Determines if a recipient's Signal session must be recreated based on an error code.
Types
@type proto_message() :: struct()
@type recent_message_entry() :: %{message: proto_message(), timestamp: integer()}
Functions
@spec add_recent_message( BaileysEx.Connection.Store.Ref.t(), String.t(), String.t(), proto_message(), keyword() ) :: :ok
Caches recently sent plaintext messages allowing retry requests to resend them.
@spec cancel_phone_request(BaileysEx.Connection.Store.Ref.t(), String.t()) :: :ok
Cancels a previously scheduled fallback request.
@spec delete_base_key(BaileysEx.Connection.Store.Ref.t(), String.t(), String.t()) :: :ok
Deletes a cached retry base key once the collision check has completed.
@spec expire_placeholder_resend(BaileysEx.Connection.Store.Ref.t(), String.t()) :: :ok
Clears an expired placeholder timeout.
@spec get_placeholder_resend(BaileysEx.Connection.Store.Ref.t(), String.t()) :: map() | boolean() | nil
Looks up a placeholder that actively blocking resolution of a message.
@spec get_recent_message( BaileysEx.Connection.Store.Ref.t(), String.t(), String.t(), keyword() ) :: recent_message_entry() | nil
Retrieves a cached sent message for a remote peer and message ID.
@spec get_retry_count(BaileysEx.Connection.Store.Ref.t(), String.t()) :: non_neg_integer()
Yields the current retry iteration count.
@spec handle_retry_receipt( BaileysEx.Connection.Store.Ref.t(), BaileysEx.BinaryNode.t(), keyword() ) :: {:ok, [map()]} | {:error, term()}
Parses an incoming retry receipt and retrieves cached messages for re-encryption.
@spec has_exceeded_max_retries?( BaileysEx.Connection.Store.Ref.t(), String.t(), pos_integer() ) :: boolean()
Checks if a message retry sequence has violated the configured limit loop.
@spec has_same_base_key?( BaileysEx.Connection.Store.Ref.t(), String.t(), String.t(), binary(), keyword() ) :: boolean()
Returns true when the cached base key exactly matches the current base key.
@spec increment_retry_count(BaileysEx.Connection.Store.Ref.t(), String.t()) :: pos_integer()
Bumps the volatile retry tally for a specific message tracking iteration count.
Indicates whether the parsed retry code suggests a fatal MAC/Signature error.
Parses stringified error codes from WhatsApp XML nodes.
@spec put_placeholder_resend( BaileysEx.Connection.Store.Ref.t(), String.t(), map() | boolean(), keyword() ) :: :ok
Records an active placeholder awaiting server response.
@spec request_placeholder_resend( BaileysEx.Connection.Store.Ref.t(), map(), map() | boolean() | nil, keyword() ) :: {:ok, String.t() | nil} | {:ok, String.t() | nil, term()} | {:error, term()}
Idempotently queues a placeholder resend command, stalling slightly to await in-flight messages.
@spec resolve_placeholder_resend(BaileysEx.Connection.Store.Ref.t(), String.t()) :: :ok
Clears a resolved placeholder from state.
@spec run_phone_request(BaileysEx.Connection.Store.Ref.t(), String.t(), (-> term())) :: :ok
Executes a scheduled fallback phone request, immediately invoking the callback.
@spec save_base_key( BaileysEx.Connection.Store.Ref.t(), String.t(), String.t(), binary(), keyword() ) :: :ok
Saves the open Signal base key observed during the rc10 retry collision check.
@spec schedule_phone_request( BaileysEx.Connection.Store.Ref.t(), String.t(), (-> term()), keyword() ) :: :ok
Schedules an asynchronous fallback request for a retry sequence.
@spec send_retry_request( BaileysEx.Connection.Store.Ref.t(), BaileysEx.BinaryNode.t(), keyword() ) :: {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}
Constructs and formats a protocol retry receipt to request a sender re-encrypt a failed message.
@spec should_recreate_session( BaileysEx.Connection.Store.Ref.t(), String.t(), boolean(), atom() | integer() | nil, keyword() ) :: %{reason: String.t(), recreate: boolean()}
Determines if a recipient's Signal session must be recreated based on an error code.