Send approval pending email during registration
authorAlex Gleason <alex@alexgleason.me>
Mon, 12 Oct 2020 01:50:09 +0000 (20:50 -0500)
committerAlex Gleason <alex@alexgleason.me>
Mon, 12 Oct 2020 01:50:09 +0000 (20:50 -0500)
lib/pleroma/emails/user_email.ex
lib/pleroma/user.ex
test/emails/user_email_test.exs

index 1d8c72ae93a5b057c106e34d45a31efcad8a2eaf..831e5464f5b12b38486c0923ccdc7970cf638a90 100644 (file)
@@ -93,6 +93,19 @@ defmodule Pleroma.Emails.UserEmail do
     |> html_body(html_body)
   end
 
+  def approval_pending_email(user) do
+    html_body = """
+    <h3>Awaiting Approval</h3>
+    <p>Your account at #{instance_name()} is being reviewed by staff. You will receive another email once your account is approved.</p>
+    """
+
+    new()
+    |> to(recipient(user))
+    |> from(sender())
+    |> subject("Your account is awaiting approval")
+    |> html_body(html_body)
+  end
+
   @doc """
   Email used in digest email notifications
   Includes Mentions and New Followers data
index 3a4f031b1d08d9425a004412acf596f3b14ec178..cde9ff0eb72faf25ae825cb7331220597f9bc5f9 100644 (file)
@@ -779,7 +779,11 @@ defmodule Pleroma.User do
   end
 
   def post_register_action(%User{approval_pending: true} = user) do
-    # TODO: Send approval explanation email
+    # Send approval pending email
+    user
+    |> Pleroma.Emails.UserEmail.approval_pending_email()
+    |> Pleroma.Emails.Mailer.deliver_async()
+
     {:ok, user}
   end
 
index a75623bb41aa3c72cd3a532e6db38c3ce2545d68..a214e59a7d1a0e944d54ddd5605adc8b152182f2 100644 (file)
@@ -45,4 +45,15 @@ defmodule Pleroma.Emails.UserEmailTest do
     assert email.html_body =~
              Router.Helpers.confirm_email_url(Endpoint, :confirm_email, user.id, "conf-token")
   end
+
+  test "build approval pending email" do
+    config = Pleroma.Config.get(:instance)
+    user = insert(:user)
+    email = UserEmail.approval_pending_email(user)
+
+    assert email.from == {config[:name], config[:notify_email]}
+    assert email.to == [{user.name, user.email}]
+    assert email.subject == "Your account is awaiting approval"
+    assert email.html_body =~ "Awaiting Approval"
+  end
 end