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.UserImportOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
10 import Pleroma.Web.ApiSpec.Helpers
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, [])
18 def follow_operation do
20 tags: ["Data import"],
21 summary: "Import follows",
22 operationId: "UserImportController.follow",
23 requestBody: request_body("Parameters", import_request(), required: true),
26 403 => Operation.response("Error", "application/json", ApiError),
27 500 => Operation.response("Error", "application/json", ApiError)
29 security: [%{"oAuth" => ["write:follow"]}]
33 def blocks_operation do
35 tags: ["Data import"],
36 summary: "Import blocks",
37 operationId: "UserImportController.blocks",
38 requestBody: request_body("Parameters", import_request(), required: true),
41 500 => Operation.response("Error", "application/json", ApiError)
43 security: [%{"oAuth" => ["write:blocks"]}]
47 def mutes_operation do
49 tags: ["Data import"],
50 summary: "Import mutes",
51 operationId: "UserImportController.mutes",
52 requestBody: request_body("Parameters", import_request(), required: true),
55 500 => Operation.response("Error", "application/json", ApiError)
57 security: [%{"oAuth" => ["write:mutes"]}]
61 defp import_request do
68 "STRING or FILE containing a whitespace-separated list of accounts to import.",
70 %Schema{type: :string, format: :binary},
71 %Schema{type: :string}
79 Operation.response("Ok", "application/json", %Schema{type: :string, example: "ok"})