forked from AkkomaGang/akkoma
Merge branch 'config-changes' into 'develop'
Config changes Closes #1547 See merge request pleroma/pleroma!2174
This commit is contained in:
commit
5499f172b2
4 changed files with 35 additions and 57 deletions
|
@ -871,7 +871,7 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :limit_to_local_content,
|
key: :limit_to_local_content,
|
||||||
type: [:atom, false],
|
type: {:dropdown, :atom},
|
||||||
description:
|
description:
|
||||||
"Limit unauthenticated users to search for local statutes and users only. Default: `:unauthenticated`.",
|
"Limit unauthenticated users to search for local statutes and users only. Default: `:unauthenticated`.",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
|
@ -942,7 +942,7 @@
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :level,
|
key: :level,
|
||||||
type: :atom,
|
type: {:dropdown, :atom},
|
||||||
description: "Log level",
|
description: "Log level",
|
||||||
suggestions: [:debug, :info, :warn, :error]
|
suggestions: [:debug, :info, :warn, :error]
|
||||||
},
|
},
|
||||||
|
@ -974,7 +974,7 @@
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :level,
|
key: :level,
|
||||||
type: :atom,
|
type: {:dropdown, :atom},
|
||||||
description: "Log level",
|
description: "Log level",
|
||||||
suggestions: [:debug, :info, :warn, :error]
|
suggestions: [:debug, :info, :warn, :error]
|
||||||
},
|
},
|
||||||
|
@ -998,7 +998,7 @@
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :level,
|
key: :level,
|
||||||
type: :atom,
|
type: {:dropdown, :atom},
|
||||||
description: "Log level",
|
description: "Log level",
|
||||||
suggestions: [:debug, :info, :warn, :error]
|
suggestions: [:debug, :info, :warn, :error]
|
||||||
},
|
},
|
||||||
|
@ -1969,7 +1969,7 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :verbose,
|
key: :verbose,
|
||||||
type: [:atom, false],
|
type: {:dropdown, :atom},
|
||||||
description: "Logs verbose mode",
|
description: "Logs verbose mode",
|
||||||
suggestions: [false, :error, :warn, :info, :debug]
|
suggestions: [false, :error, :warn, :info, :debug]
|
||||||
},
|
},
|
||||||
|
@ -2178,7 +2178,7 @@
|
||||||
%{
|
%{
|
||||||
key: :new_window,
|
key: :new_window,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Set to `false` to remove target='_blank' attribute"
|
description: "Link urls will open in new window/tab"
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :truncate,
|
key: :truncate,
|
||||||
|
|
|
@ -689,7 +689,6 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
||||||
- Response:
|
- Response:
|
||||||
- On failure:
|
- On failure:
|
||||||
- 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
|
- 400 Bad Request `"To use this endpoint you need to enable configuration from database."`
|
||||||
- 400 Bad Request `"To use configuration from database migrate your settings to database."`
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|
|
@ -797,29 +797,16 @@ def config_show(conn, %{"only_db" => true}) do
|
||||||
with :ok <- configurable_from_database(conn) do
|
with :ok <- configurable_from_database(conn) do
|
||||||
configs = Pleroma.Repo.all(ConfigDB)
|
configs = Pleroma.Repo.all(ConfigDB)
|
||||||
|
|
||||||
if configs == [] do
|
|
||||||
errors(
|
|
||||||
conn,
|
|
||||||
{:error, "To use configuration from database migrate your settings to database."}
|
|
||||||
)
|
|
||||||
else
|
|
||||||
conn
|
conn
|
||||||
|> put_view(ConfigView)
|
|> put_view(ConfigView)
|
||||||
|> render("index.json", %{configs: configs})
|
|> render("index.json", %{configs: configs})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def config_show(conn, _params) do
|
def config_show(conn, _params) do
|
||||||
with :ok <- configurable_from_database(conn) do
|
with :ok <- configurable_from_database(conn) do
|
||||||
configs = ConfigDB.get_all_as_keyword()
|
configs = ConfigDB.get_all_as_keyword()
|
||||||
|
|
||||||
if configs == [] do
|
|
||||||
errors(
|
|
||||||
conn,
|
|
||||||
{:error, "To use configuration from database migrate your settings to database."}
|
|
||||||
)
|
|
||||||
else
|
|
||||||
merged =
|
merged =
|
||||||
Pleroma.Config.Holder.config()
|
Pleroma.Config.Holder.config()
|
||||||
|> ConfigDB.merge(configs)
|
|> ConfigDB.merge(configs)
|
||||||
|
@ -854,7 +841,6 @@ def config_show(conn, _params) do
|
||||||
json(conn, %{configs: merged})
|
json(conn, %{configs: merged})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def config_update(conn, %{"configs" => configs}) do
|
def config_update(conn, %{"configs" => configs}) do
|
||||||
with :ok <- configurable_from_database(conn) do
|
with :ok <- configurable_from_database(conn) do
|
||||||
|
|
|
@ -1899,13 +1899,6 @@ test "when configuration from database is off", %{conn: conn} do
|
||||||
"To use this endpoint you need to enable configuration from database."
|
"To use this endpoint you need to enable configuration from database."
|
||||||
end
|
end
|
||||||
|
|
||||||
test "without any settings in db", %{conn: conn} do
|
|
||||||
conn = get(conn, "/api/pleroma/admin/config")
|
|
||||||
|
|
||||||
assert json_response(conn, 400) ==
|
|
||||||
"To use configuration from database migrate your settings to database."
|
|
||||||
end
|
|
||||||
|
|
||||||
test "with settings only in db", %{conn: conn} do
|
test "with settings only in db", %{conn: conn} do
|
||||||
config1 = insert(:config)
|
config1 = insert(:config)
|
||||||
config2 = insert(:config)
|
config2 = insert(:config)
|
||||||
|
|
Loading…
Reference in a new issue