diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 4d03a04b77..4230ad635a 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -24,6 +24,11 @@ class AccountsController < ApplicationController format.rss do expires_in 1.minute, public: true + if @account&.user&.setting_norss + @statuses = [] + next + end + limit = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE @statuses = filtered_statuses.without_reblogs.limit(limit) @statuses = cache_collection(@statuses, Status) diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 39715b724b..095e44c210 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -48,6 +48,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_system_font_ui, :setting_system_emoji_font, :setting_noindex, + :setting_norss, :setting_hide_followers_count, :setting_aggregate_reblogs, :setting_show_application, diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb index 796de11131..2f2b3f7e42 100644 --- a/app/lib/settings/scoped_settings.rb +++ b/app/lib/settings/scoped_settings.rb @@ -6,6 +6,7 @@ module Settings flavour skin noindex + norss ).freeze def initialize(object) diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 92c393785b..036a395a00 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -35,6 +35,7 @@ class UserSettingsDecorator user.settings['hide_followers_count'] = hide_followers_count_preference if change?('setting_hide_followers_count') user.settings['flavour'] = flavour_preference if change?('setting_flavour') user.settings['skin'] = skin_preference if change?('setting_skin') + user.settings['norss'] = norss_preference if change?('setting_norss') user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs') user.settings['show_application'] = show_application_preference if change?('setting_show_application') user.settings['advanced_layout'] = advanced_layout_preference if change?('setting_advanced_layout') @@ -115,6 +116,10 @@ class UserSettingsDecorator settings['setting_flavour'] end + def norss_preference + boolean_cast_setting 'setting_norss' + end + def skin_preference settings['setting_skin'] end diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index f76ee42e77..c5aced494c 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -34,6 +34,7 @@ class Form::AdminSettings show_domain_blocks show_domain_blocks_rationale noindex + norss outgoing_spoilers require_invite_text captcha_enabled @@ -62,6 +63,7 @@ class Form::AdminSettings trendable_by_default trending_status_cw noindex + norss require_invite_text captcha_enabled ).freeze diff --git a/app/models/user.rb b/app/models/user.rb index fc84c41aee..2c08700e17 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,7 +132,7 @@ class User < ApplicationRecord has_many :session_activations, dependent: :destroy delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal, - :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_followers_count, + :reduce_motion, :system_font_ui, :noindex, :norss, :flavour, :skin, :display_media, :hide_followers_count, :expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images, :visible_reactions, :disable_swiping, :always_send_emails, :default_content_type, :system_emoji_font, diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index e8fd27e109..2e58bdc03a 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -5,7 +5,9 @@ - if @account.user_prefers_noindex? %meta{ name: 'robots', content: 'noindex, noarchive' }/ - %link{ rel: 'alternate', type: 'application/rss+xml', href: @rss_url }/ + - if !@account.user&.setting_norss + %link{ rel: 'alternate', type: 'application/rss+xml', href: @rss_url }/ + %link{ rel: 'alternate', type: 'application/activity+json', href: ActivityPub::TagManager.instance.uri_for(@account) }/ - @account.fields.select(&:verifiable?).each do |field| diff --git a/app/views/admin/settings/discovery/show.html.haml b/app/views/admin/settings/discovery/show.html.haml index 460bb57091..5565659cb3 100644 --- a/app/views/admin/settings/discovery/show.html.haml +++ b/app/views/admin/settings/discovery/show.html.haml @@ -29,6 +29,9 @@ .fields-group = f.input :timeline_preview, as: :boolean, wrapper: :with_label + .fields-group + = f.input :norss, as: :boolean, wrapper: :with_label, label: t('admin.settings.default_norss.title'), hint: t('admin.settings.default_norss.desc_html') + .fields-group = f.input :noindex, as: :boolean, wrapper: :with_label, label: t('admin.settings.default_noindex.title'), hint: t('admin.settings.default_noindex.desc_html') diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index fb3d21060c..397d5e9e6b 100644 --- a/app/views/settings/preferences/other/show.html.haml +++ b/app/views/settings/preferences/other/show.html.haml @@ -10,6 +10,9 @@ .fields-group = f.input :setting_noindex, as: :boolean, wrapper: :with_label + .fields-group + = f.input :setting_norss, as: :boolean, wrapper: :with_label + .fields-group = f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label, recommended: true diff --git a/config/locales/en.yml b/config/locales/en.yml index 39ff4236a1..2352245a08 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -731,6 +731,9 @@ en: default_noindex: desc_html: Affects all users who have not changed this setting themselves title: Opt users out of search engine indexing by default + default_norss: + desc_html: Affects all users who have not changed this setting themselves + title: Opt users out of having an RSS feed of their public posts by default discovery: follow_recommendations: Follow recommendations preamble: Surfacing interesting content is instrumental in onboarding new users who may not know anyone Mastodon. Control how various discovery features work on your server. diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index d01f0ae753..81e9ef7f12 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -208,6 +208,7 @@ en: setting_expand_spoilers: Always expand posts marked with content warnings setting_hide_network: Hide your social graph setting_noindex: Opt-out of search engine indexing + setting_norss: Opt-out of an RSS feed for your public posts setting_reduce_motion: Reduce motion in animations setting_show_application: Disclose application used to send posts setting_system_font_ui: Use system's default font diff --git a/config/settings.yml b/config/settings.yml index da5dec5632..7f84719050 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -31,6 +31,7 @@ defaults: &defaults system_font_ui: false system_emoji_font: false noindex: false + norss: false hide_followers_count: false flavour: 'glitch' skin: 'default'