1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Config.DeprecationWarnings do
11 @type config_namespace() :: [atom()]
12 @type config_map() :: {config_namespace(), config_namespace(), String.t()}
15 {[:instance, :rewrite_policy], [:mrf, :policies],
16 "\n* `config :pleroma, :instance, rewrite_policy` is now `config :pleroma, :mrf, policies`"},
17 {[:instance, :mrf_transparency], [:mrf, :transparency],
18 "\n* `config :pleroma, :instance, mrf_transparency` is now `config :pleroma, :mrf, transparency`"},
19 {[:instance, :mrf_transparency_exclusions], [:mrf, :transparency_exclusions],
20 "\n* `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`"}
23 def check_hellthread_threshold do
24 if Config.get([:mrf_hellthread, :threshold]) do
26 !!!DEPRECATION WARNING!!!
27 You are using the old configuration mechanism for the hellthread filter. Please check config.md.
32 def mrf_user_allowlist do
33 config = Config.get(:mrf_user_allowlist)
35 if config && Enum.any?(config, fn {k, _} -> is_atom(k) end) do
37 Enum.reduce(Config.get(:mrf_user_allowlist), Map.new(), fn {k, v}, acc ->
38 Map.put(acc, to_string(k), v)
41 Config.put(:mrf_user_allowlist, rewritten)
44 !!!DEPRECATION WARNING!!!
45 As of Pleroma 2.0.7, the `mrf_user_allowlist` setting changed of format.
46 Pleroma 2.1 will remove support for the old format. Please change your configuration to match this:
48 config :pleroma, :mrf_user_allowlist, #{inspect(rewritten, pretty: true)}
54 check_hellthread_threshold()
56 check_old_mrf_config()
59 def check_old_mrf_config do
61 !!!DEPRECATION WARNING!!!
62 Your config is using old namespaces for MRF configuration. They should work for now, but you are advised to change to new namespaces to prevent possible issues later:
65 move_namespace_and_warn(@mrf_config_map, warning_preface)
68 @spec move_namespace_and_warn([config_map()], String.t()) :: :ok
69 def move_namespace_and_warn(config_map, warning_preface) do
71 Enum.reduce(config_map, "", fn
72 {old, new, err_msg}, acc ->
73 old_config = Config.get(old)
76 Config.put(new, old_config)
84 Logger.warn(warning_preface <> warning)