BaileysEx.Protocol.USync (baileys_ex v0.1.0-alpha.8)

Copy Markdown View Source

Baileys-aligned USync query builder and result parser.

Reference:

  • dev/reference/Baileys-master/src/WAUSync/USyncQuery.ts
  • dev/reference/Baileys-master/src/WAUSync/USyncUser.ts
  • dev/reference/Baileys-master/src/WAUSync/Protocols/*.ts

Summary

Functions

A fast-path method for generating a complete USync query node from raw details.

Creates a new empty USync query configuration struct.

Deserializes the query IQ response into structural data maps.

Marshals the USync struct builder mapping to a final send-able WABinary.

Modifies the invocation context context tag.

Modifies the USync node query mapping string mode value.

Appends an explicit feature protocol string to the USync query.

Appends a user resolution request payload to the USync query.

Types

context()

@type context() :: :interactive | :background | :message | :notification

mode()

@type mode() :: :query | :delta

protocol()

@type protocol() :: :devices | :contact | :status | :disappearing_mode | :lid | :bot

result()

@type result() :: %{list: [user_result()], side_list: [user_result()]}

t()

@type t() :: %BaileysEx.Protocol.USync{
  context: context(),
  mode: mode(),
  protocols: [protocol()],
  users: [BaileysEx.Protocol.USync.User.t()]
}

user_result()

@type user_result() :: %{:id => String.t(), optional(atom()) => term()}

Functions

build_query(protocols, users, opts \\ [])

@spec build_query(
  [protocol() | :device],
  [BaileysEx.Protocol.USync.User.t() | map()],
  keyword()
) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}

A fast-path method for generating a complete USync query node from raw details.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new empty USync query configuration struct.

parse_result(query, response)

@spec parse_result(t(), BaileysEx.BinaryNode.t()) ::
  {:ok, result()} | {:error, term()}

Deserializes the query IQ response into structural data maps.

to_node(query, sid)

@spec to_node(t(), String.t()) :: {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}

Marshals the USync struct builder mapping to a final send-able WABinary.

with_context(query, context)

@spec with_context(t(), context() | String.t()) :: t()

Modifies the invocation context context tag.

with_mode(query, mode)

@spec with_mode(t(), mode() | String.t()) :: t()

Modifies the USync node query mapping string mode value.

with_protocol(query, protocol)

@spec with_protocol(t(), protocol() | :device) :: t()

Appends an explicit feature protocol string to the USync query.

with_user(query, user)

@spec with_user(t(), BaileysEx.Protocol.USync.User.t() | map()) :: t()

Appends a user resolution request payload to the USync query.