Merge branch 'issue/1878' into 'develop'
[akkoma] / lib / pleroma / application_requirements.ex
index 88575a498f6db653c5b40a631961089ad1ba7660..ee88c3346e6398775c28a38412e93a43bd5ee78b 100644 (file)
@@ -16,6 +16,7 @@ defmodule Pleroma.ApplicationRequirements do
   @spec verify!() :: :ok | VerifyError.t()
   def verify! do
     :ok
+    |> check_confirmation_accounts!
     |> check_migrations_applied!()
     |> check_rum!()
     |> handle_result()
@@ -24,6 +25,24 @@ defmodule Pleroma.ApplicationRequirements do
   defp handle_result(:ok), do: :ok
   defp handle_result({:error, message}), do: raise(VerifyError, message: message)
 
+  # Checks account confirmation email
+  #
+  def check_confirmation_accounts!(:ok) do
+    if Pleroma.Config.get([:instance, :account_activation_required]) &&
+         not Pleroma.Config.get([Pleroma.Emails.Mailer, :enabled]) do
+      Logger.error(
+        "Account activation enabled, but no Mailer settings enabled.\nPlease set config :pleroma, :instance, account_activation_required: false\nOtherwise setup and enable Mailer."
+      )
+
+      {:error,
+       "Account activation enabled, but Mailer is disabled. Cannot send confirmation emails."}
+    else
+      :ok
+    end
+  end
+
+  def check_confirmation_accounts!(result), do: result
+
   # Checks for pending migrations.
   #
   def check_migrations_applied!(:ok) do