1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 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.AccountOperation
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
23 tags: ["Account credentials"],
24 summary: "Resend confirmation email",
25 description: "Expects `email` or `nickname`.",
26 operationId: "PleromaAPI.AccountController.confirmation_resend",
28 Operation.parameter(:email, :query, :string, "Email of that needs to be verified",
29 example: "cofe@cofe.io"
35 "Nickname of user that needs to be verified",
40 204 => no_content_response()
45 def favourites_operation do
47 tags: ["Retrieve account information"],
50 "Only returns data if the user has opted into sharing it. See `hide_favorites` in [Update account credentials](#operation/AccountController.update_credentials).",
51 operationId: "PleromaAPI.AccountController.favourites",
52 parameters: [id_param() | pagination_params()],
53 security: [%{"oAuth" => ["read:favourites"]}],
59 StatusOperation.array_of_statuses()
61 403 => Operation.response("Forbidden", "application/json", ApiError),
62 404 => Operation.response("Not Found", "application/json", ApiError)
67 def endorsements_operation do
69 tags: ["Retrieve account information"],
70 summary: "Endorsements",
71 description: "Returns endorsed accounts",
72 operationId: "PleromaAPI.AccountController.endorsements",
73 parameters: [with_relationships_param(), id_param()],
79 AccountOperation.array_of_accounts()
81 404 => Operation.response("Not Found", "application/json", ApiError)
86 def subscribe_operation do
88 tags: ["Account actions"],
90 description: "Receive notifications for all statuses posted by the account.",
91 operationId: "PleromaAPI.AccountController.subscribe",
92 parameters: [id_param()],
93 security: [%{"oAuth" => ["follow", "write:follows"]}],
95 200 => Operation.response("Relationship", "application/json", AccountRelationship),
96 404 => Operation.response("Not Found", "application/json", ApiError)
101 def unsubscribe_operation do
103 tags: ["Account actions"],
104 summary: "Unsubscribe",
105 description: "Stop receiving notifications for all statuses posted by the account.",
106 operationId: "PleromaAPI.AccountController.unsubscribe",
107 parameters: [id_param()],
108 security: [%{"oAuth" => ["follow", "write:follows"]}],
110 200 => Operation.response("Relationship", "application/json", AccountRelationship),
111 404 => Operation.response("Not Found", "application/json", ApiError)
116 def birthdays_operation do
118 tags: ["Retrieve account information"],
119 summary: "Birthday reminders",
120 description: "Birthday reminders about users you follow.",
121 operationId: "PleromaAPI.AccountController.birthdays",
126 %Schema{type: :integer},
127 "Day of users' birthdays"
132 %Schema{type: :integer},
133 "Month of users' birthdays"
136 security: [%{"oAuth" => ["read:accounts"]}],
139 Operation.response("Accounts", "application/json", AccountOperation.array_of_accounts())
145 Operation.parameter(:id, :path, FlakeID.schema(), "Account ID",
146 example: "9umDrYheeY451cQnEe",