2020-09-07 06:17:30 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 21:38:50 +01:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-09-07 06:17:30 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.UserImportOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
|
|
|
alias OpenApiSpex.Schema
|
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
|
|
|
|
|
|
|
import Pleroma.Web.ApiSpec.Helpers
|
|
|
|
|
|
|
|
@spec open_api_operation(atom) :: Operation.t()
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def follow_operation do
|
|
|
|
%Operation{
|
2021-02-03 13:38:59 +01:00
|
|
|
tags: ["Data import"],
|
|
|
|
summary: "Import follows",
|
2020-09-07 06:17:30 +02:00
|
|
|
operationId: "UserImportController.follow",
|
|
|
|
requestBody: request_body("Parameters", import_request(), required: true),
|
|
|
|
responses: %{
|
|
|
|
200 => ok_response(),
|
2021-02-17 01:07:56 +01:00
|
|
|
403 => Operation.response("Error", "application/json", ApiError),
|
2020-09-07 06:17:30 +02:00
|
|
|
500 => Operation.response("Error", "application/json", ApiError)
|
|
|
|
},
|
|
|
|
security: [%{"oAuth" => ["write:follow"]}]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def blocks_operation do
|
|
|
|
%Operation{
|
2021-02-03 13:38:59 +01:00
|
|
|
tags: ["Data import"],
|
|
|
|
summary: "Import blocks",
|
2020-09-07 06:17:30 +02:00
|
|
|
operationId: "UserImportController.blocks",
|
|
|
|
requestBody: request_body("Parameters", import_request(), required: true),
|
|
|
|
responses: %{
|
|
|
|
200 => ok_response(),
|
|
|
|
500 => Operation.response("Error", "application/json", ApiError)
|
|
|
|
},
|
|
|
|
security: [%{"oAuth" => ["write:blocks"]}]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def mutes_operation do
|
|
|
|
%Operation{
|
2021-02-03 13:38:59 +01:00
|
|
|
tags: ["Data import"],
|
|
|
|
summary: "Import mutes",
|
2020-09-07 06:17:30 +02:00
|
|
|
operationId: "UserImportController.mutes",
|
|
|
|
requestBody: request_body("Parameters", import_request(), required: true),
|
|
|
|
responses: %{
|
|
|
|
200 => ok_response(),
|
|
|
|
500 => Operation.response("Error", "application/json", ApiError)
|
|
|
|
},
|
|
|
|
security: [%{"oAuth" => ["write:mutes"]}]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp import_request do
|
|
|
|
%Schema{
|
|
|
|
type: :object,
|
Pleroma.Web.PleromaAPI.UserImportController: Dialyzer errors
lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex:53:call
The function call will not succeed.
Phoenix.Controller.json(
_conn :: %{
:assigns => %{:user => _, _ => _},
:body_params => %{:list => _, _ => _},
_ => _
},
<<106, 111, 98, 32, 115, 116, 97, 114, 116, 101, 100>>
)
breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
2024-01-27 21:57:21 +01:00
|
|
|
required: ["list"],
|
2020-09-07 06:17:30 +02:00
|
|
|
properties: %{
|
Pleroma.Web.PleromaAPI.UserImportController: Dialyzer errors
lib/pleroma/web/pleroma_api/controllers/user_import_controller.ex:53:call
The function call will not succeed.
Phoenix.Controller.json(
_conn :: %{
:assigns => %{:user => _, _ => _},
:body_params => %{:list => _, _ => _},
_ => _
},
<<106, 111, 98, 32, 115, 116, 97, 114, 116, 101, 100>>
)
breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
2024-01-27 21:57:21 +01:00
|
|
|
"list" => %Schema{
|
2020-09-07 06:17:30 +02:00
|
|
|
description:
|
|
|
|
"STRING or FILE containing a whitespace-separated list of accounts to import.",
|
|
|
|
anyOf: [
|
|
|
|
%Schema{type: :string, format: :binary},
|
|
|
|
%Schema{type: :string}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp ok_response do
|
|
|
|
Operation.response("Ok", "application/json", %Schema{type: :string, example: "ok"})
|
|
|
|
end
|
|
|
|
end
|