memEx/lib/memex/accounts/email_worker.ex

14 lines
402 B
Elixir
Raw Normal View History

2022-07-25 19:31:54 -04:00
defmodule Memex.EmailWorker do
2022-02-25 21:35:12 -05:00
@moduledoc """
Oban worker that dispatches emails
"""
use Oban.Worker, queue: :mailers, tags: ["email"]
2022-07-25 19:31:54 -04:00
alias Memex.{Accounts, Email, Mailer}
2022-02-25 21:35:12 -05:00
@impl Oban.Worker
def perform(%Oban.Job{args: %{"email" => email, "user_id" => user_id, "attrs" => attrs}}) do
Email.generate_email(email, user_id |> Accounts.get_user!(), attrs) |> Mailer.deliver()
end
end