From b19ae521b7d28a76e8e1d8da8157e051e9d8de6c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 24 Jan 2024 11:49:19 +0100 Subject: [PATCH 01/28] Add confirmation when redirecting logged-out requests to permalink (#27792) Co-authored-by: Claire --- .../concerns/web_app_controller_concern.rb | 15 ++++- .../redirect/accounts_controller.rb | 10 +++ app/controllers/redirect/base_controller.rb | 24 +++++++ .../redirect/statuses_controller.rb | 10 +++ .../styles/mastodon/containers.scss | 56 +++++++++++++++++ app/lib/permalink_redirector.rb | 63 +++++++++++-------- app/views/redirects/show.html.haml | 8 +++ config/locales/en.yml | 3 + config/routes.rb | 5 ++ 9 files changed, 165 insertions(+), 29 deletions(-) create mode 100644 app/controllers/redirect/accounts_controller.rb create mode 100644 app/controllers/redirect/base_controller.rb create mode 100644 app/controllers/redirect/statuses_controller.rb create mode 100644 app/views/redirects/show.html.haml diff --git a/app/controllers/concerns/web_app_controller_concern.rb b/app/controllers/concerns/web_app_controller_concern.rb index 5687d6e5b6..b8c909877b 100644 --- a/app/controllers/concerns/web_app_controller_concern.rb +++ b/app/controllers/concerns/web_app_controller_concern.rb @@ -21,10 +21,19 @@ module WebAppControllerConcern def redirect_unauthenticated_to_permalinks! return if user_signed_in? && current_account.moved_to_account_id.nil? - redirect_path = PermalinkRedirector.new(request.path).redirect_path - return if redirect_path.blank? + permalink_redirector = PermalinkRedirector.new(request.path) + return if permalink_redirector.redirect_path.blank? expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) unless user_signed_in? - redirect_to(redirect_path) + + respond_to do |format| + format.html do + redirect_to(permalink_redirector.redirect_confirmation_path, allow_other_host: false) + end + + format.json do + redirect_to(permalink_redirector.redirect_uri, allow_other_host: true) + end + end end end diff --git a/app/controllers/redirect/accounts_controller.rb b/app/controllers/redirect/accounts_controller.rb new file mode 100644 index 0000000000..98d2cc2b1f --- /dev/null +++ b/app/controllers/redirect/accounts_controller.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class Redirect::AccountsController < ApplicationController + private + + def set_resource + @resource = Account.find(params[:id]) + not_found if @resource.local? + end +end diff --git a/app/controllers/redirect/base_controller.rb b/app/controllers/redirect/base_controller.rb new file mode 100644 index 0000000000..90894ec1ed --- /dev/null +++ b/app/controllers/redirect/base_controller.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class Redirect::BaseController < ApplicationController + vary_by 'Accept-Language' + + before_action :set_resource + before_action :set_app_body_class + + def show + @redirect_path = ActivityPub::TagManager.instance.url_for(@resource) + + render 'redirects/show', layout: 'application' + end + + private + + def set_app_body_class + @body_classes = 'app-body' + end + + def set_resource + raise NotImplementedError + end +end diff --git a/app/controllers/redirect/statuses_controller.rb b/app/controllers/redirect/statuses_controller.rb new file mode 100644 index 0000000000..37a938c651 --- /dev/null +++ b/app/controllers/redirect/statuses_controller.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class Redirect::StatusesController < Redirect::BaseController + private + + def set_resource + @resource = Status.find(params[:id]) + not_found if @resource.local? || !@resource.distributable? + end +end diff --git a/app/javascript/styles/mastodon/containers.scss b/app/javascript/styles/mastodon/containers.scss index 3d646da239..b6e995787d 100644 --- a/app/javascript/styles/mastodon/containers.scss +++ b/app/javascript/styles/mastodon/containers.scss @@ -104,3 +104,59 @@ margin-inline-start: 10px; } } + +.redirect { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + font-size: 14px; + line-height: 18px; + + &__logo { + display: flex; + align-items: center; + justify-content: center; + margin-bottom: 30px; + + img { + height: 48px; + } + } + + &__message { + text-align: center; + + h1 { + font-size: 17px; + line-height: 22px; + font-weight: 700; + margin-bottom: 30px; + } + + p { + margin-bottom: 30px; + + &:last-child { + margin-bottom: 0; + } + } + + a { + color: $highlight-text-color; + font-weight: 500; + text-decoration: none; + + &:hover, + &:focus, + &:active { + text-decoration: underline; + } + } + } + + &__link { + margin-top: 15px; + } +} diff --git a/app/lib/permalink_redirector.rb b/app/lib/permalink_redirector.rb index 0dd37483e2..f551f69db8 100644 --- a/app/lib/permalink_redirector.rb +++ b/app/lib/permalink_redirector.rb @@ -5,17 +5,46 @@ class PermalinkRedirector def initialize(path) @path = path + @object = nil + end + + def object + @object ||= begin + if at_username_status_request? || statuses_status_request? + status = Status.find_by(id: second_segment) + status if status&.distributable? && !status&.local? + elsif at_username_request? + username, domain = first_segment.delete_prefix('@').split('@') + domain = nil if TagManager.instance.local_domain?(domain) + account = Account.find_remote(username, domain) + account unless account&.local? + elsif accounts_request? && record_integer_id_request? + account = Account.find_by(id: second_segment) + account unless account&.local? + end + end end def redirect_path - if at_username_status_request? || statuses_status_request? - find_status_url_by_id(second_segment) - elsif at_username_request? - find_account_url_by_name(first_segment) - elsif accounts_request? && record_integer_id_request? - find_account_url_by_id(second_segment) - elsif @path.start_with?('/deck') - @path.delete_prefix('/deck') + return ActivityPub::TagManager.instance.url_for(object) if object.present? + + @path.delete_prefix('/deck') if @path.start_with?('/deck') + end + + def redirect_uri + return ActivityPub::TagManager.instance.uri_for(object) if object.present? + + @path.delete_prefix('/deck') if @path.start_with?('/deck') + end + + def redirect_confirmation_path + case object.class.name + when 'Account' + redirect_account_path(object.id) + when 'Status' + redirect_status_path(object.id) + else + @path.delete_prefix('/deck') if @path.start_with?('/deck') end end @@ -56,22 +85,4 @@ class PermalinkRedirector def path_segments @path_segments ||= @path.delete_prefix('/deck').delete_prefix('/').split('/') end - - def find_status_url_by_id(id) - status = Status.find_by(id: id) - ActivityPub::TagManager.instance.url_for(status) if status&.distributable? && !status.account.local? - end - - def find_account_url_by_id(id) - account = Account.find_by(id: id) - ActivityPub::TagManager.instance.url_for(account) if account.present? && !account.local? - end - - def find_account_url_by_name(name) - username, domain = name.gsub(/\A@/, '').split('@') - domain = nil if TagManager.instance.local_domain?(domain) - account = Account.find_remote(username, domain) - - ActivityPub::TagManager.instance.url_for(account) if account.present? && !account.local? - end end diff --git a/app/views/redirects/show.html.haml b/app/views/redirects/show.html.haml new file mode 100644 index 0000000000..0d09387a9c --- /dev/null +++ b/app/views/redirects/show.html.haml @@ -0,0 +1,8 @@ +.redirect + .redirect__logo + = link_to render_logo, root_path + + .redirect__message + %h1= t('redirects.title', instance: site_hostname) + %p= t('redirects.prompt') + %p= link_to @redirect_path, @redirect_path, rel: 'noreferrer noopener' diff --git a/config/locales/en.yml b/config/locales/en.yml index 83eaaa4552..9d739be07f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1547,6 +1547,9 @@ en: errors: limit_reached: Limit of different reactions reached unrecognized_emoji: is not a recognized emoji + redirects: + prompt: If you trust this link, click it to continue. + title: You are leaving %{instance}. relationships: activity: Account activity confirm_follow_selected_followers: Are you sure you want to follow selected followers? diff --git a/config/routes.rb b/config/routes.rb index 85c3b18556..c4f862acaf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -162,6 +162,11 @@ Rails.application.routes.draw do end end + namespace :redirect do + resources :accounts, only: :show + resources :statuses, only: :show + end + resources :media, only: [:show] do get :player end From 41c2af22705d9a8b265f77dae5da960d2eef2150 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 12:50:41 +0100 Subject: [PATCH 02/28] chore(deps): update dependency rubocop to v1.60.1 (#28731) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 93931d8724..54955000b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -504,7 +504,7 @@ GEM orm_adapter (0.5.0) ox (2.14.17) parallel (1.24.0) - parser (3.2.2.4) + parser (3.3.0.5) ast (~> 2.4.1) racc parslet (2.0.0) @@ -610,7 +610,7 @@ GEM redis (>= 4) redlock (1.3.2) redis (>= 3.0.0, < 6.0) - regexp_parser (2.8.3) + regexp_parser (2.9.0) reline (0.4.2) io-console (~> 0.5) request_store (1.5.1) @@ -650,11 +650,11 @@ GEM rspec-mocks (~> 3.0) sidekiq (>= 5, < 8) rspec-support (3.12.1) - rubocop (1.59.0) + rubocop (1.60.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) From 1290fede651b47585de7dbfe4a9b118dc9d59856 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 24 Jan 2024 06:51:09 -0500 Subject: [PATCH 03/28] Fix `Rails/WhereExists` cop in app/lib (#28862) --- .rubocop_todo.yml | 4 ---- app/lib/activitypub/activity/create.rb | 4 ++-- app/lib/delivery_failure_tracker.rb | 2 +- app/lib/feed_manager.rb | 6 +++--- app/lib/suspicious_sign_in_detector.rb | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b62dfa72a8..302c66a16a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -77,10 +77,6 @@ Rails/WhereExists: Exclude: - 'app/controllers/activitypub/inboxes_controller.rb' - 'app/controllers/admin/email_domain_blocks_controller.rb' - - 'app/lib/activitypub/activity/create.rb' - - 'app/lib/delivery_failure_tracker.rb' - - 'app/lib/feed_manager.rb' - - 'app/lib/suspicious_sign_in_detector.rb' - 'app/policies/status_policy.rb' - 'app/serializers/rest/announcement_serializer.rb' - 'app/workers/move_worker.rb' diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 5a2d33c1fa..62c35d4dd3 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -320,7 +320,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity already_voted = true with_redis_lock("vote:#{replied_to_status.poll_id}:#{@account.id}") do - already_voted = poll.votes.where(account: @account).exists? + already_voted = poll.votes.exists?(account: @account) poll.votes.create!(account: @account, choice: poll.options.index(@object['name']), uri: object_uri) end @@ -406,7 +406,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity return false if local_usernames.empty? - Account.local.where(username: local_usernames).exists? + Account.local.exists?(username: local_usernames) end def tombstone_exists? diff --git a/app/lib/delivery_failure_tracker.rb b/app/lib/delivery_failure_tracker.rb index d938269829..e17b45d667 100644 --- a/app/lib/delivery_failure_tracker.rb +++ b/app/lib/delivery_failure_tracker.rb @@ -28,7 +28,7 @@ class DeliveryFailureTracker end def available? - !UnavailableDomain.where(domain: @host).exists? + !UnavailableDomain.exists?(domain: @host) end def exhausted_deliveries_days diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 53767486ff..38a177e645 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -420,8 +420,8 @@ class FeedManager check_for_blocks = status.active_mentions.pluck(:account_id) check_for_blocks.push(status.in_reply_to_account) if status.reply? && !status.in_reply_to_account_id.nil? - should_filter = blocks_or_mutes?(receiver_id, check_for_blocks, :mentions) # Filter if it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked (or muted) - should_filter ||= status.account.silenced? && !Follow.where(account_id: receiver_id, target_account_id: status.account_id).exists? # of if the account is silenced and I'm not following them + should_filter = blocks_or_mutes?(receiver_id, check_for_blocks, :mentions) # Filter if it's from someone I blocked, in reply to someone I blocked, or mentioning someone I blocked (or muted) + should_filter ||= status.account.silenced? && !Follow.exists?(account_id: receiver_id, target_account_id: status.account_id) # Filter if the account is silenced and I'm not following them should_filter end @@ -434,7 +434,7 @@ class FeedManager if status.reply? && status.in_reply_to_account_id != status.account_id should_filter = status.in_reply_to_account_id != list.account_id should_filter &&= !list.show_followed? - should_filter &&= !(list.show_list? && ListAccount.where(list_id: list.id, account_id: status.in_reply_to_account_id).exists?) + should_filter &&= !(list.show_list? && ListAccount.exists?(list_id: list.id, account_id: status.in_reply_to_account_id)) return !!should_filter end diff --git a/app/lib/suspicious_sign_in_detector.rb b/app/lib/suspicious_sign_in_detector.rb index 1af5188c65..74f49aa558 100644 --- a/app/lib/suspicious_sign_in_detector.rb +++ b/app/lib/suspicious_sign_in_detector.rb @@ -19,7 +19,7 @@ class SuspiciousSignInDetector end def previously_seen_ip?(request) - @user.ips.where('ip <<= ?', masked_ip(request)).exists? + @user.ips.exists?(['ip <<= ?', masked_ip(request)]) end def freshly_signed_up? From 5a838ceaa9a003bc2e2fdee727d4aa87cd53de4f Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 24 Jan 2024 13:37:43 +0100 Subject: [PATCH 04/28] Use active variants for boost icons and increase icon size (#27924) --- app/javascript/mastodon/components/status_action_bar.jsx | 4 +++- .../mastodon/features/status/components/action_bar.jsx | 4 +++- app/javascript/svg-icons/repeat_active.svg | 4 ++++ app/javascript/svg-icons/repeat_disabled.svg | 0 app/javascript/svg-icons/repeat_private.svg | 0 app/javascript/svg-icons/repeat_private_active.svg | 6 ++++++ 6 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 app/javascript/svg-icons/repeat_active.svg mode change 100755 => 100644 app/javascript/svg-icons/repeat_disabled.svg mode change 100755 => 100644 app/javascript/svg-icons/repeat_private.svg create mode 100644 app/javascript/svg-icons/repeat_private_active.svg diff --git a/app/javascript/mastodon/components/status_action_bar.jsx b/app/javascript/mastodon/components/status_action_bar.jsx index bfe77a4900..b111a65385 100644 --- a/app/javascript/mastodon/components/status_action_bar.jsx +++ b/app/javascript/mastodon/components/status_action_bar.jsx @@ -18,8 +18,10 @@ import ReplyAllIcon from '@/material-icons/400-24px/reply_all.svg?react'; import StarIcon from '@/material-icons/400-24px/star-fill.svg?react'; import StarBorderIcon from '@/material-icons/400-24px/star.svg?react'; import VisibilityIcon from '@/material-icons/400-24px/visibility.svg?react'; +import RepeatActiveIcon from '@/svg-icons/repeat_active.svg?react'; import RepeatDisabledIcon from '@/svg-icons/repeat_disabled.svg?react'; import RepeatPrivateIcon from '@/svg-icons/repeat_private.svg?react'; +import RepeatPrivateActiveIcon from '@/svg-icons/repeat_private_active.svg?react'; import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions'; import { WithRouterPropTypes } from 'mastodon/utils/react_router'; @@ -366,7 +368,7 @@ class StatusActionBar extends ImmutablePureComponent { if (status.get('reblogged')) { reblogTitle = intl.formatMessage(messages.cancel_reblog_private); - reblogIconComponent = publicStatus ? RepeatIcon : RepeatPrivateIcon; + reblogIconComponent = publicStatus ? RepeatActiveIcon : RepeatPrivateActiveIcon; } else if (publicStatus) { reblogTitle = intl.formatMessage(messages.reblog); reblogIconComponent = RepeatIcon; diff --git a/app/javascript/mastodon/features/status/components/action_bar.jsx b/app/javascript/mastodon/features/status/components/action_bar.jsx index 4cb06aac2c..c243a49129 100644 --- a/app/javascript/mastodon/features/status/components/action_bar.jsx +++ b/app/javascript/mastodon/features/status/components/action_bar.jsx @@ -17,8 +17,10 @@ import ReplyIcon from '@/material-icons/400-24px/reply.svg?react'; import ReplyAllIcon from '@/material-icons/400-24px/reply_all.svg?react'; import StarIcon from '@/material-icons/400-24px/star-fill.svg?react'; import StarBorderIcon from '@/material-icons/400-24px/star.svg?react'; +import RepeatActiveIcon from '@/svg-icons/repeat_active.svg?react'; import RepeatDisabledIcon from '@/svg-icons/repeat_disabled.svg?react'; import RepeatPrivateIcon from '@/svg-icons/repeat_private.svg?react'; +import RepeatPrivateActiveIcon from '@/svg-icons/repeat_private_active.svg?react'; import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions'; import { WithRouterPropTypes } from 'mastodon/utils/react_router'; @@ -296,7 +298,7 @@ class ActionBar extends PureComponent { if (status.get('reblogged')) { reblogTitle = intl.formatMessage(messages.cancel_reblog_private); - reblogIconComponent = publicStatus ? RepeatIcon : RepeatPrivateIcon; + reblogIconComponent = publicStatus ? RepeatActiveIcon : RepeatPrivateActiveIcon; } else if (publicStatus) { reblogTitle = intl.formatMessage(messages.reblog); reblogIconComponent = RepeatIcon; diff --git a/app/javascript/svg-icons/repeat_active.svg b/app/javascript/svg-icons/repeat_active.svg new file mode 100644 index 0000000000..a5bbb8fc4f --- /dev/null +++ b/app/javascript/svg-icons/repeat_active.svg @@ -0,0 +1,4 @@ + + + + diff --git a/app/javascript/svg-icons/repeat_disabled.svg b/app/javascript/svg-icons/repeat_disabled.svg old mode 100755 new mode 100644 diff --git a/app/javascript/svg-icons/repeat_private.svg b/app/javascript/svg-icons/repeat_private.svg old mode 100755 new mode 100644 diff --git a/app/javascript/svg-icons/repeat_private_active.svg b/app/javascript/svg-icons/repeat_private_active.svg new file mode 100644 index 0000000000..cf2a05c84e --- /dev/null +++ b/app/javascript/svg-icons/repeat_private_active.svg @@ -0,0 +1,6 @@ + + + + + + From 64993d3f779a6e01c104e1a2024a87c9785bc79d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:37:37 +0100 Subject: [PATCH 05/28] chore(deps): update dependency haml_lint to v0.55.0 (#28856) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 54955000b1..97d2b5f7a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -319,7 +319,7 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - haml_lint (0.53.0) + haml_lint (0.55.0) haml (>= 5.0) parallel (~> 1.10) rainbow From ea5397c3735145ad62374798506f57afa122959d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 15:55:06 +0100 Subject: [PATCH 06/28] chore(deps): update dependency selenium-webdriver to v4.17.0 (#28858) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 97d2b5f7a0..77d924f948 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -696,7 +696,8 @@ GEM scenic (1.7.0) activerecord (>= 4.0.0) railties (>= 4.0.0) - selenium-webdriver (4.16.0) + selenium-webdriver (4.17.0) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) From 559bbf0aa6ceca1cbf417fcc76ea7ef359e42099 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:51:18 +0100 Subject: [PATCH 07/28] chore(deps): update artifact actions (major) to v4 (major) (#28415) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/test-ruby.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index ae25648a0b..346703ced4 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -52,7 +52,7 @@ jobs: run: | tar --exclude={"*.br","*.gz"} -zcf artifacts.tar.gz public/assets public/packs* - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: matrix.mode == 'test' with: path: |- @@ -117,7 +117,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: path: './' name: ${{ github.sha }} @@ -193,7 +193,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: path: './public' name: ${{ github.sha }} @@ -213,14 +213,14 @@ jobs: - run: bundle exec rake spec:system - name: Archive logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: e2e-logs-${{ matrix.ruby-version }} path: log/ - name: Archive test screenshots - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: e2e-screenshots @@ -297,7 +297,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: path: './public' name: ${{ github.sha }} @@ -317,14 +317,14 @@ jobs: - run: bin/rspec --tag search - name: Archive logs - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: test-search-logs-${{ matrix.ruby-version }} path: log/ - name: Archive test screenshots - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: test-search-screenshots From 7019af431d2b91a4d31ede9558bb3a17c3875f37 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:51:36 +0100 Subject: [PATCH 08/28] fix(deps): update dependency dotenv to v16.4.0 (#28872) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 61f699d19e..53d2caaed9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6901,9 +6901,9 @@ __metadata: linkType: hard "dotenv@npm:^16.0.3": - version: 16.3.2 - resolution: "dotenv@npm:16.3.2" - checksum: a87d62cef0810b670cb477db1a24a42a093b6b428c9e65c185ce1d6368ad7175234b13547718ba08da18df43faae4f814180cc0366e11be1ded2277abc4dd22e + version: 16.4.0 + resolution: "dotenv@npm:16.4.0" + checksum: 70c3b422cefaffdba300aecd9157668590c3b5e66efb3742b7dec207f85023e5997364f04030fc0393fae52bf3a874979632d289ab4fafc1386ff2c68f2f2e8d languageName: node linkType: hard From 9c5be139806ba323f760ceb24476c1261af2ed41 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:51:47 +0100 Subject: [PATCH 09/28] chore(deps): update dependency chewy to v7.5.0 (#28730) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 77d924f948..d573debe4b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -180,7 +180,7 @@ GEM activesupport cbor (0.5.9.6) charlock_holmes (0.7.7) - chewy (7.4.0) + chewy (7.5.0) activesupport (>= 5.2) elasticsearch (>= 7.12.0, < 7.14.0) elasticsearch-dsl @@ -445,7 +445,7 @@ GEM mime-types-data (3.2023.1205) mini_mime (1.1.5) mini_portile2 (2.8.5) - minitest (5.20.0) + minitest (5.21.1) msgpack (1.7.2) multi_json (1.15.0) multipart-post (2.3.0) From 38f7f8b9096a3c56c676942730184f01e17bd93d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 24 Jan 2024 12:30:28 -0500 Subject: [PATCH 10/28] Tidy up association declaration in `Instance` model (#28880) --- app/models/instance.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/instance.rb b/app/models/instance.rb index 8f8d87c62a..2dec75d6fe 100644 --- a/app/models/instance.rb +++ b/app/models/instance.rb @@ -13,12 +13,12 @@ class Instance < ApplicationRecord attr_accessor :failure_days - has_many :accounts, foreign_key: :domain, primary_key: :domain, inverse_of: false - with_options foreign_key: :domain, primary_key: :domain, inverse_of: false do belongs_to :domain_block belongs_to :domain_allow - belongs_to :unavailable_domain # skipcq: RB-RL1031 + belongs_to :unavailable_domain + + has_many :accounts, dependent: nil end scope :searchable, -> { where.not(domain: DomainBlock.select(:domain)) } From 9a8293f58d0317e3917b855483a5b2958226f2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Thu, 25 Jan 2024 19:37:09 +0900 Subject: [PATCH 11/28] Fix process of receiving posts with bearcaps is not working (#26527) --- app/lib/activitypub/activity/create.rb | 2 +- app/lib/activitypub/parser/status_parser.rb | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 62c35d4dd3..85195f4c39 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -108,7 +108,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity end def process_status_params - @status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url) + @status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url, object: @object) attachment_ids = process_attachments.take(4).map(&:id) diff --git a/app/lib/activitypub/parser/status_parser.rb b/app/lib/activitypub/parser/status_parser.rb index 45f5fc5bf2..cfc2b8788b 100644 --- a/app/lib/activitypub/parser/status_parser.rb +++ b/app/lib/activitypub/parser/status_parser.rb @@ -4,12 +4,13 @@ class ActivityPub::Parser::StatusParser include JsonLdHelper # @param [Hash] json - # @param [Hash] magic_values - # @option magic_values [String] :followers_collection - def initialize(json, magic_values = {}) - @json = json - @object = json['object'] || json - @magic_values = magic_values + # @param [Hash] options + # @option options [String] :followers_collection + # @option options [Hash] :object + def initialize(json, **options) + @json = json + @object = options[:object] || json['object'] || json + @options = options end def uri @@ -78,7 +79,7 @@ class ActivityPub::Parser::StatusParser :public elsif audience_cc.any? { |cc| ActivityPub::TagManager.instance.public_collection?(cc) } :unlisted - elsif audience_to.include?(@magic_values[:followers_collection]) + elsif audience_to.include?(@options[:followers_collection]) :private else :direct From c50274a0acd3679160984bbf410bff46fd76179c Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 25 Jan 2024 11:44:25 +0100 Subject: [PATCH 12/28] Fix redirect confirmation for accounts (#28902) --- app/controllers/redirect/accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/redirect/accounts_controller.rb b/app/controllers/redirect/accounts_controller.rb index 98d2cc2b1f..713ccf2ca1 100644 --- a/app/controllers/redirect/accounts_controller.rb +++ b/app/controllers/redirect/accounts_controller.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Redirect::AccountsController < ApplicationController +class Redirect::AccountsController < Redirect::BaseController private def set_resource From 0471a780556720338fef29266f2fc2578ab2010c Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 25 Jan 2024 12:13:33 +0100 Subject: [PATCH 13/28] Add tests for redirect confirmations (#28903) --- spec/features/redirections_spec.rb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 spec/features/redirections_spec.rb diff --git a/spec/features/redirections_spec.rb b/spec/features/redirections_spec.rb new file mode 100644 index 0000000000..f73ab58470 --- /dev/null +++ b/spec/features/redirections_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe 'redirection confirmations' do + let(:account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/users/foo', url: 'https://example.com/@foo') } + let(:status) { Fabricate(:status, account: account, uri: 'https://example.com/users/foo/statuses/1', url: 'https://example.com/@foo/1') } + + context 'when a logged out user visits a local page for a remote account' do + it 'shows a confirmation page' do + visit "/@#{account.pretty_acct}" + + # It explains about the redirect + expect(page).to have_content(I18n.t('redirects.title', instance: 'cb6e6126.ngrok.io')) + + # It features an appropriate link + expect(page).to have_link(account.url, href: account.url) + end + end + + context 'when a logged out user visits a local page for a remote status' do + it 'shows a confirmation page' do + visit "/@#{account.pretty_acct}/#{status.id}" + + # It explains about the redirect + expect(page).to have_content(I18n.t('redirects.title', instance: 'cb6e6126.ngrok.io')) + + # It features an appropriate link + expect(page).to have_link(status.url, href: status.url) + end + end +end From 087415d0fe8d9a719eb2df7e915b08f4d4d0360a Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 25 Jan 2024 12:13:36 +0100 Subject: [PATCH 14/28] Add tests for processing statuses using bearcap URIs (#28904) --- spec/lib/activitypub/activity/create_spec.rb | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 3e3a4978c8..e4966cffa3 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -893,6 +893,49 @@ RSpec.describe ActivityPub::Activity::Create do end end + context 'when object URI uses bearcaps' do + subject { described_class.new(json, sender) } + + let(:token) { 'foo' } + + let(:json) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: [ActivityPub::TagManager.instance.uri_for(sender), '#foo'].join, + type: 'Create', + actor: ActivityPub::TagManager.instance.uri_for(sender), + object: Addressable::URI.new(scheme: 'bear', query_values: { t: token, u: object_json[:id] }).to_s, + }.with_indifferent_access + end + + let(:object_json) do + { + id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, + type: 'Note', + content: 'Lorem ipsum', + to: 'https://www.w3.org/ns/activitystreams#Public', + } + end + + before do + stub_request(:get, object_json[:id]) + .with(headers: { Authorization: "Bearer #{token}" }) + .to_return(body: Oj.dump(object_json), headers: { 'Content-Type': 'application/activity+json' }) + + subject.perform + end + + it 'creates status' do + status = sender.statuses.first + + expect(status).to_not be_nil + expect(status).to have_attributes( + visibility: 'public', + text: 'Lorem ipsum' + ) + end + end + context 'with an encrypted message' do subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) } From d158f7e6228e9c3f9d93bff86eccd71bdb542558 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:33:56 +0100 Subject: [PATCH 15/28] chore(deps): update dependency rspec-rails to v6.1.1 (#28905) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d573debe4b..a31d0a929c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -360,7 +360,7 @@ GEM rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) idn-ruby (0.1.5) - io-console (0.7.1) + io-console (0.7.2) irb (1.11.1) rdoc reline (>= 0.4.2) @@ -445,7 +445,7 @@ GEM mime-types-data (3.2023.1205) mini_mime (1.1.5) mini_portile2 (2.8.5) - minitest (5.21.1) + minitest (5.21.2) msgpack (1.7.2) multi_json (1.15.0) multipart-post (2.3.0) @@ -636,7 +636,7 @@ GEM rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-rails (6.1.0) + rspec-rails (6.1.1) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) From 1a565e4bea45828bfbe16c2c581ec5bc676c5223 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:36:20 +0000 Subject: [PATCH 16/28] fix(deps): update dependency axios to v1.6.6 (#28895) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 53d2caaed9..29bcb3575b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4673,13 +4673,13 @@ __metadata: linkType: hard "axios@npm:^1.4.0": - version: 1.6.5 - resolution: "axios@npm:1.6.5" + version: 1.6.6 + resolution: "axios@npm:1.6.6" dependencies: follow-redirects: "npm:^1.15.4" form-data: "npm:^4.0.0" proxy-from-env: "npm:^1.1.0" - checksum: aeb9acf87590d8aa67946072ced38e01ca71f5dfe043782c0ccea667e5dd5c45830c08afac9be3d7c894f09684b8ab2a458f497d197b73621233bcf202d9d468 + checksum: 974f54cfade94fd4c0191309122a112c8d233089cecb0070cd8e0904e9bd9c364ac3a6fd0f981c978508077249788950427c565f54b7b2110e5c3426006ff343 languageName: node linkType: hard From 7c9c6c7f80d57ea0fd504b59debe6439d28cb1b5 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 25 Jan 2024 07:37:07 -0500 Subject: [PATCH 17/28] Fix remaining `Rails/WhereExists` cop violations, regenerate todo (#28892) --- .rubocop_todo.yml | 17 +---------------- .../activitypub/inboxes_controller.rb | 2 +- .../admin/email_domain_blocks_controller.rb | 2 +- app/policies/status_policy.rb | 2 +- app/serializers/rest/announcement_serializer.rb | 2 +- app/workers/move_worker.rb | 2 +- .../process_collection_service_spec.rb | 2 +- 7 files changed, 7 insertions(+), 22 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 302c66a16a..77f7e70734 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.59.0. +# using RuboCop version 1.60.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -70,21 +70,6 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/identity.rb' - 'app/models/webauthn_credential.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: exists, where -Rails/WhereExists: - Exclude: - - 'app/controllers/activitypub/inboxes_controller.rb' - - 'app/controllers/admin/email_domain_blocks_controller.rb' - - 'app/policies/status_policy.rb' - - 'app/serializers/rest/announcement_serializer.rb' - - 'app/workers/move_worker.rb' - - 'spec/models/account_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/purge_domain_service_spec.rb' - - 'spec/services/unallow_domain_service_spec.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. # AllowedMethods: ==, equal?, eql? diff --git a/app/controllers/activitypub/inboxes_controller.rb b/app/controllers/activitypub/inboxes_controller.rb index 5ee85474e7..ba85e0a722 100644 --- a/app/controllers/activitypub/inboxes_controller.rb +++ b/app/controllers/activitypub/inboxes_controller.rb @@ -24,7 +24,7 @@ class ActivityPub::InboxesController < ActivityPub::BaseController def unknown_affected_account? json = Oj.load(body, mode: :strict) - json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.where(uri: json['actor']).exists? + json.is_a?(Hash) && %w(Delete Update).include?(json['type']) && json['actor'].present? && json['actor'] == value_or_id(json['object']) && !Account.exists?(uri: json['actor']) rescue Oj::ParseError false end diff --git a/app/controllers/admin/email_domain_blocks_controller.rb b/app/controllers/admin/email_domain_blocks_controller.rb index ff754bc0b4..faa0a061a6 100644 --- a/app/controllers/admin/email_domain_blocks_controller.rb +++ b/app/controllers/admin/email_domain_blocks_controller.rb @@ -38,7 +38,7 @@ module Admin log_action :create, @email_domain_block (@email_domain_block.other_domains || []).uniq.each do |domain| - next if EmailDomainBlock.where(domain: domain).exists? + next if EmailDomainBlock.exists?(domain: domain) other_email_domain_block = EmailDomainBlock.create!(domain: domain, allow_with_approval: @email_domain_block.allow_with_approval, parent: @email_domain_block) log_action :create, other_email_domain_block diff --git a/app/policies/status_policy.rb b/app/policies/status_policy.rb index 322d3aec5c..540e266427 100644 --- a/app/policies/status_policy.rb +++ b/app/policies/status_policy.rb @@ -57,7 +57,7 @@ class StatusPolicy < ApplicationPolicy if record.mentions.loaded? record.mentions.any? { |mention| mention.account_id == current_account.id } else - record.mentions.where(account: current_account).exists? + record.mentions.exists?(account: current_account) end end diff --git a/app/serializers/rest/announcement_serializer.rb b/app/serializers/rest/announcement_serializer.rb index 23b2fa514b..8cee271272 100644 --- a/app/serializers/rest/announcement_serializer.rb +++ b/app/serializers/rest/announcement_serializer.rb @@ -23,7 +23,7 @@ class REST::AnnouncementSerializer < ActiveModel::Serializer end def read - object.announcement_mutes.where(account: current_user.account).exists? + object.announcement_mutes.exists?(account: current_user.account) end def content diff --git a/app/workers/move_worker.rb b/app/workers/move_worker.rb index 73ae268bee..a18f38556b 100644 --- a/app/workers/move_worker.rb +++ b/app/workers/move_worker.rb @@ -123,7 +123,7 @@ class MoveWorker end def add_account_note_if_needed!(account, id) - unless AccountNote.where(account: account, target_account: @target_account).exists? + unless AccountNote.exists?(account: account, target_account: @target_account) text = I18n.with_locale(account.user&.locale.presence || I18n.default_locale) do I18n.t(id, acct: @source_account.acct) end diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index f4a2b8fec6..63502c546e 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -265,7 +265,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do anything ) - expect(Status.where(uri: 'https://example.com/users/bob/fake-status').exists?).to be false + expect(Status.exists?(uri: 'https://example.com/users/bob/fake-status')).to be false end end end From a69506a434a605fd8ad67f4eb938a328753bbe06 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:37:23 +0100 Subject: [PATCH 18/28] fix(deps): update dependency dotenv to v16.4.1 (#28889) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 29bcb3575b..78261b3b84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6901,9 +6901,9 @@ __metadata: linkType: hard "dotenv@npm:^16.0.3": - version: 16.4.0 - resolution: "dotenv@npm:16.4.0" - checksum: 70c3b422cefaffdba300aecd9157668590c3b5e66efb3742b7dec207f85023e5997364f04030fc0393fae52bf3a874979632d289ab4fafc1386ff2c68f2f2e8d + version: 16.4.1 + resolution: "dotenv@npm:16.4.1" + checksum: ef3d95f48f38146df0881a4b58447ae437d2da3f6d645074b84de4e64ef64ba75fc357c5ed66b3c2b813b5369fdeb6a4777d6ade2d50e54eed6aa06dddc98bc4 languageName: node linkType: hard From 6b6586f5d099a9089c8bf9dc7d7406a86c0a48eb Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 25 Jan 2024 08:00:34 -0500 Subject: [PATCH 19/28] Add `CustomFilterKeyword#to_regex` method (#28893) --- app/models/custom_filter.rb | 11 +------ app/models/custom_filter_keyword.rb | 16 +++++++++++ spec/models/custom_filter_keyword_spec.rb | 35 +++++++++++++++++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 spec/models/custom_filter_keyword_spec.rb diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb index 371267fc28..c8120c2395 100644 --- a/app/models/custom_filter.rb +++ b/app/models/custom_filter.rb @@ -68,16 +68,7 @@ class CustomFilter < ApplicationRecord scope = CustomFilterKeyword.includes(:custom_filter).where(custom_filter: { account_id: account_id }).where(Arel.sql('expires_at IS NULL OR expires_at > NOW()')) scope.to_a.group_by(&:custom_filter).each do |filter, keywords| - keywords.map! do |keyword| - if keyword.whole_word - sb = /\A[[:word:]]/.match?(keyword.keyword) ? '\b' : '' - eb = /[[:word:]]\z/.match?(keyword.keyword) ? '\b' : '' - - /(?mix:#{sb}#{Regexp.escape(keyword.keyword)}#{eb})/ - else - /#{Regexp.escape(keyword.keyword)}/i - end - end + keywords.map!(&:to_regex) filters_hash[filter.id] = { keywords: Regexp.union(keywords), filter: filter } end.to_h diff --git a/app/models/custom_filter_keyword.rb b/app/models/custom_filter_keyword.rb index 3158b3b79a..979d0b822e 100644 --- a/app/models/custom_filter_keyword.rb +++ b/app/models/custom_filter_keyword.rb @@ -23,8 +23,24 @@ class CustomFilterKeyword < ApplicationRecord before_destroy :prepare_cache_invalidation! after_commit :invalidate_cache! + def to_regex + if whole_word? + /(?mix:#{to_regex_sb}#{Regexp.escape(keyword)}#{to_regex_eb})/ + else + /#{Regexp.escape(keyword)}/i + end + end + private + def to_regex_sb + /\A[[:word:]]/.match?(keyword) ? '\b' : '' + end + + def to_regex_eb + /[[:word:]]\z/.match?(keyword) ? '\b' : '' + end + def prepare_cache_invalidation! custom_filter.prepare_cache_invalidation! end diff --git a/spec/models/custom_filter_keyword_spec.rb b/spec/models/custom_filter_keyword_spec.rb new file mode 100644 index 0000000000..4e3ab060a0 --- /dev/null +++ b/spec/models/custom_filter_keyword_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe CustomFilterKeyword do + describe '#to_regex' do + context 'when whole_word is true' do + it 'builds a regex with boundaries and the keyword' do + keyword = described_class.new(whole_word: true, keyword: 'test') + + expect(keyword.to_regex).to eq(/(?mix:\b#{Regexp.escape(keyword.keyword)}\b)/) + end + + it 'builds a regex with starting boundary and the keyword when end with non-word' do + keyword = described_class.new(whole_word: true, keyword: 'test#') + + expect(keyword.to_regex).to eq(/(?mix:\btest\#)/) + end + + it 'builds a regex with end boundary and the keyword when start with non-word' do + keyword = described_class.new(whole_word: true, keyword: '#test') + + expect(keyword.to_regex).to eq(/(?mix:\#test\b)/) + end + end + + context 'when whole_word is false' do + it 'builds a regex with the keyword' do + keyword = described_class.new(whole_word: false, keyword: 'test') + + expect(keyword.to_regex).to eq(/test/i) + end + end + end +end From 59d2ea0d82493fdd948c91c6c715ea461b60619b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 25 Jan 2024 14:00:44 +0100 Subject: [PATCH 20/28] New Crowdin Translations (automated) (#28899) Co-authored-by: GitHub Actions --- app/javascript/mastodon/locales/af.json | 1 + app/javascript/mastodon/locales/ca.json | 2 +- app/javascript/mastodon/locales/oc.json | 13 ++++++++ app/javascript/mastodon/locales/zh-TW.json | 12 +++---- config/locales/br.yml | 3 ++ config/locales/ca.yml | 3 ++ config/locales/da.yml | 3 ++ config/locales/de.yml | 3 ++ config/locales/devise.fr-CA.yml | 4 +++ config/locales/devise.fr.yml | 4 +++ config/locales/devise.sv.yml | 1 + config/locales/devise.zh-TW.yml | 14 ++++---- config/locales/es-AR.yml | 3 ++ config/locales/es-MX.yml | 3 ++ config/locales/es.yml | 3 ++ config/locales/eu.yml | 3 ++ config/locales/fi.yml | 7 ++-- config/locales/fo.yml | 3 ++ config/locales/fr-CA.yml | 10 ++++++ config/locales/fr.yml | 10 ++++++ config/locales/gl.yml | 3 ++ config/locales/he.yml | 5 ++- config/locales/hu.yml | 2 ++ config/locales/is.yml | 3 ++ config/locales/it.yml | 3 ++ config/locales/ja.yml | 6 ++++ config/locales/ko.yml | 7 ++++ config/locales/lad.yml | 3 ++ config/locales/lt.yml | 3 ++ config/locales/nl.yml | 6 +++- config/locales/nn.yml | 3 ++ config/locales/no.yml | 3 ++ config/locales/pl.yml | 3 ++ config/locales/pt-BR.yml | 3 ++ config/locales/pt-PT.yml | 3 ++ config/locales/ru.yml | 3 ++ config/locales/sk.yml | 3 ++ config/locales/sq.yml | 3 ++ config/locales/sr-Latn.yml | 3 ++ config/locales/sr.yml | 3 ++ config/locales/sv.yml | 3 ++ config/locales/tr.yml | 3 ++ config/locales/uk.yml | 3 ++ config/locales/vi.yml | 3 ++ config/locales/zh-CN.yml | 3 ++ config/locales/zh-HK.yml | 3 ++ config/locales/zh-TW.yml | 39 ++++++++++++---------- 47 files changed, 197 insertions(+), 36 deletions(-) diff --git a/app/javascript/mastodon/locales/af.json b/app/javascript/mastodon/locales/af.json index 6c37cdf5ca..d1873d6dce 100644 --- a/app/javascript/mastodon/locales/af.json +++ b/app/javascript/mastodon/locales/af.json @@ -3,6 +3,7 @@ "about.contact": "Kontak:", "about.disclaimer": "Mastodon is gratis oopbronsagteware en ’n handelsmerk van Mastodon gGmbH.", "about.domain_blocks.no_reason_available": "Rede nie beskikbaar nie", + "about.domain_blocks.preamble": "Mastodon generally allows you to view content from and interact with users from any other server in the fediverse. These are the exceptions that have been made on this particular server.", "about.domain_blocks.silenced.title": "Beperk", "about.domain_blocks.suspended.title": "Opgeskort", "about.not_available": "Hierdie inligting is nie op hierdie bediener beskikbaar gestel nie.", diff --git a/app/javascript/mastodon/locales/ca.json b/app/javascript/mastodon/locales/ca.json index 7d1049a30f..c763a32ba8 100644 --- a/app/javascript/mastodon/locales/ca.json +++ b/app/javascript/mastodon/locales/ca.json @@ -521,7 +521,7 @@ "poll.total_people": "{count, plural, one {# persona} other {# persones}}", "poll.total_votes": "{count, plural, one {# vot} other {# vots}}", "poll.vote": "Vota", - "poll.voted": "Vas votar per aquesta resposta", + "poll.voted": "Vau votar aquesta resposta", "poll.votes": "{votes, plural, one {# vot} other {# vots}}", "poll_button.add_poll": "Afegeix una enquesta", "poll_button.remove_poll": "Elimina l'enquesta", diff --git a/app/javascript/mastodon/locales/oc.json b/app/javascript/mastodon/locales/oc.json index 833bfe6ace..1ecfbcaf06 100644 --- a/app/javascript/mastodon/locales/oc.json +++ b/app/javascript/mastodon/locales/oc.json @@ -18,6 +18,7 @@ "account.blocked": "Blocat", "account.browse_more_on_origin_server": "Navigar sul perfil original", "account.cancel_follow_request": "Retirar la demanda d’abonament", + "account.copy": "Copiar lo ligam del perfil", "account.direct": "Mencionar @{name} en privat", "account.disable_notifications": "Quitar de m’avisar quand @{name} publica quicòm", "account.domain_blocked": "Domeni amagat", @@ -28,6 +29,7 @@ "account.featured_tags.last_status_never": "Cap de publicacion", "account.featured_tags.title": "Etiquetas en avant de {name}", "account.follow": "Sègre", + "account.follow_back": "Sègre en retorn", "account.followers": "Seguidors", "account.followers.empty": "Degun sèc pas aqueste utilizaire pel moment.", "account.followers_counter": "{count, plural, one {{counter} Seguidor} other {{counter} Seguidors}}", @@ -48,6 +50,7 @@ "account.mute_notifications_short": "Amudir las notificacions", "account.mute_short": "Amudir", "account.muted": "Mes en silenci", + "account.mutual": "Mutual", "account.no_bio": "Cap de descripcion pas fornida.", "account.open_original_page": "Dobrir la pagina d’origina", "account.posts": "Tuts", @@ -172,6 +175,7 @@ "conversation.mark_as_read": "Marcar coma legida", "conversation.open": "Veire la conversacion", "conversation.with": "Amb {names}", + "copy_icon_button.copied": "Copiat al quichapapièr", "copypaste.copied": "Copiat", "copypaste.copy_to_clipboard": "Copiar al quichapapièr", "directory.federated": "Del fediverse conegut", @@ -294,6 +298,8 @@ "keyboard_shortcuts.direct": "to open direct messages column", "keyboard_shortcuts.down": "far davalar dins la lista", "keyboard_shortcuts.enter": "dobrir los estatuts", + "keyboard_shortcuts.favourite": "Marcar coma favorit", + "keyboard_shortcuts.favourites": "Dobrir la lista dels favorits", "keyboard_shortcuts.federated": "dobrir lo flux public global", "keyboard_shortcuts.heading": "Acorchis clavièr", "keyboard_shortcuts.home": "dobrir lo flux public local", @@ -339,6 +345,7 @@ "lists.search": "Cercar demest lo mond que seguètz", "lists.subheading": "Vòstras listas", "load_pending": "{count, plural, one {# nòu element} other {# nòu elements}}", + "loading_indicator.label": "Cargament…", "media_gallery.toggle_visible": "Modificar la visibilitat", "mute_modal.duration": "Durada", "mute_modal.hide_notifications": "Rescondre las notificacions d’aquesta persona ?", @@ -371,6 +378,7 @@ "not_signed_in_indicator.not_signed_in": "Devètz vos connectar per accedir a aquesta ressorsa.", "notification.admin.report": "{name} senhalèt {target}", "notification.admin.sign_up": "{name} se marquèt", + "notification.favourite": "{name} a mes vòstre estatut en favorit", "notification.follow": "{name} vos sèc", "notification.follow_request": "{name} a demandat a vos sègre", "notification.mention": "{name} vos a mencionat", @@ -423,6 +431,8 @@ "onboarding.compose.template": "Adiu #Mastodon !", "onboarding.follows.lead": "You curate your own home feed. The more people you follow, the more active and interesting it will be. These profiles may be a good starting point—you can always unfollow them later!", "onboarding.follows.title": "Popular on Mastodon", + "onboarding.profile.display_name": "Nom d’afichatge", + "onboarding.profile.note": "Biografia", "onboarding.share.title": "Partejar vòstre perfil", "onboarding.start.lead": "Your new Mastodon account is ready to go. Here's how you can make the most of it:", "onboarding.start.skip": "Want to skip right ahead?", @@ -504,6 +514,7 @@ "report_notification.categories.spam": "Messatge indesirable", "report_notification.categories.violation": "Violacion de las règlas", "report_notification.open": "Dobrir lo senhalament", + "search.no_recent_searches": "Cap de recèrcas recentas", "search.placeholder": "Recercar", "search.search_or_paste": "Recercar o picar una URL", "search_popout.language_code": "Còdi ISO de lenga", @@ -536,6 +547,7 @@ "status.copy": "Copiar lo ligam de l’estatut", "status.delete": "Escafar", "status.detailed_status": "Vista detalhada de la convèrsa", + "status.direct": "Mencionar @{name} en privat", "status.direct_indicator": "Mencion privada", "status.edit": "Modificar", "status.edited": "Modificat {date}", @@ -626,6 +638,7 @@ "upload_modal.preview_label": "Apercebut ({ratio})", "upload_progress.label": "Mandadís…", "upload_progress.processing": "Tractament…", + "username.taken": "Aqueste nom d’utilizaire es pres. Ensajatz-ne un autre", "video.close": "Tampar la vidèo", "video.download": "Telecargar lo fichièr", "video.exit_fullscreen": "Sortir plen ecran", diff --git a/app/javascript/mastodon/locales/zh-TW.json b/app/javascript/mastodon/locales/zh-TW.json index 9983936953..cc8b583120 100644 --- a/app/javascript/mastodon/locales/zh-TW.json +++ b/app/javascript/mastodon/locales/zh-TW.json @@ -48,7 +48,7 @@ "account.locked_info": "此帳號的隱私狀態設定為鎖定。該擁有者會手動審核能跟隨此帳號的人。", "account.media": "媒體", "account.mention": "提及 @{name}", - "account.moved_to": "{name} 現在的新帳號為:", + "account.moved_to": "{name} 目前的新帳號為:", "account.mute": "靜音 @{name}", "account.mute_notifications_short": "靜音推播通知", "account.mute_short": "靜音", @@ -59,7 +59,7 @@ "account.posts": "嘟文", "account.posts_with_replies": "嘟文與回覆", "account.report": "檢舉 @{name}", - "account.requested": "正在等待核准。按一下以取消跟隨請求", + "account.requested": "正在等候審核。按一下以取消跟隨請求", "account.requested_follow": "{name} 要求跟隨您", "account.share": "分享 @{name} 的個人檔案", "account.show_reblogs": "顯示來自 @{name} 的嘟文", @@ -84,7 +84,7 @@ "admin.impact_report.title": "影響總結", "alert.rate_limited.message": "請於 {retry_time, time, medium} 後重試。", "alert.rate_limited.title": "已限速", - "alert.unexpected.message": "發生了非預期的錯誤。", + "alert.unexpected.message": "發生非預期的錯誤。", "alert.unexpected.title": "哎呀!", "announcement.announcement": "公告", "attachments_list.unprocessed": "(未經處理)", @@ -241,7 +241,7 @@ "empty_column.followed_tags": "您還沒有跟隨任何主題標籤。當您跟隨主題標籤時,它們將於此顯示。", "empty_column.hashtag": "這個主題標籤下什麼也沒有。", "empty_column.home": "您的首頁時間軸是空的!跟隨更多人來將它填滿吧!", - "empty_column.list": "這份列表下什麼也沒有。當此列表的成員嘟出了新的嘟文時,它們將顯示於此。", + "empty_column.list": "這份列表下什麼也沒有。當此列表的成員嘟出新的嘟文時,它們將顯示於此。", "empty_column.lists": "您還沒有建立任何列表。當您建立列表時,它將於此顯示。", "empty_column.mutes": "您尚未靜音任何使用者。", "empty_column.notifications": "您還沒有收到任何通知,當您與別人開始互動時,它將於此顯示。", @@ -303,8 +303,8 @@ "hashtag.counter_by_accounts": "{count, plural, one {{counter} 名} other {{counter} 名}}參與者", "hashtag.counter_by_uses": "{count, plural, one {{counter} 則} other {{counter} 則}}嘟文", "hashtag.counter_by_uses_today": "本日有 {count, plural, one {{counter} 則} other {{counter} 則}}嘟文", - "hashtag.follow": "追蹤主題標籤", - "hashtag.unfollow": "取消追蹤主題標籤", + "hashtag.follow": "跟隨主題標籤", + "hashtag.unfollow": "取消跟隨主題標籤", "hashtags.and_other": "…及其他 {count, plural, other {# 個}}", "home.actions.go_to_explore": "看看發生什麼新鮮事", "home.actions.go_to_suggestions": "尋找一些人來跟隨", diff --git a/config/locales/br.yml b/config/locales/br.yml index 7af72457d0..d20609a8ce 100644 --- a/config/locales/br.yml +++ b/config/locales/br.yml @@ -443,6 +443,9 @@ br: preferences: other: All posting_defaults: Arventennoù embann dre ziouer + redirects: + prompt: M'ho peus fiziañs el liamm-mañ, klikit warnañ evit kenderc'hel. + title: O kuitaat %{instance} emaoc'h. relationships: dormant: O kousket followers: Heulier·ezed·ien diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 38ef976b83..58f6e26374 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -1546,6 +1546,9 @@ ca: errors: limit_reached: Límit de diferents reaccions assolit unrecognized_emoji: no és un emoji reconegut + redirects: + prompt: Si confieu en aquest enllaç, feu-hi clic per a continuar. + title: Esteu sortint de %{instance}. relationships: activity: Activitat del compte confirm_follow_selected_followers: Segur que vols seguir els seguidors seleccionats? diff --git a/config/locales/da.yml b/config/locales/da.yml index d92d001905..57899d5f71 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -1546,6 +1546,9 @@ da: errors: limit_reached: Grænse for forskellige reaktioner nået unrecognized_emoji: er ikke en genkendt emoji + redirects: + prompt: Er der tillid til dette link, så klik på det for at fortsætte. + title: Nu forlades %{instance}. relationships: activity: Kontoaktivitet confirm_follow_selected_followers: Sikker på, at de valgte følgere skal følges? diff --git a/config/locales/de.yml b/config/locales/de.yml index 9568f698d1..b77f415190 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1546,6 +1546,9 @@ de: errors: limit_reached: Limit für verschiedene Reaktionen erreicht unrecognized_emoji: ist ein unbekanntes Emoji + redirects: + prompt: Wenn du diesem Link vertraust, dann klicke ihn an, um fortzufahren. + title: Du verlässt %{instance}. relationships: activity: Kontoaktivität confirm_follow_selected_followers: Möchtest du den ausgewählten Followern folgen? diff --git a/config/locales/devise.fr-CA.yml b/config/locales/devise.fr-CA.yml index 34104e0ac5..7f13f67828 100644 --- a/config/locales/devise.fr-CA.yml +++ b/config/locales/devise.fr-CA.yml @@ -73,9 +73,13 @@ fr-CA: subject: 'Mastodon: Clé de sécurité supprimée' title: Une de vos clés de sécurité a été supprimée webauthn_disabled: + explanation: L'authentification avec les clés de sécurité a été désactivée pour votre compte. + extra: La connexion est maintenant possible en utilisant uniquement le jeton généré par l'application TOTP associée. subject: 'Mastodon: Authentification avec clés de sécurité désactivée' title: Clés de sécurité désactivées webauthn_enabled: + explanation: L'authentification par clé de sécurité a été activée pour votre compte. + extra: Votre clé de sécurité peut maintenant être utilisée pour vous connecter. subject: 'Mastodon: Authentification de la clé de sécurité activée' title: Clés de sécurité activées omniauth_callbacks: diff --git a/config/locales/devise.fr.yml b/config/locales/devise.fr.yml index 1fc6663bfe..8a5b8384e0 100644 --- a/config/locales/devise.fr.yml +++ b/config/locales/devise.fr.yml @@ -73,9 +73,13 @@ fr: subject: 'Mastodon: Clé de sécurité supprimée' title: Une de vos clés de sécurité a été supprimée webauthn_disabled: + explanation: L'authentification avec les clés de sécurité a été désactivée pour votre compte. + extra: La connexion est maintenant possible en utilisant uniquement le jeton généré par l'application TOTP associée. subject: 'Mastodon: Authentification avec clés de sécurité désactivée' title: Clés de sécurité désactivées webauthn_enabled: + explanation: L'authentification par clé de sécurité a été activée pour votre compte. + extra: Votre clé de sécurité peut maintenant être utilisée pour vous connecter. subject: 'Mastodon: Authentification de la clé de sécurité activée' title: Clés de sécurité activées omniauth_callbacks: diff --git a/config/locales/devise.sv.yml b/config/locales/devise.sv.yml index b089f21427..6544f426bd 100644 --- a/config/locales/devise.sv.yml +++ b/config/locales/devise.sv.yml @@ -77,6 +77,7 @@ sv: subject: 'Mastodon: Autentisering med säkerhetsnycklar är inaktiverat' title: Säkerhetsnycklar inaktiverade webauthn_enabled: + extra: Din säkerhetsnyckel kan nu användas för inloggning. subject: 'Mastodon: Autentisering med säkerhetsnyckel är aktiverat' title: Säkerhetsnycklar aktiverade omniauth_callbacks: diff --git a/config/locales/devise.zh-TW.yml b/config/locales/devise.zh-TW.yml index 762c8eba84..06438971a7 100644 --- a/config/locales/devise.zh-TW.yml +++ b/config/locales/devise.zh-TW.yml @@ -47,14 +47,14 @@ zh-TW: subject: Mastodon:重設密碼指引 title: 重設密碼 two_factor_disabled: - explanation: 現在僅可使用電子郵件地址與密碼登入。 + explanation: 目前僅可使用電子郵件地址與密碼登入。 subject: Mastodon:已停用兩階段驗證 - subtitle: 您帳號的兩步驟驗證已停用。 + subtitle: 您帳號之兩階段驗證已停用。 title: 已停用兩階段驗證 two_factor_enabled: - explanation: 登入時需要配對的 TOTP 應用程式產生的權杖。 + explanation: 登入時需要配對的 TOTP 應用程式產生之 token。 subject: Mastodon:已啟用兩階段驗證 - subtitle: 您的帳號已啟用兩步驟驗證。 + subtitle: 您的帳號之兩階段驗證已啟用。 title: 已啟用兩階段驗證 two_factor_recovery_codes_changed: explanation: 之前的備用驗證碼已經失效,且已產生新的。 @@ -74,12 +74,12 @@ zh-TW: title: 您的一支安全密鑰已經被移除 webauthn_disabled: explanation: 您的帳號已停用安全金鑰身份驗證。 - extra: 現在僅可使用配對的 TOTP 應用程式產生的權杖登入。 + extra: 現在僅可使用配對的 TOTP 應用程式產生之 token 登入。 subject: Mastodon:安全密鑰認證方式已停用 title: 已停用安全密鑰 webauthn_enabled: - explanation: 您的帳號已啟用安全金鑰驗證。 - extra: 您的安全金鑰現在可用於登入。 + explanation: 您的帳號已啟用安全金鑰身分驗證。 + extra: 您的安全金鑰現在已可用於登入。 subject: Mastodon:已啟用安全密鑰認證 title: 已啟用安全密鑰 omniauth_callbacks: diff --git a/config/locales/es-AR.yml b/config/locales/es-AR.yml index cc55d3d3ff..d1dbdbf0b8 100644 --- a/config/locales/es-AR.yml +++ b/config/locales/es-AR.yml @@ -1546,6 +1546,9 @@ es-AR: errors: limit_reached: Se alcanzó el límite de reacciones diferentes unrecognized_emoji: no es un emoji conocido + redirects: + prompt: Si confiás en este enlace, dale clic o un toque para continuar. + title: Estás dejando %{instance}. relationships: activity: Actividad de la cuenta confirm_follow_selected_followers: "¿Estás seguro que querés seguir a los seguidores seleccionados?" diff --git a/config/locales/es-MX.yml b/config/locales/es-MX.yml index b84fb7cf96..4d228e98d4 100644 --- a/config/locales/es-MX.yml +++ b/config/locales/es-MX.yml @@ -1546,6 +1546,9 @@ es-MX: errors: limit_reached: Límite de reacciones diferentes alcanzado unrecognized_emoji: no es un emoji conocido + redirects: + prompt: Si confías en este enlace, púlsalo para continuar. + title: Vas a salir de %{instance}. relationships: activity: Actividad de la cuenta confirm_follow_selected_followers: "¿Estás seguro de que quieres seguir a las cuentas seleccionadas?" diff --git a/config/locales/es.yml b/config/locales/es.yml index 95816d6bcb..08fc0988e4 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1546,6 +1546,9 @@ es: errors: limit_reached: Límite de reacciones diferentes alcanzado unrecognized_emoji: no es un emoji conocido + redirects: + prompt: Si confías en este enlace, púlsalo para continuar. + title: Vas a salir de %{instance}. relationships: activity: Actividad de la cuenta confirm_follow_selected_followers: "¿Estás seguro de que quieres seguir a las cuentas seleccionadas?" diff --git a/config/locales/eu.yml b/config/locales/eu.yml index bd6ea8c832..44688577a9 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -1550,6 +1550,9 @@ eu: errors: limit_reached: Erreakzio desberdinen muga gaindituta unrecognized_emoji: ez da emoji ezaguna + redirects: + prompt: Esteka honetan fidatzen bazara, egin klik jarraitzeko. + title: "%{instance} instantziatik zoaz." relationships: activity: Kontuaren aktibitatea confirm_follow_selected_followers: Ziur hautatutako jarraitzaileei jarraitu nahi dituzula? diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 8e61c7b2a0..856532f8f1 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1546,6 +1546,9 @@ fi: errors: limit_reached: Erilaisten reaktioiden raja saavutettu unrecognized_emoji: ei ole tunnistettu emoji + redirects: + prompt: Jos luotat tähän linkkiin, jatka napsauttamalla. + title: Olet poistumassa palvelimelta %{instance}. relationships: activity: Tilin aktiivisuus confirm_follow_selected_followers: Haluatko varmasti seurata valittuja seuraajia? @@ -1791,8 +1794,8 @@ fi: subject: Arkisto on valmiina ladattavaksi title: Arkiston tallennus failed_2fa: - details: 'Tässä on tiedot kirjautumisyrityksestä:' - explanation: Joku on yrittänyt kirjautua tilillesi, mutta antanut virheellisen kaksivaiheisen todennuksen. + details: 'Tässä on tietoja kirjautumisyrityksestä:' + explanation: Joku on yrittänyt kirjautua tilillesi mutta on antanut virheellisen toisen vaiheen todennustekijän. further_actions_html: Jos se et ollut sinä, suosittelemme, että %{action} välittömästi, sillä se on saattanut vaarantua. subject: Kaksivaiheisen todennuksen virhe title: Epäonnistunut kaksivaiheinen todennus diff --git a/config/locales/fo.yml b/config/locales/fo.yml index 8e34265313..10b1e76f5f 100644 --- a/config/locales/fo.yml +++ b/config/locales/fo.yml @@ -1546,6 +1546,9 @@ fo: errors: limit_reached: Mark fyri ymisk aftursvar rokkið unrecognized_emoji: er ikki eitt kenslutekn, sum kennist aftur + redirects: + prompt: Um tú lítir á hetta leinkið, so kanst tú klikkja á tað fyri at halda fram. + title: Tú fer burtur úr %{instance}. relationships: activity: Kontuvirksemi confirm_follow_selected_followers: Vil tú veruliga fylgja valdu fylgjarunum? diff --git a/config/locales/fr-CA.yml b/config/locales/fr-CA.yml index dbdff5f52c..3676d0b7b5 100644 --- a/config/locales/fr-CA.yml +++ b/config/locales/fr-CA.yml @@ -1546,6 +1546,9 @@ fr-CA: errors: limit_reached: Limite de réactions différentes atteinte unrecognized_emoji: n’est pas un émoji reconnu + redirects: + prompt: Si vous faites confiance à ce lien, cliquez pour continuer. + title: Vous quittez %{instance}. relationships: activity: Activité du compte confirm_follow_selected_followers: Voulez-vous vraiment suivre les abonné⋅e⋅s sélectionné⋅e⋅s ? @@ -1790,6 +1793,12 @@ fr-CA: extra: Elle est maintenant prête à être téléchargée ! subject: Votre archive est prête à être téléchargée title: Récupération de l’archive + failed_2fa: + details: 'Voici les détails de la tentative de connexion :' + explanation: Quelqu'un a essayé de se connecter à votre compte mais a fourni un second facteur d'authentification invalide. + further_actions_html: Si ce n'était pas vous, nous vous recommandons %{action} immédiatement car il pourrait être compromis. + subject: Échec de l'authentification à double facteur + title: Échec de l'authentification à double facteur suspicious_sign_in: change_password: changer votre mot de passe details: 'Voici les détails de la connexion :' @@ -1843,6 +1852,7 @@ fr-CA: go_to_sso_account_settings: Accédez aux paramètres du compte de votre fournisseur d'identité invalid_otp_token: Le code d’authentification à deux facteurs est invalide otp_lost_help_html: Si vous perdez accès aux deux, vous pouvez contacter %{email} + rate_limited: Trop de tentatives d'authentification, réessayez plus tard. seamless_external_login: Vous êtes connecté via un service externe, donc les paramètres concernant le mot de passe et le courriel ne sont pas disponibles. signed_in_as: 'Connecté·e en tant que :' verification: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index fe1a219a31..a3aaf7a26e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1546,6 +1546,9 @@ fr: errors: limit_reached: Limite de réactions différentes atteinte unrecognized_emoji: n’est pas un émoji reconnu + redirects: + prompt: Si vous faites confiance à ce lien, cliquez pour continuer. + title: Vous quittez %{instance}. relationships: activity: Activité du compte confirm_follow_selected_followers: Voulez-vous vraiment suivre les abonné⋅e⋅s sélectionné⋅e⋅s ? @@ -1790,6 +1793,12 @@ fr: extra: Elle est maintenant prête à être téléchargée ! subject: Votre archive est prête à être téléchargée title: Récupération de l’archive + failed_2fa: + details: 'Voici les détails de la tentative de connexion :' + explanation: Quelqu'un a essayé de se connecter à votre compte mais a fourni un second facteur d'authentification invalide. + further_actions_html: Si ce n'était pas vous, nous vous recommandons %{action} immédiatement car il pourrait être compromis. + subject: Échec de l'authentification à double facteur + title: Échec de l'authentification à double facteur suspicious_sign_in: change_password: changer votre mot de passe details: 'Voici les détails de la connexion :' @@ -1843,6 +1852,7 @@ fr: go_to_sso_account_settings: Accédez aux paramètres du compte de votre fournisseur d'identité invalid_otp_token: Le code d’authentification à deux facteurs est invalide otp_lost_help_html: Si vous perdez accès aux deux, vous pouvez contacter %{email} + rate_limited: Trop de tentatives d'authentification, réessayez plus tard. seamless_external_login: Vous êtes connecté via un service externe, donc les paramètres concernant le mot de passe et le courriel ne sont pas disponibles. signed_in_as: 'Connecté·e en tant que :' verification: diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 087ed2ec76..7b3fd1a6eb 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -1546,6 +1546,9 @@ gl: errors: limit_reached: Acadouse o límite das diferentes reaccións unrecognized_emoji: non é unha emoticona recoñecida + redirects: + prompt: Se confías nesta ligazón, preme nela para continuar. + title: Vas saír de %{instance}. relationships: activity: Actividade da conta confirm_follow_selected_followers: Tes a certeza de querer seguir as seguidoras seleccionadas? diff --git a/config/locales/he.yml b/config/locales/he.yml index 1f5fd096ac..05b52213a7 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -1598,6 +1598,9 @@ he: errors: limit_reached: גבול מספר התגובות השונות הושג unrecognized_emoji: הוא לא אמוג'י מוכר + redirects: + prompt: יש ללחוץ על הקישור, אם לדעתך ניתן לסמוך עליו. + title: יציאה מתוך %{instance}. relationships: activity: רמת פעילות confirm_follow_selected_followers: האם את/ה בטוח/ה שברצונך לעקוב אחרי החשבונות שסומנו? @@ -1856,7 +1859,7 @@ he: title: הוצאת ארכיון failed_2fa: details: 'הנה פרטי נסיון ההתחברות:' - explanation: פולני אלמוני ניסה להתחבר לחשבונך אך האימות המשני נכשל. + explanation: פלוני אלמוני ניסה להתחבר לחשבונך אך האימות המשני נכשל. further_actions_html: אם הנסיון לא היה שלך, אנו ממליצים על %{action} באופן מיידי כדי שהחשבון לא יפול קורבן. subject: נכשל אימות בגורם שני title: אימות בגורם שני נכשל diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 2870435ea7..8cbbb64c97 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -1546,6 +1546,8 @@ hu: errors: limit_reached: A különböző reakciók száma elérte a határértéket unrecognized_emoji: nem ismert emodzsi + redirects: + prompt: Ha megbízunk ebben a hivatkozásban, kattintsunk rá a folytatáshoz. relationships: activity: Fiók aktivitás confirm_follow_selected_followers: Biztos, hogy követni akarod a kiválasztott követőket? diff --git a/config/locales/is.yml b/config/locales/is.yml index 191383f56c..d374c60755 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -1550,6 +1550,9 @@ is: errors: limit_reached: Hámarki mismunandi viðbragða náð unrecognized_emoji: er ekki þekkt tjáningartákn + redirects: + prompt: Ef þú treystir þessum tengli, geturðu smellt á hann til að halda áfram. + title: Þú ert að yfirgefa %{instance}. relationships: activity: Virkni aðgangs confirm_follow_selected_followers: Ertu viss um að þú viljir fylgjast með völdum fylgjendum? diff --git a/config/locales/it.yml b/config/locales/it.yml index 89ff071f36..31de2252d1 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -1548,6 +1548,9 @@ it: errors: limit_reached: Raggiunto il limite di reazioni diverse unrecognized_emoji: non è un emoji riconosciuto + redirects: + prompt: Se ti fidi di questo collegamento, fai clic su di esso per continuare. + title: Stai lasciando %{instance}. relationships: activity: Attività dell'account confirm_follow_selected_followers: Sei sicuro di voler seguire i follower selezionati? diff --git a/config/locales/ja.yml b/config/locales/ja.yml index c966cbe36f..2051e30aee 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1758,6 +1758,12 @@ ja: extra: ダウンロードの準備ができました! subject: アーカイブの準備ができました title: アーカイブの取り出し + failed_2fa: + details: '試行されたログインの詳細は以下のとおりです:' + explanation: アカウントへのログインが試行されましたが、二要素認証で不正な回答が送信されました。 + further_actions_html: このログインに心当たりがない場合は、ただちに%{action}してください。 + subject: 二要素認証に失敗しました + title: 二要素認証に失敗した記録があります suspicious_sign_in: change_password: パスワードを変更 details: 'ログインの詳細は以下のとおりです:' diff --git a/config/locales/ko.yml b/config/locales/ko.yml index b3c786e265..9f4f1343c7 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -1522,6 +1522,9 @@ ko: errors: limit_reached: 리액션 갯수 제한에 도달했습니다 unrecognized_emoji: 인식 되지 않은 에모지입니다 + redirects: + prompt: 이 링크를 믿을 수 있다면, 클릭해서 계속하세요. + title: "%{instance}를 떠나려고 합니다." relationships: activity: 계정 활동 confirm_follow_selected_followers: 정말로 선택된 팔로워들을 팔로우하시겠습니까? @@ -1762,6 +1765,10 @@ ko: title: 아카이브 테이크아웃 failed_2fa: details: '로그인 시도에 대한 상세 정보입니다:' + explanation: 누군가가 내 계정에 로그인을 시도했지만 2차인증에 올바른 값을 입력하지 못했습니다. + further_actions_html: 만약 당신이 한 게 아니었다면 유출의 가능성이 있으니 가능한 빨리 %{action} 하시기 바랍니다. + subject: 2차 인증 실패 + title: 2차 인증에 실패했습니다 suspicious_sign_in: change_password: 암호 변경 details: '로그인에 대한 상세 정보입니다:' diff --git a/config/locales/lad.yml b/config/locales/lad.yml index be5d2d21bd..02308cf2f0 100644 --- a/config/locales/lad.yml +++ b/config/locales/lad.yml @@ -1516,6 +1516,9 @@ lad: errors: limit_reached: Limito de reaksyones desferentes alkansado unrecognized_emoji: no es un emoji konesido + redirects: + prompt: Si konfiyas en este atadijo, klikalo para kontinuar. + title: Estas salyendo de %{instance}. relationships: activity: Aktivita del kuento confirm_follow_selected_followers: Estas siguro ke keres segir a los suivantes eskojidos? diff --git a/config/locales/lt.yml b/config/locales/lt.yml index ba8b53fdc9..1d159bf45a 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -478,6 +478,9 @@ lt: other: Kita privacy: hint_html: "Tikrink, kaip nori, kad tavo profilis ir įrašai būtų randami. Įjungus įvairias Mastodon funkcijas, jos gali padėti pasiekti platesnę auditoriją. Akimirką peržiūrėk šiuos nustatymus, kad įsitikintum, jog jie atitinka tavo naudojimo būdą." + redirects: + prompt: Jei pasitiki šia nuoroda, spustelėk ją, kad tęstum. + title: Palieki %{instance} remote_follow: missing_resource: Jūsų paskyros nukreipimo URL nerasta scheduled_statuses: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 2d27f9165d..a3657890da 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1546,6 +1546,9 @@ nl: errors: limit_reached: Limiet van verschillende emoji-reacties bereikt unrecognized_emoji: is geen bestaande emoji-reactie + redirects: + prompt: Als je deze link vertrouwt, klik er dan op om door te gaan. + title: Je verlaat %{instance}. relationships: activity: Accountactiviteit confirm_follow_selected_followers: Weet je zeker dat je de geselecteerde volgers wilt volgen? @@ -1792,7 +1795,8 @@ nl: title: Archief ophalen failed_2fa: details: 'Hier zijn details van de aanmeldpoging:' - explanation: Iemand heeft geprobeerd om in te loggen op uw account maar heeft een ongeldige tweede verificatiefactor opgegeven. + explanation: Iemand heeft geprobeerd om in te loggen op jouw account maar heeft een ongeldige tweede verificatiefactor opgegeven. + further_actions_html: Als jij dit niet was, raden we je aan om onmiddellijk %{action} aangezien het in gevaar kan zijn. subject: Tweede factor authenticatiefout title: Tweestapsverificatie mislukt suspicious_sign_in: diff --git a/config/locales/nn.yml b/config/locales/nn.yml index 95eed49785..ffa5198a3a 100644 --- a/config/locales/nn.yml +++ b/config/locales/nn.yml @@ -1546,6 +1546,9 @@ nn: errors: limit_reached: Grensen for forskjellige reaksjoner nådd unrecognized_emoji: er ikke en gjenkjent emoji + redirects: + prompt: Hvis du stoler på denne lenken, så trykk på den for å fortsette. + title: Du forlater %{instance}. relationships: activity: Kontoaktivitet confirm_follow_selected_followers: Er du sikker på at du ynskjer å fylgja dei valde fylgjarane? diff --git a/config/locales/no.yml b/config/locales/no.yml index 7ece8564fc..d26b20379e 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -1546,6 +1546,9 @@ errors: limit_reached: Grensen for ulike reaksjoner nådd unrecognized_emoji: er ikke en gjenkjent emoji + redirects: + prompt: Hvis du stoler på denne lenken, så trykk på den for å fortsette. + title: Du forlater %{instance}. relationships: activity: Kontoaktivitet confirm_follow_selected_followers: Er du sikker på at du vil følge valgte følgere? diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 6718f1994b..5bc78a6adf 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1598,6 +1598,9 @@ pl: errors: limit_reached: Przekroczono limit różnych reakcji unrecognized_emoji: nie jest znanym emoji + redirects: + prompt: Kliknij ten link jeżeli mu ufasz. + title: Opuszczasz %{instance}. relationships: activity: Aktywność konta confirm_follow_selected_followers: Czy na pewno chcesz obserwować wybranych obserwujących? diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index c1a47c0161..79396d627f 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1546,6 +1546,9 @@ pt-BR: errors: limit_reached: Limite de reações diferentes atingido unrecognized_emoji: não é um emoji reconhecido + redirects: + prompt: Se você confia neste link, clique nele para continuar. + title: Você está saindo de %{instance}. relationships: activity: Atividade da conta confirm_follow_selected_followers: Tem certeza que deseja seguir os seguidores selecionados? diff --git a/config/locales/pt-PT.yml b/config/locales/pt-PT.yml index 268531718d..8a20bc68a1 100644 --- a/config/locales/pt-PT.yml +++ b/config/locales/pt-PT.yml @@ -1546,6 +1546,9 @@ pt-PT: errors: limit_reached: Alcançado limite de reações diferentes unrecognized_emoji: não é um emoji reconhecido + redirects: + prompt: Se confia nesta hiperligação, clique nela para continuar. + title: Está a deixar %{instance}. relationships: activity: Atividade da conta confirm_follow_selected_followers: Tem a certeza que deseja seguir os seguidores selecionados? diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 24edbdc75e..04e49e0427 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1598,6 +1598,9 @@ ru: errors: limit_reached: Достигнут лимит разных реакций unrecognized_emoji: не является распознанным эмодзи + redirects: + prompt: Если вы доверяете этой ссылке, нажмите на нее, чтобы продолжить. + title: Вы покидаете %{instance}. relationships: activity: Активность учётной записи confirm_follow_selected_followers: Вы уверены, что хотите подписаться на выбранных подписчиков? diff --git a/config/locales/sk.yml b/config/locales/sk.yml index e83ae348f6..20df763463 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -1101,6 +1101,9 @@ sk: errors: limit_reached: Maximálny počet rôznorodých reakcií bol dosiahnutý unrecognized_emoji: je neznámy smajlík + redirects: + prompt: Ak tomuto odkazu veríš, klikni naňho pre pokračovanie. + title: Opúšťaš %{instance}. relationships: activity: Aktivita účtu confirm_follow_selected_followers: Si si istý/á, že chceš nasledovať vybraných sledujúcich? diff --git a/config/locales/sq.yml b/config/locales/sq.yml index d6e6925c70..3dd4731209 100644 --- a/config/locales/sq.yml +++ b/config/locales/sq.yml @@ -1542,6 +1542,9 @@ sq: errors: limit_reached: U mbërrit në kufirin e reagimeve të ndryshme unrecognized_emoji: s’është emotikon i pranuar + redirects: + prompt: Nëse e besoni këtë lidhje, klikoni që të vazhdohet. + title: Po e braktisni %{instance}. relationships: activity: Veprimtari llogarie confirm_follow_selected_followers: Jeni i sigurt se doni të ndiqet ndjekësit e përzgjedhur? diff --git a/config/locales/sr-Latn.yml b/config/locales/sr-Latn.yml index 9cb555c943..b55b6e0d19 100644 --- a/config/locales/sr-Latn.yml +++ b/config/locales/sr-Latn.yml @@ -1572,6 +1572,9 @@ sr-Latn: errors: limit_reached: Dostignuto je ograničenje različitih reakcija unrecognized_emoji: nije prepoznat emodži + redirects: + prompt: Ako verujete ovoj vezi, kliknite na nju za nastavak. + title: Napuštate %{instance}. relationships: activity: Aktivnost naloga confirm_follow_selected_followers: Da li ste sigurni da želite da pratite izabrane pratioce? diff --git a/config/locales/sr.yml b/config/locales/sr.yml index e1c2e992ed..8de7c90e73 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -1572,6 +1572,9 @@ sr: errors: limit_reached: Достигнуто је ограничење различитих реакција unrecognized_emoji: није препознат емоџи + redirects: + prompt: Ако верујете овој вези, кликните на њу за наставак. + title: Напуштате %{instance}. relationships: activity: Активност налога confirm_follow_selected_followers: Да ли сте сигурни да желите да пратите изабране пратиоце? diff --git a/config/locales/sv.yml b/config/locales/sv.yml index c9000d50fc..deac7cc638 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -1545,6 +1545,9 @@ sv: errors: limit_reached: Gränsen för unika reaktioner uppnådd unrecognized_emoji: är inte en igenkänd emoji + redirects: + prompt: Om du litar på denna länk, klicka på den för att fortsätta. + title: Du lämnar %{instance}. relationships: activity: Kontoaktivitet confirm_follow_selected_followers: Är du säker på att du vill följa valda följare? diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 2b5b5ad45b..b3a52715b7 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1546,6 +1546,9 @@ tr: errors: limit_reached: Farklı reaksiyonların sınırına ulaşıldı unrecognized_emoji: tanınan bir emoji değil + redirects: + prompt: Eğer bu bağlantıya güveniyorsanız, tıklayıp devam edebilirsiniz. + title: "%{instance} sunucusundan ayrılıyorsunuz." relationships: activity: Hesap etkinliği confirm_follow_selected_followers: Seçili takipçileri takip etmek istediğinizden emin misiniz? diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 40a858d72a..531bdb3d59 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1598,6 +1598,9 @@ uk: errors: limit_reached: Досягнуто обмеження різних реакцій unrecognized_emoji: не є розпізнаним емоджі + redirects: + prompt: Якщо ви довіряєте цьому посиланню, натисніть, щоб продовжити. + title: Ви покидаєте %{instance}. relationships: activity: Діяльність облікового запису confirm_follow_selected_followers: Ви справді бажаєте підписатися на обраних підписників? diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 1ece72e154..045a000e38 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1520,6 +1520,9 @@ vi: errors: limit_reached: Bạn không nên thao tác liên tục unrecognized_emoji: không phải là emoji + redirects: + prompt: Nếu bạn tin tưởng, hãy nhấn tiếp tục. + title: Bạn đang thoát khỏi %{instance}. relationships: activity: Tương tác confirm_follow_selected_followers: Bạn có chắc muốn theo dõi những người đã chọn? diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 272787ce25..d1255bfefe 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -1520,6 +1520,9 @@ zh-CN: errors: limit_reached: 互动种类的限制 unrecognized_emoji: 不是一个可识别的表情 + redirects: + prompt: 如果您信任此链接,请单击以继续跳转。 + title: 您正在离开 %{instance} 。 relationships: activity: 账号活动 confirm_follow_selected_followers: 您确定想要关注所选的关注者吗? diff --git a/config/locales/zh-HK.yml b/config/locales/zh-HK.yml index 0c39aa8c0b..b010a75c04 100644 --- a/config/locales/zh-HK.yml +++ b/config/locales/zh-HK.yml @@ -1520,6 +1520,9 @@ zh-HK: errors: limit_reached: 已達到可以給予反應極限 unrecognized_emoji: 不能識別這個emoji + redirects: + prompt: 如果你信任此連結,點擊它繼續。 + title: 你即將離開 %{instance}。 relationships: activity: 帳戶活動 confirm_follow_selected_followers: 你確定要追蹤選取的追蹤者嗎? diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 8726ea72a4..72e63e47d3 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -57,7 +57,7 @@ zh-TW: destroyed_msg: 即將刪除 %{username} 的資料 disable: 停用 disable_sign_in_token_auth: 停用電子郵件 token 驗證 - disable_two_factor_authentication: 停用兩階段認證 + disable_two_factor_authentication: 停用兩階段驗證 disabled: 已停用 display_name: 暱稱 domain: 站點 @@ -195,7 +195,7 @@ zh-TW: destroy_status: 刪除狀態 destroy_unavailable_domain: 刪除無法存取的網域 destroy_user_role: 移除角色 - disable_2fa_user: 停用兩階段認證 + disable_2fa_user: 停用兩階段驗證 disable_custom_emoji: 停用自訂顏文字 disable_sign_in_token_auth_user: 停用使用者電子郵件 token 驗證 disable_user: 停用帳號 @@ -254,7 +254,7 @@ zh-TW: destroy_status_html: "%{name} 已刪除 %{target} 的嘟文" destroy_unavailable_domain_html: "%{name} 已恢復對網域 %{target} 的發送" destroy_user_role_html: "%{name} 已刪除 %{target} 角色" - disable_2fa_user_html: "%{name} 已停用使用者 %{target} 的兩階段認證 (2FA) " + disable_2fa_user_html: "%{name} 已停用使用者 %{target} 的兩階段驗證 (2FA) " disable_custom_emoji_html: "%{name} 已停用自訂表情符號 %{target}" disable_sign_in_token_auth_user_html: "%{name} 已停用 %{target} 之使用者電子郵件 token 驗證" disable_user_html: "%{name} 將使用者 %{target} 設定為禁止登入" @@ -418,7 +418,7 @@ zh-TW: view: 顯示已封鎖網域 email_domain_blocks: add_new: 加入新項目 - allow_registrations_with_approval: 經允許後可註冊 + allow_registrations_with_approval: 經審核後可註冊 attempts_over_week: other: 上週共有 %{count} 次註冊嘗試 created_msg: 已成功將電子郵件網域加入黑名單 @@ -505,7 +505,7 @@ zh-TW: delivery_available: 可傳送 delivery_error_days: 遞送失敗天數 delivery_error_hint: 若 %{count} 日皆無法遞送 ,則會自動標記無法遞送。 - destroyed_msg: 來自 %{domain} 的資料現在正在佇列中等待刪除。 + destroyed_msg: 來自 %{domain} 的資料目前正在佇列中等待刪除。 empty: 找不到網域 known_accounts: other: "%{count} 個已知帳號" @@ -759,7 +759,7 @@ zh-TW: title: 註冊 registrations_mode: modes: - approved: 註冊需要核准 + approved: 註冊需要審核 none: 沒有人可註冊 open: 任何人皆能註冊 security: @@ -870,7 +870,7 @@ zh-TW: links: allow: 允許連結 allow_provider: 允許發行者 - description_html: 這些連結是正在被您伺服器上看到該嘟文之帳號大量分享。這些連結可以幫助您的使用者探索現在世界上正在發生的事情。除非您核准該發行者,連結將不被公開展示。您也可以核准或駁回個別連結。 + description_html: 這些連結是正在被您伺服器上看到該嘟文之帳號大量分享。這些連結可以幫助您的使用者探索目前世界上正在發生的事情。除非您核准該發行者,連結將不被公開展示。您也可以核准或駁回個別連結。 disallow: 不允許連結 disallow_provider: 不允許發行者 no_link_selected: 因未選取任何連結,所以什麼事都沒發生 @@ -1062,7 +1062,7 @@ zh-TW: cas: CAS saml: SAML register: 註冊 - registration_closed: "%{instance} 現在不開放新成員" + registration_closed: "%{instance} 目前不開放新成員" resend_confirmation: 重新傳送確認連結 reset_password: 重設密碼 rules: @@ -1522,6 +1522,9 @@ zh-TW: errors: limit_reached: 達到可回應之上限 unrecognized_emoji: 並非一個可識別的 emoji + redirects: + prompt: 若您信任此連結,請點擊以繼續。 + title: 您將要離開 %{instance} 。 relationships: activity: 帳號動態 confirm_follow_selected_followers: 您確定要跟隨選取的跟隨者嗎? @@ -1627,7 +1630,7 @@ zh-TW: relationships: 跟隨中與跟隨者 statuses_cleanup: 自動嘟文刪除 strikes: 管理警告 - two_factor_authentication: 兩階段認證 + two_factor_authentication: 兩階段驗證 webauthn_authentication: 安全金鑰 statuses: attached: @@ -1733,11 +1736,11 @@ zh-TW: disable: 停用兩階段驗證 disabled_success: 已成功啟用兩階段驗證 edit: 編輯 - enabled: 兩階段認證已啟用 - enabled_success: 已成功啟用兩階段認證 + enabled: 兩階段驗證已啟用 + enabled_success: 兩階段驗證已成功啟用 generate_recovery_codes: 產生備用驗證碼 lost_recovery_codes: 讓您能於遺失手機時,使用備用驗證碼登入。若您已遺失備用驗證碼,可於此產生一批新的,舊有的備用驗證碼將會失效。 - methods: 兩步驟方式 + methods: 兩階段驗證 otp: 驗證應用程式 recovery_codes: 備份備用驗證碼 recovery_codes_regenerated: 成功產生新的備用驗證碼 @@ -1757,15 +1760,15 @@ zh-TW: title: 申訴被駁回 backup_ready: explanation: 您要求完整備份您的 Mastodon 帳號。 - extra: 準備好下載了! + extra: 準備好可供下載了! subject: 您的備份檔已可供下載 title: 檔案匯出 failed_2fa: details: 以下是該登入嘗試之詳細資訊: - explanation: 有人嘗試登入您的帳號,但提供了無效的第二個驗證因子。 + explanation: 有人嘗試登入您的帳號,但提供了無效的兩階段驗證。 further_actions_html: 若這並非您所為,我們建議您立刻 %{action},因為其可能已被入侵。 - subject: 第二因子驗證失敗 - title: 第二因子身份驗證失敗 + subject: 兩階段驗證失敗 + title: 兩階段驗證失敗 suspicious_sign_in: change_password: 變更密碼 details: 以下是該登入之詳細資訊: @@ -1817,9 +1820,9 @@ zh-TW: users: follow_limit_reached: 您無法跟隨多於 %{limit} 個人 go_to_sso_account_settings: 前往您的身分提供商 (identity provider) 之帳號設定 - invalid_otp_token: 兩階段認證碼不正確 + invalid_otp_token: 兩階段驗證碼不正確 otp_lost_help_html: 如果您無法存取這兩者,您可以透過 %{email} 與我們聯繫 - rate_limited: 身份驗證嘗試太多次,請稍後再試。 + rate_limited: 過多次身份驗證嘗試,請稍後再試。 seamless_external_login: 由於您是由外部系統登入,所以不能設定密碼與電子郵件。 signed_in_as: 目前登入的帳號: verification: From ca7053f19c425616b90774cd2f2553f0842cd314 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 25 Jan 2024 08:10:39 -0500 Subject: [PATCH 21/28] Consolidate db test prep steps to rake task (#28886) --- .../workflows/test-migrations-one-step.yml | 19 ++-------------- .../workflows/test-migrations-two-step.yml | 22 +++---------------- lib/tasks/tests.rake | 18 +++++++++++++++ 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/.github/workflows/test-migrations-one-step.yml b/.github/workflows/test-migrations-one-step.yml index 5dca8e376d..1ff5cc06b9 100644 --- a/.github/workflows/test-migrations-one-step.yml +++ b/.github/workflows/test-migrations-one-step.yml @@ -78,23 +78,8 @@ jobs: - name: Create database run: './bin/rails db:create' - - name: Run migrations up to v2.0.0 - run: './bin/rails db:migrate VERSION=20171010025614' - - - name: Populate database with test data - run: './bin/rails tests:migrations:populate_v2' - - - name: Run migrations up to v2.4.0 - run: './bin/rails db:migrate VERSION=20180514140000' - - - name: Populate database with test data - run: './bin/rails tests:migrations:populate_v2_4' - - - name: Run migrations up to v2.4.3 - run: './bin/rails db:migrate VERSION=20180707154237' - - - name: Populate database with test data - run: './bin/rails tests:migrations:populate_v2_4_3' + - name: Run historical migrations with data population + run: './bin/rails tests:migrations:prepare_database' - name: Run all remaining migrations run: './bin/rails db:migrate' diff --git a/.github/workflows/test-migrations-two-step.yml b/.github/workflows/test-migrations-two-step.yml index 59485d285d..6698847315 100644 --- a/.github/workflows/test-migrations-two-step.yml +++ b/.github/workflows/test-migrations-two-step.yml @@ -45,6 +45,7 @@ jobs: --health-retries 5 ports: - 5432:5432 + redis: image: redis:7-alpine options: >- @@ -77,28 +78,11 @@ jobs: - name: Create database run: './bin/rails db:create' - - name: Run migrations up to v2.0.0 - run: './bin/rails db:migrate VERSION=20171010025614' - - - name: Populate database with test data - run: './bin/rails tests:migrations:populate_v2' - - - name: Run pre-deployment migrations up to v2.4.0 - run: './bin/rails db:migrate VERSION=20180514140000' + - name: Run historical migrations with data population + run: './bin/rails tests:migrations:prepare_database' env: SKIP_POST_DEPLOYMENT_MIGRATIONS: true - - name: Populate database with test data - run: './bin/rails tests:migrations:populate_v2_4' - - - name: Run migrations up to v2.4.3 - run: './bin/rails db:migrate VERSION=20180707154237' - env: - SKIP_POST_DEPLOYMENT_MIGRATIONS: true - - - name: Populate database with test data - run: './bin/rails tests:migrations:populate_v2_4_3' - - name: Run all remaining pre-deployment migrations run: './bin/rails db:migrate' env: diff --git a/lib/tasks/tests.rake b/lib/tasks/tests.rake index 45f055e218..885be79f41 100644 --- a/lib/tasks/tests.rake +++ b/lib/tasks/tests.rake @@ -2,6 +2,22 @@ namespace :tests do namespace :migrations do + desc 'Prepares all migrations and test data for consistency checks' + task prepare_database: :environment do + { + '2' => 2017_10_10_025614, + '2_4' => 2018_05_14_140000, + '2_4_3' => 2018_07_07_154237, + }.each do |release, version| + ActiveRecord::Tasks::DatabaseTasks + .migration_connection + .migration_context + .migrate(version) + Rake::Task["tests:migrations:populate_v#{release}"] + .invoke + end + end + desc 'Check that database state is consistent with a successful migration from populated data' task check_database: :environment do unless Account.find_by(username: 'admin', domain: nil)&.hide_collections? == false @@ -88,6 +104,8 @@ namespace :tests do puts 'Locale for fr-QC users not updated to fr-CA as expected' exit(1) end + + puts 'No errors found. Database state is consistent with a successful migration process.' end desc 'Populate the database with test data for 2.4.3' From c8f59d2ca4d693f328d8f68a21749ab4efc8c820 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 25 Jan 2024 08:28:49 -0500 Subject: [PATCH 22/28] Fix `Style/TernaryParentheses` cop (#28387) --- .rubocop_todo.yml | 7 ------- config/environments/development.rb | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 77f7e70734..fd9dc18ac7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -279,13 +279,6 @@ Style/StringLiterals: - 'config/initializers/webauthn.rb' - 'config/routes.rb' -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex -Style/TernaryParentheses: - Exclude: - - 'config/environments/development.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma diff --git a/config/environments/development.rb b/config/environments/development.rb index 3c13ada380..a855f5a16b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -85,7 +85,7 @@ Rails.application.configure do # If using a Heroku, Vagrant or generic remote development environment, # use letter_opener_web, accessible at /letter_opener. # Otherwise, use letter_opener, which launches a browser window to view sent mail. - config.action_mailer.delivery_method = (ENV['HEROKU'] || ENV['VAGRANT'] || ENV['REMOTE_DEV']) ? :letter_opener_web : :letter_opener + config.action_mailer.delivery_method = ENV['HEROKU'] || ENV['VAGRANT'] || ENV['REMOTE_DEV'] ? :letter_opener_web : :letter_opener # We provide a default secret for the development environment here. # This value should not be used in production environments! From 2866106ec1fb1ac5b30f432730bd20c6459f6600 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 25 Jan 2024 08:37:25 -0500 Subject: [PATCH 23/28] Reduce factory creation in `spec/models/account_statuses_cleanup_policy` (#28361) --- .../account_statuses_cleanup_policy_spec.rb | 165 +++++++----------- 1 file changed, 59 insertions(+), 106 deletions(-) diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index da2a774b2d..a08fd723a4 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -296,16 +296,11 @@ RSpec.describe AccountStatusesCleanupPolicy do let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) } - it 'returns statuses including max_id' do - expect(subject).to include(old_status.id) - end - - it 'returns statuses including older than max_id' do - expect(subject).to include(very_old_status.id) - end - - it 'does not return statuses newer than max_id' do - expect(subject).to_not include(slightly_less_old_status.id) + it 'returns statuses included the max_id and older than the max_id but not newer than max_id' do + expect(subject) + .to include(old_status.id) + .and include(very_old_status.id) + .and not_include(slightly_less_old_status.id) end end @@ -315,16 +310,11 @@ RSpec.describe AccountStatusesCleanupPolicy do let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) } - it 'returns statuses including min_id' do - expect(subject).to include(old_status.id) - end - - it 'returns statuses including newer than max_id' do - expect(subject).to include(slightly_less_old_status.id) - end - - it 'does not return statuses older than min_id' do - expect(subject).to_not include(very_old_status.id) + it 'returns statuses including min_id and newer than min_id, but not older than min_id' do + expect(subject) + .to include(old_status.id) + .and include(slightly_less_old_status.id) + .and not_include(very_old_status.id) end end @@ -339,12 +329,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.min_status_age = 2.years.seconds end - it 'does not return unrelated old status' do - expect(subject.pluck(:id)).to_not include(unrelated_status.id) - end - - it 'returns only oldest status for deletion' do - expect(subject.pluck(:id)).to eq [very_old_status.id] + it 'does not return unrelated old status and does return oldest status' do + expect(subject.pluck(:id)) + .to not_include(unrelated_status.id) + .and eq [very_old_status.id] end end @@ -358,12 +346,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = false end - it 'does not return the old direct message for deletion' do - expect(subject.pluck(:id)).to_not include(direct_message.id) - end - - it 'returns every other old status for deletion' do - expect(subject.pluck(:id)).to include(very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns every old status except does not return the old direct message for deletion' do + expect(subject.pluck(:id)) + .to not_include(direct_message.id) + .and include(very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -377,12 +363,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = true end - it 'does not return the old self-bookmarked message for deletion' do - expect(subject.pluck(:id)).to_not include(self_bookmarked.id) - end - - it 'returns every other old status for deletion' do - expect(subject.pluck(:id)).to include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns every old status but does not return the old self-bookmarked message for deletion' do + expect(subject.pluck(:id)) + .to not_include(self_bookmarked.id) + .and include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -396,12 +380,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = false end - it 'does not return the old self-bookmarked message for deletion' do - expect(subject.pluck(:id)).to_not include(self_faved.id) - end - - it 'returns every other old status for deletion' do - expect(subject.pluck(:id)).to include(direct_message.id, very_old_status.id, pinned_status.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns every old status but does not return the old self-faved message for deletion' do + expect(subject.pluck(:id)) + .to not_include(self_faved.id) + .and include(direct_message.id, very_old_status.id, pinned_status.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -415,12 +397,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = false end - it 'does not return the old message with media for deletion' do - expect(subject.pluck(:id)).to_not include(status_with_media.id) - end - - it 'returns every other old status for deletion' do - expect(subject.pluck(:id)).to include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns every old status but does not return the old message with media for deletion' do + expect(subject.pluck(:id)) + .to not_include(status_with_media.id) + .and include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -434,12 +414,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = false end - it 'does not return the old poll message for deletion' do - expect(subject.pluck(:id)).to_not include(status_with_poll.id) - end - - it 'returns every other old status for deletion' do - expect(subject.pluck(:id)).to include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns every old status but does not return the old poll message for deletion' do + expect(subject.pluck(:id)) + .to not_include(status_with_poll.id) + .and include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -453,12 +431,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = false end - it 'does not return the old pinned message for deletion' do - expect(subject.pluck(:id)).to_not include(pinned_status.id) - end - - it 'returns every other old status for deletion' do - expect(subject.pluck(:id)).to include(direct_message.id, very_old_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns every old status but does not return the old pinned message for deletion' do + expect(subject.pluck(:id)) + .to not_include(pinned_status.id) + .and include(direct_message.id, very_old_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -472,16 +448,11 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = false end - it 'does not return the recent toot' do - expect(subject.pluck(:id)).to_not include(recent_status.id) - end - - it 'does not return the unrelated toot' do - expect(subject.pluck(:id)).to_not include(unrelated_status.id) - end - - it 'returns every other old status for deletion' do - expect(subject.pluck(:id)).to include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns every old status but does not return the recent or unrelated statuses' do + expect(subject.pluck(:id)) + .to not_include(recent_status.id) + .and not_include(unrelated_status.id) + .and include(direct_message.id, very_old_status.id, pinned_status.id, self_faved.id, self_bookmarked.id, status_with_poll.id, status_with_media.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -495,12 +466,10 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.keep_self_bookmark = true end - it 'does not return unrelated old status' do - expect(subject.pluck(:id)).to_not include(unrelated_status.id) - end - - it 'returns only normal statuses for deletion' do - expect(subject.pluck(:id)).to contain_exactly(very_old_status.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns normal statuses and does not return unrelated old status' do + expect(subject.pluck(:id)) + .to not_include(unrelated_status.id) + .and contain_exactly(very_old_status.id, faved_primary.id, faved_secondary.id, reblogged_primary.id, reblogged_secondary.id) end end @@ -509,20 +478,12 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.min_reblogs = 5 end - it 'does not return the recent toot' do - expect(subject.pluck(:id)).to_not include(recent_status.id) - end - - it 'does not return the toot reblogged 5 times' do - expect(subject.pluck(:id)).to_not include(reblogged_secondary.id) - end - - it 'does not return the unrelated toot' do - expect(subject.pluck(:id)).to_not include(unrelated_status.id) - end - - it 'returns old statuses not reblogged as much' do - expect(subject.pluck(:id)).to include(very_old_status.id, faved_primary.id, faved_secondary.id, reblogged_primary.id) + it 'returns old not-reblogged statuses but does not return the recent, 5-times reblogged, or unrelated statuses' do + expect(subject.pluck(:id)) + .to not_include(recent_status.id) + .and not_include(reblogged_secondary.id) + .and not_include(unrelated_status.id) + .and include(very_old_status.id, faved_primary.id, faved_secondary.id, reblogged_primary.id) end end @@ -531,20 +492,12 @@ RSpec.describe AccountStatusesCleanupPolicy do account_statuses_cleanup_policy.min_favs = 5 end - it 'does not return the recent toot' do - expect(subject.pluck(:id)).to_not include(recent_status.id) - end - - it 'does not return the toot faved 5 times' do - expect(subject.pluck(:id)).to_not include(faved_secondary.id) - end - - it 'does not return the unrelated toot' do - expect(subject.pluck(:id)).to_not include(unrelated_status.id) - end - - it 'returns old statuses not faved as much' do - expect(subject.pluck(:id)).to include(very_old_status.id, faved_primary.id, reblogged_primary.id, reblogged_secondary.id) + it 'returns old not-faved statuses but does not return the recent, 5-times faved, or unrelated statuses' do + expect(subject.pluck(:id)) + .to not_include(recent_status.id) + .and not_include(faved_secondary.id) + .and not_include(unrelated_status.id) + .and include(very_old_status.id, faved_primary.id, reblogged_primary.id, reblogged_secondary.id) end end end From 274a48a9f4cd5bb36ad6933d736c04d04db75af0 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 25 Jan 2024 08:49:33 -0500 Subject: [PATCH 24/28] Extract helper methods for db connection and table existence check in `CLI::Maintenance` task (#28281) --- lib/mastodon/cli/maintenance.rb | 150 +++++++++++++++++--------------- 1 file changed, 81 insertions(+), 69 deletions(-) diff --git a/lib/mastodon/cli/maintenance.rb b/lib/mastodon/cli/maintenance.rb index 73012812fd..c644729b5e 100644 --- a/lib/mastodon/cli/maintenance.rb +++ b/lib/mastodon/cli/maintenance.rb @@ -72,6 +72,10 @@ module Mastodon::CLI local? ? username : "#{username}@#{domain}" end + def db_table_exists?(table) + ActiveRecord::Base.connection.table_exists?(table) + end + # This is a duplicate of the Account::Merging concern because we need it # to be independent from code version. def merge_with!(other_account) @@ -88,12 +92,12 @@ module Mastodon::CLI AccountModerationNote, AccountPin, AccountStat, ListAccount, PollVote, Mention ] - owned_classes << AccountDeletionRequest if ActiveRecord::Base.connection.table_exists?(:account_deletion_requests) - owned_classes << AccountNote if ActiveRecord::Base.connection.table_exists?(:account_notes) - owned_classes << FollowRecommendationSuppression if ActiveRecord::Base.connection.table_exists?(:follow_recommendation_suppressions) - owned_classes << AccountIdentityProof if ActiveRecord::Base.connection.table_exists?(:account_identity_proofs) - owned_classes << Appeal if ActiveRecord::Base.connection.table_exists?(:appeals) - owned_classes << BulkImport if ActiveRecord::Base.connection.table_exists?(:bulk_imports) + owned_classes << AccountDeletionRequest if db_table_exists?(:account_deletion_requests) + owned_classes << AccountNote if db_table_exists?(:account_notes) + owned_classes << FollowRecommendationSuppression if db_table_exists?(:follow_recommendation_suppressions) + owned_classes << AccountIdentityProof if db_table_exists?(:account_identity_proofs) + owned_classes << Appeal if db_table_exists?(:appeals) + owned_classes << BulkImport if db_table_exists?(:bulk_imports) owned_classes.each do |klass| klass.where(account_id: other_account.id).find_each do |record| @@ -104,7 +108,7 @@ module Mastodon::CLI end target_classes = [Follow, FollowRequest, Block, Mute, AccountModerationNote, AccountPin] - target_classes << AccountNote if ActiveRecord::Base.connection.table_exists?(:account_notes) + target_classes << AccountNote if db_table_exists?(:account_notes) target_classes.each do |klass| klass.where(target_account_id: other_account.id).find_each do |record| @@ -114,13 +118,13 @@ module Mastodon::CLI end end - if ActiveRecord::Base.connection.table_exists?(:canonical_email_blocks) + if db_table_exists?(:canonical_email_blocks) CanonicalEmailBlock.where(reference_account_id: other_account.id).find_each do |record| record.update_attribute(:reference_account_id, id) end end - if ActiveRecord::Base.connection.table_exists?(:appeals) + if db_table_exists?(:appeals) Appeal.where(account_warning_id: other_account.id).find_each do |record| record.update_attribute(:account_warning_id, id) end @@ -234,16 +238,16 @@ module Mastodon::CLI say 'Restoring index_accounts_on_username_and_domain_lower…' if migrator_version < 2020_06_20_164023 - ActiveRecord::Base.connection.add_index :accounts, 'lower (username), lower(domain)', name: 'index_accounts_on_username_and_domain_lower', unique: true + database_connection.add_index :accounts, 'lower (username), lower(domain)', name: 'index_accounts_on_username_and_domain_lower', unique: true else - ActiveRecord::Base.connection.add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true + database_connection.add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true end say 'Reindexing textual indexes on accounts…' - ActiveRecord::Base.connection.execute('REINDEX INDEX search_index;') - ActiveRecord::Base.connection.execute('REINDEX INDEX index_accounts_on_uri;') - ActiveRecord::Base.connection.execute('REINDEX INDEX index_accounts_on_url;') - ActiveRecord::Base.connection.execute('REINDEX INDEX index_accounts_on_domain_and_id;') if migrator_version >= 2023_05_24_190515 + database_connection.execute('REINDEX INDEX search_index;') + database_connection.execute('REINDEX INDEX index_accounts_on_uri;') + database_connection.execute('REINDEX INDEX index_accounts_on_url;') + database_connection.execute('REINDEX INDEX index_accounts_on_domain_and_id;') if migrator_version >= 2023_05_24_190515 end def deduplicate_users! @@ -260,21 +264,21 @@ module Mastodon::CLI deduplicate_users_process_password_token say 'Restoring users indexes…' - ActiveRecord::Base.connection.add_index :users, ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true - ActiveRecord::Base.connection.add_index :users, ['email'], name: 'index_users_on_email', unique: true - ActiveRecord::Base.connection.add_index :users, ['remember_token'], name: 'index_users_on_remember_token', unique: true if migrator_version < 2022_01_18_183010 + database_connection.add_index :users, ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true + database_connection.add_index :users, ['email'], name: 'index_users_on_email', unique: true + database_connection.add_index :users, ['remember_token'], name: 'index_users_on_remember_token', unique: true if migrator_version < 2022_01_18_183010 if migrator_version < 2022_03_10_060641 - ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true + database_connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true else - ActiveRecord::Base.connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, where: 'reset_password_token IS NOT NULL', opclass: :text_pattern_ops + database_connection.add_index :users, ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, where: 'reset_password_token IS NOT NULL', opclass: :text_pattern_ops end - ActiveRecord::Base.connection.execute('REINDEX INDEX index_users_on_unconfirmed_email;') if migrator_version >= 2023_07_02_151753 + database_connection.execute('REINDEX INDEX index_users_on_unconfirmed_email;') if migrator_version >= 2023_07_02_151753 end def deduplicate_users_process_email - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users GROUP BY email HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users GROUP BY email HAVING count(*) > 1").each do |row| users = User.where(id: row['ids'].split(',')).order(updated_at: :desc).includes(:account).to_a ref_user = users.shift say "Multiple users registered with e-mail address #{ref_user.email}.", :yellow @@ -288,7 +292,7 @@ module Mastodon::CLI end def deduplicate_users_process_confirmation_token - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE confirmation_token IS NOT NULL GROUP BY confirmation_token HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE confirmation_token IS NOT NULL GROUP BY confirmation_token HAVING count(*) > 1").each do |row| users = User.where(id: row['ids'].split(',')).order(created_at: :desc).includes(:account).to_a.drop(1) say "Unsetting confirmation token for those accounts: #{users.map { |user| user.account.acct }.join(', ')}", :yellow @@ -300,7 +304,7 @@ module Mastodon::CLI def deduplicate_users_process_remember_token if migrator_version < 2022_01_18_183010 - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE remember_token IS NOT NULL GROUP BY remember_token HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE remember_token IS NOT NULL GROUP BY remember_token HAVING count(*) > 1").each do |row| users = User.where(id: row['ids'].split(',')).order(updated_at: :desc).to_a.drop(1) say "Unsetting remember token for those accounts: #{users.map { |user| user.account.acct }.join(', ')}", :yellow @@ -312,7 +316,7 @@ module Mastodon::CLI end def deduplicate_users_process_password_token - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE reset_password_token IS NOT NULL GROUP BY reset_password_token HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM users WHERE reset_password_token IS NOT NULL GROUP BY reset_password_token HAVING count(*) > 1").each do |row| users = User.where(id: row['ids'].split(',')).order(updated_at: :desc).includes(:account).to_a.drop(1) say "Unsetting password reset token for those accounts: #{users.map { |user| user.account.acct }.join(', ')}", :yellow @@ -326,47 +330,47 @@ module Mastodon::CLI remove_index_if_exists!(:account_domain_blocks, 'index_account_domain_blocks_on_account_id_and_domain') say 'Removing duplicate account domain blocks…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM account_domain_blocks GROUP BY account_id, domain HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM account_domain_blocks GROUP BY account_id, domain HAVING count(*) > 1").each do |row| AccountDomainBlock.where(id: row['ids'].split(',').drop(1)).delete_all end say 'Restoring account domain blocks indexes…' - ActiveRecord::Base.connection.add_index :account_domain_blocks, %w(account_id domain), name: 'index_account_domain_blocks_on_account_id_and_domain', unique: true + database_connection.add_index :account_domain_blocks, %w(account_id domain), name: 'index_account_domain_blocks_on_account_id_and_domain', unique: true end def deduplicate_account_identity_proofs! - return unless ActiveRecord::Base.connection.table_exists?(:account_identity_proofs) + return unless db_table_exists?(:account_identity_proofs) remove_index_if_exists!(:account_identity_proofs, 'index_account_proofs_on_account_and_provider_and_username') say 'Removing duplicate account identity proofs…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM account_identity_proofs GROUP BY account_id, provider, provider_username HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM account_identity_proofs GROUP BY account_id, provider, provider_username HAVING count(*) > 1").each do |row| AccountIdentityProof.where(id: row['ids'].split(',')).order(id: :desc).to_a.drop(1).each(&:destroy) end say 'Restoring account identity proofs indexes…' - ActiveRecord::Base.connection.add_index :account_identity_proofs, %w(account_id provider provider_username), name: 'index_account_proofs_on_account_and_provider_and_username', unique: true + database_connection.add_index :account_identity_proofs, %w(account_id provider provider_username), name: 'index_account_proofs_on_account_and_provider_and_username', unique: true end def deduplicate_announcement_reactions! - return unless ActiveRecord::Base.connection.table_exists?(:announcement_reactions) + return unless db_table_exists?(:announcement_reactions) remove_index_if_exists!(:announcement_reactions, 'index_announcement_reactions_on_account_id_and_announcement_id') say 'Removing duplicate announcement reactions…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM announcement_reactions GROUP BY account_id, announcement_id, name HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM announcement_reactions GROUP BY account_id, announcement_id, name HAVING count(*) > 1").each do |row| AnnouncementReaction.where(id: row['ids'].split(',')).order(id: :desc).to_a.drop(1).each(&:destroy) end say 'Restoring announcement_reactions indexes…' - ActiveRecord::Base.connection.add_index :announcement_reactions, %w(account_id announcement_id name), name: 'index_announcement_reactions_on_account_id_and_announcement_id', unique: true + database_connection.add_index :announcement_reactions, %w(account_id announcement_id name), name: 'index_announcement_reactions_on_account_id_and_announcement_id', unique: true end def deduplicate_conversations! remove_index_if_exists!(:conversations, 'index_conversations_on_uri') say 'Deduplicating conversations…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM conversations WHERE uri IS NOT NULL GROUP BY uri HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM conversations WHERE uri IS NOT NULL GROUP BY uri HAVING count(*) > 1").each do |row| conversations = Conversation.where(id: row['ids'].split(',')).order(id: :desc).to_a ref_conversation = conversations.shift @@ -379,9 +383,9 @@ module Mastodon::CLI say 'Restoring conversations indexes…' if migrator_version < 2022_03_07_083603 - ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true + database_connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true else - ActiveRecord::Base.connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops + database_connection.add_index :conversations, ['uri'], name: 'index_conversations_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops end end @@ -389,7 +393,7 @@ module Mastodon::CLI remove_index_if_exists!(:custom_emojis, 'index_custom_emojis_on_shortcode_and_domain') say 'Deduplicating custom_emojis…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM custom_emojis GROUP BY shortcode, domain HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM custom_emojis GROUP BY shortcode, domain HAVING count(*) > 1").each do |row| emojis = CustomEmoji.where(id: row['ids'].split(',')).order(id: :desc).to_a ref_emoji = emojis.shift @@ -401,14 +405,14 @@ module Mastodon::CLI end say 'Restoring custom_emojis indexes…' - ActiveRecord::Base.connection.add_index :custom_emojis, %w(shortcode domain), name: 'index_custom_emojis_on_shortcode_and_domain', unique: true + database_connection.add_index :custom_emojis, %w(shortcode domain), name: 'index_custom_emojis_on_shortcode_and_domain', unique: true end def deduplicate_custom_emoji_categories! remove_index_if_exists!(:custom_emoji_categories, 'index_custom_emoji_categories_on_name') say 'Deduplicating custom_emoji_categories…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM custom_emoji_categories GROUP BY name HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM custom_emoji_categories GROUP BY name HAVING count(*) > 1").each do |row| categories = CustomEmojiCategory.where(id: row['ids'].split(',')).order(id: :desc).to_a ref_category = categories.shift @@ -420,26 +424,26 @@ module Mastodon::CLI end say 'Restoring custom_emoji_categories indexes…' - ActiveRecord::Base.connection.add_index :custom_emoji_categories, ['name'], name: 'index_custom_emoji_categories_on_name', unique: true + database_connection.add_index :custom_emoji_categories, ['name'], name: 'index_custom_emoji_categories_on_name', unique: true end def deduplicate_domain_allows! remove_index_if_exists!(:domain_allows, 'index_domain_allows_on_domain') say 'Deduplicating domain_allows…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM domain_allows GROUP BY domain HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM domain_allows GROUP BY domain HAVING count(*) > 1").each do |row| DomainAllow.where(id: row['ids'].split(',')).order(id: :desc).to_a.drop(1).each(&:destroy) end say 'Restoring domain_allows indexes…' - ActiveRecord::Base.connection.add_index :domain_allows, ['domain'], name: 'index_domain_allows_on_domain', unique: true + database_connection.add_index :domain_allows, ['domain'], name: 'index_domain_allows_on_domain', unique: true end def deduplicate_domain_blocks! remove_index_if_exists!(:domain_blocks, 'index_domain_blocks_on_domain') say 'Deduplicating domain_blocks…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM domain_blocks GROUP BY domain HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM domain_blocks GROUP BY domain HAVING count(*) > 1").each do |row| domain_blocks = DomainBlock.where(id: row['ids'].split(',')).by_severity.reverse.to_a reject_media = domain_blocks.any?(&:reject_media?) @@ -456,49 +460,49 @@ module Mastodon::CLI end say 'Restoring domain_blocks indexes…' - ActiveRecord::Base.connection.add_index :domain_blocks, ['domain'], name: 'index_domain_blocks_on_domain', unique: true + database_connection.add_index :domain_blocks, ['domain'], name: 'index_domain_blocks_on_domain', unique: true end def deduplicate_unavailable_domains! - return unless ActiveRecord::Base.connection.table_exists?(:unavailable_domains) + return unless db_table_exists?(:unavailable_domains) remove_index_if_exists!(:unavailable_domains, 'index_unavailable_domains_on_domain') say 'Deduplicating unavailable_domains…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM unavailable_domains GROUP BY domain HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM unavailable_domains GROUP BY domain HAVING count(*) > 1").each do |row| UnavailableDomain.where(id: row['ids'].split(',')).order(id: :desc).to_a.drop(1).each(&:destroy) end say 'Restoring unavailable_domains indexes…' - ActiveRecord::Base.connection.add_index :unavailable_domains, ['domain'], name: 'index_unavailable_domains_on_domain', unique: true + database_connection.add_index :unavailable_domains, ['domain'], name: 'index_unavailable_domains_on_domain', unique: true end def deduplicate_email_domain_blocks! remove_index_if_exists!(:email_domain_blocks, 'index_email_domain_blocks_on_domain') say 'Deduplicating email_domain_blocks…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM email_domain_blocks GROUP BY domain HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM email_domain_blocks GROUP BY domain HAVING count(*) > 1").each do |row| domain_blocks = EmailDomainBlock.where(id: row['ids'].split(',')).order(EmailDomainBlock.arel_table[:parent_id].asc.nulls_first).to_a domain_blocks.drop(1).each(&:destroy) end say 'Restoring email_domain_blocks indexes…' - ActiveRecord::Base.connection.add_index :email_domain_blocks, ['domain'], name: 'index_email_domain_blocks_on_domain', unique: true + database_connection.add_index :email_domain_blocks, ['domain'], name: 'index_email_domain_blocks_on_domain', unique: true end def deduplicate_media_attachments! remove_index_if_exists!(:media_attachments, 'index_media_attachments_on_shortcode') say 'Deduplicating media_attachments…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM media_attachments WHERE shortcode IS NOT NULL GROUP BY shortcode HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM media_attachments WHERE shortcode IS NOT NULL GROUP BY shortcode HAVING count(*) > 1").each do |row| MediaAttachment.where(id: row['ids'].split(',').drop(1)).update_all(shortcode: nil) end say 'Restoring media_attachments indexes…' if migrator_version < 2022_03_10_060626 - ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true + database_connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true else - ActiveRecord::Base.connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true, where: 'shortcode IS NOT NULL', opclass: :text_pattern_ops + database_connection.add_index :media_attachments, ['shortcode'], name: 'index_media_attachments_on_shortcode', unique: true, where: 'shortcode IS NOT NULL', opclass: :text_pattern_ops end end @@ -506,19 +510,19 @@ module Mastodon::CLI remove_index_if_exists!(:preview_cards, 'index_preview_cards_on_url') say 'Deduplicating preview_cards…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM preview_cards GROUP BY url HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM preview_cards GROUP BY url HAVING count(*) > 1").each do |row| PreviewCard.where(id: row['ids'].split(',')).order(id: :desc).to_a.drop(1).each(&:destroy) end say 'Restoring preview_cards indexes…' - ActiveRecord::Base.connection.add_index :preview_cards, ['url'], name: 'index_preview_cards_on_url', unique: true + database_connection.add_index :preview_cards, ['url'], name: 'index_preview_cards_on_url', unique: true end def deduplicate_statuses! remove_index_if_exists!(:statuses, 'index_statuses_on_uri') say 'Deduplicating statuses…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM statuses WHERE uri IS NOT NULL GROUP BY uri HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM statuses WHERE uri IS NOT NULL GROUP BY uri HAVING count(*) > 1").each do |row| statuses = Status.where(id: row['ids'].split(',')).order(id: :asc).to_a ref_status = statuses.shift statuses.each do |status| @@ -529,9 +533,9 @@ module Mastodon::CLI say 'Restoring statuses indexes…' if migrator_version < 2022_03_10_060706 - ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true + database_connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true else - ActiveRecord::Base.connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops + database_connection.add_index :statuses, ['uri'], name: 'index_statuses_on_uri', unique: true, where: 'uri IS NOT NULL', opclass: :text_pattern_ops end end @@ -540,7 +544,7 @@ module Mastodon::CLI remove_index_if_exists!(:tags, 'index_tags_on_name_lower_btree') say 'Deduplicating tags…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM tags GROUP BY lower((name)::text) HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM tags GROUP BY lower((name)::text) HAVING count(*) > 1").each do |row| tags = Tag.where(id: row['ids'].split(',')).order(Arel.sql('(usable::int + trendable::int + listable::int) desc')).to_a ref_tag = tags.shift tags.each do |tag| @@ -551,38 +555,38 @@ module Mastodon::CLI say 'Restoring tags indexes…' if migrator_version < 2021_04_21_121431 - ActiveRecord::Base.connection.add_index :tags, 'lower((name)::text)', name: 'index_tags_on_name_lower', unique: true + database_connection.add_index :tags, 'lower((name)::text)', name: 'index_tags_on_name_lower', unique: true else - ActiveRecord::Base.connection.execute 'CREATE UNIQUE INDEX index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)' + database_connection.execute 'CREATE UNIQUE INDEX index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)' end end def deduplicate_webauthn_credentials! - return unless ActiveRecord::Base.connection.table_exists?(:webauthn_credentials) + return unless db_table_exists?(:webauthn_credentials) remove_index_if_exists!(:webauthn_credentials, 'index_webauthn_credentials_on_external_id') say 'Deduplicating webauthn_credentials…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM webauthn_credentials GROUP BY external_id HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM webauthn_credentials GROUP BY external_id HAVING count(*) > 1").each do |row| WebauthnCredential.where(id: row['ids'].split(',')).order(id: :desc).to_a.drop(1).each(&:destroy) end say 'Restoring webauthn_credentials indexes…' - ActiveRecord::Base.connection.add_index :webauthn_credentials, ['external_id'], name: 'index_webauthn_credentials_on_external_id', unique: true + database_connection.add_index :webauthn_credentials, ['external_id'], name: 'index_webauthn_credentials_on_external_id', unique: true end def deduplicate_webhooks! - return unless ActiveRecord::Base.connection.table_exists?(:webhooks) + return unless db_table_exists?(:webhooks) remove_index_if_exists!(:webhooks, 'index_webhooks_on_url') say 'Deduplicating webhooks…' - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM webhooks GROUP BY url HAVING count(*) > 1").each do |row| + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM webhooks GROUP BY url HAVING count(*) > 1").each do |row| Webhook.where(id: row['ids'].split(',')).order(id: :desc).drop(1).each(&:destroy) end say 'Restoring webhooks indexes…' - ActiveRecord::Base.connection.add_index :webhooks, ['url'], name: 'index_webhooks_on_url', unique: true + database_connection.add_index :webhooks, ['url'], name: 'index_webhooks_on_url', unique: true end def deduplicate_software_updates! @@ -672,7 +676,7 @@ module Mastodon::CLI def merge_statuses!(main_status, duplicate_status) owned_classes = [Favourite, Mention, Poll] - owned_classes << Bookmark if ActiveRecord::Base.connection.table_exists?(:bookmarks) + owned_classes << Bookmark if db_table_exists?(:bookmarks) owned_classes.each do |klass| klass.where(status_id: duplicate_status.id).find_each do |record| record.update_attribute(:status_id, main_status.id) @@ -715,13 +719,21 @@ module Mastodon::CLI end def find_duplicate_accounts - ActiveRecord::Base.connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM accounts GROUP BY lower(username), COALESCE(lower(domain), '') HAVING count(*) > 1") + database_connection.select_all("SELECT string_agg(id::text, ',') AS ids FROM accounts GROUP BY lower(username), COALESCE(lower(domain), '') HAVING count(*) > 1") end def remove_index_if_exists!(table, name) - ActiveRecord::Base.connection.remove_index(table, name: name) if ActiveRecord::Base.connection.index_name_exists?(table, name) + database_connection.remove_index(table, name: name) if database_connection.index_name_exists?(table, name) rescue ArgumentError, ActiveRecord::StatementInvalid nil end + + def database_connection + ActiveRecord::Base.connection + end + + def db_table_exists?(table) + database_connection.table_exists?(table) + end end end From 3205a654caf903002c2db872f802a3332201678b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 25 Jan 2024 15:34:26 +0100 Subject: [PATCH 25/28] Refactor conversations components in web UI (#28833) Co-authored-by: Claire --- .../components/conversation.jsx | 288 ++++++++++-------- .../components/conversations_list.jsx | 117 ++++--- .../containers/conversation_container.js | 80 ----- .../conversations_list_container.js | 16 - .../features/direct_timeline/index.jsx | 134 ++++---- 5 files changed, 274 insertions(+), 361 deletions(-) delete mode 100644 app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js delete mode 100644 app/javascript/mastodon/features/direct_timeline/containers/conversations_list_container.js diff --git a/app/javascript/mastodon/features/direct_timeline/components/conversation.jsx b/app/javascript/mastodon/features/direct_timeline/components/conversation.jsx index 274cfa69f5..3af89f9974 100644 --- a/app/javascript/mastodon/features/direct_timeline/components/conversation.jsx +++ b/app/javascript/mastodon/features/direct_timeline/components/conversation.jsx @@ -1,17 +1,24 @@ import PropTypes from 'prop-types'; +import { useCallback } from 'react'; -import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; +import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; -import { Link, withRouter } from 'react-router-dom'; +import { Link, useHistory } from 'react-router-dom'; +import { createSelector } from '@reduxjs/toolkit'; import ImmutablePropTypes from 'react-immutable-proptypes'; -import ImmutablePureComponent from 'react-immutable-pure-component'; +import { useDispatch, useSelector } from 'react-redux'; + import { HotKeys } from 'react-hotkeys'; import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react'; import ReplyIcon from '@/material-icons/400-24px/reply.svg?react'; +import { replyCompose } from 'mastodon/actions/compose'; +import { markConversationRead, deleteConversation } from 'mastodon/actions/conversations'; +import { openModal } from 'mastodon/actions/modal'; +import { muteStatus, unmuteStatus, revealStatus, hideStatus } from 'mastodon/actions/statuses'; import AttachmentList from 'mastodon/components/attachment_list'; import AvatarComposite from 'mastodon/components/avatar_composite'; import { IconButton } from 'mastodon/components/icon_button'; @@ -19,7 +26,7 @@ import { RelativeTimestamp } from 'mastodon/components/relative_timestamp'; import StatusContent from 'mastodon/components/status_content'; import DropdownMenuContainer from 'mastodon/containers/dropdown_menu_container'; import { autoPlayGif } from 'mastodon/initial_state'; -import { WithRouterPropTypes } from 'mastodon/utils/react_router'; +import { makeGetStatus } from 'mastodon/selectors'; const messages = defineMessages({ more: { id: 'status.more', defaultMessage: 'More' }, @@ -29,25 +36,31 @@ const messages = defineMessages({ delete: { id: 'conversation.delete', defaultMessage: 'Delete conversation' }, muteConversation: { id: 'status.mute_conversation', defaultMessage: 'Mute conversation' }, unmuteConversation: { id: 'status.unmute_conversation', defaultMessage: 'Unmute conversation' }, + replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, + replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, }); -class Conversation extends ImmutablePureComponent { +const getAccounts = createSelector( + (state) => state.get('accounts'), + (_, accountIds) => accountIds, + (accounts, accountIds) => + accountIds.map(id => accounts.get(id)) +); - static propTypes = { - conversationId: PropTypes.string.isRequired, - accounts: ImmutablePropTypes.list.isRequired, - lastStatus: ImmutablePropTypes.map, - unread:PropTypes.bool.isRequired, - scrollKey: PropTypes.string, - onMoveUp: PropTypes.func, - onMoveDown: PropTypes.func, - markRead: PropTypes.func.isRequired, - delete: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired, - ...WithRouterPropTypes, - }; +const getStatus = makeGetStatus(); - handleMouseEnter = ({ currentTarget }) => { +export const Conversation = ({ conversation, scrollKey, onMoveUp, onMoveDown }) => { + const id = conversation.get('id'); + const unread = conversation.get('unread'); + const lastStatusId = conversation.get('last_status'); + const accountIds = conversation.get('accounts'); + const intl = useIntl(); + const dispatch = useDispatch(); + const history = useHistory(); + const lastStatus = useSelector(state => getStatus(state, { id: lastStatusId })); + const accounts = useSelector(state => getAccounts(state, accountIds)); + + const handleMouseEnter = useCallback(({ currentTarget }) => { if (autoPlayGif) { return; } @@ -58,9 +71,9 @@ class Conversation extends ImmutablePureComponent { let emoji = emojis[i]; emoji.src = emoji.getAttribute('data-original'); } - }; + }, []); - handleMouseLeave = ({ currentTarget }) => { + const handleMouseLeave = useCallback(({ currentTarget }) => { if (autoPlayGif) { return; } @@ -71,136 +84,161 @@ class Conversation extends ImmutablePureComponent { let emoji = emojis[i]; emoji.src = emoji.getAttribute('data-static'); } - }; - - handleClick = () => { - if (!this.props.history) { - return; - } - - const { lastStatus, unread, markRead } = this.props; + }, []); + const handleClick = useCallback(() => { if (unread) { - markRead(); + dispatch(markConversationRead(id)); } - this.props.history.push(`/@${lastStatus.getIn(['account', 'acct'])}/${lastStatus.get('id')}`); - }; + history.push(`/@${lastStatus.getIn(['account', 'acct'])}/${lastStatus.get('id')}`); + }, [dispatch, history, unread, id, lastStatus]); - handleMarkAsRead = () => { - this.props.markRead(); - }; + const handleMarkAsRead = useCallback(() => { + dispatch(markConversationRead(id)); + }, [dispatch, id]); - handleReply = () => { - this.props.reply(this.props.lastStatus, this.props.history); - }; + const handleReply = useCallback(() => { + dispatch((_, getState) => { + let state = getState(); - handleDelete = () => { - this.props.delete(); - }; + if (state.getIn(['compose', 'text']).trim().length !== 0) { + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + message: intl.formatMessage(messages.replyMessage), + confirm: intl.formatMessage(messages.replyConfirm), + onConfirm: () => dispatch(replyCompose(lastStatus, history)), + }, + })); + } else { + dispatch(replyCompose(lastStatus, history)); + } + }); + }, [dispatch, lastStatus, history, intl]); - handleHotkeyMoveUp = () => { - this.props.onMoveUp(this.props.conversationId); - }; + const handleDelete = useCallback(() => { + dispatch(deleteConversation(id)); + }, [dispatch, id]); - handleHotkeyMoveDown = () => { - this.props.onMoveDown(this.props.conversationId); - }; + const handleHotkeyMoveUp = useCallback(() => { + onMoveUp(id); + }, [id, onMoveUp]); - handleConversationMute = () => { - this.props.onMute(this.props.lastStatus); - }; + const handleHotkeyMoveDown = useCallback(() => { + onMoveDown(id); + }, [id, onMoveDown]); - handleShowMore = () => { - this.props.onToggleHidden(this.props.lastStatus); - }; - - render () { - const { accounts, lastStatus, unread, scrollKey, intl } = this.props; - - if (lastStatus === null) { - return null; + const handleConversationMute = useCallback(() => { + if (lastStatus.get('muted')) { + dispatch(unmuteStatus(lastStatus.get('id'))); + } else { + dispatch(muteStatus(lastStatus.get('id'))); } + }, [dispatch, lastStatus]); - const menu = [ - { text: intl.formatMessage(messages.open), action: this.handleClick }, - null, - ]; - - menu.push({ text: intl.formatMessage(lastStatus.get('muted') ? messages.unmuteConversation : messages.muteConversation), action: this.handleConversationMute }); - - if (unread) { - menu.push({ text: intl.formatMessage(messages.markAsRead), action: this.handleMarkAsRead }); - menu.push(null); + const handleShowMore = useCallback(() => { + if (lastStatus.get('hidden')) { + dispatch(revealStatus(lastStatus.get('id'))); + } else { + dispatch(hideStatus(lastStatus.get('id'))); } + }, [dispatch, lastStatus]); - menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDelete }); + if (!lastStatus) { + return null; + } - const names = accounts.map(a => ).reduce((prev, cur) => [prev, ', ', cur]); + const menu = [ + { text: intl.formatMessage(messages.open), action: handleClick }, + null, + { text: intl.formatMessage(lastStatus.get('muted') ? messages.unmuteConversation : messages.muteConversation), action: handleConversationMute }, + ]; - const handlers = { - reply: this.handleReply, - open: this.handleClick, - moveUp: this.handleHotkeyMoveUp, - moveDown: this.handleHotkeyMoveDown, - toggleHidden: this.handleShowMore, - }; + if (unread) { + menu.push({ text: intl.formatMessage(messages.markAsRead), action: handleMarkAsRead }); + menu.push(null); + } - return ( - -
-
- -
+ menu.push({ text: intl.formatMessage(messages.delete), action: handleDelete }); -
-
-
- {unread && } -
+ const names = accounts.map(a => ( + + + + + + )).reduce((prev, cur) => [prev, ', ', cur]); -
- {names} }} /> -
+ const handlers = { + reply: handleReply, + open: handleClick, + moveUp: handleHotkeyMoveUp, + moveDown: handleHotkeyMoveDown, + toggleHidden: handleShowMore, + }; + + return ( + +
+
+ +
+ +
+
+
+ {unread && }
- + {names} }} /> +
+
+ + + + {lastStatus.get('media_attachments').size > 0 && ( + + )} - {lastStatus.get('media_attachments').size > 0 && ( - + + +
+ - )} - -
- - -
- -
-
- ); - } +
+ + ); +}; -} - -export default withRouter(injectIntl(Conversation)); +Conversation.propTypes = { + conversation: ImmutablePropTypes.map.isRequired, + scrollKey: PropTypes.string, + onMoveUp: PropTypes.func, + onMoveDown: PropTypes.func, +}; diff --git a/app/javascript/mastodon/features/direct_timeline/components/conversations_list.jsx b/app/javascript/mastodon/features/direct_timeline/components/conversations_list.jsx index 8c12ea9e5f..c9fc098a52 100644 --- a/app/javascript/mastodon/features/direct_timeline/components/conversations_list.jsx +++ b/app/javascript/mastodon/features/direct_timeline/components/conversations_list.jsx @@ -1,77 +1,72 @@ import PropTypes from 'prop-types'; +import { useRef, useMemo, useCallback } from 'react'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import ImmutablePureComponent from 'react-immutable-pure-component'; +import { useSelector, useDispatch } from 'react-redux'; import { debounce } from 'lodash'; -import ScrollableList from '../../../components/scrollable_list'; -import ConversationContainer from '../containers/conversation_container'; +import { expandConversations } from 'mastodon/actions/conversations'; +import ScrollableList from 'mastodon/components/scrollable_list'; -export default class ConversationsList extends ImmutablePureComponent { +import { Conversation } from './conversation'; - static propTypes = { - conversations: ImmutablePropTypes.list.isRequired, - scrollKey: PropTypes.string.isRequired, - hasMore: PropTypes.bool, - isLoading: PropTypes.bool, - onLoadMore: PropTypes.func, - }; +const focusChild = (node, index, alignTop) => { + const element = node.querySelector(`article:nth-of-type(${index + 1}) .focusable`); - getCurrentIndex = id => this.props.conversations.findIndex(x => x.get('id') === id); - - handleMoveUp = id => { - const elementIndex = this.getCurrentIndex(id) - 1; - this._selectChild(elementIndex, true); - }; - - handleMoveDown = id => { - const elementIndex = this.getCurrentIndex(id) + 1; - this._selectChild(elementIndex, false); - }; - - _selectChild (index, align_top) { - const container = this.node.node; - const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`); - - if (element) { - if (align_top && container.scrollTop > element.offsetTop) { - element.scrollIntoView(true); - } else if (!align_top && container.scrollTop + container.clientHeight < element.offsetTop + element.offsetHeight) { - element.scrollIntoView(false); - } - element.focus(); + if (element) { + if (alignTop && node.scrollTop > element.offsetTop) { + element.scrollIntoView(true); + } else if (!alignTop && node.scrollTop + node.clientHeight < element.offsetTop + element.offsetHeight) { + element.scrollIntoView(false); } + + element.focus(); } +}; - setRef = c => { - this.node = c; - }; +export const ConversationsList = ({ scrollKey, ...other }) => { + const listRef = useRef(); + const conversations = useSelector(state => state.getIn(['conversations', 'items'])); + const isLoading = useSelector(state => state.getIn(['conversations', 'isLoading'], true)); + const hasMore = useSelector(state => state.getIn(['conversations', 'hasMore'], false)); + const dispatch = useDispatch(); + const lastStatusId = conversations.last()?.get('last_status'); - handleLoadOlder = debounce(() => { - const last = this.props.conversations.last(); + const handleMoveUp = useCallback(id => { + const elementIndex = conversations.findIndex(x => x.get('id') === id) - 1; + focusChild(listRef.current.node, elementIndex, true); + }, [listRef, conversations]); - if (last && last.get('last_status')) { - this.props.onLoadMore(last.get('last_status')); + const handleMoveDown = useCallback(id => { + const elementIndex = conversations.findIndex(x => x.get('id') === id) + 1; + focusChild(listRef.current.node, elementIndex, false); + }, [listRef, conversations]); + + const debouncedLoadMore = useMemo(() => debounce(id => { + dispatch(expandConversations({ maxId: id })); + }, 300, { leading: true }), [dispatch]); + + const handleLoadMore = useCallback(() => { + if (lastStatusId) { + debouncedLoadMore(lastStatusId); } - }, 300, { leading: true }); + }, [debouncedLoadMore, lastStatusId]); - render () { - const { conversations, isLoading, onLoadMore, ...other } = this.props; + return ( + + {conversations.map(item => ( + + ))} + + ); +}; - return ( - - {conversations.map(item => ( - - ))} - - ); - } - -} +ConversationsList.propTypes = { + scrollKey: PropTypes.string.isRequired, +}; diff --git a/app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js b/app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js deleted file mode 100644 index 456fc7d7cc..0000000000 --- a/app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js +++ /dev/null @@ -1,80 +0,0 @@ -import { defineMessages, injectIntl } from 'react-intl'; - -import { connect } from 'react-redux'; - -import { replyCompose } from 'mastodon/actions/compose'; -import { markConversationRead, deleteConversation } from 'mastodon/actions/conversations'; -import { openModal } from 'mastodon/actions/modal'; -import { muteStatus, unmuteStatus, hideStatus, revealStatus } from 'mastodon/actions/statuses'; -import { makeGetStatus } from 'mastodon/selectors'; - -import Conversation from '../components/conversation'; - -const messages = defineMessages({ - replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' }, - replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' }, -}); - -const mapStateToProps = () => { - const getStatus = makeGetStatus(); - - return (state, { conversationId }) => { - const conversation = state.getIn(['conversations', 'items']).find(x => x.get('id') === conversationId); - const lastStatusId = conversation.get('last_status', null); - - return { - accounts: conversation.get('accounts').map(accountId => state.getIn(['accounts', accountId], null)), - unread: conversation.get('unread'), - lastStatus: lastStatusId && getStatus(state, { id: lastStatusId }), - }; - }; -}; - -const mapDispatchToProps = (dispatch, { intl, conversationId }) => ({ - - markRead () { - dispatch(markConversationRead(conversationId)); - }, - - reply (status, router) { - dispatch((_, getState) => { - let state = getState(); - - if (state.getIn(['compose', 'text']).trim().length !== 0) { - dispatch(openModal({ - modalType: 'CONFIRM', - modalProps: { - message: intl.formatMessage(messages.replyMessage), - confirm: intl.formatMessage(messages.replyConfirm), - onConfirm: () => dispatch(replyCompose(status, router)), - }, - })); - } else { - dispatch(replyCompose(status, router)); - } - }); - }, - - delete () { - dispatch(deleteConversation(conversationId)); - }, - - onMute (status) { - if (status.get('muted')) { - dispatch(unmuteStatus(status.get('id'))); - } else { - dispatch(muteStatus(status.get('id'))); - } - }, - - onToggleHidden (status) { - if (status.get('hidden')) { - dispatch(revealStatus(status.get('id'))); - } else { - dispatch(hideStatus(status.get('id'))); - } - }, - -}); - -export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(Conversation)); diff --git a/app/javascript/mastodon/features/direct_timeline/containers/conversations_list_container.js b/app/javascript/mastodon/features/direct_timeline/containers/conversations_list_container.js deleted file mode 100644 index 1dcd3ec1bd..0000000000 --- a/app/javascript/mastodon/features/direct_timeline/containers/conversations_list_container.js +++ /dev/null @@ -1,16 +0,0 @@ -import { connect } from 'react-redux'; - -import { expandConversations } from '../../../actions/conversations'; -import ConversationsList from '../components/conversations_list'; - -const mapStateToProps = state => ({ - conversations: state.getIn(['conversations', 'items']), - isLoading: state.getIn(['conversations', 'isLoading'], true), - hasMore: state.getIn(['conversations', 'hasMore'], false), -}); - -const mapDispatchToProps = dispatch => ({ - onLoadMore: maxId => dispatch(expandConversations({ maxId })), -}); - -export default connect(mapStateToProps, mapDispatchToProps)(ConversationsList); diff --git a/app/javascript/mastodon/features/direct_timeline/index.jsx b/app/javascript/mastodon/features/direct_timeline/index.jsx index af29d7a5b8..7aee83ec10 100644 --- a/app/javascript/mastodon/features/direct_timeline/index.jsx +++ b/app/javascript/mastodon/features/direct_timeline/index.jsx @@ -1,11 +1,11 @@ import PropTypes from 'prop-types'; -import { PureComponent } from 'react'; +import { useRef, useCallback, useEffect } from 'react'; -import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; +import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { Helmet } from 'react-helmet'; -import { connect } from 'react-redux'; +import { useDispatch } from 'react-redux'; import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react'; import { addColumn, removeColumn, moveColumn } from 'mastodon/actions/columns'; @@ -14,103 +14,79 @@ import { connectDirectStream } from 'mastodon/actions/streaming'; import Column from 'mastodon/components/column'; import ColumnHeader from 'mastodon/components/column_header'; -import ConversationsListContainer from './containers/conversations_list_container'; +import { ConversationsList } from './components/conversations_list'; const messages = defineMessages({ title: { id: 'column.direct', defaultMessage: 'Private mentions' }, }); -class DirectTimeline extends PureComponent { - - static propTypes = { - dispatch: PropTypes.func.isRequired, - columnId: PropTypes.string, - intl: PropTypes.object.isRequired, - hasUnread: PropTypes.bool, - multiColumn: PropTypes.bool, - }; - - handlePin = () => { - const { columnId, dispatch } = this.props; +const DirectTimeline = ({ columnId, multiColumn }) => { + const columnRef = useRef(); + const intl = useIntl(); + const dispatch = useDispatch(); + const pinned = !!columnId; + const handlePin = useCallback(() => { if (columnId) { dispatch(removeColumn(columnId)); } else { dispatch(addColumn('DIRECT', {})); } - }; + }, [dispatch, columnId]); - handleMove = (dir) => { - const { columnId, dispatch } = this.props; + const handleMove = useCallback((dir) => { dispatch(moveColumn(columnId, dir)); - }; + }, [dispatch, columnId]); - handleHeaderClick = () => { - this.column.scrollTop(); - }; - - componentDidMount () { - const { dispatch } = this.props; + const handleHeaderClick = useCallback(() => { + columnRef.current.scrollTop(); + }, [columnRef]); + useEffect(() => { dispatch(mountConversations()); dispatch(expandConversations()); - this.disconnect = dispatch(connectDirectStream()); - } - componentWillUnmount () { - this.props.dispatch(unmountConversations()); + const disconnect = dispatch(connectDirectStream()); - if (this.disconnect) { - this.disconnect(); - this.disconnect = null; - } - } + return () => { + dispatch(unmountConversations()); + disconnect(); + }; + }, [dispatch]); - setRef = c => { - this.column = c; - }; + return ( + + - handleLoadMore = maxId => { - this.props.dispatch(expandConversations({ maxId })); - }; + } + bindToDocument={!multiColumn} + prepend={
} + alwaysPrepend + /> - render () { - const { intl, hasUnread, columnId, multiColumn } = this.props; - const pinned = !!columnId; + + {intl.formatMessage(messages.title)} + + +
+ ); +}; - return ( - - +DirectTimeline.propTypes = { + columnId: PropTypes.string, + multiColumn: PropTypes.bool, +}; -
} - alwaysPrepend - emptyMessage={} - /> - - - {intl.formatMessage(messages.title)} - - - - ); - } - -} - -export default connect()(injectIntl(DirectTimeline)); +export default DirectTimeline; From e5f50478b517444d46776c5f5f81042c80fdf9b7 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 24 Jan 2024 11:49:19 +0100 Subject: [PATCH 26/28] [Glitch] Add confirmation when redirecting logged-out requests to permalink Port SCSS changes from b19ae521b7d28a76e8e1d8da8157e051e9d8de6c to glitch-soc Co-authored-by: Claire Signed-off-by: Claire --- .../flavours/glitch/styles/containers.scss | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/app/javascript/flavours/glitch/styles/containers.scss b/app/javascript/flavours/glitch/styles/containers.scss index 4d3d4c546c..6d72e43924 100644 --- a/app/javascript/flavours/glitch/styles/containers.scss +++ b/app/javascript/flavours/glitch/styles/containers.scss @@ -107,3 +107,59 @@ margin-inline-start: 10px; } } + +.redirect { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + font-size: 14px; + line-height: 18px; + + &__logo { + display: flex; + align-items: center; + justify-content: center; + margin-bottom: 30px; + + img { + height: 48px; + } + } + + &__message { + text-align: center; + + h1 { + font-size: 17px; + line-height: 22px; + font-weight: 700; + margin-bottom: 30px; + } + + p { + margin-bottom: 30px; + + &:last-child { + margin-bottom: 0; + } + } + + a { + color: $highlight-text-color; + font-weight: 500; + text-decoration: none; + + &:hover, + &:focus, + &:active { + text-decoration: underline; + } + } + } + + &__link { + margin-top: 15px; + } +} From 54ece5040d50c155c4ebe4f732caf3b29546ad7f Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 24 Jan 2024 13:37:43 +0100 Subject: [PATCH 27/28] [Glitch] Use active variants for boost icons and increase icon size Port 5a838ceaa9a003bc2e2fdee727d4aa87cd53de4f to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/status_action_bar.jsx | 4 +++- .../flavours/glitch/features/status/components/action_bar.jsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status_action_bar.jsx b/app/javascript/flavours/glitch/components/status_action_bar.jsx index 5727f36c86..c10122d234 100644 --- a/app/javascript/flavours/glitch/components/status_action_bar.jsx +++ b/app/javascript/flavours/glitch/components/status_action_bar.jsx @@ -17,8 +17,10 @@ import ReplyAllIcon from '@/material-icons/400-24px/reply_all.svg?react'; import StarIcon from '@/material-icons/400-24px/star-fill.svg?react'; import StarBorderIcon from '@/material-icons/400-24px/star.svg?react'; import VisibilityIcon from '@/material-icons/400-24px/visibility.svg?react'; +import RepeatActiveIcon from '@/svg-icons/repeat_active.svg?react'; import RepeatDisabledIcon from '@/svg-icons/repeat_disabled.svg'; import RepeatPrivateIcon from '@/svg-icons/repeat_private.svg'; +import RepeatPrivateActiveIcon from '@/svg-icons/repeat_private_active.svg?react'; import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'flavours/glitch/permissions'; import { accountAdminLink, statusAdminLink } from 'flavours/glitch/utils/backend_links'; import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router'; @@ -303,7 +305,7 @@ class StatusActionBar extends ImmutablePureComponent { if (status.get('reblogged')) { reblogTitle = intl.formatMessage(messages.cancel_reblog_private); - reblogIconComponent = publicStatus ? RepeatIcon : RepeatPrivateIcon; + reblogIconComponent = publicStatus ? RepeatActiveIcon : RepeatPrivateActiveIcon; } else if (publicStatus) { reblogTitle = intl.formatMessage(messages.reblog); reblogIconComponent = RepeatIcon; diff --git a/app/javascript/flavours/glitch/features/status/components/action_bar.jsx b/app/javascript/flavours/glitch/features/status/components/action_bar.jsx index 9edd47f5b0..1d8707ccbf 100644 --- a/app/javascript/flavours/glitch/features/status/components/action_bar.jsx +++ b/app/javascript/flavours/glitch/features/status/components/action_bar.jsx @@ -16,8 +16,10 @@ import ReplyIcon from '@/material-icons/400-24px/reply.svg?react'; import ReplyAllIcon from '@/material-icons/400-24px/reply_all.svg?react'; import StarIcon from '@/material-icons/400-24px/star-fill.svg?react'; import StarBorderIcon from '@/material-icons/400-24px/star.svg?react'; +import RepeatActiveIcon from '@/svg-icons/repeat_active.svg?react'; import RepeatDisabledIcon from '@/svg-icons/repeat_disabled.svg'; import RepeatPrivateIcon from '@/svg-icons/repeat_private.svg'; +import RepeatPrivateActiveIcon from '@/svg-icons/repeat_private_active.svg?react'; import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'flavours/glitch/permissions'; import { accountAdminLink, statusAdminLink } from 'flavours/glitch/utils/backend_links'; import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router'; @@ -235,7 +237,7 @@ class ActionBar extends PureComponent { if (status.get('reblogged')) { reblogTitle = intl.formatMessage(messages.cancel_reblog_private); - reblogIconComponent = publicStatus ? RepeatIcon : RepeatPrivateIcon; + reblogIconComponent = publicStatus ? RepeatActiveIcon : RepeatPrivateActiveIcon; } else if (publicStatus) { reblogTitle = intl.formatMessage(messages.reblog); reblogIconComponent = RepeatIcon; From dd7a66949aca9e2d8b793664f2f19d3681e9178f Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 26 Jan 2024 21:04:02 +0100 Subject: [PATCH 28/28] Fix CSS loading in redirect controller --- app/controllers/redirect/base_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/redirect/base_controller.rb b/app/controllers/redirect/base_controller.rb index 90894ec1ed..ce55cfc53a 100644 --- a/app/controllers/redirect/base_controller.rb +++ b/app/controllers/redirect/base_controller.rb @@ -3,6 +3,7 @@ class Redirect::BaseController < ApplicationController vary_by 'Accept-Language' + before_action :set_pack before_action :set_resource before_action :set_app_body_class @@ -21,4 +22,8 @@ class Redirect::BaseController < ApplicationController def set_resource raise NotImplementedError end + + def set_pack + use_pack 'public' + end end