add server directory and default server opt in options (#40750)

This commit is contained in:
Pia B.
2026-10-05 13:49:58 +00:00
committed by GitHub
parent 842b86096d
commit c2b968fc16
7 changed files with 53 additions and 1 deletions

View File

@@ -47,6 +47,8 @@ class Form::AdminSettings
landing_page
wrapstodon
email_footer_text
opt_in_server_directory
opt_in_server_recommendation
).freeze
INTEGER_KEYS = %i(
@@ -68,6 +70,8 @@ class Form::AdminSettings
noindex
require_invite_text
captcha_enabled
opt_in_server_directory
opt_in_server_recommendation
wrapstodon
).freeze

View File

@@ -41,6 +41,8 @@ class NodeInfo::Serializer < ActiveModel::Serializer
{
nodeName: Setting.site_title,
nodeDescription: Setting.site_short_description,
optInServerDirectory: Setting.opt_in_server_directory,
optInServerRecommendation: Setting.opt_in_server_recommendation,
}
end

View File

@@ -10,6 +10,22 @@
%p.lead= t('admin.settings.external.preamble')
%h2= t('admin.settings.external.directory')
.fields-group
= f.input :opt_in_server_directory,
as: :boolean,
hint: t('admin.settings.external.opt_in_server_directory.description'),
label: t('admin.settings.external.opt_in_server_directory.title'),
wrapper: :with_label
.fields-group
= f.input :opt_in_server_recommendation,
as: :boolean,
hint: t('admin.settings.external.opt_in_server_recommendation.description'),
label: t('admin.settings.external.opt_in_server_recommendation.title'),
wrapper: :with_label
%h2= t('admin.settings.external.privacy')
.fields-group

View File

@@ -1007,6 +1007,13 @@ en:
disabled: To no one
users: To logged-in local users
external:
directory: Server Directory
opt_in_server_directory:
description: Allow your server to be listed in server directories such as the one featured on https://joinmastodon.org/servers.
title: Opt your server in for the server directory
opt_in_server_recommendation:
description: Allow your server to be recommended at sign-up time in applications such as the official Mastodon clients.
title: Opt your server in for server recommendation
preamble: Control how much information about your server gets shared with other services and how discoverable your server should be.
privacy: Privacy
publish_statistics: Publish statistics

View File

@@ -34,6 +34,8 @@ defaults: &defaults
captcha_enabled: false
allow_referrer_origin: false
landing_page: 'trends'
opt_in_server_directory: false
opt_in_server_recommendation: false
wrapstodon: true
development:

View File

@@ -17,7 +17,7 @@ RSpec.describe 'Admin Settings External Discovery' do
end
describe 'PUT /admin/settings/external with valid params' do
let(:request) { put admin_settings_external_path, params: { form_admin_settings: { activity_api_enabled: 'false' } } }
let(:request) { put admin_settings_external_path, params: { form_admin_settings: { activity_api_enabled: '0' } } }
it 'saves the value for a valid key' do
expect { request }.to change(Setting, :activity_api_enabled).from(true)

View File

@@ -55,4 +55,25 @@ RSpec.describe 'The well-known node-info endpoints' do
{ 'foo' => 0 }
end
end
describe '#nodeinfo/2.0 endpoint containing opt in metadata' do
before do
Setting.opt_in_server_directory = 'true'
end
let(:expected_metadata) do
{
nodeName: 'Mastodon',
nodeDescription: '',
optInServerDirectory: 'true',
optInServerRecommendation: false,
}
end
it 'returns server directory opt in data' do
get '/nodeinfo/2.0'
expect(response.parsed_body[:metadata].symbolize_keys).to eq(expected_metadata)
end
end
end