2018-12-23 20:04:54 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 06:49:20 +00:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 20:04:54 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-05-02 19:31:42 +00:00
|
|
|
defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
|
|
|
|
use Pleroma.Web, :controller
|
|
|
|
|
2019-02-09 15:16:26 +00:00
|
|
|
alias Pleroma.Config
|
2018-05-02 19:31:42 +00:00
|
|
|
alias Pleroma.Stats
|
2019-02-09 15:16:26 +00:00
|
|
|
alias Pleroma.User
|
2019-05-12 19:15:29 +00:00
|
|
|
alias Pleroma.Web.Federator.Publisher
|
2020-04-27 12:28:08 +00:00
|
|
|
alias Pleroma.Web.MastodonAPI.InstanceView
|
2021-05-31 20:09:11 +00:00
|
|
|
alias Pleroma.Web.Endpoint
|
2023-03-17 15:33:28 +00:00
|
|
|
alias Pleroma.Web.Nodeinfo.Nodeinfo
|
2018-05-02 19:31:42 +00:00
|
|
|
|
|
|
|
def schemas(conn, _params) do
|
|
|
|
response = %{
|
|
|
|
links: [
|
2019-02-01 17:23:40 +00:00
|
|
|
%{
|
|
|
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
2021-05-31 20:09:11 +00:00
|
|
|
href: Endpoint.url() <> "/nodeinfo/2.0.json"
|
2019-02-01 17:23:40 +00:00
|
|
|
},
|
2018-05-02 19:31:42 +00:00
|
|
|
%{
|
2019-02-01 06:55:10 +00:00
|
|
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
2021-05-31 20:09:11 +00:00
|
|
|
href: Endpoint.url() <> "/nodeinfo/2.1.json"
|
2018-05-02 19:31:42 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
json(conn, response)
|
|
|
|
end
|
|
|
|
|
2019-02-01 17:23:40 +00: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
|
2023-03-17 15:33:28 +00:00
|
|
|
def nodeinfo(conn, %{"version" => version}) when version in ["2.0", "2.1"] do
|
2019-02-01 17:23:40 +00:00
|
|
|
conn
|
|
|
|
|> put_resp_header(
|
|
|
|
"content-type",
|
|
|
|
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
|
|
|
|
)
|
2023-03-17 15:33:28 +00:00
|
|
|
|> json(Nodeinfo.get_nodeinfo(version))
|
2018-05-02 19:31:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def nodeinfo(conn, _) do
|
2019-07-10 09:25:58 +00:00
|
|
|
render_error(conn, :not_found, "Nodeinfo schema version not handled")
|
2018-05-02 19:31:42 +00:00
|
|
|
end
|
|
|
|
end
|