aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-04-14 09:39:57 -0500
committerMark Felder <feld@feld.me>2021-04-14 09:39:57 -0500
commitf95b52255b2d7373a3e0bf4adff81f83c080b2ef (patch)
treef157cca32923f2e82a1ff7dbb906a297f20eaf27 /lib
parentc3b8c77967b0c42f93286f864236b7d6f1471c13 (diff)
downloadpleroma-f95b52255b2d7373a3e0bf4adff81f83c080b2ef.tar.gz
Revert guards on string_to_elixir_types/1, remove unnecessary assignment in test
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/config_db.ex12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/pleroma/config_db.ex b/lib/pleroma/config_db.ex
index eeeb026c1..cb57673e3 100644
--- 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]))
-
- 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},
@@ -327,7 +325,7 @@ defmodule Pleroma.ConfigDB do
@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
@@ -341,9 +339,9 @@ defmodule Pleroma.ConfigDB do
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
String.to_existing_atom("Elixir." <> value)
else
@@ -351,8 +349,6 @@ defmodule Pleroma.ConfigDB do
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