Amarula.Content.LinkPreview (amarula v0.4.2)
View SourceThe 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 (OpenGraphog:title).:description— the link's description.:thumbnail— raw JPEG thumbnail bytes, ornil.:type—:none | :video | :placeholder | :image | :payment_links | :profile, the kind of preview WhatsApp rendered (nilif absent). A plain link card is usually:none;:video/:imagemark 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
@type preview_type() ::
:none | :video | :placeholder | :image | :payment_links | :profile
@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
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.