Unilateral remove from followers (#232)
[akkoma] / lib / pleroma / web / api_spec / operations / pleroma_account_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
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
11
12 import Pleroma.Web.ApiSpec.Helpers
13
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
17 end
18
19 def confirmation_resend_operation do
20 %Operation{
21 tags: ["Account credentials"],
22 summary: "Resend confirmation email",
23 description: "Expects `email` or `nickname`.",
24 operationId: "PleromaAPI.AccountController.confirmation_resend",
25 parameters: [
26 Operation.parameter(:email, :query, :string, "Email of that needs to be verified",
27 example: "cofe@cofe.io"
28 ),
29 Operation.parameter(
30 :nickname,
31 :query,
32 :string,
33 "Nickname of user that needs to be verified",
34 example: "cofefe"
35 )
36 ],
37 responses: %{
38 204 => no_content_response()
39 }
40 }
41 end
42
43 def favourites_operation do
44 %Operation{
45 tags: ["Retrieve account information"],
46 summary: "Favorites",
47 description:
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"]}],
52 responses: %{
53 200 =>
54 Operation.response(
55 "Array of Statuses",
56 "application/json",
57 StatusOperation.array_of_statuses()
58 ),
59 403 => Operation.response("Forbidden", "application/json", ApiError),
60 404 => Operation.response("Not Found", "application/json", ApiError)
61 }
62 }
63 end
64
65 def subscribe_operation do
66 %Operation{
67 tags: ["Account actions"],
68 summary: "Subscribe",
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"]}],
73 responses: %{
74 200 => Operation.response("Relationship", "application/json", AccountRelationship),
75 404 => Operation.response("Not Found", "application/json", ApiError)
76 }
77 }
78 end
79
80 def unsubscribe_operation do
81 %Operation{
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"]}],
88 responses: %{
89 200 => Operation.response("Relationship", "application/json", AccountRelationship),
90 404 => Operation.response("Not Found", "application/json", ApiError)
91 }
92 }
93 end
94
95 defp id_param do
96 Operation.parameter(:id, :path, FlakeID, "Account ID",
97 example: "9umDrYheeY451cQnEe",
98 required: true
99 )
100 end
101 end