diff options
author | Ilja <ilja@ilja.space> | 2022-02-20 15:44:40 +0100 |
---|---|---|
committer | Ilja <ilja@ilja.space> | 2022-07-01 12:15:02 +0200 |
commit | cc5686bbd6f8a5fbf345de2f54a9e07ec7ff2b5c (patch) | |
tree | b79e2836330b68637694b47e9546673869437312 /priv | |
parent | d0d48a9e8832ed81e67126a2af019981cb761a2b (diff) | |
download | pleroma-cc5686bbd6f8a5fbf345de2f54a9e07ec7ff2b5c.tar.gz pleroma-cc5686bbd6f8a5fbf345de2f54a9e07ec7ff2b5c.zip |
Migration for exiftool filter
Rename to Exiftool.StripLocation
Diffstat (limited to 'priv')
-rw-r--r-- | priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs b/priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs new file mode 100644 index 000000000..7afb7479a --- /dev/null +++ b/priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs @@ -0,0 +1,34 @@ +defmodule Pleroma.Repo.Migrations.UploadFilterExiftoolToExiftoolStripLocation do + use Ecto.Migration + + alias Pleroma.ConfigDB + + def up, + do: + ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}) + |> update_filtername( + Pleroma.Upload.Filter.Exiftool, + Pleroma.Upload.Filter.Exiftool.StripLocation + ) + + def down, + do: + ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload}) + |> update_filtername( + Pleroma.Upload.Filter.Exiftool.StripLocation, + Pleroma.Upload.Filter.Exiftool + ) + + defp update_filtername(%{value: value}, from_filtername, to_filtername) do + new_filters = + value[:filters] + |> Enum.map(fn + ^from_filtername -> to_filtername + filter -> filter + end) + + new_value = value |> Keyword.update(:filters, [], fn _ -> new_filters end) + + ConfigDB.update_or_create(%{group: :pleroma, key: Pleroma.Upload, value: new_value}) + end +end |