AshDispatch.Transports.InApp (AshDispatch v0.5.1)

View Source

In-app notification transport.

Creates in-app notifications immediately (synchronous).

Behavior

  1. Checks user preferences (if event is user_configurable)
  2. Resolves recipients from context
  3. Creates Notification records
  4. Updates receipt status to :sent

Status Flow

pending  sent (success)
         failed (error)
         skipped (user opted out)

Example

receipt = %{
  content: %{
    title: "Order Created",
    message: "Your order #1234 is being processed",
    action_url: "/orders/1234",
    notification_type: :success
  }
}

InApp.deliver(receipt, context, channel, event_config)
# -> Creates Notification records
# -> Returns {:ok, updated_receipt}

Summary

Functions

Delivers an in-app notification.

Retry a failed in-app delivery directly from a stored receipt.

Functions

deliver(receipt, context, channel, event_config)

Delivers an in-app notification.

Parameters

  • receipt - DeliveryReceipt map
  • context - Event context
  • channel - Channel configuration
  • event_config - Event configuration

Returns

  • {:ok, updated_receipt} on success
  • {:error, reason} on failure

retry_from_receipt(receipt)

Retry a failed in-app delivery directly from a stored receipt.

In-app delivery is synchronous (DB write + PubSub broadcast), so we re-attempt the Notification.create directly rather than going through Oban.

Uses the receipt's stored content and idempotency_key to prevent duplicates.

Returns :ok on success or {:error, reason} on failure.