Keeps the session's Signal sessions loaded, pruned and persisted.
The worker holds Signal sessions in memory and mirrors them to the store; this module owns that mirroring, plus the two moments the set is pruned: dropping stale one-way sessions when a connection comes up, and clearing a peer's sessions when its identity changes.
Every function returns usable state even when the store misbehaves: losing a Signal session costs one renegotiation, whereas crashing the session process costs the connection.
Summary
Functions
Forgets every session recorded for one peer, across its JID aliases.
Replaces a peer's session from a freshly fetched prekey bundle.
Loads the persisted sessions, falling back to an empty set.
Coerces a persisted or in-memory session set into the ETS-backed form.
Mirrors the in-memory sessions to the store, flushing them to disk.
Prunes sessions a new connection should not reuse.
Functions
@spec clear_for_jid(ExWapp.Session.Worker.t(), String.t()) :: ExWapp.Session.Worker.t()
Forgets every session recorded for one peer, across its JID aliases.
@spec install_refreshed_identity(ExWapp.Session.Worker.t(), String.t(), map()) :: ExWapp.Session.Worker.t()
Replaces a peer's session from a freshly fetched prekey bundle.
Used after an identity change: the old session can no longer decrypt, so it is
rebuilt with force: true. An unusable bundle is logged and the state is left
alone rather than raising inside the session process.
@spec load(ExWapp.Store.t() | nil) :: ExWapp.Signal.SessionStore.t() | nil
Loads the persisted sessions, falling back to an empty set.
@spec normalize(term()) :: ExWapp.Signal.SessionStore.t()
Coerces a persisted or in-memory session set into the ETS-backed form.
@spec persist(ExWapp.Store.t() | nil, ExWapp.Signal.SessionStore.t()) :: :ok
Mirrors the in-memory sessions to the store, flushing them to disk.
@spec refresh_on_connect(ExWapp.Session.Worker.t()) :: ExWapp.Session.Worker.t()
Prunes sessions a new connection should not reuse.
With signal.reset_sessions_on_connect every session goes; otherwise only the
one-way ones, which are the sessions a peer never answered on and which would
otherwise make the next send undecryptable.