forked from AkkomaGang/akkoma
fix for db key
This commit is contained in:
parent
8023fa48db
commit
dcae5914d1
3 changed files with 23 additions and 2 deletions
|
@ -205,9 +205,14 @@ def delete(params) do
|
||||||
{config, sub_keys} when is_list(sub_keys) <- {config, params[:subkeys]},
|
{config, sub_keys} when is_list(sub_keys) <- {config, params[:subkeys]},
|
||||||
old_value <- from_binary(config.value),
|
old_value <- from_binary(config.value),
|
||||||
keys <- Enum.map(sub_keys, &do_transform_string(&1)),
|
keys <- Enum.map(sub_keys, &do_transform_string(&1)),
|
||||||
new_value <- Keyword.drop(old_value, keys) do
|
{:partial_remove, config, new_value} when new_value != [] <-
|
||||||
|
{:partial_remove, config, Keyword.drop(old_value, keys)} do
|
||||||
ConfigDB.update(config, %{value: new_value})
|
ConfigDB.update(config, %{value: new_value})
|
||||||
else
|
else
|
||||||
|
{:partial_remove, config, []} ->
|
||||||
|
Repo.delete(config)
|
||||||
|
{:ok, nil}
|
||||||
|
|
||||||
{config, nil} ->
|
{config, nil} ->
|
||||||
Repo.delete(config)
|
Repo.delete(config)
|
||||||
{:ok, nil}
|
{:ok, nil}
|
||||||
|
|
|
@ -831,7 +831,7 @@ def config_show(conn, _params) do
|
||||||
Enum.map(values, fn {key, value} ->
|
Enum.map(values, fn {key, value} ->
|
||||||
db =
|
db =
|
||||||
if configs[group][key] do
|
if configs[group][key] do
|
||||||
ConfigDB.get_db_keys(value, key)
|
ConfigDB.get_db_keys(configs[group][key], key)
|
||||||
end
|
end
|
||||||
|
|
||||||
db_value = configs[group][key]
|
db_value = configs[group][key]
|
||||||
|
|
|
@ -1907,6 +1907,22 @@ test "with settings only in db", %{conn: conn} do
|
||||||
assert key2 == config2.key
|
assert key2 == config2.key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "db is added to settings that are in db", %{conn: conn} do
|
||||||
|
_config = insert(:config, key: ":instance", value: ConfigDB.to_binary(name: "Some name"))
|
||||||
|
|
||||||
|
%{"configs" => configs} =
|
||||||
|
conn
|
||||||
|
|> get("/api/pleroma/admin/config")
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
[instance_config] =
|
||||||
|
Enum.filter(configs, fn %{"group" => group, "key" => key} ->
|
||||||
|
group == ":pleroma" and key == ":instance"
|
||||||
|
end)
|
||||||
|
|
||||||
|
assert instance_config["db"] == [":name"]
|
||||||
|
end
|
||||||
|
|
||||||
test "merged default setting with db settings", %{conn: conn} do
|
test "merged default setting with db settings", %{conn: conn} do
|
||||||
config1 = insert(:config)
|
config1 = insert(:config)
|
||||||
config2 = insert(:config)
|
config2 = insert(:config)
|
||||||
|
|
Loading…
Reference in a new issue