Adding a `norss` user preference
There is now a `norss` user preference for a user to opt out of having an RSS feed of their public posts. This operates on the exact same logic as the existing `noindex` for the search engine opt-out: the admin can check a box in Site Settings for a default setting for users. If a user has never touched their RSS opt-out setting then it is equal to whatever the default is. But individual users can override the default in their Preferences -> Other menu. So a privacy-minded server admin could opt everyone out by default, but the overall default behavior is to have RSS feeds of public posts for everyone, which is the default Mastodon behavior anyway. The `norss`, like `noindex`, is just a key on a pre-existing `settings` object that is a key-value store, so there doesn't even need to be a database migration for this! Fixes #1232
This commit is contained in:
parent
4360a50949
commit
427596ab01
|
@ -45,6 +45,11 @@ class AccountsController < ApplicationController
|
|||
format.rss do
|
||||
expires_in 1.minute, public: true
|
||||
|
||||
if @account&.user&.setting_norss == true
|
||||
@statuses = []
|
||||
next
|
||||
end
|
||||
|
||||
limit = params[:limit].present? ? [params[:limit].to_i, PAGE_SIZE_MAX].min : PAGE_SIZE
|
||||
@statuses = filtered_statuses.without_reblogs.without_local_only.limit(limit)
|
||||
@statuses = cache_collection(@statuses, Status)
|
||||
|
|
|
@ -47,6 +47,7 @@ class Settings::PreferencesController < Settings::BaseController
|
|||
:setting_disable_swiping,
|
||||
:setting_system_font_ui,
|
||||
:setting_noindex,
|
||||
:setting_norss,
|
||||
:setting_theme,
|
||||
:setting_aggregate_reblogs,
|
||||
:setting_show_application,
|
||||
|
|
|
@ -5,6 +5,7 @@ module Settings
|
|||
DEFAULTING_TO_UNSCOPED = %w(
|
||||
theme
|
||||
noindex
|
||||
norss
|
||||
).freeze
|
||||
|
||||
def initialize(object)
|
||||
|
|
|
@ -31,6 +31,7 @@ class UserSettingsDecorator
|
|||
user.settings['disable_swiping'] = disable_swiping_preference if change?('setting_disable_swiping')
|
||||
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
|
||||
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
|
||||
user.settings['norss'] = norss_preference if change?('setting_norss')
|
||||
user.settings['theme'] = theme_preference if change?('setting_theme')
|
||||
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
|
||||
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
|
||||
|
@ -102,6 +103,10 @@ class UserSettingsDecorator
|
|||
boolean_cast_setting 'setting_noindex'
|
||||
end
|
||||
|
||||
def norss_preference
|
||||
boolean_cast_setting 'setting_norss'
|
||||
end
|
||||
|
||||
def show_application_preference
|
||||
boolean_cast_setting 'setting_show_application'
|
||||
end
|
||||
|
|
|
@ -33,6 +33,7 @@ class Form::AdminSettings
|
|||
show_domain_blocks
|
||||
show_domain_blocks_rationale
|
||||
noindex
|
||||
norss
|
||||
require_invite_text
|
||||
).freeze
|
||||
|
||||
|
@ -48,6 +49,7 @@ class Form::AdminSettings
|
|||
trends
|
||||
trendable_by_default
|
||||
noindex
|
||||
norss
|
||||
require_invite_text
|
||||
).freeze
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ class User < ApplicationRecord
|
|||
has_many :session_activations, dependent: :destroy
|
||||
|
||||
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
|
||||
:reduce_motion, :system_font_ui, :noindex, :theme, :display_media,
|
||||
:reduce_motion, :system_font_ui, :noindex, :norss, :theme, :display_media,
|
||||
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
||||
:advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
|
||||
:disable_swiping, :default_federation, :always_send_emails,
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
- if @account.user&.setting_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) }/
|
||||
|
||||
- if @older_url
|
||||
|
|
|
@ -91,6 +91,9 @@
|
|||
.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')
|
||||
|
||||
.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')
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
.fields-group
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -671,6 +671,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
|
||||
domain_blocks:
|
||||
all: To everyone
|
||||
disabled: To no one
|
||||
|
|
|
@ -170,6 +170,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
|
||||
|
|
|
@ -30,6 +30,7 @@ defaults: &defaults
|
|||
show_application: true
|
||||
system_font_ui: false
|
||||
noindex: false
|
||||
norss: false
|
||||
theme: 'default'
|
||||
aggregate_reblogs: true
|
||||
advanced_layout: false
|
||||
|
|
Loading…
Reference in New Issue