spc-pleroma/lib/pleroma/web/api_spec/operations/admin/relay_operation.ex

105 lines
2.6 KiB
Elixir
Raw Normal View History

# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ApiSpec.Admin.RelayOperation do
alias OpenApiSpex.Operation
alias OpenApiSpex.Schema
import Pleroma.Web.ApiSpec.Helpers
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
apply(__MODULE__, operation, [])
end
def index_operation do
%Operation{
tags: ["Relays"],
summary: "Retrieve a list of relays",
operationId: "AdminAPI.RelayController.index",
security: [%{"oAuth" => ["admin:read"]}],
parameters: admin_api_params(),
responses: %{
200 =>
Operation.response("Response", "application/json", %Schema{
type: :object,
properties: %{
relays: %Schema{
type: :array,
2020-08-18 15:21:34 +00:00
items: relay()
}
}
})
}
}
end
def follow_operation do
%Operation{
tags: ["Relays"],
summary: "Follow a relay",
operationId: "AdminAPI.RelayController.follow",
security: [%{"oAuth" => ["admin:write:follows"]}],
parameters: admin_api_params(),
2020-08-18 15:21:34 +00:00
requestBody: request_body("Parameters", relay_url()),
responses: %{
2020-08-18 15:21:34 +00:00
200 => Operation.response("Status", "application/json", relay())
}
}
end
def unfollow_operation do
%Operation{
tags: ["Relays"],
summary: "Unfollow a relay",
operationId: "AdminAPI.RelayController.unfollow",
security: [%{"oAuth" => ["admin:write:follows"]}],
parameters: admin_api_params(),
requestBody: request_body("Parameters", relay_unfollow()),
responses: %{
200 =>
Operation.response("Status", "application/json", %Schema{
type: :string,
example: "http://mastodon.example.org/users/admin"
})
}
}
end
2020-08-18 15:21:34 +00:00
defp relay do
%Schema{
type: :object,
properties: %{
actor: %Schema{
type: :string,
example: "https://example.com/relay"
},
followed_back: %Schema{
type: :boolean,
description: "Is relay followed back by this actor?"
}
}
}
end
defp relay_url do
%Schema{
type: :object,
properties: %{
Pleroma.Web.AdminAPI.RelayController: dialyzer errors lib/pleroma/web/admin_api/controllers/relay_controller.ex:34:no_return Function follow/2 has no local return. ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:38:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, %{:actor => binary(), :followed_back => boolean()} ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:41:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, 500 ) breaks the contract (t(), status()) :: t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:47:no_return Function unfollow/2 has no local return. ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:51:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, _target :: binary() ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:54:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, 500 ) breaks the contract (t(), status()) :: t()
2024-01-28 21:09:55 +00:00
"relay_url" => %Schema{type: :string, format: :uri}
2020-08-18 15:21:34 +00:00
}
}
end
defp relay_unfollow do
%Schema{
type: :object,
properties: %{
Pleroma.Web.AdminAPI.RelayController: dialyzer errors lib/pleroma/web/admin_api/controllers/relay_controller.ex:34:no_return Function follow/2 has no local return. ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:38:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, %{:actor => binary(), :followed_back => boolean()} ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:41:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, 500 ) breaks the contract (t(), status()) :: t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:47:no_return Function unfollow/2 has no local return. ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:51:call The function call will not succeed. Phoenix.Controller.json( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, _target :: binary() ) breaks the contract (Plug.Conn.t(), term()) :: Plug.Conn.t() ________________________________________________________________________________ lib/pleroma/web/admin_api/controllers/relay_controller.ex:54:call The function call will not succeed. Plug.Conn.put_status( _conn :: %{ :assigns => %{:user => _, _ => _}, :body_params => %{:relay_url => _, _ => _}, _ => _ }, 500 ) breaks the contract (t(), status()) :: t()
2024-01-28 21:09:55 +00:00
"relay_url" => %Schema{type: :string, format: :uri},
"force" => %Schema{type: :boolean, default: false}
}
}
end
end