defmodule Pleroma.Web.MastodonAPI.DomainBlockController do
use Pleroma.Web, :controller
+ alias Pleroma.Plugs.OAuthScopesPlug
alias Pleroma.User
+ plug(
+ OAuthScopesPlug,
+ %{scopes: ["follow", "read:blocks"]} when action == :index
+ )
+
+ plug(
+ OAuthScopesPlug,
+ %{scopes: ["follow", "write:blocks"]} when action != :index
+ )
+
+ plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug)
+
@doc "GET /api/v1/domain_blocks"
- def index(%{assigns: %{user: %{info: info}}} = conn, _) do
- json(conn, Map.get(info, :domain_blocks, []))
+ def index(%{assigns: %{user: user}} = conn, _) do
+ json(conn, Map.get(user, :domain_blocks, []))
end
@doc "POST /api/v1/domain_blocks"