Synchronization and transport helpers for app-state collections.
This module owns the IQ request/response flow with WhatsApp, including collection fetches, mutation sends, external blob downloads, and the sequencing required to apply snapshots and patch chains into the local store.
Summary
Functions
Applies a collection response payload to the local store.
Applies a collection response payload and optionally uses a live session when external blobs must be fetched while decoding snapshots or patch chains.
Applies a collection response using feature-specific persistence options.
Fetches a single app-state collection and applies its snapshot and patches.
Synchronizes the affected collection, encodes and sends a mutation patch, then applies the acknowledged change locally and schedules a background refresh. Operations for the same store collection are serialized.
Types
@type hash_state() :: %{version: non_neg_integer(), hash: binary()}
@type patch_info() :: ExWapp.AppState.Engine.Codec.patch_info()
Functions
@spec apply_collection_response(struct(), String.t(), ExWapp.Binary.Node.t()) :: {:ok, non_neg_integer()} | {:error, term()}
Applies a collection response payload to the local store.
@spec apply_collection_response( struct(), String.t(), ExWapp.Binary.Node.t(), pid() | nil ) :: {:ok, non_neg_integer()} | {:error, term()}
Applies a collection response payload and optionally uses a live session when external blobs must be fetched while decoding snapshots or patch chains.
@spec apply_collection_response( struct(), String.t(), ExWapp.Binary.Node.t(), pid() | nil, keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Applies a collection response using feature-specific persistence options.
The :max_records option is forwarded to call-log mutations.
@spec fetch_collection(GenServer.server(), struct(), String.t()) :: :ok | {:error, term()}
Fetches a single app-state collection and applies its snapshot and patches.
@spec fetch_collection(GenServer.server(), struct(), String.t(), keyword()) :: :ok | {:error, term()}
@spec send_mutation(GenServer.server(), patch_info(), struct()) :: {:ok, hash_state(), map()} | {:error, term()}
Synchronizes the affected collection, encodes and sends a mutation patch, then applies the acknowledged change locally and schedules a background refresh. Operations for the same store collection are serialized.
@spec send_mutation(GenServer.server(), patch_info(), struct(), keyword()) :: {:ok, hash_state(), map()} | {:error, term()}