return db key on update requests
This commit is contained in:
parent
7676ed8239
commit
89e93fb33f
7 changed files with 125 additions and 40 deletions
|
|
@ -16,6 +16,7 @@ defmodule Pleroma.ConfigDB do
|
|||
field(:key, :string)
|
||||
field(:group, :string)
|
||||
field(:value, :binary)
|
||||
field(:db, {:array, :string}, virtual: true, default: [])
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
|
@ -61,6 +62,22 @@ defmodule Pleroma.ConfigDB do
|
|||
|> Repo.update()
|
||||
end
|
||||
|
||||
@spec get_db_keys(ConfigDB.t()) :: [String.t()]
|
||||
def get_db_keys(%ConfigDB{} = config) do
|
||||
config.value
|
||||
|> ConfigDB.from_binary()
|
||||
|> get_db_keys(config.key)
|
||||
end
|
||||
|
||||
@spec get_db_keys(keyword() | any()) :: [String.t()]
|
||||
def get_db_keys(value, key) do
|
||||
if Keyword.keyword?(value) do
|
||||
value |> Keyword.keys() |> Enum.map(&convert(&1))
|
||||
else
|
||||
[convert(key)]
|
||||
end
|
||||
end
|
||||
|
||||
@full_key_update [
|
||||
{:pleroma, :ecto_repos},
|
||||
{:pleroma, :assets},
|
||||
|
|
@ -317,7 +334,7 @@ defmodule Pleroma.ConfigDB do
|
|||
|
||||
@spec is_module_name?(String.t()) :: boolean()
|
||||
def is_module_name?(string) do
|
||||
Regex.match?(~r/^(Pleroma|Phoenix|Tesla|Quack)\./, string) or
|
||||
Regex.match?(~r/^(Pleroma|Phoenix|Tesla|Quack|Ueberauth)\./, string) or
|
||||
string in ["Oban", "Ueberauth", "ExSyslogger"]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ defmodule Pleroma.Config.Loader do
|
|||
# support for Elixir less than 1.9
|
||||
@spec load() :: map()
|
||||
def load do
|
||||
{config, _paths} = load("config/config.exs")
|
||||
{env_config, _paths} = load("config/#{Mix.env()}.exs")
|
||||
config = load("config/config.exs")
|
||||
env_config = load("config/#{Mix.env()}.exs")
|
||||
|
||||
Mix.Config.merge(config, env_config)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -66,7 +66,9 @@ defmodule Pleroma.Config.TransferTask do
|
|||
rescue
|
||||
e ->
|
||||
Logger.warn(
|
||||
"updating env causes error, key: #{inspect(setting.key)}, error: #{inspect(e)}"
|
||||
"updating env causes error, group: #{inspect(setting.group)}, key: #{
|
||||
inspect(setting.key)
|
||||
}, value: #{inspect(ConfigDB.from_binary(setting.value))}, error: #{inspect(e)}"
|
||||
)
|
||||
|
||||
nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue