1 defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
2 use Pleroma.Web, :controller
6 alias Pleroma.{User, Repo}
7 alias Pleroma.Web.ActivityPub.MRF
9 plug(Pleroma.Web.FederatingPlug)
11 def schemas(conn, _params) do
15 rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
16 href: Web.base_url() <> "/nodeinfo/2.0.json"
24 # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
25 def nodeinfo(conn, %{"version" => "2.0"}) do
26 instance = Application.get_env(:pleroma, :instance)
27 media_proxy = Application.get_env(:pleroma, :media_proxy)
28 suggestions = Application.get_env(:pleroma, :suggestions)
29 chat = Application.get_env(:pleroma, :chat)
30 gopher = Application.get_env(:pleroma, :gopher)
31 stats = Stats.get_stats()
34 Application.get_env(:pleroma, :mrf_simple)
39 |> Enum.map(fn policy -> to_string(policy) |> String.split(".") |> List.last() end)
41 quarantined = Keyword.get(instance, :quarantined_instances)
44 if is_list(quarantined) do
51 User.moderator_user_query()
53 |> Enum.map(fn u -> u.ap_id end)
55 mrf_transparency = Keyword.get(instance, :mrf_transparency)
58 if mrf_transparency do
60 mrf_policies: mrf_policies,
61 mrf_simple: mrf_simple,
62 quarantined_instances: quarantined
71 "mastodon_api_streaming",
72 if Keyword.get(media_proxy, :enabled) do
75 if Keyword.get(gopher, :enabled) do
78 if Keyword.get(chat, :enabled) do
81 if Keyword.get(suggestions, :enabled) do
89 name: Pleroma.Application.name(),
90 version: Pleroma.Application.version()
92 protocols: ["ostatus", "activitypub"],
97 openRegistrations: Keyword.get(instance, :registrations_open),
100 total: stats.user_count || 0
102 localPosts: stats.status_count || 0
105 nodeName: Keyword.get(instance, :name),
106 nodeDescription: Keyword.get(instance, :description),
107 private: !Keyword.get(instance, :public, true),
109 enabled: Keyword.get(suggestions, :enabled, false),
110 thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""),
111 timeout: Keyword.get(suggestions, :timeout, 5000),
112 limit: Keyword.get(suggestions, :limit, 23),
113 web: Keyword.get(suggestions, :web, "")
115 staffAccounts: staff_accounts,
116 federation: federation_response,
117 postFormats: Keyword.get(instance, :allowed_post_formats),
119 general: Keyword.get(instance, :upload_limit),
120 avatar: Keyword.get(instance, :avatar_upload_limit),
121 banner: Keyword.get(instance, :banner_upload_limit),
122 background: Keyword.get(instance, :background_upload_limit)
131 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
136 def nodeinfo(conn, _) do
139 |> json(%{error: "Nodeinfo schema version not handled"})