1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.DomainMuteOperation do
alias OpenApiSpex.Operation
alias OpenApiSpex.Schema
import Pleroma.Web.ApiSpec.Helpers
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
apply(__MODULE__, operation, [])
end
def index_operation do
%Operation{
tags: ["domain_mutes"],
summary: "Fetch domain mutes",
description: "View domains the user has muted.",
security: [%{"oAuth" => ["follow", "read:mutes"]}],
operationId: "DomainMuteController.index",
responses: %{
200 =>
Operation.response("Domain mutes", "application/json", %Schema{
description: "Response schema for domain mutes",
type: :array,
items: %Schema{type: :string},
example: ["google.com", "facebook.com"]
})
}
}
end
def create_operation do
%Operation{
tags: ["domain_mutes"],
summary: "Mute a domain",
description: """
Mute a domain to:
- hide all posts from it
- hide all notifications from it
""",
operationId: "DomainMuteController.create",
requestBody: domain_mute_request(),
security: [%{"oAuth" => ["follow", "write:mutes"]}],
responses: %{200 => empty_object_response()}
}
end
def delete_operation do
%Operation{
tags: ["domain_mutes"],
summary: "Unmute a domain",
description: "Remove a domain mute, if it exists in the user's array of muted domains.",
operationId: "DomainMuteController.delete",
requestBody: domain_mute_request(),
security: [%{"oAuth" => ["follow", "write:mutes"]}],
responses: %{200 => empty_object_response()}
}
end
defp domain_mute_request do
request_body(
"Parameters",
%Schema{
type: :object,
properties: %{
domain: %Schema{type: :string}
},
required: [:domain]
},
required: true,
example: %{
"domain" => "facebook.com"
}
)
end
end
|