lib/pleroma/web/admin_api/controllers/config_controller.ex:162:call The function call will not succeed. Phoenix.Controller.render( _conn :: %{:body_params => %{:configs => _, _ => _}, _ => _}, <<105, 110, 100, 101, 120, 46, 106, 115, 111, 110>>, %{:configs => [any()], :need_reboot => _} ) will never return since the success typing is: ( %Plug.Conn{ :adapter => {atom(), _}, :assigns => %{atom() => _}, :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _}, :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _}, :halted => boolean(), :host => binary(), :method => binary(), :owner => pid(), :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _}, :path_info => [binary()], :path_params => %{binary() => binary() | [any()] | map()}, :port => char(), :private => %{atom() => _}, :query_params => %Plug.Conn.Unfetched{ :aspect => atom(), binary() => binary() | [any()] | map() }, :query_string => binary(), :remote_ip => {byte(), byte(), byte(), byte()} | {char(), char(), char(), char(), char(), char(), char(), char()}, :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()}, :req_headers => [{_, _}], :request_path => binary(), :resp_body => nil | binary() | maybe_improper_list( binary() | maybe_improper_list(any(), binary() | []) | byte(), binary() | [] ), :resp_cookies => %{binary() => map()}, :resp_headers => [{_, _}], :scheme => :http | :https, :script_name => [binary()], :secret_key_base => nil | binary(), :state => :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded, :status => nil | non_neg_integer() }, atom() | binary(), atom() | binary() | [{_, _}] | map() ) :: %Plug.Conn{ :adapter => {atom(), _}, :assigns => %{atom() => _}, :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _}, :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _}, :halted => boolean(), :host => binary(), :method => binary(), :owner => pid(), :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _}, :path_info => [binary()], :path_params => %{binary() => binary() | [any()] | map()}, :port => char(), :private => %{atom() => _}, :query_params => %Plug.Conn.Unfetched{ :aspect => atom(), binary() => binary() | [any()] | map() }, :query_string => binary(), :remote_ip => {byte(), byte(), byte(), byte()} | {char(), char(), char(), char(), char(), char(), char(), char()}, :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()}, :req_headers => [{_, _}], :request_path => binary(), :resp_body => nil | binary() | maybe_improper_list( binary() | maybe_improper_list(any(), binary() | []) | byte(), binary() | [] ), :resp_cookies => %{binary() => map()}, :resp_headers => [{_, _}], :scheme => :http | :https, :script_name => [binary()], :secret_key_base => nil | binary(), :state => :sent, :status => nil | non_neg_integer() } and the contract is (Plug.Conn.t(), binary() | atom(), Keyword.t() | map()) :: Plug.Conn.t()
146 lines
4.3 KiB
Elixir
146 lines
4.3 KiB
Elixir
# 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.ConfigOperation do
|
|
alias OpenApiSpex.Operation
|
|
alias OpenApiSpex.Schema
|
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
|
|
|
import Pleroma.Web.ApiSpec.Helpers
|
|
|
|
def open_api_operation(action) do
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
apply(__MODULE__, operation, [])
|
|
end
|
|
|
|
def show_operation do
|
|
%Operation{
|
|
tags: ["Instance configuration"],
|
|
summary: "Retrieve instance configuration",
|
|
operationId: "AdminAPI.ConfigController.show",
|
|
parameters: [
|
|
Operation.parameter(
|
|
:only_db,
|
|
:query,
|
|
%Schema{type: :boolean, default: false},
|
|
"Get only saved in database settings"
|
|
)
|
|
| admin_api_params()
|
|
],
|
|
security: [%{"oAuth" => ["admin:read"]}],
|
|
responses: %{
|
|
200 => Operation.response("Config", "application/json", config_response()),
|
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
|
}
|
|
}
|
|
end
|
|
|
|
def update_operation do
|
|
%Operation{
|
|
tags: ["Instance configuration"],
|
|
summary: "Update instance configuration",
|
|
operationId: "AdminAPI.ConfigController.update",
|
|
security: [%{"oAuth" => ["admin:write"]}],
|
|
parameters: admin_api_params(),
|
|
requestBody:
|
|
request_body("Parameters", %Schema{
|
|
type: :object,
|
|
properties: %{
|
|
"configs" => %Schema{
|
|
type: :array,
|
|
items: %Schema{
|
|
type: :object,
|
|
properties: %{
|
|
group: %Schema{type: :string},
|
|
key: %Schema{type: :string},
|
|
value: any(),
|
|
delete: %Schema{type: :boolean},
|
|
subkeys: %Schema{type: :array, items: %Schema{type: :string}}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}),
|
|
responses: %{
|
|
200 => Operation.response("Config", "application/json", config_response()),
|
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
|
}
|
|
}
|
|
end
|
|
|
|
def descriptions_operation do
|
|
%Operation{
|
|
tags: ["Instance configuration"],
|
|
summary: "Retrieve config description",
|
|
operationId: "AdminAPI.ConfigController.descriptions",
|
|
security: [%{"oAuth" => ["admin:read"]}],
|
|
parameters: admin_api_params(),
|
|
responses: %{
|
|
200 =>
|
|
Operation.response("Config Descriptions", "application/json", %Schema{
|
|
type: :array,
|
|
items: %Schema{
|
|
type: :object,
|
|
properties: %{
|
|
group: %Schema{type: :string},
|
|
key: %Schema{type: :string},
|
|
type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
|
|
description: %Schema{type: :string},
|
|
children: %Schema{
|
|
type: :array,
|
|
items: %Schema{
|
|
type: :object,
|
|
properties: %{
|
|
key: %Schema{type: :string},
|
|
type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
|
|
description: %Schema{type: :string},
|
|
suggestions: %Schema{type: :array}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}),
|
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
|
}
|
|
}
|
|
end
|
|
|
|
defp any do
|
|
%Schema{
|
|
oneOf: [
|
|
%Schema{type: :array},
|
|
%Schema{type: :object},
|
|
%Schema{type: :string},
|
|
%Schema{type: :integer},
|
|
%Schema{type: :boolean}
|
|
]
|
|
}
|
|
end
|
|
|
|
defp config_response do
|
|
%Schema{
|
|
type: :object,
|
|
properties: %{
|
|
configs: %Schema{
|
|
type: :array,
|
|
items: %Schema{
|
|
type: :object,
|
|
properties: %{
|
|
group: %Schema{type: :string},
|
|
key: %Schema{type: :string},
|
|
value: any()
|
|
}
|
|
}
|
|
},
|
|
need_reboot: %Schema{
|
|
type: :boolean,
|
|
description:
|
|
"If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect"
|
|
}
|
|
}
|
|
}
|
|
end
|
|
end
|