Amarula.Protocol.AppState.SyncAction (amarula v0.1.0)

View Source

Turn a decoded app-state mutation (Amarula.Protocol.AppState.Patch output) into a consumer-facing change, ported from Baileys processSyncAction (chat-utils.ts).

A mutation's index is [type, id, msg_id, from_me] and the SyncActionValue carries the change. We map the chat/contact-relevant ones to %Amarula.Chat{} / %Amarula.Contact{} tagged tuples; everything else is {:other, action} so nothing is silently lost.

Pure: decode/1 takes a mutation map, returns a tagged result.

Summary

Functions

Decode one mutation into a tagged consumer change.

Types

result()

@type result() ::
  {:chat, Amarula.Chat.t()}
  | {:contact, Amarula.Contact.t()}
  | {:push_name, String.t()}
  | {:other, term()}

Functions

decode(map)

@spec decode(%{operation: :set | :remove, action: struct(), index: [String.t()]}) ::
  result()

Decode one mutation into a tagged consumer change.