mandate published on notes
[akkoma] / lib / pleroma / web / endpoint.ex
index 196d0006b12da73d268e956c5b574df297e418e5..6dd66a424a0d11f9f58a18a204ef219ae63170a6 100644 (file)
@@ -9,9 +9,7 @@ defmodule Pleroma.Web.Endpoint do
 
   alias Pleroma.Config
 
-  socket("/socket", Pleroma.Web.UserSocket)
-
-  plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint])
+  socket("/live", Phoenix.LiveView.Socket)
 
   plug(Pleroma.Web.Plugs.SetLocalePlug)
   plug(CORSPlug)
@@ -67,18 +65,28 @@ defmodule Pleroma.Web.Endpoint do
     }
   )
 
-  plug(Plug.Static.IndexHtml, at: "/pleroma/fedife/")
+  plug(Plug.Static.IndexHtml, at: "/akkoma/swaggerui")
 
   plug(Pleroma.Web.Plugs.FrontendStatic,
-    at: "/pleroma/fedife",
-    frontend_type: :fedife,
+    at: "/akkoma/swaggerui",
+    frontend_type: :swagger,
     gzip: true,
+    if: &Pleroma.Web.Swagger.ui_enabled?/0,
     cache_control_for_etags: @static_cache_control,
     headers: %{
       "cache-control" => @static_cache_control
     }
   )
 
+  plug(Pleroma.Web.Plugs.FrontendStatic,
+    at: "/",
+    frontend_type: :mastodon,
+    gzip: true,
+    cache_control_for_etags: @static_cache_control,
+    headers: %{
+      "cache-control" => @static_cache_control
+    }
+  )
 
   # Serve at "/" the static files from "priv/static" directory.
   #
@@ -153,47 +161,6 @@ defmodule Pleroma.Web.Endpoint do
 
   plug(Pleroma.Web.Plugs.RemoteIp)
 
-  defmodule Instrumenter do
-    use Prometheus.PhoenixInstrumenter
-  end
-
-  defmodule PipelineInstrumenter do
-    use Prometheus.PlugPipelineInstrumenter
-  end
-
-  defmodule MetricsExporter do
-    use Prometheus.PlugExporter
-  end
-
-  defmodule MetricsExporterCaller do
-    @behaviour Plug
-
-    def init(opts), do: opts
-
-    def call(conn, opts) do
-      prometheus_config = Application.get_env(:prometheus, MetricsExporter, [])
-      ip_whitelist = List.wrap(prometheus_config[:ip_whitelist])
-
-      cond do
-        !prometheus_config[:enabled] ->
-          conn
-
-        ip_whitelist != [] and
-            !Enum.find(ip_whitelist, fn ip ->
-              Pleroma.Helpers.InetHelper.parse_address(ip) == {:ok, conn.remote_ip}
-            end) ->
-          conn
-
-        true ->
-          MetricsExporter.call(conn, opts)
-      end
-    end
-  end
-
-  plug(PipelineInstrumenter)
-
-  plug(MetricsExporterCaller)
-
   plug(Pleroma.Web.Router)
 
   @doc """