ensure only pickable frontends can be returned
[akkoma] / lib / pleroma / web / plugs / frontend_static.ex
index 91dfc77c34f28080bee5b09383868c4ab0272d27..41b8ba46b90d659a5ba17069f9a8da6eae87076b 100644 (file)
@@ -50,7 +50,6 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
   end
 
   def call(conn, opts) do
-    IO.inspect("OPTS: #{inspect(opts)}")
     with false <- api_route?(conn.path_info),
          false <- invalid_path?(conn.path_info),
          true <- enabled?(opts[:if]),
@@ -79,11 +78,15 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
         :primary
 
       frontend ->
-        frontend
+        if Enum.member?(Pleroma.Config.get([:frontends, :pickable], []), frontend) do
+          frontend
+        else
+          :primary
+        end
     end
   end
 
-  def preferred_or_fallback(conn, fallback), do: fallback
+  def preferred_or_fallback(_conn, fallback), do: fallback
 
   defp enabled?(if_opt) when is_function(if_opt), do: if_opt.()
   defp enabled?(true), do: true
@@ -106,7 +109,6 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
 
   defp call_static(conn, opts, from) do
     opts = Map.put(opts, :from, from)
-    IO.inspect(opts, label: "opts")
     Plug.Static.call(conn, opts)
   end
 end