Amarula.Protocol.Call (amarula v0.4.2)
View SourceParse inbound <call> stanzas, ported from Baileys handleCall /
getCallStatusFromNode (src/Socket/messages-recv.ts).
A <call> wraps a single info child whose tag carries the lifecycle event:
offer / offer_notice (someone is calling), terminate (call ended —
reason="timeout" = nobody answered), reject, accept, and the various
in-progress tags (preaccept, transport, …) which map to :ringing.
Pure parsing; the Connection acks the node and surfaces the result as a
:call_update consumer event.
Summary
Functions
Parse a <call> node into a t/0. Returns {:error, :invalid} for a node with
no info child (the lifecycle tag we key the status off).
Types
@type status() :: :offer | :terminate | :timeout | :reject | :accept | :ringing
A call lifecycle status (Baileys WACallEvent['status']):
:offer— an incoming call is ringing (offer/offer_notice):terminate— the call ended (caller hung up / it was answered elsewhere):timeout— aterminatewithreason="timeout": nobody answered:reject— the call was rejected:accept— the call was accepted:ringing— any other in-progress signalling tag
@type t() :: %{ chat: Amarula.Address.t() | nil, from: Amarula.Address.t() | nil, id: String.t() | nil, status: status(), timestamp: integer() | nil, offline: boolean(), video?: boolean(), group?: boolean(), group_jid: Amarula.Address.t() | nil }
A parsed inbound call event:
:chat— the chat the call is in (attrs.from); for a 1:1 call this is the caller, for a group call the group:from— who started the call (call-creator):id— thecall-id(correlates offer→terminate for one call):status— the lifecyclestatus/0:timestamp— unix seconds (attrs.t), ornil:offline—trueif delivered from the offline queue (not live):video?—truefor a video call (offer only;falseotherwise):group?—truefor a group call:group_jid— the groupAddressfor a group call, elsenil
Functions
@spec parse(Amarula.Protocol.Binary.Node.t()) :: {:ok, t()} | {:error, :invalid}
Parse a <call> node into a t/0. Returns {:error, :invalid} for a node with
no info child (the lifecycle tag we key the status off).