1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.DomainBlockOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Helpers
10 def open_api_operation(action) do
11 operation = String.to_existing_atom("#{action}_operation")
12 apply(__MODULE__, operation, [])
15 def index_operation do
17 tags: ["domain_blocks"],
18 summary: "Fetch domain blocks",
19 description: "View domains the user has blocked.",
20 security: [%{"oAuth" => ["follow", "read:blocks"]}],
21 operationId: "DomainBlockController.index",
24 Operation.response("Domain blocks", "application/json", %Schema{
25 description: "Response schema for domain blocks",
27 items: %Schema{type: :string},
28 example: ["google.com", "facebook.com"]
34 def create_operation do
36 tags: ["domain_blocks"],
37 summary: "Block a domain",
41 - hide all public posts from it
42 - hide all notifications from it
43 - remove all followers from it
44 - prevent following new users from it (but does not remove existing follows)
46 operationId: "DomainBlockController.create",
47 requestBody: domain_block_request(),
48 security: [%{"oAuth" => ["follow", "write:blocks"]}],
50 200 => Operation.response("Empty object", "application/json", %Schema{type: :object})
55 def delete_operation do
57 tags: ["domain_blocks"],
58 summary: "Unblock a domain",
59 description: "Remove a domain block, if it exists in the user's array of blocked domains.",
60 operationId: "DomainBlockController.delete",
61 requestBody: domain_block_request(),
62 security: [%{"oAuth" => ["follow", "write:blocks"]}],
64 200 => Operation.response("Empty object", "application/json", %Schema{type: :object})
69 defp domain_block_request do
75 domain: %Schema{type: :string}
81 "domain" => "facebook.com"