Prekey target decisions and Signal-session bootstrap for outbound messages.
Raw network requests, response receives, and persistence remain in the outbound worker. This module owns deterministic target selection, batch and individual fallback decisions, missing-bundle retries, and the transformation of parsed prekey bundles into Signal sessions.
Summary
Functions
Creates Signal sessions and bundle aliases from parsed prekey bundles.
Returns outbound devices that require a prekey bootstrap.
Expands a partial recipient prekey selection to all known recipient devices.
Fetches direct-message prekeys with batch fallback and missing-bundle retry.
Fetches group distribution prekeys with batch and individual fallback.
Returns requested device JIDs for which no prekey bundle was returned.
Selects targets requiring prekeys with an explicit forced identity set.
Types
@type fetch_many_fun() :: ([String.t()], ExWapp.Signal.SessionStore.t() -> fetch_result())
@type fetch_one_fun() :: (String.t(), ExWapp.Signal.SessionStore.t() -> fetch_result())
@type fetch_result() :: {:ok, ExWapp.Signal.SessionStore.t(), map()} | {:error, term()}
@type fetch_state() :: ExWapp.Signal.SessionStore.t() | {:error, term()}
Functions
@spec create_sessions_for_bundles( ExWapp.Signal.SessionStore.t(), term(), [map()], term(), non_neg_integer(), map() ) :: {:ok, ExWapp.Signal.SessionStore.t(), map()} | {:error, term()}
Creates Signal sessions and bundle aliases from parsed prekey bundles.
@spec devices_needing_prekeys( ExWapp.Signal.SessionStore.t(), [term()], [term()], map(), pos_integer(), integer() ) :: [String.t()]
Returns outbound devices that require a prekey bootstrap.
Local-account identities are always refreshed. Other targets are selected when their PN/LID session is missing or older than the configured maximum.
Expands a partial recipient prekey selection to all known recipient devices.
@spec fetch_direct( [String.t()], ExWapp.Signal.SessionStore.t(), String.t(), fetch_many_fun(), fetch_one_fun() ) :: {fetch_state(), map()}
Fetches direct-message prekeys with batch fallback and missing-bundle retry.
@spec fetch_group( [String.t()], ExWapp.Signal.SessionStore.t(), term(), fetch_many_fun(), fetch_one_fun() ) :: {fetch_state(), map()}
Fetches group distribution prekeys with batch and individual fallback.
Missing bundles are retried individually after the initial result.
Returns requested device JIDs for which no prekey bundle was returned.
@spec targets_needing_prekeys( ExWapp.Signal.SessionStore.t(), [term()], MapSet.t({String.t(), String.t()}), map(), pos_integer(), integer() ) :: [String.t()]
Selects targets requiring prekeys with an explicit forced identity set.
This form is shared by group sender-key distribution.