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 500 => Operation.response("Error", "application/json", ApiError)
28 security: [%{"oAuth" => ["write:follow"]}]
32 def blocks_operation do
34 tags: ["Data import"],
35 summary: "Import blocks",
36 operationId: "UserImportController.blocks",
37 requestBody: request_body("Parameters", import_request(), required: true),
40 500 => Operation.response("Error", "application/json", ApiError)
42 security: [%{"oAuth" => ["write:blocks"]}]
46 def mutes_operation do
48 tags: ["Data import"],
49 summary: "Import mutes",
50 operationId: "UserImportController.mutes",
51 requestBody: request_body("Parameters", import_request(), required: true),
54 500 => Operation.response("Error", "application/json", ApiError)
56 security: [%{"oAuth" => ["write:mutes"]}]
60 defp import_request do
67 "STRING or FILE containing a whitespace-separated list of accounts to import.",
69 %Schema{type: :string, format: :binary},
70 %Schema{type: :string}
78 Operation.response("Ok", "application/json", %Schema{type: :string, example: "ok"})