projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request 'Add /api/v1/followed_tags' (#410) from followed-tags into develop
[akkoma]
/
lib
/
pleroma
/
web.ex
diff --git
a/lib/pleroma/web.ex
b/lib/pleroma/web.ex
index 0a4c98e4778c4f59d1f4249b7e8590943b94bdc5..24560d4a3da91cc4eab96b910e1329b4ede068b4 100644
(file)
--- a/
lib/pleroma/web.ex
+++ b/
lib/pleroma/web.ex
@@
-28,8
+28,6
@@
defmodule Pleroma.Web do
alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Plugs.PlugHelper
alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Plugs.PlugHelper
- @mix_env Mix.env()
-
def controller do
quote do
use Phoenix.Controller, namespace: Pleroma.Web
def controller do
quote do
use Phoenix.Controller, namespace: Pleroma.Web
@@
-37,9
+35,10
@@
defmodule Pleroma.Web do
import Plug.Conn
import Pleroma.Web.Gettext
import Plug.Conn
import Pleroma.Web.Gettext
- import Pleroma.Web.Router.Helpers
import Pleroma.Web.TranslationHelpers
import Pleroma.Web.TranslationHelpers
+ alias Pleroma.Web.Router.Helpers, as: Routes
+
plug(:set_put_layout)
defp set_put_layout(conn, _) do
plug(:set_put_layout)
defp set_put_layout(conn, _) do
@@
-57,12
+56,23
@@
defmodule Pleroma.Web do
plug_module.skip_plug(conn)
rescue
UndefinedFunctionError ->
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
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 <-
# Executed just before actual controller action, invokes before-action hooks (callbacks)
defp action(conn, params) do
with %{halted: false} = conn <-
@@
-133,7
+143,8
@@
defmodule Pleroma.Web do
import Pleroma.Web.ErrorHelpers
import Pleroma.Web.Gettext
import Pleroma.Web.ErrorHelpers
import Pleroma.Web.Gettext
- import Pleroma.Web.Router.Helpers
+
+ alias Pleroma.Web.Router.Helpers, as: Routes
require Logger
require Logger
@@
-231,23
+242,4
@@
defmodule Pleroma.Web do
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
defmacro __using__(which) when is_atom(which) do
apply(__MODULE__, which, [])
end
-
- def base_url do
- Pleroma.Web.Endpoint.url()
- end
-
- def get_api_routes do
- Pleroma.Web.Router.__routes__()
- |> Enum.reject(fn
- r ->
- r.plug == Pleroma.Web.Fallback.RedirectController or
- String.starts_with?(r.path, "/#{@mix_env}")
- end)
- |> Enum.map(fn r ->
- r.path
- |> String.split("/", trim: true)
- |> List.first()
- end)
- |> Enum.uniq()
- end
end
end