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.PleromaAccountOperation do
6 alias OpenApiSpex.Operation
7 alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
9 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
10 alias Pleroma.Web.ApiSpec.StatusOperation
12 import Pleroma.Web.ApiSpec.Helpers
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
19 def confirmation_resend_operation do
21 tags: ["Account credentials"],
22 summary: "Resend confirmation email",
23 description: "Expects `email` or `nickname`.",
24 operationId: "PleromaAPI.AccountController.confirmation_resend",
26 Operation.parameter(:email, :query, :string, "Email of that needs to be verified",
27 example: "cofe@cofe.io"
33 "Nickname of user that needs to be verified",
38 204 => no_content_response()
43 def favourites_operation do
45 tags: ["Retrieve account information"],
48 "Only returns data if the user has opted into sharing it. See `hide_favorites` in [Update account credentials](#operation/AccountController.update_credentials).",
49 operationId: "PleromaAPI.AccountController.favourites",
50 parameters: [id_param() | pagination_params()],
51 security: [%{"oAuth" => ["read:favourites"]}],
57 StatusOperation.array_of_statuses()
59 403 => Operation.response("Forbidden", "application/json", ApiError),
60 404 => Operation.response("Not Found", "application/json", ApiError)
65 def subscribe_operation do
67 tags: ["Account actions"],
69 description: "Receive notifications for all statuses posted by the account.",
70 operationId: "PleromaAPI.AccountController.subscribe",
71 parameters: [id_param()],
72 security: [%{"oAuth" => ["follow", "write:follows"]}],
74 200 => Operation.response("Relationship", "application/json", AccountRelationship),
75 404 => Operation.response("Not Found", "application/json", ApiError)
80 def unsubscribe_operation do
82 tags: ["Account actions"],
83 summary: "Unsubscribe",
84 description: "Stop receiving notifications for all statuses posted by the account.",
85 operationId: "PleromaAPI.AccountController.unsubscribe",
86 parameters: [id_param()],
87 security: [%{"oAuth" => ["follow", "write:follows"]}],
89 200 => Operation.response("Relationship", "application/json", AccountRelationship),
90 404 => Operation.response("Not Found", "application/json", ApiError)
96 Operation.parameter(:id, :path, FlakeID, "Account ID",
97 example: "9umDrYheeY451cQnEe",