Refactor User.post_register_action/1 emails
This commit is contained in:
parent
cb29769a22
commit
66e00ace7c
|
@ -779,21 +779,10 @@ def post_register_action(%User{confirmation_pending: true} = user) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_register_action(%User{approval_pending: true} = user) do
|
def post_register_action(%User{approval_pending: true} = user) do
|
||||||
# Send approval pending email to user
|
with {:ok, _} <- send_user_approval_email(user),
|
||||||
user
|
{:ok, _} <- send_admin_approval_emails(user) do
|
||||||
|> Pleroma.Emails.UserEmail.approval_pending_email()
|
{:ok, user}
|
||||||
|> Pleroma.Emails.Mailer.deliver_async()
|
end
|
||||||
|
|
||||||
# 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
|
end
|
||||||
|
|
||||||
def post_register_action(%User{approval_pending: false, confirmation_pending: false} = user) do
|
def post_register_action(%User{approval_pending: false, confirmation_pending: false} = user) do
|
||||||
|
@ -806,6 +795,26 @@ def post_register_action(%User{approval_pending: false, confirmation_pending: fa
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp send_user_approval_email(user) do
|
||||||
|
user
|
||||||
|
|> Pleroma.Emails.UserEmail.approval_pending_email()
|
||||||
|
|> Pleroma.Emails.Mailer.deliver_async()
|
||||||
|
|
||||||
|
{:ok, :enqueued}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp send_admin_approval_emails(user) do
|
||||||
|
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, :enqueued}
|
||||||
|
end
|
||||||
|
|
||||||
def send_welcome_message(user) do
|
def send_welcome_message(user) do
|
||||||
if User.WelcomeMessage.enabled?() do
|
if User.WelcomeMessage.enabled?() do
|
||||||
User.WelcomeMessage.post_message(user)
|
User.WelcomeMessage.post_message(user)
|
||||||
|
|
Loading…
Reference in New Issue