1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.TwitterUtilOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
9 alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
11 def open_api_operation(action) do
12 operation = String.to_existing_atom("#{action}_operation")
13 apply(__MODULE__, operation, [])
16 def emoji_operation do
19 summary: "List all custom emojis",
20 operationId: "UtilController.emoji",
24 Operation.response("List", "application/json", %Schema{
26 additionalProperties: %Schema{
29 image_url: %Schema{type: :string},
30 tags: %Schema{type: :array, items: %Schema{type: :string}}
35 "image_url" => "/emoji/firefox.png",
44 def frontend_configurations_operation do
46 tags: ["Configuration"],
47 summary: "Dump frontend configurations",
48 operationId: "UtilController.frontend_configurations",
52 Operation.response("List", "application/json", %Schema{
54 additionalProperties: %Schema{type: :object}
60 def change_password_operation do
62 tags: ["Account credentials"],
63 summary: "Change account password",
64 security: [%{"oAuth" => ["write:accounts"]}],
65 operationId: "UtilController.change_password",
67 Operation.parameter(:password, :query, :string, "Current password", required: true),
68 Operation.parameter(:new_password, :query, :string, "New password", required: true),
70 :new_password_confirmation,
73 "New password, confirmation",
79 Operation.response("Success", "application/json", %Schema{
81 properties: %{status: %Schema{type: :string, example: "success"}}
83 400 => Operation.response("Error", "application/json", ApiError),
84 403 => Operation.response("Error", "application/json", ApiError)
89 def change_email_operation do
91 tags: ["Account credentials"],
92 summary: "Change account email",
93 security: [%{"oAuth" => ["write:accounts"]}],
94 operationId: "UtilController.change_email",
96 Operation.parameter(:password, :query, :string, "Current password", required: true),
97 Operation.parameter(:email, :query, :string, "New email", required: true)
102 Operation.response("Success", "application/json", %Schema{
104 properties: %{status: %Schema{type: :string, example: "success"}}
106 400 => Operation.response("Error", "application/json", ApiError),
107 403 => Operation.response("Error", "application/json", ApiError)
112 def update_notificaton_settings_operation do
115 summary: "Update Notification Settings",
116 security: [%{"oAuth" => ["write:accounts"]}],
117 operationId: "UtilController.update_notificaton_settings",
120 :block_from_strangers,
123 "blocks notifications from accounts you do not follow"
126 :hide_notification_contents,
129 "removes the contents of a message from the push notification"
135 Operation.response("Success", "application/json", %Schema{
137 properties: %{status: %Schema{type: :string, example: "success"}}
139 400 => Operation.response("Error", "application/json", ApiError)
144 def disable_account_operation do
146 tags: ["Account credentials"],
147 summary: "Disable Account",
148 security: [%{"oAuth" => ["write:accounts"]}],
149 operationId: "UtilController.disable_account",
151 Operation.parameter(:password, :query, :string, "Password")
155 Operation.response("Success", "application/json", %Schema{
157 properties: %{status: %Schema{type: :string, example: "success"}}
159 403 => Operation.response("Error", "application/json", ApiError)
164 def delete_account_operation do
166 tags: ["Account credentials"],
167 summary: "Delete Account",
168 security: [%{"oAuth" => ["write:accounts"]}],
169 operationId: "UtilController.delete_account",
171 Operation.parameter(:password, :query, :string, "Password")
175 Operation.response("Success", "application/json", %Schema{
177 properties: %{status: %Schema{type: :string, example: "success"}}
179 403 => Operation.response("Error", "application/json", ApiError)
184 def captcha_operation do
186 summary: "Get a captcha",
187 operationId: "UtilController.captcha",
190 200 => Operation.response("Success", "application/json", %Schema{type: :object})
195 def healthcheck_operation do
198 summary: "Quick status check on the instance",
199 security: [%{"oAuth" => ["write:accounts"]}],
200 operationId: "UtilController.healthcheck",
203 200 => Operation.response("Healthy", "application/json", %Schema{type: :object}),
205 Operation.response("Disabled or Unhealthy", "application/json", %Schema{type: :object})
210 def remote_subscribe_operation do
213 summary: "Remote Subscribe",
214 operationId: "UtilController.remote_subscribe",
216 responses: %{200 => Operation.response("Web Page", "test/html", %Schema{type: :string})}