PhoenixKit.Notifications.Render (phoenix_kit v1.7.164)

Copy Markdown View Source

Human-readable rendering for notifications.

Maps {activity.action, activity.metadata}%{icon, text, link, actor_uuid} so the bell dropdown and inbox page don't need to know the action taxonomy.

Unknown actions fall back to the raw action string with a generic icon, so a new action that hasn't been mapped yet still displays safely.

Summary

Functions

Returns the display payload for a notification.

Types

render_result()

@type render_result() :: %{
  icon: String.t(),
  text: String.t(),
  link: String.t() | nil,
  actor_uuid: String.t() | nil
}

Functions

render(notification, locale \\ nil)

Returns the display payload for a notification.

notification.activity must be preloaded. locale is the recipient's current locale (base code, e.g. "en"); it's threaded into the built link so the click-through lands on the right locale-prefixed path. When nil, link building falls back to Routes.path's determine_locale/0 (the process Gettext locale) — used by callers that don't track a locale (e.g. the admin inbox). The metadata notification_link override is returned verbatim and is expected to already be prefix/locale-correct (built via Routes.path/1).