logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 7f8a9329e566140f9f36cecac58b13097b7e0519
parent e944b1529862a2a40158803da5fe04a024f7aa4f
Author: Mark Felder <feld@feld.me>
Date:   Thu, 16 May 2024 16:03:05 -0400

Startup detection for configured MRF modules that are missing or incorrectly defined

Diffstat:

Achangelog.d/missing-mrfs.add1+
Mlib/pleroma/application_requirements.ex22++++++++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/changelog.d/missing-mrfs.add b/changelog.d/missing-mrfs.add @@ -0,0 +1 @@ +Startup detection for configured MRF modules that are missing or incorrectly defined diff --git a/lib/pleroma/application_requirements.ex b/lib/pleroma/application_requirements.ex @@ -28,6 +28,7 @@ defmodule Pleroma.ApplicationRequirements do |> check_welcome_message_config!() |> check_rum!() |> check_repo_pool_size!() + |> check_mrfs() |> handle_result() end @@ -234,4 +235,25 @@ defmodule Pleroma.ApplicationRequirements do true end end + + defp check_mrfs(:ok) do + mrfs = Config.get!([:mrf, :policies]) + + missing_mrfs = + Enum.reduce(mrfs, [], fn x, acc -> + if Code.ensure_compiled(x) do + acc + else + acc ++ [x] + end + end) + + if Enum.empty?(missing_mrfs) do + :ok + else + {:error, "The following MRF modules are configured but missing: #{inspect(missing_mrfs)}"} + end + end + + defp check_mrfs(result), do: result end