Remove Twemoji stuff from MastoFE
[akkoma] / lib / pleroma / web / api_spec / operations / user_import_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.UserImportOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
9
10 import Pleroma.Web.ApiSpec.Helpers
11
12 @spec open_api_operation(atom) :: Operation.t()
13 def open_api_operation(action) do
14 operation = String.to_existing_atom("#{action}_operation")
15 apply(__MODULE__, operation, [])
16 end
17
18 def follow_operation do
19 %Operation{
20 tags: ["Data import"],
21 summary: "Import follows",
22 operationId: "UserImportController.follow",
23 requestBody: request_body("Parameters", import_request(), required: true),
24 responses: %{
25 200 => ok_response(),
26 500 => Operation.response("Error", "application/json", ApiError)
27 },
28 security: [%{"oAuth" => ["write:follow"]}]
29 }
30 end
31
32 def blocks_operation do
33 %Operation{
34 tags: ["Data import"],
35 summary: "Import blocks",
36 operationId: "UserImportController.blocks",
37 requestBody: request_body("Parameters", import_request(), required: true),
38 responses: %{
39 200 => ok_response(),
40 500 => Operation.response("Error", "application/json", ApiError)
41 },
42 security: [%{"oAuth" => ["write:blocks"]}]
43 }
44 end
45
46 def mutes_operation do
47 %Operation{
48 tags: ["Data import"],
49 summary: "Import mutes",
50 operationId: "UserImportController.mutes",
51 requestBody: request_body("Parameters", import_request(), required: true),
52 responses: %{
53 200 => ok_response(),
54 500 => Operation.response("Error", "application/json", ApiError)
55 },
56 security: [%{"oAuth" => ["write:mutes"]}]
57 }
58 end
59
60 defp import_request do
61 %Schema{
62 type: :object,
63 required: [:list],
64 properties: %{
65 list: %Schema{
66 description:
67 "STRING or FILE containing a whitespace-separated list of accounts to import.",
68 anyOf: [
69 %Schema{type: :string, format: :binary},
70 %Schema{type: :string}
71 ]
72 }
73 }
74 }
75 end
76
77 defp ok_response do
78 Operation.response("Ok", "application/json", %Schema{type: :string, example: "ok"})
79 end
80 end