Amarula.Protocol.Groups.Ops (amarula v0.1.0)
View SourceGroup management operations: build the w:g2 IQs that CHANGE a group, and parse
their replies. Port of the group op builders in Baileys groups.ts (the write
side; Groups.Metadata is the read side).
Every op is a <iq xmlns="w:g2" type=get|set to=<group>> with a single child
naming the action. Builders return a %Node{}; parsers turn the reply into the
affected participants / invite code / etc. The IQ round-trip lives in
Connection (via send_waiter_iq).
Summary
Functions
Accept an invite by code — joins the group.
Create a group with subject and initial participants (jids).
Fetch the group's invite code (get).
Look up a group's metadata from an invite code without joining (get).
Turn join-approval (admin must approve joiners) on/off.
Leave group id (a bare id or full jid).
Who may add members: :admin_add or :all_member_add.
Parse the joined group's jid from an accept-invite reply.
Parse the invite code from an invite/revoke reply.
Parse the affected-participants list from an add/remove/promote/demote reply.
Parse pending join requests into a list of attr maps.
Parse the affected participants from an approve/reject reply.
Add/remove/promote/demote participants (jids) in a group.
List pending join-approval requests (get).
Approve/reject pending join requests for participants (jids).
Revoke + regenerate the group's invite code (set).
Change a group setting: announcement (admins-only msgs) / locked (admins-only edit).
Toggle disappearing messages. 0 turns it off; else seconds of expiration.
Set or clear the group description. nil/"" clears it; prev is the previous
description id (from metadata) when editing.
Change the group subject (title).
Types
Functions
@spec accept_invite(String.t()) :: Amarula.Protocol.Binary.Node.t()
Accept an invite by code — joins the group.
@spec create(String.t(), [String.t()]) :: Amarula.Protocol.Binary.Node.t()
Create a group with subject and initial participants (jids).
@spec invite_code(String.t()) :: Amarula.Protocol.Binary.Node.t()
Fetch the group's invite code (get).
@spec invite_info(String.t()) :: Amarula.Protocol.Binary.Node.t()
Look up a group's metadata from an invite code without joining (get).
@spec join_approval_mode(String.t(), :on | :off) :: Amarula.Protocol.Binary.Node.t()
Turn join-approval (admin must approve joiners) on/off.
@spec leave(String.t()) :: Amarula.Protocol.Binary.Node.t()
Leave group id (a bare id or full jid).
@spec member_add_mode(String.t(), :admin_add | :all_member_add) :: Amarula.Protocol.Binary.Node.t()
Who may add members: :admin_add or :all_member_add.
@spec parse_accepted_jid(Amarula.Protocol.Binary.Node.t()) :: {:ok, String.t()} | {:error, term()}
Parse the joined group's jid from an accept-invite reply.
@spec parse_invite_code(Amarula.Protocol.Binary.Node.t()) :: {:ok, String.t()} | {:error, term()}
Parse the invite code from an invite/revoke reply.
@spec parse_participants(Amarula.Protocol.Binary.Node.t(), action()) :: {:ok, [affected()]} | {:error, term()}
Parse the affected-participants list from an add/remove/promote/demote reply.
@spec parse_request_list(Amarula.Protocol.Binary.Node.t()) :: {:ok, [map()]}
Parse pending join requests into a list of attr maps.
@spec parse_request_update(Amarula.Protocol.Binary.Node.t(), :approve | :reject) :: {:ok, [affected()]}
Parse the affected participants from an approve/reject reply.
@spec participants_update(String.t(), [String.t()], action()) :: Amarula.Protocol.Binary.Node.t()
Add/remove/promote/demote participants (jids) in a group.
@spec request_list(String.t()) :: Amarula.Protocol.Binary.Node.t()
List pending join-approval requests (get).
@spec request_update(String.t(), [String.t()], :approve | :reject) :: Amarula.Protocol.Binary.Node.t()
Approve/reject pending join requests for participants (jids).
@spec revoke_invite(String.t()) :: Amarula.Protocol.Binary.Node.t()
Revoke + regenerate the group's invite code (set).
@spec setting_update(String.t(), setting()) :: Amarula.Protocol.Binary.Node.t()
Change a group setting: announcement (admins-only msgs) / locked (admins-only edit).
@spec toggle_ephemeral(String.t(), non_neg_integer()) :: Amarula.Protocol.Binary.Node.t()
Toggle disappearing messages. 0 turns it off; else seconds of expiration.
@spec update_description(String.t(), String.t() | nil, String.t() | nil) :: Amarula.Protocol.Binary.Node.t()
Set or clear the group description. nil/"" clears it; prev is the previous
description id (from metadata) when editing.
@spec update_subject(String.t(), String.t()) :: Amarula.Protocol.Binary.Node.t()
Change the group subject (title).