Amarula.Protocol.Groups.Notification (amarula v0.1.0)

View Source

Parse a w:gp2 group notification into a structured update, ported from the group branch of Baileys handleGroupNotification (Socket/messages-recv.ts).

A w:gp2 notification's first child names the change; we turn it into a {action, payload} the connection emits as a :group_update event. Only the common, high-value changes are decoded; unrecognised children yield {:other, tag} so nothing is silently lost.

Summary

Functions

Parse a w:gp2 notification node. Returns {:ok, %{group, author, action}} or {:error, reason} when there's no change child to interpret.

Types

action()

@type action() ::
  {:participants, :add | :remove | :promote | :demote | :leave, [participant()]}
  | {:subject, String.t()}
  | {:description, String.t() | nil}
  | {:announce, boolean()}
  | {:restrict, boolean()}
  | {:invite_code, String.t()}
  | {:other, String.t()}

participant()

@type participant() :: %{address: Amarula.Address.t(), admin: String.t() | nil}

t()

@type t() :: %{
  group: Amarula.Address.t(),
  author: Amarula.Address.t() | nil,
  action: action()
}

Functions

parse(node)

@spec parse(Amarula.Protocol.Binary.Node.t()) :: {:ok, t()} | {:error, term()}

Parse a w:gp2 notification node. Returns {:ok, %{group, author, action}} or {:error, reason} when there's no change child to interpret.