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 Application.get_env(:pleroma, :mrf_simple)
34 mrf_policies = Keyword.get(instance, :rewrite_policy)
37 if(is_list(mrf_policies)) do
39 |> Enum.map(fn policy -> to_string(policy) |> String.split(".") |> List.last() end)
41 [to_string(mrf_policies) |> String.split(".") |> List.last()]
44 quarantined = Keyword.get(instance, :quarantined_instances)
47 if is_list(quarantined) do
54 User.moderator_user_query()
56 |> Enum.map(fn u -> u.ap_id end)
62 version: Keyword.get(instance, :version)
64 protocols: ["ostatus", "activitypub"],
69 openRegistrations: Keyword.get(instance, :registrations_open),
72 total: stats.user_count || 0
74 localPosts: stats.status_count || 0
77 nodeName: Keyword.get(instance, :name),
78 nodeDescription: Keyword.get(instance, :description),
79 mediaProxy: Keyword.get(media_proxy, :enabled),
80 private: !Keyword.get(instance, :public, true),
82 enabled: Keyword.get(suggestions, :enabled, false),
83 thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""),
84 timeout: Keyword.get(suggestions, :timeout, 5000),
85 limit: Keyword.get(suggestions, :limit, 23),
86 web: Keyword.get(suggestions, :web, "")
88 staffAccounts: staff_accounts,
89 chat: Keyword.get(chat, :enabled),
90 gopher: Keyword.get(gopher, :enabled),
92 mrf_policies: mrf_policies,
93 mrf_simple: mrf_simple,
94 quarantined_instances: quarantined
96 postFormats: Keyword.get(instance, :allowed_post_formats)
103 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
108 def nodeinfo(conn, _) do
111 |> json(%{error: "Nodeinfo schema version not handled"})