Add key- and valuePlaceholders for quarantined_instances and mrf_simple

* I also added for keywordpolicy as well now. It was done in the admin-fe, but is better to be done here
* I also added comments to explain why we did the _info keys (backwards compatibility)
This commit is contained in:
Ilja 2020-12-18 14:29:38 +01:00
parent b3f9717e29
commit 6f9ee416d5
4 changed files with 32 additions and 0 deletions

View File

@ -759,6 +759,8 @@
%{ %{
key: :quarantined_instances, key: :quarantined_instances,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: description:
"List of ActivityPub instances where private (DMs, followers-only) activities will not be sent and the reason for doing so", "List of ActivityPub instances where private (DMs, followers-only) activities will not be sent and the reason for doing so",
suggestions: [ suggestions: [

View File

@ -159,6 +159,8 @@ def config_description do
%{ %{
key: :replace, key: :replace,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "pattern",
valuePlaceholder: "replacement",
description: """ description: """
**Pattern**: a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`. **Pattern**: a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`.

View File

@ -253,6 +253,10 @@ def describe do
end) end)
|> Enum.into(%{}) |> Enum.into(%{})
# This is for backwards compatibility. We originally didn't sent
# extra info like a reason why an instance was rejected/quarantined/etc.
# Because we didn't want to break backwards compatibility it was decided
# to add an extra "info" key.
mrf_simple_info = mrf_simple_info =
mrf_simple_excluded mrf_simple_excluded
|> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn {_, reason} -> reason == "" end)} end) |> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn {_, reason} -> reason == "" end)} end)
@ -276,6 +280,8 @@ def config_description do
%{ %{
key: :media_removal, key: :media_removal,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: description:
"List of instances to strip media attachments from and the reason for doing so", "List of instances to strip media attachments from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
@ -284,6 +290,8 @@ def config_description do
key: :media_nsfw, key: :media_nsfw,
label: "Media NSFW", label: "Media NSFW",
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: description:
"List of instances to tag all media as NSFW (sensitive) from and the reason for doing so", "List of instances to tag all media as NSFW (sensitive) from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
@ -291,6 +299,8 @@ def config_description do
%{ %{
key: :federated_timeline_removal, key: :federated_timeline_removal,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: description:
"List of instances to remove from the Federated Timeline (aka The Whole Known Network) and the reason for doing so", "List of instances to remove from the Federated Timeline (aka The Whole Known Network) and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
@ -298,6 +308,8 @@ def config_description do
%{ %{
key: :reject, key: :reject,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: description:
"List of instances to reject activities (except deletes) from and the reason for doing so", "List of instances to reject activities (except deletes) from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
@ -305,6 +317,8 @@ def config_description do
%{ %{
key: :accept, key: :accept,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: description:
"List of instances to only accept activities (except deletes) from and the reason for doing so", "List of instances to only accept activities (except deletes) from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
@ -312,6 +326,8 @@ def config_description do
%{ %{
key: :followers_only, key: :followers_only,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: description:
"Force posts from the given instances to be visible by followers only and the reason for doing so", "Force posts from the given instances to be visible by followers only and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
@ -319,24 +335,32 @@ def config_description do
%{ %{
key: :report_removal, key: :report_removal,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: "List of instances to reject reports from and the reason for doing so", description: "List of instances to reject reports from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
}, },
%{ %{
key: :avatar_removal, key: :avatar_removal,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: "List of instances to strip avatars from and the reason for doing so", description: "List of instances to strip avatars from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
}, },
%{ %{
key: :banner_removal, key: :banner_removal,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: "List of instances to strip banners from and the reason for doing so", description: "List of instances to strip banners from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
}, },
%{ %{
key: :reject_deletes, key: :reject_deletes,
type: {:list, :tuple}, type: {:list, :tuple},
keyPlaceholder: "instance",
valuePlaceholder: "reason",
description: "List of instances to reject deletions from and the reason for doing so", description: "List of instances to reject deletions from and the reason for doing so",
suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}] suggestions: [{"example.com", "Some reason"}, {"*.example.com", "Another reason"}]
} }

View File

@ -93,6 +93,10 @@ def federation do
quarantined quarantined
|> Enum.map(fn {instance, _reason} -> instance end) |> Enum.map(fn {instance, _reason} -> instance end)
}) })
# This is for backwards compatibility. We originally didn't sent
# extra info like a reason why an instance was rejected/quarantined/etc.
# Because we didn't want to break backwards compatibility it was decided
# to add an extra "info" key.
|> Map.merge(%{ |> Map.merge(%{
quarantined_instances_info: %{ quarantined_instances_info: %{
"quarantined_instances" => "quarantined_instances" =>