# `ExWapp.Media.Retry`
[🔗](https://github.com/elchemista/ex_wapp/blob/v0.1.5/lib/ex_wapp/media/retry.ex#L1)

Implements WhatsApp's media re-upload protocol.

When a CDN object is no longer available, a companion sends a
`<receipt type="server-error">` containing an authenticated
`ServerErrorReceipt`. The phone answers with a `mediaretry` notification
carrying a fresh direct path encrypted with the same key.

# `result`

```elixir
@type result() ::
  :general_error | :success | :not_found | :decryption_error | non_neg_integer()
```

# `build_receipt`

```elixir
@spec build_receipt(
  String.t(),
  String.t(),
  String.t(),
  boolean(),
  String.t() | nil,
  binary()
) :: ExWapp.Binary.Node.t()
```

Builds a media re-upload request addressed to the local primary identity.

`participant_jid` is required only when the original message belongs to a
group. The encrypted protobuf is authenticated with the message ID as AAD.

# `decode_notification`

```elixir
@spec decode_notification(ExWapp.Binary.Node.t(), binary()) ::
  {:ok, String.t()} | {:error, term()}
```

Decrypts a `mediaretry` notification.

A successful result returns the refreshed direct path. Error code `2` is the
wire-level indication that the phone no longer has the media.

# `retry_key`

```elixir
@spec retry_key(binary()) :: binary()
```

Derives the AES-256-GCM key used by media-retry payloads.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
