akkoma/lib/pleroma/web/admin_api/views/config_view.ex

31 lines
765 B
Elixir
Raw Normal View History

# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.ConfigView do
use Pleroma.Web, :view
2020-05-31 01:46:02 -06:00
alias Pleroma.ConfigDB
def render("index.json", %{configs: configs} = params) do
2020-05-31 01:46:02 -06:00
%{
configs: render_many(configs, __MODULE__, "show.json", as: :config),
need_reboot: params[:need_reboot]
}
end
def render("show.json", %{config: config}) do
2020-01-17 08:08:45 -07:00
map = %{
2020-05-31 01:46:02 -06:00
key: ConfigDB.to_json_types(config.key),
group: ConfigDB.to_json_types(config.group),
value: ConfigDB.to_json_types(config.value)
}
2020-01-17 08:08:45 -07:00
if config.db != [] do
Map.put(map, :db, config.db)
else
map
end
end
end