ExWapp.Session.Outbound.Fanout (ExWapp v0.1.2)

Copy Markdown View Source

Resolves direct-message fanout targets.

This module owns the pure decision layer for recipient devices, linked devices, self-chat payload selection, and soft cached targets. Store reads, cache eviction, logging, encryption, and transport remain at the worker boundary.

Summary

Functions

Resolves all encrypted target specifications from a prepared session context.

Resolves live and cached target candidates without applying cache effects.

Returns whether the destination belongs to the local account identity.

Types

context()

@type context() :: %{
  signal_sessions: ExWapp.Signal.SessionStore.t() | nil,
  jid: String.t(),
  prekey_bundles: term(),
  target_hints: map(),
  own_base_jid: String.t(),
  own_lid_jid: String.t(),
  own_device_id: integer(),
  lid_mapping: map(),
  self_chat_mode: term()
}

payload_kind()

@type payload_kind() :: :recipient | :own

resolution()

@type resolution() :: %{
  target_specs: [target_spec()],
  recipient_targets: [String.t()],
  own_targets: [String.t()],
  all_usync_devices: term(),
  cached_eviction_batches: [[String.t()]],
  family_rejections: [String.t()],
  self_chat?: boolean()
}

target_spec()

@type target_spec() :: %{jid: String.t(), payload_kind: payload_kind()}

Functions

resolve(map)

@spec resolve(context()) :: resolution()

Resolves all encrypted target specifications from a prepared session context.

Cached-only targets are included only when a prekey bundle proves them reachable. Unreachable cached targets are returned as eviction batches so the worker can apply the storage effect after this pure decision.

resolve_soft_targets(signal_sessions, prekey_bundles, live_targets, cached_targets, lid_mapping)

@spec resolve_soft_targets(
  ExWapp.Signal.SessionStore.t() | nil,
  term(),
  term(),
  term(),
  term()
) :: {[String.t()], [String.t()]}

Resolves live and cached target candidates without applying cache effects.

The second tuple element contains cached targets that the caller should evict. Returning that decision keeps persistence outside this module.

self_chat_destination?(jid, own_sender_jid, own_base_jid, own_lid_jid)

@spec self_chat_destination?(term(), term(), term(), term()) :: boolean()

Returns whether the destination belongs to the local account identity.

Both phone-number and LID identities are considered.