Amarula.Connection.Notifications (amarula v0.4.2)
View SourcePure notification parsers for Amarula.Connection.
Server <notification> stanzas are acked + dispatched by Connection (it
emits events, mutates creds, drops caches, runs IQ continuations — all
socket/state-bound). The parsing of a node into an event payload or a
decision is pure, and lives here: account_sync, devices, and picture.
The handlers stay on Connection and call these to get the data to act on.
Summary
Functions
Classify an account_sync notification
Parse a devices notification into {tag, normalized_users} where tag is
"add"/"remove"/"update", or :ignore for an unrecognized shape. The
caller drops cached device lists (and, for "remove", sessions) for the users.
Parse a picture notification into {from, img_url} where img_url is
"changed" (a <set> is present) or "removed".
Functions
@spec account_sync(Amarula.Protocol.Binary.Node.t()) :: {:disappearing, String.t() | nil} | {:blocklist, [map()]} | :ignore
Classify an account_sync notification:
{:disappearing, duration}— default disappearing-mode changed{:blocklist, [%{jid, action}]}— blocklist additions/removals:ignore— nothing we handle
@spec devices(Amarula.Protocol.Binary.Node.t()) :: {String.t(), [String.t()]} | :ignore
Parse a devices notification into {tag, normalized_users} where tag is
"add"/"remove"/"update", or :ignore for an unrecognized shape. The
caller drops cached device lists (and, for "remove", sessions) for the users.
@spec picture(Amarula.Protocol.Binary.Node.t()) :: {String.t(), String.t()}
Parse a picture notification into {from, img_url} where img_url is
"changed" (a <set> is present) or "removed".