add swoosh and oban

This commit is contained in:
2022-02-08 19:59:23 -05:00
parent acf64cee18
commit a39c3da351
26 changed files with 365 additions and 84 deletions

View File

@@ -4,4 +4,30 @@ defmodule Cannery.Mailer do
"""
use Swoosh.Mailer, otp_app: :cannery
alias Cannery.{Accounts.User, Email, EmailWorker}
alias Oban.Job
@doc """
Deliver instructions to confirm account.
"""
@spec deliver_confirmation_instructions(User.t(), String.t()) :: {:ok, Job.t()}
def deliver_confirmation_instructions(user, url) do
{:ok, Email.welcome_email(user, url) |> EmailWorker.new() |> Oban.insert!()}
end
@doc """
Deliver instructions to reset a user password.
"""
@spec deliver_reset_password_instructions(User.t(), String.t()) :: {:ok, Job.t()}
def deliver_reset_password_instructions(user, url) do
{:ok, Email.reset_password_email(user, url) |> EmailWorker.new() |> Oban.insert!()}
end
@doc """
Deliver instructions to update a user email.
"""
@spec deliver_update_email_instructions(User.t(), String.t()) :: {:ok, Job.t()}
def deliver_update_email_instructions(user, url) do
{:ok, Email.update_email(user, url) |> EmailWorker.new() |> Oban.insert!()}
end
end