logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

nodeinfo_controller.ex (1322B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
  5. use Pleroma.Web, :controller
  6. alias Pleroma.Web.Endpoint
  7. alias Pleroma.Web.Nodeinfo.Nodeinfo
  8. def schemas(conn, _params) do
  9. response = %{
  10. links: [
  11. %{
  12. rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
  13. href: Endpoint.url() <> "/nodeinfo/2.0.json"
  14. },
  15. %{
  16. rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
  17. href: Endpoint.url() <> "/nodeinfo/2.1.json"
  18. }
  19. ]
  20. }
  21. json(conn, response)
  22. end
  23. # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
  24. # and https://github.com/jhass/nodeinfo/blob/master/schemas/2.1/schema.json
  25. def nodeinfo(conn, %{"version" => version}) do
  26. case Nodeinfo.get_nodeinfo(version) do
  27. {:error, :missing} ->
  28. render_error(conn, :not_found, "Nodeinfo schema version not handled")
  29. node_info ->
  30. conn
  31. |> put_resp_header(
  32. "content-type",
  33. "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
  34. )
  35. |> json(node_info)
  36. end
  37. end
  38. end