akkoma/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex

43 lines
1.3 KiB
Elixir
Raw Permalink Normal View History

# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# 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
alias Pleroma.Web.Endpoint
2023-03-17 09:33:28 -06:00
alias Pleroma.Web.Nodeinfo.Nodeinfo
2018-05-02 13:31:42 -06:00
def schemas(conn, _params) do
response = %{
links: [
%{
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
href: Endpoint.url() <> "/nodeinfo/2.0.json"
},
2018-05-02 13:31:42 -06:00
%{
rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
href: Endpoint.url() <> "/nodeinfo/2.1.json"
2018-05-02 13:31:42 -06:00
}
]
}
json(conn, response)
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
2023-03-17 09:33:28 -06:00
def nodeinfo(conn, %{"version" => version}) when version in ["2.0", "2.1"] do
conn
|> put_resp_header(
"content-type",
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
)
2023-03-17 09:33:28 -06:00
|> json(Nodeinfo.get_nodeinfo(version))
2018-05-02 13:31:42 -06:00
end
def nodeinfo(conn, _) do
render_error(conn, :not_found, "Nodeinfo schema version not handled")
2018-05-02 13:31:42 -06:00
end
end