logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

20200722185515_fix_malformed_formatter_config.exs (761B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfig do
  5. use Ecto.Migration
  6. alias Pleroma.ConfigDB
  7. @config_path %{group: :pleroma, key: Pleroma.Formatter}
  8. def change do
  9. with %ConfigDB{value: %{} = opts} <- ConfigDB.get_by_params(@config_path),
  10. fixed_opts <- Map.to_list(opts) do
  11. fix_config(fixed_opts)
  12. else
  13. _ -> :skipped
  14. end
  15. end
  16. defp fix_config(fixed_opts) when is_list(fixed_opts) do
  17. {:ok, _} =
  18. ConfigDB.update_or_create(%{
  19. group: :pleroma,
  20. key: Pleroma.Formatter,
  21. value: fixed_opts
  22. })
  23. :ok
  24. end
  25. end