| 1 |
|
defmodule WalletNotifications.Commands.SendNotification do |
| 2 |
|
@moduledoc """ |
| 3 |
|
Command to synchronously send a single queued notification. |
| 4 |
|
|
| 5 |
|
Used for test drains and urgent operational sends. |
| 6 |
|
Delegates to `NotificationWorker.perform/1` directly. |
| 7 |
|
|
| 8 |
|
Returns `:ok` or `{:error, reason}`. |
| 9 |
|
""" |
| 10 |
|
|
| 11 |
|
alias WalletNotifications.Workers.NotificationWorker |
| 12 |
|
|
| 13 |
|
@spec execute(notification_id :: String.t(), opts :: keyword()) :: :ok | {:error, term()} |
| 14 |
15 |
def execute(notification_id, opts \\ []) do |
| 15 |
15 |
correlation_id = Keyword.get(opts, :correlation_id, WalletSharedKernel.Correlation.new_correlation_id()) |
| 16 |
15 |
NotificationWorker.perform(%{"notification_id" => notification_id, "correlation_id" => correlation_id}) |
| 17 |
|
end |
| 18 |
|
end |