projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request 'exiftool doesn’t support JPEG XL either' (#426) from darkkirb...
[akkoma]
/
lib
/
pleroma
/
config_db.ex
diff --git
a/lib/pleroma/config_db.ex
b/lib/pleroma/config_db.ex
index eeeb026c16de078bd31061f028857938a885c1d0..9e4e6f3ea7ae5b91c4e1e109faef1510a6732e07 100644
(file)
--- a/
lib/pleroma/config_db.ex
+++ b/
lib/pleroma/config_db.ex
@@
-141,9
+141,7
@@
defmodule Pleroma.ConfigDB do
@spec update_or_create(map()) :: {:ok, ConfigDB.t()} | {:error, Changeset.t()}
def update_or_create(params) do
params = Map.put(params, :value, to_elixir_types(params[:value]))
@spec update_or_create(map()) :: {:ok, ConfigDB.t()} | {:error, Changeset.t()}
def update_or_create(params) do
params = Map.put(params, :value, to_elixir_types(params[:value]))
-
- search_opts =
- Map.take(params, [:group, :key]) |> Map.update!(:key, &string_to_elixir_types(&1))
+ search_opts = Map.take(params, [:group, :key])
with %ConfigDB{} = config <- ConfigDB.get_by_params(search_opts),
{_, true, config} <- {:partial_update, can_be_partially_updated?(config), config},
with %ConfigDB{} = config <- ConfigDB.get_by_params(search_opts),
{_, true, config} <- {:partial_update, can_be_partially_updated?(config), config},
@@
-165,7
+163,6
@@
defmodule Pleroma.ConfigDB do
defp only_full_update?(%ConfigDB{group: group, key: key}) do
full_key_update = [
{:pleroma, :ecto_repos},
defp only_full_update?(%ConfigDB{group: group, key: key}) do
full_key_update = [
{:pleroma, :ecto_repos},
- {:quack, :meta},
{:mime, :types},
{:cors_plug, [:max_age, :methods, :expose, :headers]},
{:swarm, :node_blacklist},
{:mime, :types},
{:cors_plug, [:max_age, :methods, :expose, :headers]},
{:swarm, :node_blacklist},
@@
-327,7
+324,7
@@
defmodule Pleroma.ConfigDB do
@spec string_to_elixir_types(String.t()) ::
atom() | Regex.t() | module() | String.t() | no_return()
@spec string_to_elixir_types(String.t()) ::
atom() | Regex.t() | module() | String.t() | no_return()
- def string_to_elixir_types("~r" <> _pattern = regex)
when is_binary(regex)
do
+ def string_to_elixir_types("~r" <> _pattern = regex) do
pattern =
~r/^~r(?'delimiter'[\/|"'([{<]{1})(?'pattern'.+)[\/|"')\]}>]{1}(?'modifier'[uismxfU]*)/u
pattern =
~r/^~r(?'delimiter'[\/|"'([{<]{1})(?'pattern'.+)[\/|"')\]}>]{1}(?'modifier'[uismxfU]*)/u
@@
-341,18
+338,20
@@
defmodule Pleroma.ConfigDB do
end
end
end
end
- def string_to_elixir_types(":" <> atom)
when is_binary(atom)
, do: String.to_atom(atom)
+ def string_to_elixir_types(":" <> atom), do: String.to_atom(atom)
- def string_to_elixir_types(value)
when is_binary(value)
do
+ def string_to_elixir_types(value) do
if module_name?(value) do
if module_name?(value) do
- String.to_existing_atom("Elixir." <> value)
+ try do
+ String.to_existing_atom("Elixir." <> value)
+ rescue
+ ArgumentError -> :invalid_atom
+ end
else
value
end
end
else
value
end
end
- def string_to_elixir_types(value) when is_atom(value), do: value
-
defp parse_host("localhost"), do: :localhost
defp parse_host(host) do
defp parse_host("localhost"), do: :localhost
defp parse_host(host) do