Amarula.Protocol.Groups.Metadata (amarula v0.1.0)
View SourceGroup metadata: build the w:g2 query IQ and parse its result into the bits a
group send needs. Port of Baileys groupQuery/extractGroupMetadata
(src/Socket/groups.ts), trimmed to the send-relevant fields (participants +
addressing mode); description/community/etc. are skipped until a consumer needs
them.
Usage (the IQ goes through Connection.query_iq/2):
iq = Metadata.query_iq(group_jid)
{:ok, reply} = Connection.query_iq(conn, iq)
{:ok, meta} = Metadata.parse(reply)
Summary
Functions
Parse a group-metadata IQ result. Returns {:ok, metadata} or
{:error, reason} (missing <group>, surfaced <error>, or missing id).
Parse an "all participating" IQ result (<groups><group>…</groups>) into a
list of metadata maps. Unparseable group nodes are skipped.
Build the "all participating groups" query IQ (Baileys
groupFetchAllParticipating)
Build the interactive group-metadata query IQ
Types
@type t() :: %{ id: String.t(), subject: String.t() | nil, owner: String.t() | nil, addressing_mode: :pn | :lid, size: non_neg_integer(), participants: [participant()] }
Functions
@spec parse(Amarula.Protocol.Binary.Node.t()) :: {:ok, t()} | {:error, term()}
Parse a group-metadata IQ result. Returns {:ok, metadata} or
{:error, reason} (missing <group>, surfaced <error>, or missing id).
@spec parse_all(Amarula.Protocol.Binary.Node.t()) :: {:ok, [t()]}
Parse an "all participating" IQ result (<groups><group>…</groups>) into a
list of metadata maps. Unparseable group nodes are skipped.
@spec query_all_iq() :: Amarula.Protocol.Binary.Node.t()
Build the "all participating groups" query IQ (Baileys
groupFetchAllParticipating):
<iq to="@g.us" xmlns="w:g2" type="get">
<participating><participants/><description/></participating></iq>
@spec query_iq(String.t()) :: Amarula.Protocol.Binary.Node.t()
Build the interactive group-metadata query IQ:
<iq type=get xmlns=w:g2 to=<group>><query request=interactive/></iq>