forked from AkkomaGang/akkoma
removing confusing error
This commit is contained in:
parent
15cb1f6804
commit
c85aa6e87f
3 changed files with 29 additions and 51 deletions
|
@ -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,16 +797,9 @@ 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
|
conn
|
||||||
errors(
|
|> put_view(ConfigView)
|
||||||
conn,
|
|> render("index.json", %{configs: configs})
|
||||||
{:error, "To use configuration from database migrate your settings to database."}
|
|
||||||
)
|
|
||||||
else
|
|
||||||
conn
|
|
||||||
|> put_view(ConfigView)
|
|
||||||
|> render("index.json", %{configs: configs})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -814,45 +807,38 @@ 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
|
merged =
|
||||||
errors(
|
Pleroma.Config.Holder.config()
|
||||||
conn,
|
|> ConfigDB.merge(configs)
|
||||||
{:error, "To use configuration from database migrate your settings to database."}
|
|> Enum.map(fn {group, values} ->
|
||||||
)
|
Enum.map(values, fn {key, value} ->
|
||||||
else
|
db =
|
||||||
merged =
|
if configs[group][key] do
|
||||||
Pleroma.Config.Holder.config()
|
ConfigDB.get_db_keys(configs[group][key], key)
|
||||||
|> ConfigDB.merge(configs)
|
end
|
||||||
|> Enum.map(fn {group, values} ->
|
|
||||||
Enum.map(values, fn {key, value} ->
|
|
||||||
db =
|
|
||||||
if configs[group][key] do
|
|
||||||
ConfigDB.get_db_keys(configs[group][key], key)
|
|
||||||
end
|
|
||||||
|
|
||||||
db_value = configs[group][key]
|
db_value = configs[group][key]
|
||||||
|
|
||||||
merged_value =
|
merged_value =
|
||||||
if !is_nil(db_value) and Keyword.keyword?(db_value) and
|
if !is_nil(db_value) and Keyword.keyword?(db_value) and
|
||||||
ConfigDB.sub_key_full_update?(group, key, Keyword.keys(db_value)) do
|
ConfigDB.sub_key_full_update?(group, key, Keyword.keys(db_value)) do
|
||||||
ConfigDB.merge_group(group, key, value, db_value)
|
ConfigDB.merge_group(group, key, value, db_value)
|
||||||
else
|
else
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
setting = %{
|
setting = %{
|
||||||
group: ConfigDB.convert(group),
|
group: ConfigDB.convert(group),
|
||||||
key: ConfigDB.convert(key),
|
key: ConfigDB.convert(key),
|
||||||
value: ConfigDB.convert(merged_value)
|
value: ConfigDB.convert(merged_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if db, do: Map.put(setting, :db, db), else: setting
|
if db, do: Map.put(setting, :db, db), else: setting
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|> List.flatten()
|
end)
|
||||||
|
|> List.flatten()
|
||||||
|
|
||||||
json(conn, %{configs: merged})
|
json(conn, %{configs: merged})
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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