fix an issue with emails not being able to be sent

This commit is contained in:
shibao 2024-06-16 11:27:05 -04:00
parent 70701a27d3
commit b963baa49d
4 changed files with 5 additions and 7 deletions

View File

@ -1,5 +1,6 @@
# v0.9.10
- Fix issue with logger failing on oban exceptions
- Fix an issue with emails not being able to be sent
- Update deps
# v0.9.9

View File

@ -26,21 +26,21 @@ defmodule Cannery.Email do
end
@spec generate_email(key :: String.t(), User.t(), attrs :: map()) :: t()
def generate_email("welcome", user, %{"url" => url}) do
def generate_email("welcome", user, %{url: url}) do
user
|> base_email(dgettext("emails", "Confirm your Cannery account"))
|> html_email(:confirm_email_html, %{user: user, url: url})
|> text_email(:confirm_email_text, %{user: user, url: url})
end
def generate_email("reset_password", user, %{"url" => url}) do
def generate_email("reset_password", user, %{url: url}) do
user
|> base_email(dgettext("emails", "Reset your Cannery password"))
|> html_email(:reset_password_html, %{user: user, url: url})
|> text_email(:reset_password_text, %{user: user, url: url})
end
def generate_email("update_email", user, %{"url" => url}) do
def generate_email("update_email", user, %{url: url}) do
user
|> base_email(dgettext("emails", "Update your Cannery email"))
|> html_email(:update_email_html, %{user: user, url: url})

View File

@ -7,7 +7,7 @@ defmodule Cannery.EmailWorker do
alias Cannery.{Accounts, Email, Mailer}
@impl Oban.Worker
def perform(%Oban.Job{args: %{"email" => email, "user_id" => user_id, "attrs" => attrs}}) do
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

View File

@ -48,9 +48,6 @@ defmodule Cannery.Fixtures do
def extract_user_token(fun) do
%{args: %{attrs: attrs, email: email_key, user_id: user_id}} = fun.(&"[TOKEN]#{&1}[TOKEN]")
# convert atoms to string keys
attrs = attrs |> Map.new(fn {atom_key, value} -> {atom_key |> Atom.to_string(), value} end)
email =
email_key
|> Atom.to_string()