From 7694c62bc6aa765c3fbe87a0236717ec5b481e61 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: Tue, 9 Jan 2024 16:19:23 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20#437=20=E3=83=89=E3=83=A1=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF=E3=81=A7=E3=80=8C?= =?UTF-8?q?=E6=9C=AA=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=83=BC=E3=81=AB=E9=9D=9E=E5=85=AC=E9=96=8B=E3=80=8D?= =?UTF-8?q?=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92=E3=80=8C=E9=9D=9E=E5=85=AC?= =?UTF-8?q?=E9=96=8B=E3=80=8D=E3=81=AB=E3=82=B3=E3=83=94=E3=83=BC=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC=E3=83=BC=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=B3=E3=83=BC=E3=83=89=20(#439)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add: #437 ドメインブロックで「未ログインユーザーに非公開」の設定を「非公開」にコピーするマイグレーションコード * Fix test for LTS * Fix test --- .../api/v1/admin/domain_blocks_controller.rb | 4 ++-- app/models/domain_block.rb | 3 +-- ...ove_hidden_anonymous_from_domain_blocks.rb | 18 +++++++++++++++++ db/schema.rb | 3 +-- .../api/v1/instances/domain_blocks_spec.rb | 20 ------------------- 5 files changed, 22 insertions(+), 26 deletions(-) create mode 100644 db/migrate/20240109035435_remove_hidden_anonymous_from_domain_blocks.rb diff --git a/app/controllers/api/v1/admin/domain_blocks_controller.rb b/app/controllers/api/v1/admin/domain_blocks_controller.rb index e157ed1e1f..d9cdb34154 100644 --- a/app/controllers/api/v1/admin/domain_blocks_controller.rb +++ b/app/controllers/api/v1/admin/domain_blocks_controller.rb @@ -70,7 +70,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController def domain_block_params params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, - :reject_new_follow, :reject_friend, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) + :reject_new_follow, :reject_friend, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden) end def insert_pagination_headers @@ -103,6 +103,6 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController def resource_params params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, - :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) + :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden) end end diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 83763c044c..2eac84e25a 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -25,7 +25,6 @@ # reject_straight_follow :boolean default(FALSE), not null # reject_new_follow :boolean default(FALSE), not null # hidden :boolean default(FALSE), not null -# hidden_anonymous :boolean default(FALSE), not null # detect_invalid_subscription :boolean default(FALSE), not null # reject_reply_exclude_followers :boolean default(FALSE), not null # reject_friend :boolean default(FALSE), not null @@ -44,7 +43,7 @@ class DomainBlock < ApplicationRecord delegate :count, to: :accounts, prefix: true scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) } - scope :with_user_facing_limitations, -> { where(hidden: false, hidden_anonymous: false) } + scope :with_user_facing_limitations, -> { where(hidden: false) } scope :with_limitations, lambda { where(severity: [:silence, :suspend]) .or(where(reject_media: true)) diff --git a/db/migrate/20240109035435_remove_hidden_anonymous_from_domain_blocks.rb b/db/migrate/20240109035435_remove_hidden_anonymous_from_domain_blocks.rb new file mode 100644 index 0000000000..d1272cd79f --- /dev/null +++ b/db/migrate/20240109035435_remove_hidden_anonymous_from_domain_blocks.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class RemoveHiddenAnonymousFromDomainBlocks < ActiveRecord::Migration[7.0] + class DomainBlock < ApplicationRecord; end + + def up + safety_assured do + DomainBlock.where(hidden_anonymous: true, hidden: false).update_all(hidden: true) + remove_column :domain_blocks, :hidden_anonymous + end + end + + def down + safety_assured do + add_column :domain_blocks, :hidden_anonymous, :boolean, null: false, default: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a22b8313a0..e4b7b7b5b2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_12_22_100226) do +ActiveRecord::Schema[7.1].define(version: 2024_01_09_035435) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -584,7 +584,6 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_22_100226) do t.boolean "reject_straight_follow", default: false, null: false t.boolean "reject_new_follow", default: false, null: false t.boolean "hidden", default: false, null: false - t.boolean "hidden_anonymous", default: false, null: false t.boolean "detect_invalid_subscription", default: false, null: false t.boolean "reject_reply_exclude_followers", default: false, null: false t.boolean "reject_friend", default: false, null: false diff --git a/spec/requests/api/v1/instances/domain_blocks_spec.rb b/spec/requests/api/v1/instances/domain_blocks_spec.rb index a0e75de093..e9206a0b86 100644 --- a/spec/requests/api/v1/instances/domain_blocks_spec.rb +++ b/spec/requests/api/v1/instances/domain_blocks_spec.rb @@ -37,16 +37,6 @@ RSpec.describe 'Domain Blocks' do expect(body_as_json.pluck(:domain)).to_not include('hello.com') end end - - context 'with hidden domain block from anonymous' do - before { Fabricate(:domain_block, domain: 'hello.com', hidden_anonymous: true) } - - it 'returns http success and dont include hidden record' do - get api_v1_instance_domain_blocks_path - - expect(body_as_json.pluck(:domain)).to_not include('hello.com') - end - end end context 'with domain blocks set to users' do @@ -84,16 +74,6 @@ RSpec.describe 'Domain Blocks' do expect(body_as_json.pluck(:domain)).to_not include('hello.com') end end - - context 'with hidden domain block from anonymous' do - before { Fabricate(:domain_block, domain: 'hello.com', hidden_anonymous: true) } - - it 'returns http success and dont include hidden record' do - get api_v1_instance_domain_blocks_path, headers: headers - - expect(body_as_json.pluck(:domain)).to_not include('hello.com') - end - end end context 'with domain blocks set to disabled' do