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 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
22 summary: "Resend confirmation email. Expects `email` or `nickname`",
23 operationId: "PleromaAPI.AccountController.confirmation_resend",
25 Operation.parameter(:email, :query, :string, "Email of that needs to be verified",
26 example: "cofe@cofe.io"
32 "Nickname of user that needs to be verified",
37 204 => no_content_response()
42 def favourites_operation do
45 summary: "Returns favorites timeline of any user",
46 operationId: "PleromaAPI.AccountController.favourites",
47 parameters: [id_param() | pagination_params()],
48 security: [%{"oAuth" => ["read:favourites"]}],
54 StatusOperation.array_of_statuses()
56 403 => Operation.response("Forbidden", "application/json", ApiError),
57 404 => Operation.response("Not Found", "application/json", ApiError)
62 def subscribe_operation do
65 summary: "Subscribe to receive notifications for all statuses posted by a user",
66 operationId: "PleromaAPI.AccountController.subscribe",
67 parameters: [id_param()],
68 security: [%{"oAuth" => ["follow", "write:follows"]}],
70 200 => Operation.response("Relationship", "application/json", AccountRelationship),
71 404 => Operation.response("Not Found", "application/json", ApiError)
76 def unsubscribe_operation do
79 summary: "Unsubscribe to stop receiving notifications from user statuses",
80 operationId: "PleromaAPI.AccountController.unsubscribe",
81 parameters: [id_param()],
82 security: [%{"oAuth" => ["follow", "write:follows"]}],
84 200 => Operation.response("Relationship", "application/json", AccountRelationship),
85 404 => Operation.response("Not Found", "application/json", ApiError)
91 Operation.parameter(:id, :path, FlakeID, "Account ID",
92 example: "9umDrYheeY451cQnEe",