From f4028c908c56736b88caa5edb71f5aad21244de1 Mon Sep 17 00:00:00 2001 From: Ilja Date: Fri, 18 Dec 2020 14:29:38 +0100 Subject: [PATCH] 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) --- config/description.exs | 2 ++ lib/pleroma/web/activity_pub/mrf/keyword_policy.ex | 2 ++ lib/pleroma/web/activity_pub/mrf/simple_policy.ex | 4 ++++ lib/pleroma/web/mastodon_api/views/instance_view.ex | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/config/description.exs b/config/description.exs index 252aa63d8..411029c27 100644 --- a/config/description.exs +++ b/config/description.exs @@ -688,6 +688,8 @@ config :pleroma, :config_description, [ %{ key: :quarantined_instances, type: {:list, :tuple}, + keyPlaceholder: "instance", + valuePlaceholder: "reason", description: "List of ActivityPub instances where private (DMs, followers-only) activities will not be sent and the reason for doing so", suggestions: [ diff --git a/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex b/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex index 646008dd9..aebf78b46 100644 --- a/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex @@ -159,6 +159,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do %{ key: :replace, type: {:list, :tuple}, + keyPlaceholder: "pattern", + valuePlaceholder: "replacement", description: """ **Pattern**: a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`. diff --git a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex index 22999ef58..00a74ead8 100644 --- a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex @@ -271,6 +271,10 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do end) |> 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_excluded |> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn {_, reason} -> reason == "" end)} end) diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index a341ca6f4..f62b52a64 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -100,6 +100,10 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do quarantined |> 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(%{ quarantined_instances_info: %{ "quarantined_instances" =>