Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / lib / pleroma / web / api_spec / operations / domain_block_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.DomainBlockOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Helpers
9 alias Pleroma.Web.ApiSpec.Schemas.DomainBlockRequest
10 alias Pleroma.Web.ApiSpec.Schemas.DomainBlocksResponse
11
12 def open_api_operation(action) do
13 operation = String.to_existing_atom("#{action}_operation")
14 apply(__MODULE__, operation, [])
15 end
16
17 def index_operation do
18 %Operation{
19 tags: ["domain_blocks"],
20 summary: "Fetch domain blocks",
21 description: "View domains the user has blocked.",
22 security: [%{"oAuth" => ["follow", "read:blocks"]}],
23 operationId: "DomainBlockController.index",
24 responses: %{
25 200 => Operation.response("Domain blocks", "application/json", DomainBlocksResponse)
26 }
27 }
28 end
29
30 def create_operation do
31 %Operation{
32 tags: ["domain_blocks"],
33 summary: "Block a domain",
34 description: """
35 Block a domain to:
36
37 - hide all public posts from it
38 - hide all notifications from it
39 - remove all followers from it
40 - prevent following new users from it (but does not remove existing follows)
41 """,
42 operationId: "DomainBlockController.create",
43 requestBody: Helpers.request_body("Parameters", DomainBlockRequest, required: true),
44 security: [%{"oAuth" => ["follow", "write:blocks"]}],
45 responses: %{
46 200 => Operation.response("Empty object", "application/json", %Schema{type: :object})
47 }
48 }
49 end
50
51 def delete_operation do
52 %Operation{
53 tags: ["domain_blocks"],
54 summary: "Unblock a domain",
55 description: "Remove a domain block, if it exists in the user's array of blocked domains.",
56 operationId: "DomainBlockController.delete",
57 requestBody: Helpers.request_body("Parameters", DomainBlockRequest, required: true),
58 security: [%{"oAuth" => ["follow", "write:blocks"]}],
59 responses: %{
60 200 => Operation.response("Empty object", "application/json", %Schema{type: :object})
61 }
62 }
63 end
64 end