forked from shibao/cannery
fix an issue with emails not being able to be sent
This commit is contained in:
parent
70701a27d3
commit
b963baa49d
@ -1,5 +1,6 @@
|
|||||||
# v0.9.10
|
# v0.9.10
|
||||||
- Fix issue with logger failing on oban exceptions
|
- Fix issue with logger failing on oban exceptions
|
||||||
|
- Fix an issue with emails not being able to be sent
|
||||||
- Update deps
|
- Update deps
|
||||||
|
|
||||||
# v0.9.9
|
# v0.9.9
|
||||||
|
@ -26,21 +26,21 @@ defmodule Cannery.Email do
|
|||||||
end
|
end
|
||||||
|
|
||||||
@spec generate_email(key :: String.t(), User.t(), attrs :: map()) :: t()
|
@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
|
user
|
||||||
|> base_email(dgettext("emails", "Confirm your Cannery account"))
|
|> base_email(dgettext("emails", "Confirm your Cannery account"))
|
||||||
|> html_email(:confirm_email_html, %{user: user, url: url})
|
|> html_email(:confirm_email_html, %{user: user, url: url})
|
||||||
|> text_email(:confirm_email_text, %{user: user, url: url})
|
|> text_email(:confirm_email_text, %{user: user, url: url})
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_email("reset_password", user, %{"url" => url}) do
|
def generate_email("reset_password", user, %{url: url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "Reset your Cannery password"))
|
|> base_email(dgettext("emails", "Reset your Cannery password"))
|
||||||
|> html_email(:reset_password_html, %{user: user, url: url})
|
|> html_email(:reset_password_html, %{user: user, url: url})
|
||||||
|> text_email(:reset_password_text, %{user: user, url: url})
|
|> text_email(:reset_password_text, %{user: user, url: url})
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_email("update_email", user, %{"url" => url}) do
|
def generate_email("update_email", user, %{url: url}) do
|
||||||
user
|
user
|
||||||
|> base_email(dgettext("emails", "Update your Cannery email"))
|
|> base_email(dgettext("emails", "Update your Cannery email"))
|
||||||
|> html_email(:update_email_html, %{user: user, url: url})
|
|> html_email(:update_email_html, %{user: user, url: url})
|
||||||
|
@ -7,7 +7,7 @@ defmodule Cannery.EmailWorker do
|
|||||||
alias Cannery.{Accounts, Email, Mailer}
|
alias Cannery.{Accounts, Email, Mailer}
|
||||||
|
|
||||||
@impl Oban.Worker
|
@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()
|
Email.generate_email(email, user_id |> Accounts.get_user!(), attrs) |> Mailer.deliver()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -48,9 +48,6 @@ defmodule Cannery.Fixtures do
|
|||||||
def extract_user_token(fun) do
|
def extract_user_token(fun) do
|
||||||
%{args: %{attrs: attrs, email: email_key, user_id: user_id}} = fun.(&"[TOKEN]#{&1}[TOKEN]")
|
%{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 =
|
||||||
email_key
|
email_key
|
||||||
|> Atom.to_string()
|
|> Atom.to_string()
|
||||||
|
Loading…
Reference in New Issue
Block a user