Adjusted MediaProxyControllerTest to gracefully fail on missing dependencies. Install...
[akkoma] / lib / pleroma / application.ex
index c39e24919c4c76e4ce0c682f99767e71106ba234..d7d8e423e5e72df01b757277da5c170080d1de68 100644 (file)
@@ -99,7 +99,7 @@ defmodule Pleroma.Application do
           {Oban, Config.get(Oban)}
         ] ++
         task_children(@env) ++
-        streamer_child(@env) ++
+        dont_run_in_test(@env) ++
         chat_child(@env, chat_enabled?()) ++
         [
           Pleroma.Web.Endpoint,
@@ -188,16 +188,17 @@ defmodule Pleroma.Application do
 
   defp chat_enabled?, do: Config.get([:chat, :enabled])
 
-  defp streamer_child(env) when env in [:test, :benchmark], do: []
+  defp dont_run_in_test(env) when env in [:test, :benchmark], do: []
 
-  defp streamer_child(_) do
+  defp dont_run_in_test(_) do
     [
       {Registry,
        [
          name: Pleroma.Web.Streamer.registry(),
          keys: :duplicate,
          partitions: System.schedulers_online()
-       ]}
+       ]},
+      Pleroma.Web.FedSockets.Supervisor
     ]
   end
 
@@ -267,7 +268,8 @@ defmodule Pleroma.Application do
       with true <- filter in filters,
            false <- Pleroma.Utils.command_available?(command_required) do
         Logger.error(
-          "#{filter} is specified in list of Pleroma.Upload filters, but the #{command_required} command is not found"
+          "#{filter} is specified in list of Pleroma.Upload filters, but the " <>
+            "#{command_required} command is not found"
         )
       end
     end
@@ -275,5 +277,20 @@ defmodule Pleroma.Application do
     check_filter.(Pleroma.Upload.Filters.Exiftool, "exiftool")
     check_filter.(Pleroma.Upload.Filters.Mogrify, "mogrify")
     check_filter.(Pleroma.Upload.Filters.Mogrifun, "mogrify")
+
+    with true <- Config.get([:media_preview_proxy, :enabled]),
+         missing_graphics_tools = Pleroma.Helpers.MediaHelper.missing_dependencies(),
+         [] <- missing_graphics_tools do
+      :noop
+    else
+      false ->
+        :noop
+
+      missing_graphics_tools ->
+        Logger.error(
+          "The following dependencies required by Media preview proxy " <>
+            "(which is currently enabled) are not installed: #{inspect(missing_graphics_tools)}"
+        )
+    end
   end
 end