1 defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
2 use Pleroma.Web, :controller
6 alias Pleroma.{User, Repo}
8 alias Pleroma.Web.ActivityPub.MRF
10 plug(Pleroma.Web.FederatingPlug)
12 def schemas(conn, _params) do
16 rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
17 href: Web.base_url() <> "/nodeinfo/2.0.json"
25 # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
26 def nodeinfo(conn, %{"version" => "2.0"}) do
27 instance = Application.get_env(:pleroma, :instance)
28 media_proxy = Application.get_env(:pleroma, :media_proxy)
29 suggestions = Application.get_env(:pleroma, :suggestions)
30 chat = Application.get_env(:pleroma, :chat)
31 gopher = Application.get_env(:pleroma, :gopher)
32 stats = Stats.get_stats()
35 Application.get_env(:pleroma, :mrf_simple)
40 |> Enum.map(fn policy -> to_string(policy) |> String.split(".") |> List.last() end)
42 quarantined = Keyword.get(instance, :quarantined_instances)
45 if is_list(quarantined) do
52 User.moderator_user_query()
54 |> Enum.map(fn u -> u.ap_id end)
57 Config.get([:mrf_user_allowlist], [])
58 |> Enum.into(%{}, fn {k, v} -> {k, length(v)} end)
60 mrf_transparency = Keyword.get(instance, :mrf_transparency)
63 if mrf_transparency do
65 mrf_policies: mrf_policies,
66 mrf_simple: mrf_simple,
67 mrf_user_allowlist: mrf_user_allowlist,
68 quarantined_instances: quarantined
78 "mastodon_api_streaming",
79 if Keyword.get(media_proxy, :enabled) do
82 if Keyword.get(gopher, :enabled) do
85 if Keyword.get(chat, :enabled) do
88 if Keyword.get(suggestions, :enabled) do
91 if Keyword.get(instance, :allow_relay) do
100 name: Pleroma.Application.name(),
101 version: Pleroma.Application.version()
103 protocols: ["ostatus", "activitypub"],
108 openRegistrations: Keyword.get(instance, :registrations_open),
111 total: stats.user_count || 0
113 localPosts: stats.status_count || 0
116 nodeName: Keyword.get(instance, :name),
117 nodeDescription: Keyword.get(instance, :description),
118 private: !Keyword.get(instance, :public, true),
120 enabled: Keyword.get(suggestions, :enabled, false),
121 thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""),
122 timeout: Keyword.get(suggestions, :timeout, 5000),
123 limit: Keyword.get(suggestions, :limit, 23),
124 web: Keyword.get(suggestions, :web, "")
126 staffAccounts: staff_accounts,
127 federation: federation_response,
128 postFormats: Keyword.get(instance, :allowed_post_formats),
130 general: Keyword.get(instance, :upload_limit),
131 avatar: Keyword.get(instance, :avatar_upload_limit),
132 banner: Keyword.get(instance, :banner_upload_limit),
133 background: Keyword.get(instance, :background_upload_limit)
135 invitesEnabled: Keyword.get(instance, :invites_enabled, false),
143 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
148 def nodeinfo(conn, _) do
151 |> json(%{error: "Nodeinfo schema version not handled"})