mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-25 04:53:06 +00:00
Deprecate and rewrite settings for quarentine settings
* This is for the settings, not yet a DB migration
This commit is contained in:
parent
27fe7b0274
commit
e0c7d77197
|
@ -80,6 +80,44 @@ def check_simple_policy_tuples do
|
|||
end
|
||||
end
|
||||
|
||||
def check_quarantined_instances_tuples do
|
||||
has_strings =
|
||||
Config.get([:instance, :quarantined_instances]) |> Enum.any?(fn e -> is_binary(e) end)
|
||||
|
||||
if has_strings do
|
||||
Logger.warn("""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
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:
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
quarantined_instances: ["instance.tld"]
|
||||
```
|
||||
|
||||
Is now
|
||||
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
quarantined_instances: [{"instance.tld", "Reason for quarantine"}]
|
||||
```
|
||||
""")
|
||||
|
||||
new_config =
|
||||
Config.get([:instance, :quarantined_instances])
|
||||
|> Enum.map(fn
|
||||
{instance, reason} -> {instance, reason}
|
||||
instance -> {instance, ""}
|
||||
end)
|
||||
|
||||
Config.put([:instance, :quarantined_instances], new_config)
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def check_hellthread_threshold do
|
||||
if Config.get([:mrf_hellthread, :threshold]) do
|
||||
Logger.warn("""
|
||||
|
@ -103,6 +141,7 @@ def warn do
|
|||
:ok <- check_remote_ip_plug_name(),
|
||||
:ok <- check_uploders_s3_public_endpoint(),
|
||||
:ok <- check_old_chat_shoutbox(),
|
||||
:ok <- check_quarantined_instances_tuples(),
|
||||
:ok <- check_simple_policy_tuples() do
|
||||
:ok
|
||||
else
|
||||
|
|
|
@ -87,6 +87,56 @@ test "doesn't give a warning with correct config" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "quarantined_instances tuples" do
|
||||
test "gives warning when there are still strings" do
|
||||
clear_config([:instance, :quarantined_instances], [
|
||||
{"domain.com", "some reason"},
|
||||
"somedomain.tld"
|
||||
])
|
||||
|
||||
assert capture_log(fn -> DeprecationWarnings.check_quarantined_instances_tuples() end) =~
|
||||
"""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
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:
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
quarantined_instances: ["instance.tld"]
|
||||
```
|
||||
|
||||
Is now
|
||||
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
quarantined_instances: [{"instance.tld", "Reason for quarantine"}]
|
||||
```
|
||||
"""
|
||||
end
|
||||
|
||||
test "transforms config to tuples" do
|
||||
clear_config([:instance, :quarantined_instances], [
|
||||
{"domain.com", "some reason"},
|
||||
"some.tld"
|
||||
])
|
||||
|
||||
expected_config = [{"domain.com", "some reason"}, {"some.tld", ""}]
|
||||
|
||||
capture_log(fn -> DeprecationWarnings.check_quarantined_instances_tuples() end)
|
||||
|
||||
assert Config.get([:instance, :quarantined_instances]) == expected_config
|
||||
end
|
||||
|
||||
test "doesn't give a warning with correct config" do
|
||||
clear_config([:instance, :quarantined_instances], [
|
||||
{"domain.com", "some reason"},
|
||||
{"some.tld", ""}
|
||||
])
|
||||
|
||||
assert capture_log(fn -> DeprecationWarnings.check_quarantined_instances_tuples() end) == ""
|
||||
end
|
||||
end
|
||||
|
||||
test "check_old_mrf_config/0" do
|
||||
clear_config([:instance, :rewrite_policy], [])
|
||||
clear_config([:instance, :mrf_transparency], true)
|
||||
|
|
Loading…
Reference in a new issue