forked from AkkomaGang/akkoma
merge fix
This commit is contained in:
parent
efb8ef5abe
commit
8023fa48db
2 changed files with 20 additions and 2 deletions
|
@ -102,7 +102,7 @@ def deep_merge(group, key, old_value, new_value) do
|
||||||
|
|
||||||
subkeys = sub_key_full_update(group, key, intersect_keys)
|
subkeys = sub_key_full_update(group, key, intersect_keys)
|
||||||
|
|
||||||
merged_value = DeepMerge.deep_merge(old_value, new_value)
|
merged_value = ConfigDB.merge(old_value, new_value)
|
||||||
|
|
||||||
Enum.reduce(subkeys, merged_value, fn subkey, acc ->
|
Enum.reduce(subkeys, merged_value, fn subkey, acc ->
|
||||||
Keyword.put(acc, subkey, new_value[subkey])
|
Keyword.put(acc, subkey, new_value[subkey])
|
||||||
|
@ -127,6 +127,24 @@ defp sub_key_full_update(group, key, subkeys) do
|
||||||
|> List.flatten()
|
|> List.flatten()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def merge(config1, config2) when is_list(config1) and is_list(config2) do
|
||||||
|
Keyword.merge(config1, config2, fn _, app1, app2 ->
|
||||||
|
if Keyword.keyword?(app1) and Keyword.keyword?(app2) do
|
||||||
|
Keyword.merge(app1, app2, &deep_merge/3)
|
||||||
|
else
|
||||||
|
app2
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp deep_merge(_key, value1, value2) do
|
||||||
|
if Keyword.keyword?(value1) and Keyword.keyword?(value2) do
|
||||||
|
Keyword.merge(value1, value2, &deep_merge/3)
|
||||||
|
else
|
||||||
|
value2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@full_key_update [
|
@full_key_update [
|
||||||
{:pleroma, :ecto_repos},
|
{:pleroma, :ecto_repos},
|
||||||
{:quack, :meta},
|
{:quack, :meta},
|
||||||
|
|
|
@ -826,7 +826,7 @@ def config_show(conn, _params) do
|
||||||
else
|
else
|
||||||
merged =
|
merged =
|
||||||
Pleroma.Config.Holder.config()
|
Pleroma.Config.Holder.config()
|
||||||
|> DeepMerge.deep_merge(configs)
|
|> ConfigDB.merge(configs)
|
||||||
|> Enum.map(fn {group, values} ->
|
|> Enum.map(fn {group, values} ->
|
||||||
Enum.map(values, fn {key, value} ->
|
Enum.map(values, fn {key, value} ->
|
||||||
db =
|
db =
|
||||||
|
|
Loading…
Reference in a new issue