1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.DomainBlockController do
6 use Pleroma.Web, :controller
8 alias Pleroma.Plugs.OAuthScopesPlug
13 %{scopes: ["follow", "read:blocks"]} when action == :index
18 %{scopes: ["follow", "write:blocks"]} when action != :index
21 @doc "GET /api/v1/domain_blocks"
22 def index(%{assigns: %{user: %{info: info}}} = conn, _) do
23 json(conn, Map.get(info, :domain_blocks, []))
26 @doc "POST /api/v1/domain_blocks"
27 def create(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
28 User.block_domain(blocker, domain)
32 @doc "DELETE /api/v1/domain_blocks"
33 def delete(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
34 User.unblock_domain(blocker, domain)