expose bubble instances via nodeinfo (#136)
authorfloatingghost <hannah@coffee-and-dreams.uk>
Tue, 2 Aug 2022 09:11:22 +0000 (09:11 +0000)
committerfloatingghost <hannah@coffee-and-dreams.uk>
Tue, 2 Aug 2022 09:11:22 +0000 (09:11 +0000)
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/136

lib/pleroma/web/nodeinfo/nodeinfo.ex
lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
test/pleroma/web/node_info_test.exs

index 80a2ce67681c4f9b07de3b79c9430de0f9eee75f..bf0d65f4522ae1b72aa6267b47263d2e15b08a6a 100644 (file)
@@ -70,7 +70,8 @@ defmodule Pleroma.Web.Nodeinfo.Nodeinfo do
         features: features,
         restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
         skipThreadContainment: Config.get([:instance, :skip_thread_containment], false),
-        privilegedStaff: Config.get([:instance, :privileged_staff])
+        privilegedStaff: Config.get([:instance, :privileged_staff]),
+        localBubbleInstances: Config.get([:instance, :local_bubble], [])
       }
     }
   end
index 5cee26afe5d86f3de4f82d86a8b938c6f95310cd..a0dee7c6bc283d370e667a051bb61ad530adcdf4 100644 (file)
@@ -88,7 +88,8 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
         mailerEnabled: Config.get([Pleroma.Emails.Mailer, :enabled], false),
         features: features,
         restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
-        skipThreadContainment: Config.get([:instance, :skip_thread_containment], false)
+        skipThreadContainment: Config.get([:instance, :skip_thread_containment], false),
+        localBubbleInstances: Config.get([:instance, :local_bubble], [])
       }
     }
   end
index 6eb0a585a9dbac60916528bcb3b2420d15f6d7f3..05a078266c1d41d950f09653a4e37a0fa10de9e1 100644 (file)
@@ -188,6 +188,25 @@ defmodule Pleroma.Web.NodeInfoTest do
     end
   end
 
+  test "Bubble instances", %{conn: conn} do
+    clear_config([:instance, :local_bubble], [])
+
+    response =
+      conn
+      |> get("/nodeinfo/2.1.json")
+      |> json_response(:ok)
+
+    assert response["metadata"]["localBubbleInstances"] == []
+    clear_config([:instance, :local_bubble], ["example.com"])
+
+    response =
+      conn
+      |> get("/nodeinfo/2.1.json")
+      |> json_response(:ok)
+
+    assert response["metadata"]["localBubbleInstances"] == ["example.com"]
+  end
+
   describe "MRF SimplePolicy" do
     setup do
       clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])