BaileysEx.Message.Receipt (baileys_ex v0.1.0-alpha.9)

Copy Markdown View Source

Receipt node construction and receipt-event parsing.

Summary

Functions

Builds an ACK/NACK stanza for a received node.

Constructs a receipt node (delivery, read, played, etc.) for the given message IDs.

Parses incoming receipt nodes and generates runtime update events.

Aggregates message keys and sends read receipts according to privacy settings.

Builds and sends a receipt node using the provided sender function.

Types

receipt_type()

@type receipt_type() ::
  :delivered
  | :read
  | :read_self
  | :played
  | :sender
  | :retry
  | :hist_sync
  | :peer_msg

Functions

build_ack_stanza(binary_node, error_code \\ nil, me_id \\ nil)

@spec build_ack_stanza(
  BaileysEx.BinaryNode.t(),
  non_neg_integer() | nil,
  String.t() | nil
) ::
  BaileysEx.BinaryNode.t()

Builds an ACK/NACK stanza for a received node.

Mirrors Baileys rc10 buildAckStanza/3: copies the stanza id, source, class, participant, recipient, and type, and includes from for message ACKs when the local device JID is known.

build_receipt_node(jid, participant, list, type, opts \\ [])

@spec build_receipt_node(
  String.t(),
  String.t() | nil,
  [String.t()],
  receipt_type(),
  keyword()
) ::
  BaileysEx.BinaryNode.t()

Constructs a receipt node (delivery, read, played, etc.) for the given message IDs.

process_receipt(node, event_emitter)

@spec process_receipt(BaileysEx.BinaryNode.t(), GenServer.server()) :: :ok

Parses incoming receipt nodes and generates runtime update events.

read_messages(sender, keys, privacy_settings, opts \\ [])

@spec read_messages(
  (BaileysEx.BinaryNode.t() -> :ok | {:error, term()}),
  [map()],
  map(),
  keyword()
) ::
  :ok | {:error, term()}

Aggregates message keys and sends read receipts according to privacy settings.

send_receipt(sender, jid, participant, ids, type, opts \\ [])

@spec send_receipt(
  (BaileysEx.BinaryNode.t() -> :ok | {:error, term()}),
  String.t(),
  String.t() | nil,
  [String.t()],
  receipt_type(),
  keyword()
) :: :ok | {:error, term()}

Builds and sends a receipt node using the provided sender function.