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.FollowRequestOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.Account
9 alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
11 def open_api_operation(action) do
12 operation = String.to_existing_atom("#{action}_operation")
13 apply(__MODULE__, operation, [])
16 def index_operation do
18 tags: ["Follow requests"],
19 summary: "Retrieve follow requests",
20 security: [%{"oAuth" => ["read:follows", "follow"]}],
21 operationId: "FollowRequestController.index",
22 parameters: pagination_params(),
25 Operation.response("Array of Account", "application/json", %Schema{
28 example: [Account.schema().example]
34 def authorize_operation do
36 tags: ["Follow requests"],
37 summary: "Accept follow request",
38 operationId: "FollowRequestController.authorize",
39 parameters: [id_param()],
40 security: [%{"oAuth" => ["follow", "write:follows"]}],
42 200 => Operation.response("Relationship", "application/json", AccountRelationship)
47 def reject_operation do
49 tags: ["Follow requests"],
50 summary: "Reject follow request",
51 operationId: "FollowRequestController.reject",
52 parameters: [id_param()],
53 security: [%{"oAuth" => ["follow", "write:follows"]}],
55 200 => Operation.response("Relationship", "application/json", AccountRelationship)
61 Operation.parameter(:id, :path, :string, "Conversation ID",
67 defp pagination_params do
69 Operation.parameter(:max_id, :query, :string, "Return items older than this ID"),
74 "Return the oldest items newer than this ID"
79 %Schema{type: :integer, default: 20},
80 "Maximum number of items to return. Will be ignored if it's more than 40"