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
77 "mastodon_api_streaming",
78 if Keyword.get(media_proxy, :enabled) do
81 if Keyword.get(gopher, :enabled) do
84 if Keyword.get(chat, :enabled) do
87 if Keyword.get(suggestions, :enabled) do
95 name: Pleroma.Application.name(),
96 version: Pleroma.Application.version()
98 protocols: ["ostatus", "activitypub"],
103 openRegistrations: Keyword.get(instance, :registrations_open),
106 total: stats.user_count || 0
108 localPosts: stats.status_count || 0
111 nodeName: Keyword.get(instance, :name),
112 nodeDescription: Keyword.get(instance, :description),
113 private: !Keyword.get(instance, :public, true),
115 enabled: Keyword.get(suggestions, :enabled, false),
116 thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""),
117 timeout: Keyword.get(suggestions, :timeout, 5000),
118 limit: Keyword.get(suggestions, :limit, 23),
119 web: Keyword.get(suggestions, :web, "")
121 staffAccounts: staff_accounts,
122 federation: federation_response,
123 postFormats: Keyword.get(instance, :allowed_post_formats),
125 general: Keyword.get(instance, :upload_limit),
126 avatar: Keyword.get(instance, :avatar_upload_limit),
127 banner: Keyword.get(instance, :banner_upload_limit),
128 background: Keyword.get(instance, :background_upload_limit)
137 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
142 def nodeinfo(conn, _) do
145 |> json(%{error: "Nodeinfo schema version not handled"})