ExWapp.Media (ExWapp v0.1.2)

Copy Markdown View Source

Public media helpers shared by send and receive flows.

The media domain is split into smaller files under lib/ex_wapp/domains/media/ so the public API stays easy to find while crypto, HTTP, and source-handling details live in focused modules.

Summary

Types

Media kinds currently supported by the high-level API.

Accepted media input values when sending a message.

Functions

Builds the authenticated server-error receipt used to re-request expired media.

Decrypts a mediaretry notification with the original message media key.

Normalizes a send source into plaintext bytes.

Converts upload metadata into a reusable download reference.

Derives the media-retry wrapping key from a media key.

Types

media_type()

@type media_type() :: :image | :audio | :document

Media kinds currently supported by the high-level API.

source()

@type source() :: {:bytes, binary()} | {:path, Path.t()} | ExWapp.Media.Upload.t()

Accepted media input values when sending a message.

{:bytes, binary} keeps everything in memory, {:path, path} reads from disk, and %ExWapp.Media.Upload{} skips the upload step when the caller already has WhatsApp upload metadata.

Functions

build_retry_receipt(msg_id, own_jid, chat_jid, from_me, participant_jid, media_key)

Builds the authenticated server-error receipt used to re-request expired media.

decode_retry_notification(node, media_key)

Decrypts a mediaretry notification with the original message media key.

read_source(source)

@spec read_source(source()) :: {:ok, binary()} | {:error, term()}

Normalizes a send source into plaintext bytes.

This is the boundary between the user-facing send API and the upload pipeline. Existing %Upload{} values are rejected because they already represent uploaded server-side media rather than local plaintext bytes.

ref_from_upload(upload, opts \\ [])

@spec ref_from_upload(
  ExWapp.Media.Upload.t(),
  keyword()
) :: ExWapp.Media.Ref.t()

Converts upload metadata into a reusable download reference.

The resulting %ExWapp.Media.Ref{} can be attached to an event payload or passed back into ExWapp.download_media/3.

retry_key(media_key)

Derives the media-retry wrapping key from a media key.