Merge pull request 'metrics' (#375) from stats into develop
[akkoma] / lib / pleroma / web.ex
index 24751faba4a3928158cc7c288586e96470259392..24560d4a3da91cc4eab96b910e1329b4ede068b4 100644 (file)
@@ -56,12 +56,23 @@ defmodule Pleroma.Web do
               plug_module.skip_plug(conn)
             rescue
               UndefinedFunctionError ->
-                raise "`#{plug_module}` is not skippable. Append `use Pleroma.Web, :plug` to its code."
+                reraise(
+                  "`#{plug_module}` is not skippable. Append `use Pleroma.Web, :plug` to its code.",
+                  __STACKTRACE__
+                )
             end
           end
         )
       end
 
+      defp skip_auth(conn, _) do
+        skip_plug(conn, [OAuthScopesPlug, EnsurePublicOrAuthenticatedPlug])
+      end
+
+      defp skip_public_check(conn, _) do
+        skip_plug(conn, EnsurePublicOrAuthenticatedPlug)
+      end
+
       # Executed just before actual controller action, invokes before-action hooks (callbacks)
       defp action(conn, params) do
         with %{halted: false} = conn <-
@@ -231,20 +242,4 @@ defmodule Pleroma.Web do
   defmacro __using__(which) when is_atom(which) do
     apply(__MODULE__, which, [])
   end
-
-  def base_url do
-    Pleroma.Web.Endpoint.url()
-  end
-
-  # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
-  def get_api_routes do
-    Pleroma.Web.Router.__routes__()
-    |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
-    |> Enum.map(fn r ->
-      r.path
-      |> String.split("/", trim: true)
-      |> List.first()
-    end)
-    |> Enum.uniq()
-  end
 end