X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fnodeinfo%2Fnodeinfo_controller.ex;h=21694a5ee4983b0dc383c19705d8302c1f676d45;hb=10130fa7d6a2dca4250ada1144fcfcfe75c26f45;hp=1265d81c54614ed7229874dc41b23bb540cebe90;hpb=2791ce9a1ff2365ac7256f5e1dc2324dee2f82c9;p=akkoma
diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
index 1265d81c5..21694a5ee 100644
--- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
+++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
@@ -19,6 +19,10 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
%{
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
href: Web.base_url() <> "/nodeinfo/2.0.json"
+ },
+ %{
+ rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
+ href: Web.base_url() <> "/nodeinfo/2.1.json"
}
]
}
@@ -26,8 +30,9 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
json(conn, response)
end
- # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
- def nodeinfo(conn, %{"version" => "2.0"}) do
+ # returns a nodeinfo 2.0 map, since 2.1 just adds a repository field
+ # under software.
+ def raw_nodeinfo() do
instance = Application.get_env(:pleroma, :instance)
media_proxy = Application.get_env(:pleroma, :media_proxy)
suggestions = Application.get_env(:pleroma, :suggestions)
@@ -98,10 +103,10 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
]
|> Enum.filter(& &1)
- response = %{
+ %{
version: "2.0",
software: %{
- name: Pleroma.Application.name(),
+ name: Pleroma.Application.name() |> String.downcase(),
version: Pleroma.Application.version()
},
protocols: ["ostatus", "activitypub"],
@@ -138,15 +143,41 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
},
accountActivationRequired: Keyword.get(instance, :account_activation_required, false),
invitesEnabled: Keyword.get(instance, :invites_enabled, false),
- features: features
+ features: features,
+ restrictedNicknames: Pleroma.Config.get([Pleroma.User, :restricted_nicknames])
}
}
+ end
+ # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
+ # and https://github.com/jhass/nodeinfo/blob/master/schemas/2.1/schema.json
+ def nodeinfo(conn, %{"version" => "2.0"}) do
conn
|> put_resp_header(
"content-type",
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
)
+ |> json(raw_nodeinfo())
+ end
+
+ def nodeinfo(conn, %{"version" => "2.1"}) do
+ raw_response = raw_nodeinfo()
+
+ updated_software =
+ raw_response
+ |> Map.get(:software)
+ |> Map.put(:repository, Pleroma.Application.repository())
+
+ response =
+ raw_response
+ |> Map.put(:software, updated_software)
+ |> Map.put(:version, "2.1")
+
+ conn
+ |> put_resp_header(
+ "content-type",
+ "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.1#; charset=utf-8"
+ )
|> json(response)
end