Gamend.Accounts.ConfirmationMailer (gamend_core v1.0.1296)

Copy Markdown View Source

Sends a new account's confirmation email, off the request.

Registration enqueues this in the transaction that inserts the user, so a committed account always has its email queued and the transaction holds the database for two inserts rather than an SMTP conversation. On SQLite the repo has a single connection, and a registration that sent its mail inline stalled every other query in the server for the length of the SMTP session.

The job mints the link token and the code itself: either in the job's args would sit in the jobs table in the clear. A failed send is retried with backoff, minting new ones each attempt (unused links expire; a new code replaces the last). A job that outlives timeout/1 is killed, so a hung relay costs one mailers slot, never the database.

Summary

Functions

The job for user. confirmation_url_fun maps an encoded token to its URL and runs now, with a placeholder; notifier delivers. opts go to Oban.Worker.new/2 (a resend passes :unique).

Functions

new_for(user, confirmation_url_fun, notifier \\ UserNotifier, opts \\ [])

@spec new_for(
  Gamend.Accounts.User.t(),
  (String.t() -> String.t()),
  module(),
  keyword()
) ::
  Ecto.Changeset.t()

The job for user. confirmation_url_fun maps an encoded token to its URL and runs now, with a placeholder; notifier delivers. opts go to Oban.Worker.new/2 (a resend passes :unique).