1 defmodule Pleroma.Repo.Migrations.AutolinkerToLinkify do
5 @autolinker_path %{group: :auto_linker, key: :opts}
6 @linkify_path %{group: :pleroma, key: Pleroma.Formatter}
8 @compat_opts [:class, :rel, :new_window, :truncate, :strip_prefix, :extra]
11 with {:ok, {old, new}} <- maybe_get_params() do
16 defp move_config(%{} = old, %{} = new) do
17 {:ok, _} = ConfigDB.update_or_create(new)
18 {:ok, _} = ConfigDB.delete(old)
22 defp maybe_get_params() do
23 with %ConfigDB{value: opts} <- ConfigDB.get_by_params(@autolinker_path),
24 opts <- transform_opts(opts),
25 %{} = linkify_params <- Map.put(@linkify_path, :value, opts) do
26 {:ok, {@autolinker_path, linkify_params}}
30 def transform_opts(opts) when is_list(opts) do
33 |> Map.take(@compat_opts)