mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Apply 6 suggestion(s) to 1 file(s)
This commit is contained in:
parent
95e908e4e2
commit
60c4ac0f70
1 changed files with 20 additions and 41 deletions
|
@ -62,7 +62,10 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
group = maybe_atomize(group)
|
group = maybe_atomize(group)
|
||||||
key = maybe_atomize(key)
|
key = maybe_atomize(key)
|
||||||
|
|
||||||
dump_key(group, key)
|
%{group: group, key: key}
|
||||||
|
|> ConfigDB.get_by_params()
|
||||||
|
|> Repo.all()
|
||||||
|
|> Enum.each(&dump/1)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -297,44 +300,27 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp dump_group(group) when is_atom(group) do
|
defp dump_group(group) when is_atom(group) do
|
||||||
ConfigDB
|
%{group: group}
|
||||||
|
|> ConfigDB.get_by_params()
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> Enum.filter(fn x ->
|
|> Enum.each(&dump/1)
|
||||||
if x.group == group do
|
|
||||||
x |> dump
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp group_exists?(group) when is_atom(group) do
|
defp group_exists?(group) do
|
||||||
result =
|
%{group: group}
|
||||||
ConfigDB
|
|> ConfigDB.get_by_params()
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> Enum.filter(fn x ->
|
|> Enum.empty?()
|
||||||
if x.group == group do
|
|
||||||
x
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
unless result == [] do
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_atomize(arg) when is_atom(arg), do: arg
|
defp maybe_atomize(arg) when is_atom(arg), do: arg
|
||||||
|
|
||||||
defp maybe_atomize(arg) when is_binary(arg) do
|
defp maybe_atomize(arg) when is_binary(arg) do
|
||||||
chars = String.codepoints(arg)
|
if Pleroma.ConfigDB.module_name?(arg) do
|
||||||
|
String.to_existing_atom("Elixir." <> arg)
|
||||||
# hack to make sure input like Pleroma.Mailer.Foo is formatted correctly
|
|
||||||
# for matching against values returned by Ecto
|
|
||||||
if "." in chars do
|
|
||||||
:"Elixir.#{arg}"
|
|
||||||
else
|
else
|
||||||
String.to_atom(arg)
|
String.to_atom(arg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp check_configdb(callback) do
|
defp check_configdb(callback) do
|
||||||
|
@ -350,13 +336,9 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
|
|
||||||
defp delete_key(group, key) do
|
defp delete_key(group, key) do
|
||||||
check_configdb(fn ->
|
check_configdb(fn ->
|
||||||
ConfigDB
|
ConfigDB.get_by_params(%{group: group, key: key})
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> Enum.filter(fn x ->
|
|> Enum.each(&delete(&1, true))
|
||||||
if x.group == group and x.key == key do
|
|
||||||
x |> delete(true)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -366,13 +348,10 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
shell_info("The following settings will be removed from ConfigDB:\n")
|
shell_info("The following settings will be removed from ConfigDB:\n")
|
||||||
dump_group(group)
|
dump_group(group)
|
||||||
|
|
||||||
ConfigDB
|
ConfigDB.get_by_params(%{group: group})
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> Enum.filter(fn x ->
|
|> Enum.each(&delete(&1, true))
|
||||||
if x.group == group do
|
|
||||||
x |> delete(true)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
else
|
else
|
||||||
_ -> shell_error("No settings in ConfigDB for #{inspect(group)}. Aborting.")
|
_ -> shell_error("No settings in ConfigDB for #{inspect(group)}. Aborting.")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue