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})
49 |> Map.put(:enabled, Config.get([:instance, :federating]))
58 "mastodon_api_streaming",
60 "pleroma_explicit_addressing",
61 "shareable_emoji_packs",
63 if Config.get([:media_proxy, :enabled]) do
66 if Config.get([:gopher, :enabled]) do
69 if Config.get([:chat, :enabled]) do
72 if Config.get([:instance, :allow_relay]) do
75 if Config.get([:instance, :safe_dm_mentions]) do
84 name: Pleroma.Application.name() |> String.downcase(),
85 version: Pleroma.Application.version()
87 protocols: Publisher.gather_nodeinfo_protocol_names(),
92 openRegistrations: Config.get([:instance, :registrations_open]),
95 total: stats.user_count || 0
97 localPosts: stats.status_count || 0
100 nodeName: Config.get([:instance, :name]),
101 nodeDescription: Config.get([:instance, :description]),
102 private: !Config.get([:instance, :public], true),
106 staffAccounts: staff_accounts,
107 federation: federation_response,
108 pollLimits: Config.get([:instance, :poll_limits]),
109 postFormats: Config.get([:instance, :allowed_post_formats]),
111 general: Config.get([:instance, :upload_limit]),
112 avatar: Config.get([:instance, :avatar_upload_limit]),
113 banner: Config.get([:instance, :banner_upload_limit]),
114 background: Config.get([:instance, :background_upload_limit])
117 maxFields: Config.get([:instance, :max_account_fields]),
118 maxRemoteFields: Config.get([:instance, :max_remote_account_fields]),
119 nameLength: Config.get([:instance, :account_field_name_length]),
120 valueLength: Config.get([:instance, :account_field_value_length])
122 accountActivationRequired: Config.get([:instance, :account_activation_required], false),
123 invitesEnabled: Config.get([:instance, :invites_enabled], false),
124 mailerEnabled: Config.get([Pleroma.Emails.Mailer, :enabled], false),
126 restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
127 skipThreadContainment: Config.get([:instance, :skip_thread_containment], false)
132 # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
133 # and https://github.com/jhass/nodeinfo/blob/master/schemas/2.1/schema.json
134 def nodeinfo(conn, %{"version" => "2.0"}) do
138 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8"
140 |> json(raw_nodeinfo())
143 def nodeinfo(conn, %{"version" => "2.1"}) do
144 raw_response = raw_nodeinfo()
148 |> Map.get(:software)
149 |> Map.put(:repository, Pleroma.Application.repository())
153 |> Map.put(:software, updated_software)
154 |> Map.put(:version, "2.1")
159 "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.1#; charset=utf-8"
164 def nodeinfo(conn, _) do
165 render_error(conn, :not_found, "Nodeinfo schema version not handled")