nodeinfo: gather supported protocol names from federation modules
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 12 May 2019 19:15:29 +0000 (19:15 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 12 May 2019 19:15:29 +0000 (19:15 +0000)
lib/pleroma/web/activity_pub/publisher.ex
lib/pleroma/web/federator/publisher.ex
lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
lib/pleroma/web/salmon/salmon.ex
lib/pleroma/web/websub/websub.ex

index 5c97485c8f3e43acd33632a3eaee5e4af103e4ff..8e3af0a813868b91df3e839dd518e8d67d244162 100644 (file)
@@ -147,4 +147,6 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
       }
     ]
   end
+
+  def gather_nodeinfo_protocol_names, do: ["activitypub"]
 end
index 112a0574f9606f72eda6ae9a22ca0818659257cd..916bcdcba9e721ec48eeba2cad36173005dbd44a 100644 (file)
@@ -79,4 +79,17 @@ defmodule Pleroma.Web.Federator.Publisher do
       links ++ module.gather_webfinger_links(user)
     end)
   end
+
+  @doc """
+  Gathers nodeinfo protocol names supported by the federation module.
+  """
+  @callback gather_nodeinfo_protocol_names() :: list()
+
+  @spec gather_nodeinfo_protocol_names() :: list()
+  def gather_nodeinfo_protocol_names do
+    Config.get([:instance, :federation_publisher_modules])
+    |> Enum.reduce([], fn module, links ->
+      links ++ module.gather_nodeinfo_protocol_names()
+    end)
+  end
 end
index 216a962bd45e834a380d2a2215d46d2108982708..3bf2a0fbcb262d59fa7f235c55f2fa4fa8470199 100644 (file)
@@ -10,6 +10,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
   alias Pleroma.User
   alias Pleroma.Web
   alias Pleroma.Web.ActivityPub.MRF
+  alias Pleroma.Web.Federator.Publisher
 
   plug(Pleroma.Web.FederatingPlug)
 
@@ -137,7 +138,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
         name: Pleroma.Application.name() |> String.downcase(),
         version: Pleroma.Application.version()
       },
-      protocols: ["ostatus", "activitypub"],
+      protocols: Publisher.gather_nodeinfo_protocol_names(),
       services: %{
         inbound: [],
         outbound: []
index 92e85b5e951457af1b8ffbd508a0dc6a0008ecf1..42709ab47251531d594cdf7938b68d089a7a729e 100644 (file)
@@ -264,4 +264,6 @@ defmodule Pleroma.Web.Salmon do
       }
     ]
   end
+
+  def gather_nodeinfo_protocol_names, do: []
 end
index 2ce6dcc19888cc466d94d3d6cf1d6e56a4939e5a..7ad0414ab7db1b1516aa38e1f05f966264763c98 100644 (file)
@@ -328,4 +328,6 @@ defmodule Pleroma.Web.Websub do
       }
     ]
   end
+
+  def gather_nodeinfo_protocol_names, do: ["ostatus"]
 end