mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 08:16:16 +00:00
Merge branch 'fix/admin-configure' into 'develop'
don't delete config settings on admin update See merge request pleroma/pleroma!1340
This commit is contained in:
commit
6587e2358c
|
@ -579,7 +579,7 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
||||||
## `/api/pleroma/admin/config`
|
## `/api/pleroma/admin/config`
|
||||||
### Update config settings
|
### Update config settings
|
||||||
Module name can be passed as string, which starts with `Pleroma`, e.g. `"Pleroma.Upload"`.
|
Module name can be passed as string, which starts with `Pleroma`, e.g. `"Pleroma.Upload"`.
|
||||||
Atom or boolean value can be passed with `:` in the beginning, e.g. `":true"`, `":upload"`.
|
Atom or boolean value can be passed with `:` in the beginning, e.g. `":true"`, `":upload"`. For keys it is not needed.
|
||||||
Integer with `i:`, e.g. `"i:150"`.
|
Integer with `i:`, e.g. `"i:150"`.
|
||||||
Tuple with more than 2 values with `{"tuple": ["first_val", Pleroma.Module, []]}`.
|
Tuple with more than 2 values with `{"tuple": ["first_val", Pleroma.Module, []]}`.
|
||||||
`{"tuple": ["some_string", "Pleroma.Some.Module", []]}` will be converted to `{"some_string", Pleroma.Some.Module, []}`.
|
`{"tuple": ["some_string", "Pleroma.Some.Module", []]}` will be converted to `{"some_string", Pleroma.Some.Module, []}`.
|
||||||
|
|
|
@ -36,9 +36,11 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(["migrate_from_db", env]) do
|
def run(["migrate_from_db", env, delete?]) do
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
|
||||||
|
delete? = if delete? == "true", do: true, else: false
|
||||||
|
|
||||||
if Pleroma.Config.get([:instance, :dynamic_configuration]) do
|
if Pleroma.Config.get([:instance, :dynamic_configuration]) do
|
||||||
config_path = "config/#{env}.exported_from_db.secret.exs"
|
config_path = "config/#{env}.exported_from_db.secret.exs"
|
||||||
|
|
||||||
|
@ -47,7 +49,11 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
|
|
||||||
Repo.all(Config)
|
Repo.all(Config)
|
||||||
|> Enum.each(fn config ->
|
|> Enum.each(fn config ->
|
||||||
mark = if String.starts_with?(config.key, "Pleroma."), do: ",", else: ":"
|
mark =
|
||||||
|
if String.starts_with?(config.key, "Pleroma.") or
|
||||||
|
String.starts_with?(config.key, "Ueberauth"),
|
||||||
|
do: ",",
|
||||||
|
else: ":"
|
||||||
|
|
||||||
IO.write(
|
IO.write(
|
||||||
file,
|
file,
|
||||||
|
@ -56,8 +62,10 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
}\r\n"
|
}\r\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
{:ok, _} = Repo.delete(config)
|
if delete? do
|
||||||
Mix.shell().info("#{config.key} deleted from DB.")
|
{:ok, _} = Repo.delete(config)
|
||||||
|
Mix.shell().info("#{config.key} deleted from DB.")
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
File.close(file)
|
File.close(file)
|
||||||
|
|
|
@ -388,7 +388,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
|> Enum.reject(&is_nil(&1))
|
|> Enum.reject(&is_nil(&1))
|
||||||
|
|
||||||
Pleroma.Config.TransferTask.load_and_update_env()
|
Pleroma.Config.TransferTask.load_and_update_env()
|
||||||
Mix.Tasks.Pleroma.Config.run(["migrate_from_db", Pleroma.Config.get(:env)])
|
Mix.Tasks.Pleroma.Config.run(["migrate_from_db", Pleroma.Config.get(:env), "false"])
|
||||||
updated
|
updated
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -51,7 +51,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
||||||
value: [key: "valu2", key2: [Pleroma.Repo]]
|
value: [key: "valu2", key2: [Pleroma.Repo]]
|
||||||
})
|
})
|
||||||
|
|
||||||
Mix.Tasks.Pleroma.Config.run(["migrate_from_db", "temp"])
|
Mix.Tasks.Pleroma.Config.run(["migrate_from_db", "temp", "true"])
|
||||||
|
|
||||||
assert Repo.all(Config) == []
|
assert Repo.all(Config) == []
|
||||||
assert File.exists?(temp_file)
|
assert File.exists?(temp_file)
|
||||||
|
|
Loading…
Reference in a new issue