From ca5c920a372993b047e9a7d2cd9cb0c0bd7a5b9a Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 18:47:21 -0800 Subject: [PATCH 01/12] Swap version numbers and add identifier For better compatibility with third party apps and to be more in line with what other fediverse software does (including other Mastodon forks), I am changing the semver version to reflect the synchronized Mastodon version, and making the Hometown version part of the build metadata after the '+' sign. I am also adding a 'hometown' identifier to the build metadata. Fixes #1213 --- lib/mastodon/version.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 35edaca3b..1571b0410 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -5,15 +5,15 @@ module Mastodon module_function def major - 1 + 3 end def minor - 0 + 5 end def patch - 7 + 5 end def flags @@ -21,7 +21,7 @@ module Mastodon end def suffix - '+3.5.5' + '+hometown-1.0.8' end def to_a From 6341c9419cdb044c338beccbb9f1b3638ae36bba Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 19:11:42 -0800 Subject: [PATCH 02/12] Make the "I don't like it" category let you report an account This makes it so that when a user reports an account and selects "I don't like it", instead of getting a message about how they should personally block that person, it sends them to the normal reporting interface and they can file their report. Fixes #1202 --- app/javascript/mastodon/features/report/category.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/mastodon/features/report/category.js b/app/javascript/mastodon/features/report/category.js index 9215b3f51..d8ccc0417 100644 --- a/app/javascript/mastodon/features/report/category.js +++ b/app/javascript/mastodon/features/report/category.js @@ -41,7 +41,7 @@ class Category extends React.PureComponent { switch(category) { case 'dislike': - onNextStep('thanks'); + onNextStep('statuses'); break; case 'violation': onNextStep('rules'); From b8c624b673c255560baeb53f4abe997f790d32fd Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 19:36:42 -0800 Subject: [PATCH 03/12] Fix references to Mastodon in footer We now link the Hometown documentation, and list Hometown first as the place to report issues. Fixes #1206 --- .../features/ui/components/link_footer.js | 16 +++++++++------- app/javascript/mastodon/locales/en.json | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/javascript/mastodon/features/ui/components/link_footer.js b/app/javascript/mastodon/features/ui/components/link_footer.js index 5367d11ca..ee85197a2 100644 --- a/app/javascript/mastodon/features/ui/components/link_footer.js +++ b/app/javascript/mastodon/features/ui/components/link_footer.js @@ -56,22 +56,24 @@ class LinkFooter extends React.PureComponent {
  • ·
  • ·
  • ·
  • -
  • ·
  • +
  • ·
  • - {repository} (v{version}) }} - /> hometown-fork/hometown }} />

    +

    + {repository} (v{version}) }} + /> +

    ); } diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index d39931dd4..3cbea9e48 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -212,9 +212,9 @@ "getting_started.directory": "Profile directory", "getting_started.documentation": "Documentation", "getting_started.heading": "Getting started", - "getting_started.hometown_open_source_notice": "Hometown is also open source, at {hometown}.", + "getting_started.hometown_open_source_notice": "Hometown is open source software. You can contribute or report issues on GitHub at {hometown}.", "getting_started.invite": "Invite people", - "getting_started.open_source_notice": "Mastodon is open source software. You can contribute or report issues on GitHub at {github}.", + "getting_started.open_source_notice": "Mastodon is also open source, and is available at {github}.", "getting_started.security": "Account settings", "getting_started.terms": "Terms of service", "hashtag.column_header.tag_mode.all": "and {additional}", From fb23e84d58d4601159b9e0578e318477b57079d6 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 19:45:40 -0800 Subject: [PATCH 04/12] Add toggle for multiple choice polls Adding an explicit toggle to the poll interface so the multiple choice polls are no longer a "hidden" feature. Fixes #1174 --- .../features/compose/components/poll_form.js | 7 +++++++ app/javascript/mastodon/locales/en.json | 1 + app/javascript/styles/mastodon/components.scss | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/app/javascript/mastodon/features/compose/components/poll_form.js b/app/javascript/mastodon/features/compose/components/poll_form.js index db49f90eb..aec76e683 100644 --- a/app/javascript/mastodon/features/compose/components/poll_form.js +++ b/app/javascript/mastodon/features/compose/components/poll_form.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; +import Toggle from 'react-toggle'; import IconButton from 'mastodon/components/icon_button'; import Icon from 'mastodon/components/icon'; import AutosuggestInput from 'mastodon/components/autosuggest_input'; @@ -155,6 +156,12 @@ class PollForm extends ImmutablePureComponent {
      {options.map((title, i) =>
    +
    + + + + +
    diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index d39931dd4..5e7de401b 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -374,6 +374,7 @@ "poll.vote": "Vote", "poll.voted": "You voted for this answer", "poll.votes": "{votes, plural, one {# vote} other {# votes}}", + "poll.is_multiple": "Multiple choice", "poll_button.add_poll": "Add a poll", "poll_button.remove_poll": "Remove poll", "privacy.change": "Change post privacy", diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 6eb943b27..dddb71c71 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -4116,6 +4116,21 @@ a.status-card.compact:hover { } } +// Hometown: Styling for toggle for multiple choice polls +.is-multiple-toggle { + display: block; + line-height: 24px; + padding-left: 10px; +} + +.is-multiple-toggle__label { + color: $inverted-text-color; + display: inline-block; + margin-bottom: 14px; + margin-left: 8px; + vertical-align: middle; +} + .setting-toggle { display: block; line-height: 24px; From 503efed083259e21e4d635ff644067cdd155e7e0 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 20:28:45 -0800 Subject: [PATCH 05/12] Add option to keep local-only posts on auto-delete This adds a `keep_local` column to the `account_statuses_cleanup_policy` table in the database. There is a new checkbox in the preferences for automatic post deletion, and when calculating which statuses to delete there is now a filter for `without_local_scope`. --- app/controllers/statuses_cleanup_controller.rb | 2 +- app/models/account_statuses_cleanup_policy.rb | 6 ++++++ app/views/statuses_cleanup/show.html.haml | 4 ++++ config/locales/en.yml | 2 ++ ...1_add_keep_local_to_account_statuses_cleanup_policies.rb | 5 +++++ db/schema.rb | 3 ++- 6 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb diff --git a/app/controllers/statuses_cleanup_controller.rb b/app/controllers/statuses_cleanup_controller.rb index be234cdcb..74c5676ce 100644 --- a/app/controllers/statuses_cleanup_controller.rb +++ b/app/controllers/statuses_cleanup_controller.rb @@ -26,7 +26,7 @@ class StatusesCleanupController < ApplicationController end def resource_params - params.require(:account_statuses_cleanup_policy).permit(:enabled, :min_status_age, :keep_direct, :keep_pinned, :keep_polls, :keep_media, :keep_self_fav, :keep_self_bookmark, :min_favs, :min_reblogs) + params.require(:account_statuses_cleanup_policy).permit(:enabled, :min_status_age, :keep_direct, :keep_pinned, :keep_polls, :keep_media, :keep_self_fav, :keep_local, :keep_self_bookmark, :min_favs, :min_reblogs) end def set_body_classes diff --git a/app/models/account_statuses_cleanup_policy.rb b/app/models/account_statuses_cleanup_policy.rb index 365123653..7f2bc58fb 100644 --- a/app/models/account_statuses_cleanup_policy.rb +++ b/app/models/account_statuses_cleanup_policy.rb @@ -14,6 +14,7 @@ # keep_media :boolean default(FALSE), not null # keep_self_fav :boolean default(TRUE), not null # keep_self_bookmark :boolean default(TRUE), not null +# keep_local :boolean default(TRUE), not null # min_favs :integer # min_reblogs :integer # created_at :datetime not null @@ -66,6 +67,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord scope.merge!(without_poll_scope) if keep_polls? scope.merge!(without_media_scope) if keep_media? scope.merge!(without_self_fav_scope) if keep_self_fav? + scope.merge!(without_local_scope) if keep_local? scope.merge!(without_self_bookmark_scope) if keep_self_bookmark? scope.reorder(id: :asc).limit(limit) @@ -143,6 +145,10 @@ class AccountStatusesCleanupPolicy < ApplicationRecord Status.where(Status.arel_table[:id].lteq(max_id)) end + def without_local_scope + Status.where(local_only: false) + end + def without_self_fav_scope Status.where('NOT EXISTS (SELECT * FROM favourites fav WHERE fav.account_id = statuses.account_id AND fav.status_id = statuses.id)') end diff --git a/app/views/statuses_cleanup/show.html.haml b/app/views/statuses_cleanup/show.html.haml index 59de4b5aa..07b1071ba 100644 --- a/app/views/statuses_cleanup/show.html.haml +++ b/app/views/statuses_cleanup/show.html.haml @@ -34,6 +34,10 @@ .fields-row__column.fields-row__column-6.fields-group = f.input :keep_media, wrapper: :with_label, label: t('statuses_cleanup.keep_media'), hint: t('statuses_cleanup.keep_media_hint') + .fields-row + .fields-row__column.fields-row__column-6.fields-group + = f.input :keep_local, wrapper: :with_label, label: t('statuses_cleanup.keep_local'), hint: t('statuses_cleanup.keep_local_hint') + %h4= t('statuses_cleanup.interaction_exceptions') .fields-row diff --git a/config/locales/en.yml b/config/locales/en.yml index ea954691b..10e2d6c74 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1494,6 +1494,8 @@ en: interaction_exceptions_explanation: Note that there is no guarantee for posts to be deleted if they go below the favourite or boost threshold after having once gone over them. keep_direct: Keep direct messages keep_direct_hint: Doesn't delete any of your direct messages + keep_local: Keep local-only messages + keep_local_hint: Doesn't delete any of your local-only posts keep_media: Keep posts with media attachments keep_media_hint: Doesn't delete any of your posts that have media attachments keep_pinned: Keep pinned posts diff --git a/db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb b/db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb new file mode 100644 index 000000000..ae674189e --- /dev/null +++ b/db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb @@ -0,0 +1,5 @@ +class AddKeepLocalToAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1] + def change + add_column :account_statuses_cleanup_policies, :keep_local, :boolean, null: false, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 6c8c61ac4..c6da51728 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_04_29_101850) do +ActiveRecord::Schema.define(version: 2022_12_02_035831) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -116,6 +116,7 @@ ActiveRecord::Schema.define(version: 2022_04_29_101850) do t.integer "min_reblogs" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.boolean "keep_local", default: true, null: false t.index ["account_id"], name: "index_account_statuses_cleanup_policies_on_account_id" end From 160c575c8bc7764825821d7bd7fbfb94b3a24551 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 21:07:04 -0800 Subject: [PATCH 06/12] Making the "media gallery" not show up on Articles When we fetch Articles, we render images inline as intended by the Article. There is no need for a Media Gallery item. --- app/javascript/mastodon/components/status.js | 2 +- .../mastodon/features/status/components/detailed_status.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index a3d770e7d..8a3c4f1d7 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -498,7 +498,7 @@ class Status extends ImmutablePureComponent { - {media} + {status.get('activity_pub_type') === 'Article' ? null : media}
    diff --git a/app/javascript/mastodon/features/status/components/detailed_status.js b/app/javascript/mastodon/features/status/components/detailed_status.js index 11b1aab21..f46ce9b61 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.js +++ b/app/javascript/mastodon/features/status/components/detailed_status.js @@ -264,7 +264,7 @@ class DetailedStatus extends ImmutablePureComponent { - {media} + {status.get('activity_pub_type') === 'Article' ? null : media}
    From a52bd88273ac4e6c0987aa5faa3dfafb2caa3f08 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 21:23:10 -0800 Subject: [PATCH 07/12] Expose the "default_federation" preference on the preferences API Now when you make a call to `api/v1/preferences` you get a `posting:default:federation` response, which is `true` if the user's posts federate by default, and `false` if the user's posts are local-only by default. --- app/serializers/rest/preferences_serializer.rb | 5 +++++ config/locales/simple_form.en.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/serializers/rest/preferences_serializer.rb b/app/serializers/rest/preferences_serializer.rb index 874bd990d..e8f719716 100644 --- a/app/serializers/rest/preferences_serializer.rb +++ b/app/serializers/rest/preferences_serializer.rb @@ -4,6 +4,7 @@ class REST::PreferencesSerializer < ActiveModel::Serializer attribute :posting_default_privacy, key: 'posting:default:visibility' attribute :posting_default_sensitive, key: 'posting:default:sensitive' attribute :posting_default_language, key: 'posting:default:language' + attribute :posting_default_federation, key: 'posting:default:federation' attribute :reading_default_sensitive_media, key: 'reading:expand:media' attribute :reading_default_sensitive_text, key: 'reading:expand:spoilers' @@ -27,4 +28,8 @@ class REST::PreferencesSerializer < ActiveModel::Serializer def reading_default_sensitive_text object.user.setting_expand_spoilers end + + def posting_default_federation + object.user.setting_default_federation + end end diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index a0c523a9e..d727eb495 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -157,7 +157,7 @@ en: setting_auto_play_gif: Auto-play animated GIFs setting_boost_modal: Show confirmation dialog before boosting setting_crop_images: Crop images in non-expanded posts to 16x9 - setting_default_federation: Allow my posts to reach other instances by default + setting_default_federation: Allow my posts to reach other servers by default setting_default_language: Posting language setting_default_privacy: Posting privacy setting_default_sensitive: Always mark media as sensitive From ae7eee009850dffdf55cbf1ee7244312adb82868 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 22:13:39 -0800 Subject: [PATCH 08/12] Change to migration so it's not "strong" --- ...5831_add_keep_local_to_account_statuses_cleanup_policies.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb b/db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb index ae674189e..9bd268ea7 100644 --- a/db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb +++ b/db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb @@ -1,5 +1,6 @@ class AddKeepLocalToAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1] def change - add_column :account_statuses_cleanup_policies, :keep_local, :boolean, null: false, default: true + add_column :account_statuses_cleanup_policies, :keep_local, :boolean + change_column_default :account_statuses_cleanup_policies, :keep_local, false end end From f6e4ef606adb50cfbb33cba7b19b21b7bfec647e Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Thu, 1 Dec 2022 22:17:50 -0800 Subject: [PATCH 09/12] Fix positioning of version in link footer --- app/javascript/mastodon/features/ui/components/link_footer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/features/ui/components/link_footer.js b/app/javascript/mastodon/features/ui/components/link_footer.js index ee85197a2..0b7414953 100644 --- a/app/javascript/mastodon/features/ui/components/link_footer.js +++ b/app/javascript/mastodon/features/ui/components/link_footer.js @@ -64,14 +64,14 @@ class LinkFooter extends React.PureComponent { hometown-fork/hometown }} + values={{ hometown: hometown-fork/hometown (v{version}) }} />

    {repository} (v{version}) }} + values={{ github: {repository} }} />

    From 9c4df2175352f21e77a5381234b38db37fab0f45 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Fri, 2 Dec 2022 17:13:06 -0800 Subject: [PATCH 10/12] Fix ActivityPub Article rendering bugs * re-add the `article-type` class to article content in feed * fix margin on `article-type` * handle images where `src` is formatted like `/foo/bar.png` by inferring the protocol and domain (and port and password if applicable) from `url` in the AP object received -- without this we can't make a reasonable inference of origin since the domain for the content might be different from the domain of the activitypub server itself --- app/javascript/mastodon/components/status_content.js | 2 +- app/javascript/styles/mastodon/components.scss | 5 +++++ app/lib/activitypub/activity/create.rb | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 8cec89fae..322171c38 100644 --- a/app/javascript/mastodon/components/status_content.js +++ b/app/javascript/mastodon/components/status_content.js @@ -225,7 +225,7 @@ export default class StatusContent extends React.PureComponent { {mentionsPlaceholder} -
    +
    {!hidden && !!status.get('poll') && } {renderViewThread && showThreadButton} diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index dddb71c71..0d3f32381 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -922,6 +922,11 @@ } } + .article-type { + display: inline-block; + margin-top: 10px; + } + .article-type img { max-width: 95%; } diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 2658405e4..25d3e809f 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -165,6 +165,15 @@ class ActivityPub::Activity::Create < ActivityPub::Activity handler = Handler.new(proc) Ox.sax_parse(handler, @object['content']) handler.srcs.each do |src| + # Handle images where the src is formatted as "/foo/bar.png" + # we assume that the `url` field is populated which lets us infer + # the protocol and domain of the _original_ article, as though + # we were looking at it via a web browser + if src[0] == '/' && !@object['url'].nil? + site = Addressable::URI.parse(@object['url']).site + src = site + src + end + if skip_download? @object['content'].gsub!(src, '') next From 4360a5094936fd166452380d94150cf0ce94ef9b Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Fri, 2 Dec 2022 17:38:01 -0800 Subject: [PATCH 11/12] Fix sanitizer rule We don't need to add a class to every span! --- lib/sanitize_ext/sanitize_config.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index 9cdd08d62..dd58264ed 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -86,9 +86,6 @@ class Sanitize 'rel' => 'nofollow noopener noreferrer', 'target' => '_blank', }, - 'span' => { - 'class' => 'article-type', - }, }, protocols: { From 427596ab0171bb1c5c40614c8aa71b81fb917f30 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Sat, 3 Dec 2022 22:01:19 -0800 Subject: [PATCH 12/12] 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 --- app/controllers/accounts_controller.rb | 5 +++++ app/controllers/settings/preferences_controller.rb | 1 + app/lib/settings/scoped_settings.rb | 1 + app/lib/user_settings_decorator.rb | 5 +++++ app/models/form/admin_settings.rb | 2 ++ app/models/user.rb | 2 +- app/views/accounts/show.html.haml | 3 ++- app/views/admin/settings/edit.html.haml | 3 +++ app/views/settings/preferences/other/show.html.haml | 3 +++ config/locales/en.yml | 3 +++ config/locales/simple_form.en.yml | 1 + config/settings.yml | 1 + 12 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index a19125f60..610456d8a 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -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) diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index e47ff5c48..08e63c49c 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -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, diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb index 1e18d6d46..4eeb8ed8c 100644 --- a/app/lib/settings/scoped_settings.rb +++ b/app/lib/settings/scoped_settings.rb @@ -5,6 +5,7 @@ module Settings DEFAULTING_TO_UNSCOPED = %w( theme noindex + norss ).freeze def initialize(object) diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 70f9bc81d..d529de5a9 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -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 diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 6fc7c56fd..4213cb0f8 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 46afa85d3..25ea3ee4d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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, diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index 72e9c6611..f770872de 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -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 diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 66ba77d36..d0dbdb628 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -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 diff --git a/app/views/settings/preferences/other/show.html.haml b/app/views/settings/preferences/other/show.html.haml index 086308594..92734ec7d 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 10e2d6c74..e344186dc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index d727eb495..651095a13 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -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 diff --git a/config/settings.yml b/config/settings.yml index 7912341ed..71a672272 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -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