From c3eea8dc7d005ccc2384a5e6e744d8084aff3e0c Mon Sep 17 00:00:00 2001 From: floatingghost Date: Tue, 2 Aug 2022 09:11:22 +0000 Subject: [PATCH] expose bubble instances via nodeinfo (#136) Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/136 --- lib/pleroma/web/nodeinfo/nodeinfo.ex | 3 ++- .../web/nodeinfo/nodeinfo_controller.ex | 3 ++- test/pleroma/web/node_info_test.exs | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/nodeinfo/nodeinfo.ex b/lib/pleroma/web/nodeinfo/nodeinfo.ex index 80a2ce676..bf0d65f45 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo.ex @@ -70,7 +70,8 @@ def get_nodeinfo("2.0") 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 diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 5cee26afe..a0dee7c6b 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -88,7 +88,8 @@ def raw_nodeinfo 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 diff --git a/test/pleroma/web/node_info_test.exs b/test/pleroma/web/node_info_test.exs index 6eb0a585a..05a078266 100644 --- a/test/pleroma/web/node_info_test.exs +++ b/test/pleroma/web/node_info_test.exs @@ -188,6 +188,25 @@ test "shows extra information in the quarantined_info field for relevant entries 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])