1 defmodule Pleroma.Repo.Migrations.AutolinkerToLinkify do
7 @autolinker_path %{group: :auto_linker, key: :opts}
8 @linkify_path %{group: :pleroma, key: Pleroma.Formatter}
10 @compat_opts [:class, :rel, :new_window, :truncate, :strip_prefix, :extra]
13 with {:ok, {old, new}} <- maybe_get_params() do
18 defp move_config(%{} = old, %{} = new) do
19 {:ok, _} = ConfigDB.update_or_create(new)
20 {:ok, _} = ConfigDB.delete(old)
24 defp maybe_get_params() do
25 with %ConfigDB{value: opts} <- ConfigDB.get_by_params(@autolinker_path),
26 opts <- transform_opts(opts),
27 %{} = linkify_params <- Map.put(@linkify_path, :value, opts) do
28 {:ok, {@autolinker_path, linkify_params}}
32 defp transform_opts(opts) when is_list(opts) do
35 |> Map.take(@compat_opts)