def describe do
exclusions = Config.get([:mrf, :transparency_exclusions]) |> MRF.instance_list_from_tuples()
- mrf_simple =
+ mrf_simple_excluded =
Config.get(:mrf_simple)
|> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn {v, _} -> v in exclusions end)} end)
+
+ mrf_simple =
+ mrf_simple_excluded
|> Enum.map(fn {k, v} ->
- {k, Enum.map(v, fn {i, r} -> %{"instance" => i, "reason" => r} end)}
+ {k, Enum.map(v, fn {instance, _} -> instance end)}
+ end)
+ |> Enum.into(%{})
+
+ mrf_simple_info =
+ mrf_simple_excluded
+ |> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn {_, reason} -> reason == "" end)} end)
+ |> Enum.reject(fn {_, v} -> v == [] end)
+ |> Enum.map(fn {k, l} ->
+ {k, l |> Enum.map(fn {i, r} -> {i, %{"reason" => r}} end) |> Enum.into(%{})}
end)
|> Enum.into(%{})
- {:ok, %{mrf_simple: mrf_simple}}
+ {:ok, %{mrf_simple: mrf_simple, mrf_simple_info: mrf_simple_info}}
end
@impl true
assert response["metadata"]["federation"]["quarantined_instances"] == expected_config
end
- test "it shows MRF transparency data if enabled", %{conn: conn} do
- clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
- clear_config([:mrf, :transparency], true)
+ describe "MRF SimplePolicy" do
+ setup do
+ clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
+ clear_config([:mrf, :transparency], true)
+ end
- simple_config = %{"reject" => [{"example.com", ""}]}
- clear_config(:mrf_simple, simple_config)
+ test "shows MRF transparency data if enabled", %{conn: conn} do
+ simple_config = %{"reject" => [{"example.com", ""}]}
+ clear_config(:mrf_simple, simple_config)
- expected_config = %{"reject" => [%{"instance" => "example.com", "reason" => ""}]}
+ expected_config = %{"reject" => ["example.com"]}
- response =
- conn
- |> get("/nodeinfo/2.1.json")
- |> json_response(:ok)
+ response =
+ conn
+ |> get("/nodeinfo/2.1.json")
+ |> json_response(:ok)
- assert response["metadata"]["federation"]["mrf_simple"] == expected_config
- end
+ assert response["metadata"]["federation"]["mrf_simple"] == expected_config
+ end
- test "it performs exclusions from MRF transparency data if configured", %{conn: conn} do
- clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
- clear_config([:mrf, :transparency], true)
- clear_config([:mrf, :transparency_exclusions], [{"other.site", "We don't want them to know"}])
+ test "performs exclusions from MRF transparency data if configured", %{conn: conn} do
+ clear_config([:mrf, :transparency_exclusions], [
+ {"other.site", "We don't want them to know"}
+ ])
- simple_config = %{"reject" => [{"example.com", ""}, {"other.site", ""}]}
- clear_config(:mrf_simple, simple_config)
+ simple_config = %{"reject" => [{"example.com", ""}, {"other.site", ""}]}
+ clear_config(:mrf_simple, simple_config)
- expected_config = %{"reject" => [%{"instance" => "example.com", "reason" => ""}]}
+ expected_config = %{"reject" => ["example.com"]}
- response =
- conn
- |> get("/nodeinfo/2.1.json")
- |> json_response(:ok)
+ response =
+ conn
+ |> get("/nodeinfo/2.1.json")
+ |> json_response(:ok)
+
+ assert response["metadata"]["federation"]["mrf_simple"] == expected_config
+ assert response["metadata"]["federation"]["exclusions"] == true
+ end
- assert response["metadata"]["federation"]["mrf_simple"] == expected_config
- assert response["metadata"]["federation"]["exclusions"] == true
+ test "shows extra information in the mrf_simple_extra field for relevant entries", %{
+ conn: conn
+ } do
+ simple_config = %{
+ media_removal: [{"no.media", "LEEWWWDD >//<"}],
+ media_nsfw: [],
+ federated_timeline_removal: [{"no.ftl", ""}],
+ report_removal: [],
+ reject: [
+ {"example.instance", "Some reason"},
+ {"uwu.owo", "awoo to much"},
+ {"no.reason", ""}
+ ],
+ followers_only: [],
+ accept: [],
+ avatar_removal: [],
+ banner_removal: [],
+ reject_deletes: [
+ {"peak.me", "I want to peak at what they don't want me to see, eheh"}
+ ]
+ }
+
+ clear_config(:mrf_simple, simple_config)
+
+ clear_config([:mrf, :transparency_exclusions], [
+ {"peak.me", "I don't want them to know"}
+ ])
+
+ expected_config = %{
+ "media_removal" => %{
+ "no.media" => %{"reason" => "LEEWWWDD >//<"}
+ },
+ "reject" => %{
+ "example.instance" => %{"reason" => "Some reason"},
+ "uwu.owo" => %{"reason" => "awoo to much"}
+ }
+ }
+
+ response =
+ conn
+ |> get("/nodeinfo/2.1.json")
+ |> json_response(:ok)
+
+ assert response["metadata"]["federation"]["mrf_simple_info"] == expected_config
+ end
end
end