1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Config.DeprecationWarnings do
11 @type config_namespace() :: atom() | [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`"},
21 {[:instance, :quarantined_instances], [:mrf_simple, :reject],
22 "\n* `config :pleroma, :instance, :quarantined_instances` is now covered by `:pleroma, :mrf_simple, :reject`"}
25 def check_simple_policy_tuples do
27 Config.get([:mrf_simple])
28 |> Enum.any?(fn {_, v} -> is_list(v) and Enum.any?(v, &is_binary/1) end)
32 !!!DEPRECATION WARNING!!!
33 Your config is using strings in the SimplePolicy configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
36 config :pleroma, :mrf_simple,
37 media_removal: ["instance.tld"],
38 media_nsfw: ["instance.tld"],
39 federated_timeline_removal: ["instance.tld"],
40 report_removal: ["instance.tld"],
41 reject: ["instance.tld"],
42 followers_only: ["instance.tld"],
43 accept: ["instance.tld"],
44 avatar_removal: ["instance.tld"],
45 banner_removal: ["instance.tld"],
46 reject_deletes: ["instance.tld"]
53 config :pleroma, :mrf_simple,
54 media_removal: [{"instance.tld", "Reason for media removal"}],
55 media_nsfw: [{"instance.tld", "Reason for media nsfw"}],
56 federated_timeline_removal: [{"instance.tld", "Reason for federated timeline removal"}],
57 report_removal: [{"instance.tld", "Reason for report removal"}],
58 reject: [{"instance.tld", "Reason for reject"}],
59 followers_only: [{"instance.tld", "Reason for followers only"}],
60 accept: [{"instance.tld", "Reason for accept"}],
61 avatar_removal: [{"instance.tld", "Reason for avatar removal"}],
62 banner_removal: [{"instance.tld", "Reason for banner removal"}],
63 reject_deletes: [{"instance.tld", "Reason for reject deletes"}]
68 Config.get([:mrf_simple])
69 |> Enum.filter(fn {_k, v} -> not is_atom(v) end)
70 |> Enum.map(fn {k, v} ->
73 {instance, reason} -> {instance, reason}
74 instance -> {instance, ""}
78 Config.put([:mrf_simple], new_config)
86 def check_quarantined_instances_tuples do
87 has_strings = Config.get([:instance, :quarantined_instances], []) |> Enum.any?(&is_binary/1)
91 !!!DEPRECATION WARNING!!!
92 Your config is using strings in the quarantined_instances configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
95 config :pleroma, :instance,
96 quarantined_instances: ["instance.tld"]
103 config :pleroma, :instance,
104 quarantined_instances: [{"instance.tld", "Reason for quarantine"}]
109 Config.get([:instance, :quarantined_instances])
111 {instance, reason} -> {instance, reason}
112 instance -> {instance, ""}
115 Config.put([:instance, :quarantined_instances], new_config)
123 def check_transparency_exclusions_tuples do
124 has_strings = Config.get([:mrf, :transparency_exclusions]) |> Enum.any?(&is_binary/1)
128 !!!DEPRECATION WARNING!!!
129 Your config is using strings in the transparency_exclusions configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
132 config :pleroma, :mrf,
133 transparency_exclusions: ["instance.tld"]
140 config :pleroma, :mrf,
141 transparency_exclusions: [{"instance.tld", "Reason to exlude transparency"}]
146 Config.get([:mrf, :transparency_exclusions])
148 {instance, reason} -> {instance, reason}
149 instance -> {instance, ""}
152 Config.put([:mrf, :transparency_exclusions], new_config)
160 def check_hellthread_threshold do
161 if Config.get([:mrf_hellthread, :threshold]) do
163 !!!DEPRECATION WARNING!!!
164 You are using the old configuration mechanism for the hellthread filter. Please check config.md.
175 check_hellthread_threshold(),
176 check_old_mrf_config(),
177 check_media_proxy_whitelist_config(),
178 check_welcome_message_config(),
179 check_activity_expiration_config(),
180 check_remote_ip_plug_name(),
181 check_uploders_s3_public_endpoint(),
182 check_quarantined_instances_tuples(),
183 check_transparency_exclusions_tuples(),
184 check_simple_policy_tuples(),
187 |> Enum.reduce(:ok, fn
193 def check_welcome_message_config do
194 instance_config = Pleroma.Config.get([:instance])
197 Keyword.has_key?(instance_config, :welcome_user_nickname) or
198 Keyword.has_key?(instance_config, :welcome_message)
202 !!!DEPRECATION WARNING!!!
203 Your config is using the old namespace for Welcome messages configuration. You need to convert to the new namespace. e.g.,
204 \n* `config :pleroma, :instance, welcome_user_nickname` and `config :pleroma, :instance, welcome_message` are now equal to:
205 \n* `config :pleroma, :welcome, direct_message: [enabled: true, sender_nickname: "NICKNAME", message: "Your welcome message"]`"
214 def check_http_adapter do
215 http_adapter = Application.get_env(:tesla, :adapter)
217 {Tesla.Adapter.Finch, _} ->
223 Your config is using a custom tesla adapter, this was standardised
224 to finch in 2022.06, and alternate adapters were removed in 2023.02.
225 Please ensure you either:
226 \n* do not have any custom value for `:tesla, :adapter`, or
227 \n* have `config :tesla, :adapter, {Tesla.Adapter.Finch, name: MyFinch}`
234 def check_old_mrf_config do
235 warning_preface = """
236 !!!DEPRECATION WARNING!!!
237 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:
240 move_namespace_and_warn(@mrf_config_map, warning_preface)
243 @spec move_namespace_and_warn([config_map()], String.t()) :: :ok | nil
244 def move_namespace_and_warn(config_map, warning_preface) do
246 Enum.reduce(config_map, "", fn
247 {old, new, err_msg}, acc ->
248 old_config = Config.get(old)
251 Config.put(new, old_config)
261 Logger.warn(warning_preface <> warning)
266 @spec check_media_proxy_whitelist_config() :: :ok | nil
267 def check_media_proxy_whitelist_config do
268 whitelist = Config.get([:media_proxy, :whitelist])
270 if Enum.any?(whitelist, &(not String.starts_with?(&1, "http"))) do
272 !!!DEPRECATION WARNING!!!
273 Your config is using old format (only domain) for MediaProxy whitelist option. Setting should work for now, but you are advised to change format to scheme with port to prevent possible issues later.
282 @spec check_activity_expiration_config() :: :ok | nil
283 def check_activity_expiration_config do
284 warning_preface = """
285 !!!DEPRECATION WARNING!!!
286 Your config is using old namespace for activity expiration configuration. Setting should work for now, but you are advised to change to new namespace to prevent possible issues later:
289 move_namespace_and_warn(
291 {Pleroma.ActivityExpiration, Pleroma.Workers.PurgeExpiredActivity,
292 "\n* `config :pleroma, Pleroma.ActivityExpiration` is now `config :pleroma, Pleroma.Workers.PurgeExpiredActivity`"}
298 @spec check_remote_ip_plug_name() :: :ok | nil
299 def check_remote_ip_plug_name do
300 warning_preface = """
301 !!!DEPRECATION WARNING!!!
302 Your config is using old namespace for RemoteIp Plug. Setting should work for now, but you are advised to change to new namespace to prevent possible issues later:
305 move_namespace_and_warn(
307 {Pleroma.Plugs.RemoteIp, Pleroma.Web.Plugs.RemoteIp,
308 "\n* `config :pleroma, Pleroma.Plugs.RemoteIp` is now `config :pleroma, Pleroma.Web.Plugs.RemoteIp`"}
314 @spec check_uploders_s3_public_endpoint() :: :ok | nil
315 def check_uploders_s3_public_endpoint do
316 s3_config = Pleroma.Config.get([Pleroma.Uploaders.S3])
318 use_old_config = Keyword.has_key?(s3_config, :public_endpoint)
322 !!!DEPRECATION WARNING!!!
323 Your config is using the old setting for controlling the URL of media uploaded to your S3 bucket.\n
324 Please make the following change at your earliest convenience.\n
325 \n* `config :pleroma, Pleroma.Uploaders.S3, public_endpoint` is now equal to:
326 \n* `config :pleroma, Pleroma.Upload, base_url`