2018-12-23 13:04:54 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 13:04:54 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-05-02 13:31:42 -06:00
|
|
|
defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
|
|
|
|
use Pleroma.Web, :controller
|
|
|
|
|
2021-05-31 14:09:11 -06:00
|
|
|
alias Pleroma.Web.Endpoint
|
2020-05-12 09:08:00 -06:00
|
|
|
alias Pleroma.Web.Nodeinfo.Nodeinfo
|
2018-05-02 13:31:42 -06:00
|
|
|
|
|
|
|
def schemas(conn, _params) do
|
|
|
|
response = %{
|
|
|
|
links: [
|
2019-02-01 10:23:40 -07:00
|
|
|
%{
|
|
|
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
2021-05-31 14:09:11 -06:00
|
|
|
href: Endpoint.url() <> "/nodeinfo/2.0.json"
|
2019-02-01 10:23:40 -07:00
|
|
|
},
|
2018-05-02 13:31:42 -06:00
|
|
|
%{
|
2019-01-31 23:55:10 -07:00
|
|
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
2021-05-31 14:09:11 -06:00
|
|
|
href: Endpoint.url() <> "/nodeinfo/2.1.json"
|
2018-05-02 13:31:42 -06:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
json(conn, response)
|
|
|
|
end
|
|
|
|
|
2019-02-01 10:23:40 -07:00
|
|
|
# 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
|
2020-05-12 09:08:00 -06:00
|
|
|
def nodeinfo(conn, %{"version" => version}) do
|
|
|
|
case Nodeinfo.get_nodeinfo(version) do
|
|
|
|
{:error, :missing} ->
|
|
|
|
render_error(conn, :not_found, "Nodeinfo schema version not handled")
|
|
|
|
|
|
|
|
node_info ->
|
|
|
|
conn
|
|
|
|
|> put_resp_header(
|
|
|
|
"content-type",
|
|
|
|
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
|
|
|
|
)
|
|
|
|
|> json(node_info)
|
|
|
|
end
|
2018-05-02 13:31:42 -06:00
|
|
|
end
|
|
|
|
end
|