feat(activitypub): implement FEP-2677 to identify the application actor used for federation

Instead of always assuming it will be @relay@host.tld

Closes #1367

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-12-14 16:31:58 +01:00
parent 049ffd61b7
commit f10977a99a
4 changed files with 56 additions and 5 deletions

View File

@@ -7,13 +7,17 @@ defmodule Mobilizon.Web.NodeInfoController do
use Mobilizon.Web, :controller
alias Mobilizon.Config
alias Mobilizon.Federation.ActivityPub.Relay
alias Mobilizon.Service.Statistics
@node_info_supported_versions ["2.0", "2.1"]
@node_info_schema_uri "http://nodeinfo.diaspora.software/ns/schema/"
@application_uri "https://www.w3.org/ns/activitystreams#Application"
@spec schemas(Plug.Conn.t(), any) :: Plug.Conn.t()
def schemas(conn, _params) do
relay = Relay.get_actor()
links =
@node_info_supported_versions
|> Enum.map(fn version ->
@@ -22,6 +26,12 @@ defmodule Mobilizon.Web.NodeInfoController do
href: url(~p"/.well-known/nodeinfo/#{version}")
}
end)
|> Kernel.++([
%{
rel: @application_uri,
href: relay.url
}
])
json(conn, %{
links: links