diff options
author | Alex Gleason <alex@alexgleason.me> | 2020-10-11 21:44:22 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2020-10-11 21:46:10 -0500 |
commit | bb8c0614efa978ad33d15fdafd452792180a1c15 (patch) | |
tree | a920c297f5c11f2763fd2cd2818749fd60be007e | |
parent | 521e965884d916c21d76ff12544e678b7fcdb1d4 (diff) | |
download | pleroma-bb8c0614efa978ad33d15fdafd452792180a1c15.tar.gz pleroma-bb8c0614efa978ad33d15fdafd452792180a1c15.zip |
Move admin approval email logic into User.post_register_action/1
-rw-r--r-- | lib/pleroma/user.ex | 11 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api.ex | 13 |
2 files changed, 10 insertions, 14 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index ae2fe93fc..b56620c54 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -779,11 +779,20 @@ defmodule Pleroma.User do end def post_register_action(%User{approval_pending: true} = user) do - # Send approval pending email + # Send approval pending email to user user |> Pleroma.Emails.UserEmail.approval_pending_email() |> Pleroma.Emails.Mailer.deliver_async() + # Notify admins + all_superusers() + |> Enum.filter(fn user -> not is_nil(user.email) end) + |> Enum.each(fn superuser -> + superuser + |> Pleroma.Emails.AdminEmail.new_unapproved_registration(user) + |> Pleroma.Emails.Mailer.deliver_async() + end) + {:ok, user} end diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 5d7948507..8e20b0d55 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -45,7 +45,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do case User.register(changeset) do {:ok, user} -> - maybe_notify_admins(user) {:ok, user} {:error, changeset} -> @@ -58,18 +57,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do end end - defp maybe_notify_admins(%User{} = account) do - if Pleroma.Config.get([:instance, :account_approval_required]) do - User.all_superusers() - |> Enum.filter(fn user -> not is_nil(user.email) end) - |> Enum.each(fn superuser -> - superuser - |> Pleroma.Emails.AdminEmail.new_unapproved_registration(account) - |> Pleroma.Emails.Mailer.deliver_async() - end) - end - end - def password_reset(nickname_or_email) do with true <- is_binary(nickname_or_email), %User{local: true, email: email, deactivated: false} = user when is_binary(email) <- |