fix(migration): leave ConfigDB upload configs without filters alone

Keyword.update/4 added filters: [] to a Pleroma.Upload ConfigDB entry
without a :filters key, which would hide the filters from the config
file, GPS stripping included. Only rewrite lists that change.
This commit is contained in:
Lain Soykaf 2026-10-27 18:14:34 +04:00
commit ce8b2276c2
No known key found for this signature in database
2 changed files with 22 additions and 13 deletions

View file

@ -22,20 +22,20 @@ defmodule Pleroma.Repo.Migrations.UploadFilterExiftoolToExif do
def down, do: rename_filters(@down)
# Only touch configs that list filters: adding an empty list would hide the
# filters from the config file.
defp rename_filters(renames) do
case ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}) do
%{value: value} ->
new_value =
Keyword.update(value, :filters, [], fn filters ->
filters
|> Enum.map(&Map.get(renames, &1, &1))
|> Enum.uniq()
end)
ConfigDB.update_or_create(%{group: :pleroma, key: Pleroma.Upload, value: new_value})
_ ->
nil
with %{value: value} <- ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}),
filters when is_list(filters) <- value[:filters],
new_filters when new_filters != filters <-
filters |> Enum.map(&Map.get(renames, &1, &1)) |> Enum.uniq() do
ConfigDB.update_or_create(%{
group: :pleroma,
key: Pleroma.Upload,
value: Keyword.put(value, :filters, new_filters)
})
else
_ -> nil
end
end
end