aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/plugs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/plugs')
-rw-r--r--lib/pleroma/plugs/static_fe_plug.ex18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/pleroma/plugs/static_fe_plug.ex b/lib/pleroma/plugs/static_fe_plug.ex
index 143665c71..ea8d5ab0c 100644
--- a/lib/pleroma/plugs/static_fe_plug.ex
+++ b/lib/pleroma/plugs/static_fe_plug.ex
@@ -4,23 +4,25 @@
defmodule Pleroma.Plugs.StaticFEPlug do
import Plug.Conn
- alias Pleroma.Web.StaticFE.StaticFEController
def init(options), do: options
- def call(conn, _) do
- if enabled?() and requires_html?(conn) do
+ def call(%{private: %{frontend: %{"static" => true}}} = conn, _) do
+ action = Phoenix.Controller.action_name(conn)
+
+ if requires_html?(conn) and has_action?(action) do
conn
- |> StaticFEController.call(:show)
+ |> Pleroma.Web.FrontendController.call(action)
|> halt()
else
conn
end
end
- defp enabled?, do: Pleroma.Config.get([:static_fe, :enabled], false)
+ def call(conn, _), do: conn
- defp requires_html?(conn) do
- Phoenix.Controller.get_format(conn) == "html"
- end
+ defp requires_html?(conn), do: Phoenix.Controller.get_format(conn) == "html"
+
+ defp has_action?(action),
+ do: function_exported?(Pleroma.Web.Frontend.StaticController, action, 2)
end