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

Copy Markdown View Source

Pure device-discovery decisions for outbound messages.

The worker remains responsible for USync I/O, cache reads, and logging. This module builds query identities and turns those inputs into normalized recipient and linked-device target sets.

Summary

Functions

Selects the preferred local identity for cache and fanout resolution.

Builds the USync query set for a recipient and all local identity families.

Resolves normalized recipient, linked-device, and aggregate device sets.

Resolves USync devices for one identity, preferring its current JID family.

Types

resolution()

@type resolution() :: %{
  recipient_devices: [String.t()],
  recipient_cached_devices: [String.t()],
  own_devices: [String.t()],
  own_cached_devices: [String.t()],
  all_usync_devices: [String.t()],
  all_device_jids: [String.t()]
}

resolution_context()

@type resolution_context() :: %{
  device_map: map(),
  recipient_base_jid: String.t(),
  recipient_cached_devices: [String.t()],
  own_sender_jid: String.t(),
  own_base_jid: String.t(),
  own_lid_jid: String.t(),
  own_cached_devices: [String.t()],
  own_device_id: integer(),
  lid_mapping: map()
}

Functions

own_preferred_jid(own_base_jid, own_sender_jid)

@spec own_preferred_jid(term(), term()) :: String.t()

Selects the preferred local identity for cache and fanout resolution.

query_jids(recipient_base_jid, own_sender_jid, own_base_jid, own_lid_jid, lid_mapping)

@spec query_jids(term(), term(), term(), term(), map()) :: [String.t()]

Builds the USync query set for a recipient and all local identity families.

resolve(map)

@spec resolve(resolution_context()) :: resolution()

Resolves normalized recipient, linked-device, and aggregate device sets.

resolve_identity_devices(device_map, base_jid, lid_mapping)

@spec resolve_identity_devices(map(), term(), map()) :: [String.t()]

Resolves USync devices for one identity, preferring its current JID family.