03db6c9b838d82b1569a85bb1e485dc2a027f0e4
[akkoma] / lib / pleroma / web / mastodon_api / controllers / domain_block_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MastodonAPI.DomainBlockController do
6 use Pleroma.Web, :controller
7
8 alias Pleroma.User
9
10 @doc "GET /api/v1/domain_blocks"
11 def index(%{assigns: %{user: %{info: info}}} = conn, _) do
12 json(conn, Map.get(info, :domain_blocks, []))
13 end
14
15 @doc "POST /api/v1/domain_blocks"
16 def create(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
17 User.block_domain(blocker, domain)
18 json(conn, %{})
19 end
20
21 @doc "DELETE /api/v1/domain_blocks"
22 def delete(%{assigns: %{user: blocker}} = conn, %{"domain" => domain}) do
23 User.unblock_domain(blocker, domain)
24 json(conn, %{})
25 end
26 end