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 ->
|> 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