Amarula.Protocol.Profile.Ops (amarula v0.1.0)

View Source

Profile operations: build the IQs that read/change your (or a target's) profile picture and status, and parse their replies. Port of the profile-picture/status builders in Baileys chats.ts (profilePictureUrl, updateProfilePicture, removeProfilePicture, updateProfileStatus).

Pure: builders return a %Node{}, parsers turn the reply node into a value. The IQ round-trip lives in Amarula.Connection (via query_iq/3). target is the jid being acted on, or nil for your own profile — Baileys omits the target attr entirely for self (sending it for your own jid makes the server never reply).

Summary

Functions

Pull the URL from a w:profile:picture reply (<picture url="...">), or nil.

Fetch a profile picture URL. target is the jid to look up (a user or group jid); type is :preview (small) or :image (full). Reply parsed by parse_url/1.

Remove a profile picture. target is the jid, or nil for your own profile.

Set a profile picture from already-encoded JPEG bytes. target is the jid being updated, or nil for your own profile. WhatsApp expects a small square JPEG; the caller is responsible for sizing it (Baileys resizes to 640px q50 before upload — Amarula does not resize, to avoid a native image dependency).

Set your own profile status/bio text.

Types

pic_type()

@type pic_type() :: :preview | :image

Functions

parse_url(reply)

@spec parse_url(Amarula.Protocol.Binary.Node.t()) :: String.t() | nil

Pull the URL from a w:profile:picture reply (<picture url="...">), or nil.

picture_url_query(target, type \\ :preview)

@spec picture_url_query(String.t(), pic_type()) :: Amarula.Protocol.Binary.Node.t()

Fetch a profile picture URL. target is the jid to look up (a user or group jid); type is :preview (small) or :image (full). Reply parsed by parse_url/1.

remove_picture(target)

@spec remove_picture(String.t() | nil) :: Amarula.Protocol.Binary.Node.t()

Remove a profile picture. target is the jid, or nil for your own profile.

set_picture(target, jpeg_bytes)

@spec set_picture(String.t() | nil, binary()) :: Amarula.Protocol.Binary.Node.t()

Set a profile picture from already-encoded JPEG bytes. target is the jid being updated, or nil for your own profile. WhatsApp expects a small square JPEG; the caller is responsible for sizing it (Baileys resizes to 640px q50 before upload — Amarula does not resize, to avoid a native image dependency).

set_status(status)

@spec set_status(String.t()) :: Amarula.Protocol.Binary.Node.t()

Set your own profile status/bio text.