Merge remote-tracking branch 'parent/main' into kb_migration

This commit is contained in:
KMY 2023-03-21 15:20:15 +09:00
commit 348a641eca
15 changed files with 75 additions and 59 deletions

View file

@ -245,7 +245,7 @@ Metrics/BlockNesting:
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 368
Max: 375
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
@ -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'

View file

@ -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'

View file

@ -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)
@ -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)

View file

@ -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?

View file

@ -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

View file

@ -8300,11 +8300,13 @@ noscript {
img {
margin-top: 2em;
margin-bottom: 2em;
max-width: 100%;
}
video {
margin-top: 2em;
margin-bottom: 2em;
max-width: 100%;
}
figure {

View file

@ -123,6 +123,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,
@ -606,4 +608,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

View file

@ -116,6 +116,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,
@ -572,4 +575,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

View file

@ -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) }

View file

@ -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',

View file

@ -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',
}

View file

@ -230,7 +230,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

View file

@ -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

View file

@ -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",
@ -154,11 +154,11 @@
"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",
"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"

View file

@ -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"
@ -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"
@ -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"
@ -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"