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.PleromaAccountOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.Account
9 alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
10 alias Pleroma.Web.ApiSpec.Schemas.ApiError
11 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
12 alias Pleroma.Web.ApiSpec.StatusOperation
14 import Pleroma.Web.ApiSpec.Helpers
16 def open_api_operation(action) do
17 operation = String.to_existing_atom("#{action}_operation")
18 apply(__MODULE__, operation, [])
21 def confirmation_resend_operation do
24 summary: "Resend confirmation email. Expects `email` or `nickname`",
25 operationId: "PleromaAPI.AccountController.confirmation_resend",
27 Operation.parameter(:email, :query, :string, "Email of that needs to be verified",
28 example: "cofe@cofe.io"
34 "Nickname of user that needs to be verified",
39 204 => no_content_response()
44 def favourites_operation do
47 summary: "Returns favorites timeline of any user",
48 operationId: "PleromaAPI.AccountController.favourites",
49 parameters: [id_param() | pagination_params()],
50 security: [%{"oAuth" => ["read:favourites"]}],
56 StatusOperation.array_of_statuses()
58 403 => Operation.response("Forbidden", "application/json", ApiError),
59 404 => Operation.response("Not Found", "application/json", ApiError)
64 def subscribe_operation do
67 summary: "Subscribe to receive notifications for all statuses posted by a user",
68 operationId: "PleromaAPI.AccountController.subscribe",
69 parameters: [id_param()],
70 security: [%{"oAuth" => ["follow", "write:follows"]}],
72 200 => Operation.response("Relationship", "application/json", AccountRelationship),
73 404 => Operation.response("Not Found", "application/json", ApiError)
78 def unsubscribe_operation do
81 summary: "Unsubscribe to stop receiving notifications from user statuses",
82 operationId: "PleromaAPI.AccountController.unsubscribe",
83 parameters: [id_param()],
84 security: [%{"oAuth" => ["follow", "write:follows"]}],
86 200 => Operation.response("Relationship", "application/json", AccountRelationship),
87 404 => Operation.response("Not Found", "application/json", ApiError)
92 def add_aliases_operation do
95 summary: "Add ActivityPub aliases",
96 operationId: "PleromaAPI.AccountController.add_aliases",
97 requestBody: request_body("Parameters", alias_request(), required: true),
98 security: [%{"oAuth" => ["write:accounts"]}],
100 200 => Operation.response("Account", "application/json", Account),
101 403 => Operation.response("Forbidden", "application/json", ApiError)
106 def delete_aliases_operation do
109 summary: "Delete ActivityPub aliases",
110 operationId: "PleromaAPI.AccountController.delete_aliases",
111 requestBody: request_body("Parameters", alias_request(), required: true),
112 security: [%{"oAuth" => ["write:accounts"]}],
114 200 => Operation.response("Account", "application/json", Account)
120 Operation.parameter(:id, :path, FlakeID, "Account ID",
121 example: "9umDrYheeY451cQnEe",
126 defp alias_request do
128 title: "AccountAliasRequest",
129 description: "POST body for adding/deleting AP aliases",
134 items: %Schema{type: :string}
138 "aliases" => ["https://beepboop.social/users/beep", "https://mushroom.kingdom/users/toad"]