Amarula.Protocol.Call (amarula v0.4.2)

View Source

Parse 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

Types

A call lifecycle status (Baileys WACallEvent['status'])

t()

A parsed inbound call event

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

status()

@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 — a terminate with reason="timeout": nobody answered
  • :reject — the call was rejected
  • :accept — the call was accepted
  • :ringing — any other in-progress signalling tag

t()

@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 — the call-id (correlates offer→terminate for one call)
  • :status — the lifecycle status/0
  • :timestamp — unix seconds (attrs.t), or nil
  • :offlinetrue if delivered from the offline queue (not live)
  • :video?true for a video call (offer only; false otherwise)
  • :group?true for a group call
  • :group_jid — the group Address for a group call, else nil

Functions

parse(node)

@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).