1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
6 use Pleroma.Web, :controller
12 alias Pleroma.Web.ActivityPub.MRF
13 alias Pleroma.Web.Federator.Publisher
15 def schemas(conn, _params) do
19 rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
20 href: Web.base_url() <> "/nodeinfo/2.0.json"
23 rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
24 href: Web.base_url() <> "/nodeinfo/2.1.json"
32 # returns a nodeinfo 2.0 map, since 2.1 just adds a repository field
35 stats = Stats.get_stats()
37 quarantined = Config.get([:instance, :quarantined_instances], [])
41 |> Enum.map(fn u -> u.ap_id end)
44 if Config.get([:instance, :mrf_transparency]) do
45 {:ok, data} = MRF.describe()
48 |> Map.merge(%{quarantined_instances: quarantined})
57 "mastodon_api_streaming",
59 "pleroma_explicit_addressing",
60 "shareable_emoji_packs",
61 if Config.get([:media_proxy, :enabled]) do
64 if Config.get([:gopher, :enabled]) do
67 if Config.get([:chat, :enabled]) do
70 if Config.get([:suggestions, :enabled]) do
73 if Config.get([:instance, :allow_relay]) do
76 if Config.get([:instance, :safe_dm_mentions]) do
85 name: Pleroma.Application.name() |> String.downcase(),
86 version: Pleroma.Application.version()
88 protocols: Publisher.gather_nodeinfo_protocol_names(),
93 openRegistrations: Config.get([:instance, :registrations_open]),
96 total: stats.user_count || 0
98 localPosts: stats.status_count || 0
101 nodeName: Config.get([:instance, :name]),
102 nodeDescription: Config.get([:instance, :description]),
103 private: !Config.get([:instance, :public], true),
105 enabled: Config.get([:suggestions, :enabled], false),
106 thirdPartyEngine: Config.get([:suggestions, :third_party_engine], ""),
107 timeout: Config.get([:suggestions, :timeout], 5000),
108 limit: Config.get([:suggestions, :limit], 23),
109 web: Config.get([:suggestions, :web], "")
111 staffAccounts: staff_accounts,
112 federation: federation_response,
113 pollLimits: Config.get([:instance, :poll_limits]),
114 postFormats: Config.get([:instance, :allowed_post_formats]),
116 general: Config.get([:instance, :upload_limit]),
117 avatar: Config.get([:instance, :avatar_upload_limit]),
118 banner: Config.get([:instance, :banner_upload_limit]),
119 background: Config.get([:instance, :background_upload_limit])
121 accountActivationRequired: Config.get([:instance, :account_activation_required], false),
122 invitesEnabled: Config.get([:instance, :invites_enabled], false),
123 mailerEnabled: Config.get([Pleroma.Emails.Mailer, :enabled], false),
125 restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
126 skipThreadContainment: Config.get([:instance, :skip_thread_containment], false)
131 # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
132 # and https://github.com/jhass/nodeinfo/blob/master/schemas/2.1/schema.json
133 def nodeinfo(conn, %{"version" => "2.0"}) do
137 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
139 |> json(raw_nodeinfo())
142 def nodeinfo(conn, %{"version" => "2.1"}) do
143 raw_response = raw_nodeinfo()
147 |> Map.get(:software)
148 |> Map.put(:repository, Pleroma.Application.repository())
152 |> Map.put(:software, updated_software)
153 |> Map.put(:version, "2.1")
158 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.1#; charset=utf-8"
163 def nodeinfo(conn, _) do
164 render_error(conn, :not_found, "Nodeinfo schema version not handled")