Change path of nodeinfo to use .json format
[akkoma] / lib / pleroma / web / nodeinfo / nodeinfo_controller.ex
1 defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
2 use Pleroma.Web, :controller
3
4 alias Pleroma.Web.Nodeinfo
5 alias Pleroma.Stats
6 alias Pleroma.Web
7
8 @instance Application.get_env(:pleroma, :instance)
9
10 def schemas(conn, _params) do
11 response = %{
12 links: [
13 %{
14 rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
15 href: Web.base_url() <> "/nodeinfo/2.0.json"
16 }
17 ]
18 }
19
20 json(conn, response)
21 end
22
23 # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
24 def nodeinfo(conn, %{"version" => "2.0"}) do
25 response = %{
26 version: "2.0",
27 software: %{
28 name: "pleroma",
29 version: "#{Keyword.get(@instance, :version)})"
30 },
31 protocols: ["ostatus", "activitypub"],
32 services: %{
33 inbound: [],
34 outbound: []
35 },
36 openRegistrations: Keyword.get(@instance, :registrations_open),
37 usage: %{
38 users: %{
39 total: Stats.get_stats().user_count
40 }
41 },
42 metadata: %{}
43 }
44
45 json(conn, response)
46 end
47
48 def nodeinfo(conn, _) do
49 conn
50 |> put_status(404)
51 |> json(%{error: "Nodeinfo schema not handled"})
52 end
53 end