Merge branch 'feat/simplify-pool-managment' into 'develop'
[akkoma] / lib / pleroma / application_requirements.ex
index 3bba70b7b42d31783f78083cf9ff1f7ab33705c1..16f62b6f5d43e00caa18e612479f66e82bffcaae 100644 (file)
@@ -16,7 +16,9 @@ defmodule Pleroma.ApplicationRequirements do
   @spec verify!() :: :ok | VerifyError.t()
   def verify! do
     :ok
+    |> check_confirmation_accounts!
     |> check_migrations_applied!()
+    |> check_welcome_message_config!()
     |> check_rum!()
     |> handle_result()
   end
@@ -24,7 +26,43 @@ defmodule Pleroma.ApplicationRequirements do
   defp handle_result(:ok), do: :ok
   defp handle_result({:error, message}), do: raise(VerifyError, message: message)
 
-  defp check_migrations_applied!(:ok) do
+  defp check_welcome_message_config!(:ok) do
+    if Pleroma.Config.get([:welcome, :email, :enabled], false) and
+         not Pleroma.Emails.Mailer.enabled?() do
+      Logger.error("""
+      To send welcome email do you need to enable mail.
+      \nconfig :pleroma, Pleroma.Emails.Mailer, enabled: true
+      """)
+
+      {:error, "The mail disabled."}
+    else
+      :ok
+    end
+  end
+
+  defp check_welcome_message_config!(result), do: result
+
+  # 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
     unless Pleroma.Config.get(
              [:i_am_aware_this_may_cause_data_loss, :disable_migration_check],
              false
@@ -58,8 +96,10 @@ defmodule Pleroma.ApplicationRequirements do
     end
   end
 
-  defp check_migrations_applied!(result), do: result
+  def check_migrations_applied!(result), do: result
 
+  # Checks for settings of RUM indexes.
+  #
   defp check_rum!(:ok) do
     {_, res, _} =
       Ecto.Migrator.with_repo(Pleroma.Repo, fn repo ->