1 defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
2 use Pleroma.Web, :controller
6 alias Pleroma.{User, Repo}
8 def schemas(conn, _params) do
12 rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
13 href: Web.base_url() <> "/nodeinfo/2.0.json"
21 # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
22 def nodeinfo(conn, %{"version" => "2.0"}) do
23 instance = Application.get_env(:pleroma, :instance)
24 media_proxy = Application.get_env(:pleroma, :media_proxy)
25 suggestions = Application.get_env(:pleroma, :suggestions)
26 chat = Application.get_env(:pleroma, :chat)
27 gopher = Application.get_env(:pleroma, :gopher)
28 stats = Stats.get_stats()
31 User.moderator_user_query()
33 |> Enum.map(fn u -> u.ap_id end)
39 version: Keyword.get(instance, :version)
41 protocols: ["ostatus", "activitypub"],
46 openRegistrations: Keyword.get(instance, :registrations_open),
49 total: stats.user_count || 0
51 localPosts: stats.status_count || 0
54 nodeName: Keyword.get(instance, :name),
55 nodeDescription: Keyword.get(instance, :description),
56 mediaProxy: Keyword.get(media_proxy, :enabled),
57 private: !Keyword.get(instance, :public, true),
59 enabled: Keyword.get(suggestions, :enabled, false),
60 thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""),
61 timeout: Keyword.get(suggestions, :timeout, 5000),
62 web: Keyword.get(suggestions, :web, "")
64 staffAccounts: staff_accounts,
65 chat: Keyword.get(chat, :enabled),
66 gopher: Keyword.get(gopher, :enabled)
73 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
78 def nodeinfo(conn, _) do
81 |> json(%{error: "Nodeinfo schema version not handled"})