BaileysEx.Feature.TcToken (baileys_ex v0.1.0-alpha.8)

Copy Markdown View Source

Trusted-contact token helpers aligned with Baileys' privacy-token flow.

Summary

Functions

Append a stored TC token node to the provided content list.

Build a tctoken child node for a JID when a stored token exists.

Fetch trusted-contact privacy tokens for the given JIDs.

Handle a privacy_token notification by persisting trusted-contact tokens.

Functions

build_content(store, jid, base_content \\ [])

@spec build_content(BaileysEx.Signal.Store.t() | nil, String.t(), [
  BaileysEx.BinaryNode.t()
]) ::
  [BaileysEx.BinaryNode.t()] | nil

Append a stored TC token node to the provided content list.

Mirrors Baileys buildTcTokenFromJid: if no token exists, returns the existing content when present or nil when it is empty.

build_node(store, jid)

@spec build_node(BaileysEx.Signal.Store.t() | nil, String.t()) ::
  BaileysEx.BinaryNode.t() | nil

Build a tctoken child node for a JID when a stored token exists.

get_privacy_tokens(queryable, jids, opts \\ [])

@spec get_privacy_tokens(term(), [String.t()], keyword()) ::
  {:ok, BaileysEx.BinaryNode.t()} | {:error, term()}

Fetch trusted-contact privacy tokens for the given JIDs.

handle_notification(node, opts \\ [])

@spec handle_notification(
  BaileysEx.BinaryNode.t(),
  keyword()
) :: :ok

Handle a privacy_token notification by persisting trusted-contact tokens.