Amarula.Protocol.Messages.HistorySync (amarula v0.1.0)

View Source

Download + decode the history-sync blob a HISTORY_SYNC_NOTIFICATION points to, ported from Baileys downloadHistory/processHistoryMessage (Utils/history.ts).

On first link (and incrementally), the primary device pushes the chat history as an external, encrypted, zlib-deflated blob referenced by the notification. We download it (media crypto, :history keys), inflate, and decode a Proto.HistorySync — yielding the conversations (chats), contacts, and their messages. This is what populates the chat list, and acking/consuming it is what moves the phone from "Paused" to "active".

Summary

Functions

Download + decode the blob for a %HistorySyncNotification{}. Returns {:ok, %{sync_type, chats, contacts}} or {:error, reason}.

Types

result()

@type result() :: %{
  sync_type: atom(),
  chats: [Amarula.Chat.t()],
  contacts: [Amarula.Contact.t()]
}

Functions

fetch(notification)

@spec fetch(struct()) :: {:ok, result()} | {:error, term()}

Download + decode the blob for a %HistorySyncNotification{}. Returns {:ok, %{sync_type, chats, contacts}} or {:error, reason}.