report federating status in nodeinfo
authorhref <href@random.sh>
Mon, 11 Nov 2019 18:03:43 +0000 (19:03 +0100)
committerrinpatch <rinpatch@sdf.org>
Fri, 13 Dec 2019 18:20:09 +0000 (21:20 +0300)
lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
test/web/node_info_test.exs

index ee14cfd6b62768634be9bef4378c95359e4392ae..09cd65b78a8f1e1b236a1e6530431057dfef015f 100644 (file)
@@ -46,6 +46,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
 
         data
         |> Map.merge(%{quarantined_instances: quarantined})
+        |> Map.put(:enabled, Config.get([:instance, :federating]))
       else
         %{}
       end
index f6147c286fdedcb79859c0f694b6912b0dc2ff51..4edcdaf60118fa1d4281bc4bbfbe6123ac063aa8 100644 (file)
@@ -84,6 +84,30 @@ defmodule Pleroma.Web.NodeInfoTest do
     Pleroma.Config.put([:instance, :safe_dm_mentions], option)
   end
 
+  test "it shows if federation is enabled/disabled", %{conn: conn} do
+    original = Pleroma.Config.get([:instance, :federating])
+
+    Pleroma.Config.put([:instance, :federating], true)
+
+    response =
+      conn
+      |> get("/nodeinfo/2.1.json")
+      |> json_response(:ok)
+
+    assert response["metadata"]["federation"]["enabled"] == true
+
+    Pleroma.Config.put([:instance, :federating], false)
+
+    response =
+      conn
+      |> get("/nodeinfo/2.1.json")
+      |> json_response(:ok)
+
+    assert response["metadata"]["federation"]["enabled"] == false
+
+    Pleroma.Config.put([:instance, :federating], original)
+  end
+
   test "it shows MRF transparency data if enabled", %{conn: conn} do
     config = Pleroma.Config.get([:instance, :rewrite_policy])
     Pleroma.Config.put([:instance, :rewrite_policy], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])