The Oban worker that delivers a request's link: the first send, a resend and the reminder.
defmodule MyApp.Signing.DeliveryWorker do
use Countersign.Workers.Delivery, queue: :notifications, max_attempts: 5
@impl Countersign.Workers.Delivery
def config, do: MyApp.Signing.config()
endjob/2 builds the job for a request (reminder: true for the reminder).
Its args carry the request id, its scope and its send_count, never the
token or the address: the link is rebuilt from the row's encrypted token
when the job runs, so a resend's job delivers the newest link. A job is
unique on the request, its send_count and whether it is the reminder.
When the job runs:
- a request that is gone, no longer pending, past its
expires_at, or resent since the job was written (itssend_countmoved on) sends nothing and completes; - while
Countersign.Host.enabled?/1answers false for the request's scope, it sends nothing and snoozes an hour, so neither a first delivery, a reminder nor a retry goes out while signing is switched off; the request stays pending, and expiry still ends it on its date; {:error, :retry}from the delivery retries, and on the last attempt fails the request (Countersign.Requests.fail/3, reason:max_attempts) and cancels;{:error, {:permanent, reason}}has already failed the request (Countersign.Requests.deliver_link/3) and cancels.
Summary
Functions
A delivery job's args for request (reminder: true for the reminder).
Runs a delivery job with config (what the generated perform/1 calls).
Callbacks
@callback config() :: Countersign.Config.t()
The config the worker delivers with.
Functions
@spec args(Countersign.Request.t(), keyword()) :: map()
A delivery job's args for request (reminder: true for the reminder).
@spec perform(Countersign.Config.t(), Oban.Job.t()) :: :ok | {:error, :retry} | {:snooze, pos_integer()} | {:cancel, term()}
Runs a delivery job with config (what the generated perform/1 calls).