From: Alex Gleason Date: Mon, 12 Oct 2020 22:21:08 +0000 (-0500) Subject: Refactor User.post_register_action/1 emails X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=66e00ace7c0708f2f9361bc6e1008ccea08cb6ef;p=akkoma Refactor User.post_register_action/1 emails --- diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index c6767cfca..0978cc02c 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -779,12 +779,31 @@ defmodule Pleroma.User do end def post_register_action(%User{approval_pending: true} = user) do - # Send approval pending email to user + with {:ok, _} <- send_user_approval_email(user), + {:ok, _} <- send_admin_approval_emails(user) do + {:ok, user} + end + end + + def post_register_action(%User{approval_pending: false, confirmation_pending: false} = user) do + with {:ok, user} <- autofollow_users(user), + {:ok, user} <- set_cache(user), + {:ok, _} <- send_welcome_email(user), + {:ok, _} <- send_welcome_message(user), + {:ok, _} <- send_welcome_chat_message(user) do + {:ok, user} + end + end + + defp send_user_approval_email(user) do user |> Pleroma.Emails.UserEmail.approval_pending_email() |> Pleroma.Emails.Mailer.deliver_async() - # Notify admins + {: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 -> @@ -793,17 +812,7 @@ defmodule Pleroma.User do |> Pleroma.Emails.Mailer.deliver_async() end) - {:ok, user} - end - - def post_register_action(%User{approval_pending: false, confirmation_pending: false} = user) do - with {:ok, user} <- autofollow_users(user), - {:ok, user} <- set_cache(user), - {:ok, _} <- send_welcome_email(user), - {:ok, _} <- send_welcome_message(user), - {:ok, _} <- send_welcome_chat_message(user) do - {:ok, user} - end + {:ok, :enqueued} end def send_welcome_message(user) do