1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.InstanceView do
9 alias Pleroma.Web.ActivityPub.MRF
11 @mastodon_api_level "2.7.2"
13 def render("show.json", _) do
14 instance = Config.get(:instance)
17 uri: Pleroma.Web.Endpoint.url(),
18 title: Keyword.get(instance, :name),
19 description: Keyword.get(instance, :description),
20 version: "#{@mastodon_api_level} (compatible; #{Pleroma.Application.named_version()})",
21 email: Keyword.get(instance, :email),
23 streaming_api: Pleroma.Web.Endpoint.websocket_url()
25 stats: Pleroma.Stats.get_stats(),
27 URI.merge(Pleroma.Web.Endpoint.url(), Keyword.get(instance, :instance_thumbnail))
30 registrations: Keyword.get(instance, :registrations_open),
31 approval_required: Keyword.get(instance, :account_approval_required),
32 # Extra (not present in Mastodon):
33 max_toot_chars: Keyword.get(instance, :limit),
34 poll_limits: Keyword.get(instance, :poll_limits),
35 upload_limit: Keyword.get(instance, :upload_limit),
36 avatar_upload_limit: Keyword.get(instance, :avatar_upload_limit),
37 background_upload_limit: Keyword.get(instance, :background_upload_limit),
38 banner_upload_limit: Keyword.get(instance, :banner_upload_limit),
39 background_image: Pleroma.Web.Endpoint.url() <> Keyword.get(instance, :background_image),
40 shout_limit: Config.get([:shout, :limit]),
41 description_limit: Keyword.get(instance, :description_limit),
44 account_activation_required: Keyword.get(instance, :account_activation_required),
46 federation: federation(),
47 fields_limits: fields_limits(),
48 post_formats: Config.get([:instance, :allowed_post_formats]),
49 privileged_staff: Config.get([:instance, :privileged_staff])
51 stats: %{mau: Pleroma.User.active_user_count()},
52 vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
61 "mastodon_api_streaming",
64 "pleroma_explicit_addressing",
65 "shareable_emoji_packs",
67 "pleroma:api/v1/notifications:include_types_filter",
68 if Config.get([:media_proxy, :enabled]) do
71 if Config.get([:gopher, :enabled]) do
75 if Config.get([:shout, :enabled]) do
78 if Config.get([:shout, :enabled]) do
81 if Config.get([:instance, :allow_relay]) do
84 if Config.get([:instance, :safe_dm_mentions]) do
87 "pleroma_emoji_reactions",
88 "pleroma_chat_messages",
89 if Config.get([:instance, :show_reactions]) do
92 if Config.get([:instance, :profile_directory]) do
95 "custom_emoji_reactions"
101 quarantined = Config.get([:instance, :quarantined_instances], [])
103 if Config.get([:mrf, :transparency]) do
104 {:ok, data} = MRF.describe()
108 :quarantined_instances,
109 Enum.map(quarantined, fn {instance, _reason} -> instance end)
111 # This is for backwards compatibility. We originally didn't sent
112 # extra info like a reason why an instance was rejected/quarantined/etc.
113 # Because we didn't want to break backwards compatibility it was decided
114 # to add an extra "info" key.
115 |> Map.put(:quarantined_instances_info, %{
116 "quarantined_instances" =>
118 |> Enum.map(fn {instance, reason} -> {instance, %{"reason" => reason}} end)
124 |> Map.put(:enabled, Config.get([:instance, :federating]))
129 max_fields: Config.get([:instance, :max_account_fields]),
130 max_remote_fields: Config.get([:instance, :max_remote_account_fields]),
131 name_length: Config.get([:instance, :account_field_name_length]),
132 value_length: Config.get([:instance, :account_field_value_length])