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.AccountOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Helpers
9 alias Pleroma.Web.ApiSpec.Schemas.Account
10 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateRequest
11 alias Pleroma.Web.ApiSpec.Schemas.AccountCreateResponse
12 alias Pleroma.Web.ApiSpec.Schemas.AccountRelationshipsResponse
13 alias Pleroma.Web.ApiSpec.Schemas.AccountUpdateCredentialsRequest
15 @spec open_api_operation(atom) :: Operation.t()
16 def open_api_operation(action) do
17 operation = String.to_existing_atom("#{action}_operation")
18 apply(__MODULE__, operation, [])
21 @spec create_operation() :: Operation.t()
22 def create_operation do
25 summary: "Register an account",
27 "Creates a user and account records. Returns an account access token for the app that initiated the request. The app should save this token for later, and should wait for the user to confirm their account by clicking a link in their email inbox.",
28 operationId: "AccountController.create",
29 requestBody: Helpers.request_body("Parameters", AccountCreateRequest, required: true),
31 200 => Operation.response("Account", "application/json", AccountCreateResponse)
36 def verify_credentials_operation do
39 description: "Test to make sure that the user token works.",
40 summary: "Verify account credentials",
41 operationId: "AccountController.verify_credentials",
42 security: [%{"oAuth" => ["read:accounts"]}],
44 200 => Operation.response("Account", "application/json", Account)
49 def update_credentials_operation do
52 summary: "Update account credentials",
53 description: "Update the user's display and preferences.",
54 operationId: "AccountController.update_credentials",
55 security: [%{"oAuth" => ["write:accounts"]}],
57 Helpers.request_body("Parameters", AccountUpdateCredentialsRequest, required: true),
59 200 => Operation.response("Account", "application/json", Account)
64 def relationships_operation do
67 summary: "Check relationships to other accounts",
68 operationId: "AccountController.relationships",
69 description: "Find out whether a given account is followed, blocked, muted, etc.",
70 security: [%{"oAuth" => ["read:follows"]}],
76 oneOf: [%Schema{type: :array, items: %Schema{type: :string}}, %Schema{type: :string}]
83 200 => Operation.response("Account", "application/json", AccountRelationshipsResponse)
92 operationId: "AccountController.show",
93 description: "View information about a profile.",
95 Operation.parameter(:id, :path, :string, "Account ID or nickname",
101 200 => Operation.response("Account", "application/json", Account)
106 def statuses_operation do
110 def followers_operation do
114 def following_operation, do: :ok
115 def lists_operation, do: :ok
116 def follow_operation, do: :ok
117 def unfollow_operation, do: :ok
118 def mute_operation, do: :ok
119 def unmute_operation, do: :ok
120 def block_operation, do: :ok
121 def unblock_operation, do: :ok
122 def follows_operation, do: :ok
123 def mutes_operation, do: :ok
124 def blocks_operation, do: :ok
125 def endorsements_operation, do: :ok