From 94cbd808b5b3e7999c7e77dc724b7e8c9dd2bdec Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Sat, 18 Mar 2023 23:47:54 -0700 Subject: [PATCH 01/17] Webhooks for local status.create, status.update, account.update (#24133) --- .rubocop_todo.yml | 2 +- app/models/account.rb | 7 +++++++ app/models/status.rb | 11 +++++++++++ app/models/webhook.rb | 3 +++ app/workers/webhooks/delivery_worker.rb | 2 +- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a3536e2023..b2f8bf52cb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -245,7 +245,7 @@ Metrics/BlockNesting: # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 368 + Max: 375 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: diff --git a/app/models/account.rb b/app/models/account.rb index 1ff083e54a..c4df488789 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -122,6 +122,8 @@ class Account < ApplicationRecord scope :not_excluded_by_account, ->(account) { where.not(id: account.excluded_from_timeline_account_ids) } scope :not_domain_blocked_by_account, ->(account) { where(arel_table[:domain].eq(nil).or(arel_table[:domain].not_in(account.excluded_from_timeline_domains))) } + after_update_commit :trigger_update_webhooks + delegate :email, :unconfirmed_email, :current_sign_in_at, @@ -593,4 +595,9 @@ class Account < ApplicationRecord CanonicalEmailBlock.where(reference_account: self).delete_all end + + # NOTE: the `account.created` webhook is triggered by the `User` model, not `Account`. + def trigger_update_webhooks + TriggerWebhookWorker.perform_async('account.updated', 'Account', id) if local? + end end diff --git a/app/models/status.rb b/app/models/status.rb index e7ea191a80..2e32c3f16b 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -111,6 +111,9 @@ class Status < ApplicationRecord where('NOT EXISTS (SELECT * FROM statuses_tags forbidden WHERE forbidden.status_id = statuses.id AND forbidden.tag_id IN (?))', tag_ids) } + after_create_commit :trigger_create_webhooks + after_update_commit :trigger_update_webhooks + cache_associated :application, :media_attachments, :conversation, @@ -535,4 +538,12 @@ class Status < ApplicationRecord reblog&.decrement_count!(:reblogs_count) if reblog? thread&.decrement_count!(:replies_count) if in_reply_to_id.present? && distributable? end + + def trigger_create_webhooks + TriggerWebhookWorker.perform_async('status.created', 'Status', id) if local? + end + + def trigger_update_webhooks + TriggerWebhookWorker.perform_async('status.updated', 'Status', id) if local? + end end diff --git a/app/models/webhook.rb b/app/models/webhook.rb index 4aafb1257b..9a056a3862 100644 --- a/app/models/webhook.rb +++ b/app/models/webhook.rb @@ -17,7 +17,10 @@ class Webhook < ApplicationRecord EVENTS = %w( account.approved account.created + account.updated report.created + status.created + status.updated ).freeze scope :enabled, -> { where(enabled: true) } diff --git a/app/workers/webhooks/delivery_worker.rb b/app/workers/webhooks/delivery_worker.rb index b1e345c5ef..f8ed669fb5 100644 --- a/app/workers/webhooks/delivery_worker.rb +++ b/app/workers/webhooks/delivery_worker.rb @@ -19,7 +19,7 @@ class Webhooks::DeliveryWorker private def perform_request - request = Request.new(:post, @webhook.url, body: @body) + request = Request.new(:post, @webhook.url, body: @body, allow_local: true) request.add_headers( 'Content-Type' => 'application/json', From 0ca54a4105907fc61792052fcdb703af8bbd1fee Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 20 Mar 2023 20:02:09 +0100 Subject: [PATCH 02/17] Remove `Permissions-Policy` header from all responses (#24124) --- config/environments/production.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 00d7834775..ef52228a0a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -127,7 +127,6 @@ Rails.application.configure do 'X-Frame-Options' => 'DENY', 'X-Content-Type-Options' => 'nosniff', 'X-XSS-Protection' => '0', - 'Permissions-Policy' => 'interest-cohort=()', 'Referrer-Policy' => 'same-origin', } From bdeb6ff18049870e76139f7434249096bc4d1fca Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 20 Mar 2023 20:02:58 +0100 Subject: [PATCH 03/17] Fix crash in `tootctl` commands making use of parallelization when Elasticsearch is enabled (#24182) --- lib/mastodon/cli_helper.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/mastodon/cli_helper.rb b/lib/mastodon/cli_helper.rb index 8704edd75e..ab1351ae80 100644 --- a/lib/mastodon/cli_helper.rb +++ b/lib/mastodon/cli_helper.rb @@ -52,14 +52,16 @@ module Mastodon progress.log("Processing #{item.id}") if options[:verbose] - result = ActiveRecord::Base.connection_pool.with_connection do - yield(item) - ensure - RedisConfiguration.pool.checkin if Thread.current[:redis] - Thread.current[:redis] = nil - end + Chewy.strategy(:mastodon) do + result = ActiveRecord::Base.connection_pool.with_connection do + yield(item) + ensure + RedisConfiguration.pool.checkin if Thread.current[:redis] + Thread.current[:redis] = nil + end - aggregate.increment(result) if result.is_a?(Integer) + aggregate.increment(result) if result.is_a?(Integer) + end rescue => e progress.log pastel.red("Error processing #{item.id}: #{e}") ensure From 7bef11630d6decac46bc006bf12e7d962dffa57e Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 20 Mar 2023 15:03:44 -0400 Subject: [PATCH 04/17] Remove references to non-existent actions (#24183) --- .rubocop_todo.yml | 2 -- app/controllers/admin/domain_blocks_controller.rb | 2 +- app/controllers/admin/email_domain_blocks_controller.rb | 6 ------ config/routes.rb | 2 +- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b2f8bf52cb..3b4ff3597e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1670,8 +1670,6 @@ Rails/InverseOf: # Include: app/controllers/**/*.rb, app/mailers/**/*.rb Rails/LexicallyScopedActionFilter: Exclude: - - 'app/controllers/admin/domain_blocks_controller.rb' - - 'app/controllers/admin/email_domain_blocks_controller.rb' - 'app/controllers/auth/passwords_controller.rb' - 'app/controllers/auth/registrations_controller.rb' - 'app/controllers/auth/sessions_controller.rb' diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index 060db11bbd..750f5c995c 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -2,7 +2,7 @@ module Admin class DomainBlocksController < BaseController - before_action :set_domain_block, only: [:show, :destroy, :edit, :update] + before_action :set_domain_block, only: [:destroy, :edit, :update] def batch authorize :domain_block, :create? diff --git a/app/controllers/admin/email_domain_blocks_controller.rb b/app/controllers/admin/email_domain_blocks_controller.rb index a0a43de192..4a3228ec30 100644 --- a/app/controllers/admin/email_domain_blocks_controller.rb +++ b/app/controllers/admin/email_domain_blocks_controller.rb @@ -2,8 +2,6 @@ module Admin class EmailDomainBlocksController < BaseController - before_action :set_email_domain_block, only: [:show, :destroy] - def index authorize :email_domain_block, :index? @@ -59,10 +57,6 @@ module Admin private - def set_email_domain_block - @email_domain_block = EmailDomainBlock.find(params[:id]) - end - def set_resolved_records Resolv::DNS.open do |dns| dns.timeouts = 5 diff --git a/config/routes.rb b/config/routes.rb index 8850545ca7..22ef10866e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -229,7 +229,7 @@ Rails.application.routes.draw do get '/dashboard', to: 'dashboard#index' resources :domain_allows, only: [:new, :create, :show, :destroy] - resources :domain_blocks, only: [:new, :create, :show, :destroy, :update, :edit] do + resources :domain_blocks, only: [:new, :create, :destroy, :update, :edit] do collection do post :batch end From 0a9def5498d9630bb9ebf1585f76b2af5fad5169 Mon Sep 17 00:00:00 2001 From: mogamin <5103195+mgmn@users.noreply.github.com> Date: Tue, 21 Mar 2023 04:04:25 +0900 Subject: [PATCH 05/17] Fit the max-width of media in .prose to parent box (#24180) --- app/javascript/styles/mastodon/components.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index ecec71804b..9f6958b37d 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -8249,11 +8249,13 @@ noscript { img { margin-top: 2em; margin-bottom: 2em; + max-width: 100%; } video { margin-top: 2em; margin-bottom: 2em; + max-width: 100%; } figure { From 4f4cbce295c7ae0777575f5807b2b44a355e49f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 00:56:45 +0100 Subject: [PATCH 06/17] Bump pghero from 3.3.0 to 3.3.1 (#24186) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8b16b9308b..8540fee5f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -485,7 +485,7 @@ GEM pastel (0.8.0) tty-color (~> 0.5) pg (1.4.6) - pghero (3.3.0) + pghero (3.3.1) activerecord (>= 6) pkg-config (1.5.1) posix-spawn (0.3.15) From 84f14b245155a43f1ba3ad93b2ac23a18fb95f77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:42:34 +0900 Subject: [PATCH 07/17] Bump rack-cors from 1.1.1 to 2.0.1 (#24189) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index b5669582bf..286b333c1c 100644 --- a/Gemfile +++ b/Gemfile @@ -69,7 +69,7 @@ gem 'public_suffix', '~> 5.0' gem 'pundit', '~> 2.3' gem 'premailer-rails' gem 'rack-attack', '~> 6.6' -gem 'rack-cors', '~> 1.1', require: 'rack/cors' +gem 'rack-cors', '~> 2.0', require: 'rack/cors' gem 'rails-i18n', '~> 6.0' gem 'rails-settings-cached', '~> 0.6', git: 'https://github.com/mastodon/rails-settings-cached.git', branch: 'v0.6.6-aliases-true' gem 'redcarpet', '~> 3.6' diff --git a/Gemfile.lock b/Gemfile.lock index 8540fee5f6..90ab6f2273 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -508,7 +508,7 @@ GEM rack (2.2.6.4) rack-attack (6.6.1) rack (>= 1.0, < 3) - rack-cors (1.1.1) + rack-cors (2.0.1) rack (>= 2.0.0) rack-oauth2 (1.21.3) activesupport @@ -848,7 +848,7 @@ DEPENDENCIES pundit (~> 2.3) rack (~> 2.2.6) rack-attack (~> 6.6) - rack-cors (~> 1.1) + rack-cors (~> 2.0) rack-test (~> 2.1) rails (~> 6.1.7) rails-controller-testing (~> 1.0) From f20843e60da93e98ffe7a26e10ec9e036d89cf8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:47:25 +0900 Subject: [PATCH 08/17] Bump react-select from 5.7.0 to 5.7.1 (#24187) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ee3eab9985..8978310fe4 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "react-redux-loading-bar": "^5.0.4", "react-router-dom": "^4.1.1", "react-router-scroll-4": "^1.0.0-beta.1", - "react-select": "^5.7.0", + "react-select": "^5.7.1", "react-sparklines": "^1.7.0", "react-swipeable-views": "^0.14.0", "react-textarea-autosize": "^8.4.0", diff --git a/yarn.lock b/yarn.lock index cd5e4f1a76..226f930ab8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9016,10 +9016,10 @@ react-router@^4.3.1: prop-types "^15.6.1" warning "^4.0.1" -react-select@^5.7.0: - version "5.7.0" - resolved "https://registry.yarnpkg.com/react-select/-/react-select-5.7.0.tgz#82921b38f1fcf1471a0b62304da01f2896cd8ce6" - integrity sha512-lJGiMxCa3cqnUr2Jjtg9YHsaytiZqeNOKeibv6WF5zbK/fPegZ1hg3y/9P1RZVLhqBTs0PfqQLKuAACednYGhQ== +react-select@^5.7.1: + version "5.7.1" + resolved "https://registry.yarnpkg.com/react-select/-/react-select-5.7.1.tgz#c85afa8a771d75c935ec698726a8fbfece662ed0" + integrity sha512-u/brzm3B6vgI+PtxNyE4/18kXgaf6bn5sOAjKhaQ54EItBfW41SRLH1AJC5fefPnGM4JmMcM51t/HAVCi5GrpQ== dependencies: "@babel/runtime" "^7.12.0" "@emotion/cache" "^11.4.0" From de6d504023ebe275c256adf600144394d48c382b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:49:48 +0900 Subject: [PATCH 09/17] Bump stylelint from 15.2.0 to 15.3.0 (#24185) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 8978310fe4..f47f65234c 100644 --- a/package.json +++ b/package.json @@ -158,7 +158,7 @@ "raf": "^3.4.1", "react-intl-translations-manager": "^5.0.3", "react-test-renderer": "^16.14.0", - "stylelint": "^15.2.0", + "stylelint": "^15.3.0", "stylelint-config-standard-scss": "^7.0.1", "webpack-dev-server": "^3.11.3", "yargs": "^17.7.1" diff --git a/yarn.lock b/yarn.lock index 226f930ab8..914b4b1698 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1098,10 +1098,10 @@ resolved "https://registry.yarnpkg.com/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.0.1.tgz#ff02629c7c95d1f4f8ea84d5ef1173461610535e" integrity sha512-B9/8PmOtU6nBiibJg0glnNktQDZ3rZnGn/7UmDfrm2vMtrdlXO3p7ErE95N0up80IRk9YEtB5jyj/TmQ1WH3dw== -"@csstools/css-tokenizer@^2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@csstools/css-tokenizer/-/css-tokenizer-2.0.1.tgz#cb1e11752db57e69d9aa0e84c3105a25845d4055" - integrity sha512-sYD3H7ReR88S/4+V5VbKiBEUJF4FqvG+8aNJkxqoPAnbhFziDG22IDZc4+h+xA63SfgM+h15lq5OnLeCxQ9nPA== +"@csstools/css-tokenizer@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@csstools/css-tokenizer/-/css-tokenizer-2.1.0.tgz#fee4de3d444db3ce9007f3af6474af8ba3e4b930" + integrity sha512-dtqFyoJBHUxGi9zPZdpCKP1xk8tq6KPHJ/NY4qWXiYo6IcSGwzk3L8x2XzZbbyOyBs9xQARoGveU2AsgLj6D2A== "@csstools/media-query-list-parser@^2.0.1": version "2.0.1" @@ -3587,10 +3587,10 @@ cosmiconfig@^7.0.0: path-type "^4.0.0" yaml "^1.10.0" -cosmiconfig@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.0.0.tgz#e9feae014eab580f858f8a0288f38997a7bebe97" - integrity sha512-da1EafcpH6b/TD8vDRaWV7xFINlHlF6zKsGwS1TsuVJTZRkquaS5HTMq7uq6h31619QjbsYl21gVDOm32KM1vQ== +cosmiconfig@^8.1.0: + version "8.1.3" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.1.3.tgz#0e614a118fcc2d9e5afc2f87d53cd09931015689" + integrity sha512-/UkO2JKI18b5jVMJUp0lvKFMpa/Gye+ZgZjKD+DGEN9y7NRcf/nK1A0sp67ONmKtnDCNMS44E6jrk0Yc3bDuUw== dependencies: import-fresh "^3.2.1" js-yaml "^4.1.0" @@ -6979,10 +6979,10 @@ klona@^2.0.4: resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.4.tgz#7bb1e3affb0cb8624547ef7e8f6708ea2e39dfc0" integrity sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA== -known-css-properties@^0.26.0: - version "0.26.0" - resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.26.0.tgz#008295115abddc045a9f4ed7e2a84dc8b3a77649" - integrity sha512-5FZRzrZzNTBruuurWpvZnvP9pum+fe0HcK8z/ooo+U+Hmp4vtbyp1/QDsqmufirXy4egGzbaH/y2uCZf+6W5Kg== +known-css-properties@^0.27.0: + version "0.27.0" + resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.27.0.tgz#82a9358dda5fe7f7bd12b5e7142c0a205393c0c5" + integrity sha512-uMCj6+hZYDoffuvAJjFAPz56E9uoowFHmTkqRtRq5WyC5Q6Cu/fTZKNQpX/RbzChBYLLl3lo8CjFZBAZXq9qFg== language-subtag-registry@~0.3.2: version "0.3.20" @@ -10292,18 +10292,18 @@ stylelint-scss@^4.4.0: postcss-selector-parser "^6.0.6" postcss-value-parser "^4.1.0" -stylelint@^15.2.0: - version "15.2.0" - resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-15.2.0.tgz#e906eb59df83bde075d148623216f298f9ceb03a" - integrity sha512-wjg5OLn8zQwjlj5cYUgyQpMWKzct42AG5dYlqkHRJQJqsystFFn3onqEc263KH4xfEI0W3lZCnlIhFfS64uwSA== +stylelint@^15.3.0: + version "15.3.0" + resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-15.3.0.tgz#5f0f3264abeb29c54f571ea3f3934eba2c2be96d" + integrity sha512-9UYBYk7K9rtlKcTUDZrtntE840sZM00qyYBQHHe7tjwMNUsPsGvR6Fd43IxHEAhRrDLzpy3TVaHb6CReBB3eFg== dependencies: "@csstools/css-parser-algorithms" "^2.0.1" - "@csstools/css-tokenizer" "^2.0.1" + "@csstools/css-tokenizer" "^2.1.0" "@csstools/media-query-list-parser" "^2.0.1" "@csstools/selector-specificity" "^2.1.1" balanced-match "^2.0.0" colord "^2.9.3" - cosmiconfig "^8.0.0" + cosmiconfig "^8.1.0" css-functions-list "^3.1.0" css-tree "^2.3.1" debug "^4.3.4" @@ -10318,7 +10318,7 @@ stylelint@^15.2.0: import-lazy "^4.0.0" imurmurhash "^0.1.4" is-plain-object "^5.0.0" - known-css-properties "^0.26.0" + known-css-properties "^0.27.0" mathml-tag-names "^2.1.3" meow "^9.0.0" micromatch "^4.0.5" @@ -10334,7 +10334,7 @@ stylelint@^15.2.0: string-width "^4.2.3" strip-ansi "^6.0.1" style-search "^0.1.0" - supports-hyperlinks "^2.3.0" + supports-hyperlinks "^3.0.0" svg-tags "^1.0.0" table "^6.8.1" v8-compile-cache "^2.3.0" @@ -10378,10 +10378,10 @@ supports-color@^8.0.0: dependencies: has-flag "^4.0.0" -supports-hyperlinks@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz#3943544347c1ff90b15effb03fc14ae45ec10624" - integrity sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA== +supports-hyperlinks@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-3.0.0.tgz#c711352a5c89070779b4dad54c05a2f14b15c94b" + integrity sha512-QBDPHyPQDRTy9ku4URNGY5Lah8PAaXs6tAAwp55sL5WCsSW7GIfdf6W5ixfziW+t7wh3GVvHyHHyQ1ESsoRvaA== dependencies: has-flag "^4.0.0" supports-color "^7.0.0" From a4d285f2f991b56ee2ad738f7f7251a56f273cf7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:51:31 +0900 Subject: [PATCH 10/17] Bump prettier from 2.8.4 to 2.8.5 (#24188) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f47f65234c..247fe66ab4 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,7 @@ "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "postcss-scss": "^4.0.6", - "prettier": "^2.8.4", + "prettier": "^2.8.5", "raf": "^3.4.1", "react-intl-translations-manager": "^5.0.3", "react-test-renderer": "^16.14.0", diff --git a/yarn.lock b/yarn.lock index 914b4b1698..d09efa23bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8606,10 +8606,10 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prettier@^2.8.4: - version "2.8.4" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3" - integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw== +prettier@^2.8.5: + version "2.8.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.5.tgz#3dd8ae1ebddc4f6aa419c9b64d8c8319a7e0d982" + integrity sha512-3gzuxrHbKUePRBB4ZeU08VNkUcqEHaUaouNt0m7LGP4Hti/NuB07C7PPTM/LkWqXoJYJn2McEo5+kxPNrtQkLQ== pretty-bytes@^5.3.0, pretty-bytes@^5.4.1: version "5.6.0" From 9f8d1601a4877459b4d332d03796e5b70f07134e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 10:25:19 +0100 Subject: [PATCH 11/17] Bump stackprof from 0.2.23 to 0.2.24 (#24190) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 90ab6f2273..6fa4894dbe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -679,7 +679,7 @@ GEM sshkit (1.21.4) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - stackprof (0.2.23) + stackprof (0.2.24) statsd-ruby (1.5.0) stoplight (3.0.1) redlock (~> 1.0) From 38c84f57b6d2de1683974f91d726c30ba7f1491b Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Tue, 21 Mar 2023 18:32:58 +0900 Subject: [PATCH 12/17] Refactoring relations_map (#24195) --- app/models/concerns/account_interactions.rb | 15 +++++++++++++++ app/models/concerns/status_threading_concern.rb | 14 +------------- app/services/import_service.rb | 12 +----------- app/services/search_service.rb | 12 +----------- 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb index 1898516b00..48ab1349dd 100644 --- a/app/models/concerns/account_interactions.rb +++ b/app/models/concerns/account_interactions.rb @@ -292,6 +292,21 @@ module AccountInteractions end end + def relations_map(account_ids, domains = nil, **options) + relations = { + blocked_by: Account.blocked_by_map(account_ids, id), + following: Account.following_map(account_ids, id), + } + + return relations if options[:skip_blocking_and_muting] + + relations.merge!({ + blocking: Account.blocking_map(account_ids, id), + muting: Account.muting_map(account_ids, id), + domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, id), + }) + end + private def remove_potential_friendship(other_account) diff --git a/app/models/concerns/status_threading_concern.rb b/app/models/concerns/status_threading_concern.rb index 8b628beea2..2ca3b66c27 100644 --- a/app/models/concerns/status_threading_concern.rb +++ b/app/models/concerns/status_threading_concern.rb @@ -79,7 +79,7 @@ module StatusThreadingConcern statuses = Status.with_accounts(ids).to_a account_ids = statuses.map(&:account_id).uniq domains = statuses.filter_map(&:account_domain).uniq - relations = relations_map_for_account(account, account_ids, domains) + relations = account&.relations_map(account_ids, domains) || {} statuses.reject! { |status| StatusFilter.new(status, account, relations).filtered? } @@ -108,16 +108,4 @@ module StatusThreadingConcern arr end - - def relations_map_for_account(account, account_ids, domains) - return {} if account.nil? - - { - blocking: Account.blocking_map(account_ids, account.id), - blocked_by: Account.blocked_by_map(account_ids, account.id), - muting: Account.muting_map(account_ids, account.id), - following: Account.following_map(account_ids, account.id), - domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, account.id), - } - end end diff --git a/app/services/import_service.rb b/app/services/import_service.rb index 940c236d4c..56f191c1fe 100644 --- a/app/services/import_service.rb +++ b/app/services/import_service.rb @@ -120,7 +120,7 @@ class ImportService < BaseService end account_ids = statuses.map(&:account_id) - preloaded_relations = relations_map_for_account(@account, account_ids) + preloaded_relations = @account.relations_map(account_ids, skip_blocking_and_muting: true) statuses.keep_if { |status| StatusPolicy.new(@account, status, preloaded_relations).show? } @@ -138,14 +138,4 @@ class ImportService < BaseService def import_data Paperclip.io_adapters.for(@import.data).read.force_encoding(Encoding::UTF_8) end - - def relations_map_for_account(account, account_ids) - { - blocking: {}, - blocked_by: Account.blocked_by_map(account_ids, account.id), - muting: {}, - following: Account.following_map(account_ids, account.id), - domain_blocking_by_domain: {}, - } - end end diff --git a/app/services/search_service.rb b/app/services/search_service.rb index 93b72fa0c4..b1ce5453fb 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -49,7 +49,7 @@ class SearchService < BaseService results = definition.limit(@limit).offset(@offset).objects.compact account_ids = results.map(&:account_id) account_domains = results.map(&:account_domain) - preloaded_relations = relations_map_for_account(@account, account_ids, account_domains) + preloaded_relations = @account.relations_map(account_ids, account_domains) results.reject { |status| StatusFilter.new(status, @account, preloaded_relations).filtered? } rescue Faraday::ConnectionFailed, Parslet::ParseFailed @@ -111,16 +111,6 @@ class SearchService < BaseService @options[:type].blank? || @options[:type] == 'statuses' end - def relations_map_for_account(account, account_ids, domains) - { - blocking: Account.blocking_map(account_ids, account.id), - blocked_by: Account.blocked_by_map(account_ids, account.id), - muting: Account.muting_map(account_ids, account.id), - following: Account.following_map(account_ids, account.id), - domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, account.id), - } - end - def parsed_query SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query)) end From 7f8e1bede4e68c01ff167fc3f4e1e63da24307a8 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 21 Mar 2023 15:04:21 +0100 Subject: [PATCH 13/17] Bump version to v4.1.1 (#24201) --- CHANGELOG.md | 51 +++++++++++++++++++++++++++++++++++++++++ lib/mastodon/version.rb | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b826fb14a..4527c50d95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,57 @@ All notable changes to this project will be documented in this file. +## [4.1.1] - 2023-03-16 + +### Added + +- Add redirection from paths with url-encoded `@` to their decoded form ([thijskh](https://github.com/mastodon/mastodon/pull/23593)) +- Add `lang` attribute to native language names in language picker in Web UI ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23749)) +- Add headers to outgoing mails to avoid auto-replies ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23597)) +- Add support for refreshing many accounts at once with `tootctl accounts refresh` ([9p4](https://github.com/mastodon/mastodon/pull/23304)) +- Add confirmation modal when clicking to edit a post with a non-empty compose form ([PauloVilarinho](https://github.com/mastodon/mastodon/pull/23936)) +- Add support for the HAproxy PROXY protocol through the `PROXY_PROTO_V1` environment variable ([CSDUMMI](https://github.com/mastodon/mastodon/pull/24064)) +- Add `SENDFILE_HEADER` environment variable ([Gargron](https://github.com/mastodon/mastodon/pull/24123)) +- Add cache headers to static files served through Rails ([Gargron](https://github.com/mastodon/mastodon/pull/24120)) + +### Changed + +- Increase contrast of upload progress bar background ([toolmantim](https://github.com/mastodon/mastodon/pull/23836)) +- Change post auto-deletion throttling constants to better scale with server size ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23320)) +- Change order of bookmark and favourite sidebar entries in single-column UI for consistency ([TerryGarcia](https://github.com/mastodon/mastodon/pull/23701)) +- Change `ActivityPub::DeliveryWorker` retries to be spread out more ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/21956)) + +### Fixed + +- Fix “Remove all followers from the selected domains” also removing follows and notifications ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23805)) +- Fix streaming metrics format ([emilweth](https://github.com/mastodon/mastodon/pull/23519), [emilweth](https://github.com/mastodon/mastodon/pull/23520)) +- Fix case-sensitive check for previously used hashtags in hashtag autocompletion ([deanveloper](https://github.com/mastodon/mastodon/pull/23526)) +- Fix focus point of already-attached media not saving after edit ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23566)) +- Fix sidebar behavior in settings/admin UI on mobile ([wxt2005](https://github.com/mastodon/mastodon/pull/23764)) +- Fix inefficiency when searching accounts per username in admin interface ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23801)) +- Fix duplicate “Publish” button on mobile ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23804)) +- Fix server error when failing to follow back followers from `/relationships` ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23787)) +- Fix server error when attempting to display the edit history of a trendable post in the admin interface ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23574)) +- Fix `tootctl accounts migrate` crashing because of a typo ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23567)) +- Fix original account being unfollowed on migration before the follow request to the new account could be sent ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/21957)) +- Fix the “Back” button in column headers sometimes leaving Mastodon ([c960657](https://github.com/mastodon/mastodon/pull/23953)) +- Fix pgBouncer resetting application name on every transaction ([Gargron](https://github.com/mastodon/mastodon/pull/23958)) +- Fix unconfirmed accounts being counted as active users ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23803)) +- Fix `/api/v1/streaming` sub-paths not being redirected ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23988)) +- Fix drag'n'drop upload area text that spans multiple lines not being centered ([vintprox](https://github.com/mastodon/mastodon/pull/24029)) +- Fix sidekiq jobs not triggering Elasticsearch index updates ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/24046)) +- Fix tags being unnecessarily stripped from plain-text short site description ([c960657](https://github.com/mastodon/mastodon/pull/23975)) +- Fix HTML entities not being un-escaped in extracted plain-text from remote posts ([c960657](https://github.com/mastodon/mastodon/pull/24019)) +- Fix dashboard crash on ElasticSearch server error ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23751)) +- Fix incorrect post links in strikes when the account is remote ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23611)) +- Fix misleading error code when receiving invalid WebAuthn credentials ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23568)) +- Fix duplicate mails being sent when the SMTP server is too slow to close the connection ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/23750)) + +### Security + +- Change user backups to use expiring URLs for download when possible ([Gargron](https://github.com/mastodon/mastodon/pull/24136)) +- Add warning for object storage misconfiguration ([ClearlyClaire](https://github.com/mastodon/mastodon/pull/24137)) + ## [4.1.0] - 2023-02-10 ### Added diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 8101e61dd2..6a797fccf9 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -13,7 +13,7 @@ module Mastodon end def patch - 0 + 1 end def flags From 148c3d589461440400c2850cecc79c45a70bdca6 Mon Sep 17 00:00:00 2001 From: Simon Elvery Date: Wed, 22 Mar 2023 20:22:35 +1000 Subject: [PATCH 14/17] Update profile link verification instructions (#19723) Co-authored-by: Effy Elden --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 5924501008..fa7fb6be08 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1697,7 +1697,7 @@ en: seamless_external_login: You are logged in via an external service, so password and e-mail settings are not available. signed_in_as: 'Signed in as:' verification: - explanation_html: 'You can verify yourself as the owner of the links in your profile metadata. For that, the linked website must contain a link back to your Mastodon profile. The link back must have a rel="me" attribute. The text content of the link does not matter. Here is an example:' + explanation_html: 'You can verify yourself as the owner of the links in your profile metadata. For that, the linked website must contain a link back to your Mastodon profile. After adding the link you may need to come back here and re-save your profile for the verification to take effect. The link back must have a rel="me" attribute. The text content of the link does not matter. Here is an example:' verification: Verification webauthn_credentials: add: Add new security key From b179ff84c76b79f91793fdb23e5e9c84ad46707a Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 22 Mar 2023 09:06:26 -0400 Subject: [PATCH 15/17] Add specs for Chewy importers (#24204) --- .../lib/importer/accounts_index_importer_spec.rb | 16 ++++++++++++++++ .../lib/importer/statuses_index_importer_spec.rb | 16 ++++++++++++++++ spec/lib/importer/tags_index_importer_spec.rb | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 spec/lib/importer/accounts_index_importer_spec.rb create mode 100644 spec/lib/importer/statuses_index_importer_spec.rb create mode 100644 spec/lib/importer/tags_index_importer_spec.rb diff --git a/spec/lib/importer/accounts_index_importer_spec.rb b/spec/lib/importer/accounts_index_importer_spec.rb new file mode 100644 index 0000000000..73f9bce399 --- /dev/null +++ b/spec/lib/importer/accounts_index_importer_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Importer::AccountsIndexImporter do + describe 'import!' do + let(:pool) { Concurrent::FixedThreadPool.new(5) } + let(:importer) { described_class.new(batch_size: 123, executor: pool) } + + before { Fabricate(:account) } + + it 'indexes relevant accounts' do + expect { importer.import! }.to update_index(AccountsIndex) + end + end +end diff --git a/spec/lib/importer/statuses_index_importer_spec.rb b/spec/lib/importer/statuses_index_importer_spec.rb new file mode 100644 index 0000000000..d5e1c9f2cb --- /dev/null +++ b/spec/lib/importer/statuses_index_importer_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Importer::StatusesIndexImporter do + describe 'import!' do + let(:pool) { Concurrent::FixedThreadPool.new(5) } + let(:importer) { described_class.new(batch_size: 123, executor: pool) } + + before { Fabricate(:status) } + + it 'indexes relevant statuses' do + expect { importer.import! }.to update_index(StatusesIndex) + end + end +end diff --git a/spec/lib/importer/tags_index_importer_spec.rb b/spec/lib/importer/tags_index_importer_spec.rb new file mode 100644 index 0000000000..348990c01e --- /dev/null +++ b/spec/lib/importer/tags_index_importer_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Importer::TagsIndexImporter do + describe 'import!' do + let(:pool) { Concurrent::FixedThreadPool.new(5) } + let(:importer) { described_class.new(batch_size: 123, executor: pool) } + + before { Fabricate(:tag) } + + it 'indexes relevant tags' do + expect { importer.import! }.to update_index(TagsIndex) + end + end +end From a7a578a05553cc3ac34f6cd3c60b43117b309763 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 22 Mar 2023 09:15:22 -0400 Subject: [PATCH 16/17] Remove unused InstancePresenter methods (#24206) --- app/presenters/instance_presenter.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb index 50e2a51566..25df4d85aa 100644 --- a/app/presenters/instance_presenter.rb +++ b/app/presenters/instance_presenter.rb @@ -22,10 +22,6 @@ class InstancePresenter < ActiveModelSerializers::Model ContactPresenter.new end - def closed_registrations_message - Setting.closed_registrations_message - end - def description Setting.site_short_description end @@ -34,10 +30,6 @@ class InstancePresenter < ActiveModelSerializers::Model Setting.site_extended_description end - def privacy_policy - Setting.site_terms - end - def status_page_url Setting.status_page_url end From 2626097869c9520c21aaba73c9bcfe72c0f25f28 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 22 Mar 2023 15:47:44 +0100 Subject: [PATCH 17/17] Fix Rails cache namespace being overriden with `v2` for cached statuses (#24202) --- app/controllers/concerns/cache_concern.rb | 4 ++-- app/models/status.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/cache_concern.rb b/app/controllers/concerns/cache_concern.rb index e606218acb..a5a9ba3e1f 100644 --- a/app/controllers/concerns/cache_concern.rb +++ b/app/controllers/concerns/cache_concern.rb @@ -187,7 +187,7 @@ module CacheConcern return [] if raw.empty? cached_keys_with_value = begin - Rails.cache.read_multi(*raw, namespace: 'v2').transform_keys(&:id).transform_values { |r| ActiveRecordCoder.load(r) } + Rails.cache.read_multi(*raw).transform_keys(&:id).transform_values { |r| ActiveRecordCoder.load(r) } rescue ActiveRecordCoder::Error {} # The serialization format may have changed, let's pretend it's a cache miss. end @@ -200,7 +200,7 @@ module CacheConcern uncached = klass.where(id: uncached_ids).with_includes.index_by(&:id) uncached.each_value do |item| - Rails.cache.write(item, ActiveRecordCoder.dump(item), namespace: 'v2') + Rails.cache.write(item, ActiveRecordCoder.dump(item)) end end diff --git a/app/models/status.rb b/app/models/status.rb index 2e32c3f16b..2757497db9 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -140,6 +140,10 @@ class Status < ApplicationRecord REAL_TIME_WINDOW = 6.hours + def cache_key + "v2:#{super}" + end + def searchable_by(preloaded = nil) ids = []