Amarula.Protocol.USync.Devices (amarula v0.1.0)

View Source

Turn a parsed USync result into the concrete list of device JIDs to encrypt for. Port of Baileys extractDeviceJids (src/Utils/signal.ts).

Each USync result entry carries the user's id (jid) and a "devices" map with a :device_list. We expand that into one JID per device, applying the same three filters Baileys uses:

  1. drop device 0 when exclude_zero_devices? is set
  2. drop our own sending device (same user and same device)
  3. drop non-zero devices that lack a key_index (server rejects them)

Summary

Functions

Expand result_list (the :list from USync.parse_result/2) into device JIDs.

Types

device_jid()

@type device_jid() :: %{
  user: String.t(),
  device: non_neg_integer(),
  server: String.t(),
  jid: String.t()
}

Functions

extract(result_list, my_jid, my_lid, exclude_zero_devices?)

@spec extract([map()], String.t(), String.t() | nil, boolean()) :: [device_jid()]

Expand result_list (the :list from USync.parse_result/2) into device JIDs.

my_jid / my_lid identify our own account so we can skip our sending device. exclude_zero_devices? mirrors Baileys' excludeZeroDevices flag.