Amarula.Content.LinkPreview (amarula v0.4.4)

View Source

The link-preview metadata a text message carries for a URL it contains — the title/description/thumbnail card WhatsApp shows under a link. Rides on an extendedTextMessage; a plain text message (or a reply/mention with no link) has none.

Surfaced on %Amarula.Msg{}.preview (not msg.content:text content stays the bare body string), and nil when the message carries no preview.

  • :url — the matched URL the preview is for (matchedText).
  • :title — the link's title (OpenGraph og:title).
  • :description — the link's description.
  • :thumbnail — raw JPEG thumbnail bytes, or nil.
  • :type:none | :video | :placeholder | :image | :payment_links | :profile, the kind of preview WhatsApp rendered (nil if absent). A plain link card is usually :none; :video/:image mark rich media links.

Summary

Functions

Build a %LinkPreview{} from an ExtendedTextMessage proto (or nil), or nil when the message carries no preview. A preview is considered present when the message has a matched URL, a title, or a description — so a plain reply/mention extendedTextMessage (text + contextInfo only) yields nil.

Types

preview_type()

@type preview_type() ::
  :none | :video | :placeholder | :image | :payment_links | :profile

t()

@type t() :: %Amarula.Content.LinkPreview{
  description: String.t() | nil,
  thumbnail: binary() | nil,
  title: String.t() | nil,
  type: preview_type() | nil,
  url: String.t() | nil
}

Functions

from_proto(ext)

@spec from_proto(struct() | nil) :: t() | nil

Build a %LinkPreview{} from an ExtendedTextMessage proto (or nil), or nil when the message carries no preview. A preview is considered present when the message has a matched URL, a title, or a description — so a plain reply/mention extendedTextMessage (text + contextInfo only) yields nil.