diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index deda7a72859db5..2a2faf9cceebde 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -88,17 +88,17 @@ def set_domain_block end def update_params - params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, + params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden) end def resource_params - params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, + params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden) end def form_domain_block_batch_params - params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, + params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden]) end diff --git a/app/controllers/admin/export_domain_blocks_controller.rb b/app/controllers/admin/export_domain_blocks_controller.rb index 205b2c032f1c6b..8d7350c765ad33 100644 --- a/app/controllers/admin/export_domain_blocks_controller.rb +++ b/app/controllers/admin/export_domain_blocks_controller.rb @@ -38,7 +38,6 @@ def import public_comment: row['#public_comment'], obfuscate: row.fetch('#obfuscate', false), reject_favourite: row.fetch('#reject_favourite', false), - reject_reply: row.fetch('#reject_reply', false), reject_send_sensitive: row.fetch('#reject_send_sensitive', false), reject_hashtag: row.fetch('#reject_hashtag', false), reject_straight_follow: row.fetch('#reject_straight_follow', false), @@ -86,7 +85,6 @@ def export_headers #public_comment #obfuscate #reject_favourite - #reject_reply #reject_send_sensitive #reject_hashtag #reject_straight_follow @@ -110,7 +108,6 @@ def export_data instance.public_comment, instance.obfuscate, instance.reject_favourite, - instance.reject_reply, instance.reject_send_sensitive, instance.reject_hashtag, instance.reject_straight_follow, diff --git a/app/controllers/api/v1/admin/domain_blocks_controller.rb b/app/controllers/api/v1/admin/domain_blocks_controller.rb index 45d4b598a72300..fd7967d6498921 100644 --- a/app/controllers/api/v1/admin/domain_blocks_controller.rb +++ b/app/controllers/api/v1/admin/domain_blocks_controller.rb @@ -69,7 +69,7 @@ def filtered_domain_blocks end def domain_block_params - params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, + params.permit(:severity, :reject_media, :reject_favourite, :reject_reply_exclude_followers, :reject_reports, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden) end @@ -102,7 +102,7 @@ def pagination_params(core_params) end def resource_params - params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, + params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply_exclude_followers, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :block_trends, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden) end end diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 36548f029b8cdd..b390fc5d249429 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -91,7 +91,6 @@ def process_status process_audience return nil unless valid_status? - return nil if (mention_to_local? || reference_to_local_account?) && reject_reply_to_local? return nil if (mention_to_local_stranger? || reference_to_local_stranger?) && reject_reply_exclude_followers? ApplicationRecord.transaction do @@ -510,10 +509,6 @@ def reply_to_local? !replied_to_status.nil? && replied_to_status.account.local? end - def mention_to_local? - mentioned_accounts.any?(&:local?) - end - def mention_to_local_stranger? mentioned_accounts.any? { |account| account.local? && !account.following?(@account) } end @@ -532,10 +527,6 @@ def reference_to_local_stranger? local_referred_accounts.any? { |account| !account.following?(@account) } end - def reject_reply_to_local? - @reject_reply_to_local ||= DomainBlock.reject_reply?(@account.domain) - end - def reject_reply_exclude_followers? @reject_reply_exclude_followers ||= DomainBlock.reject_reply_exclude_followers?(@account.domain) end diff --git a/app/models/admin/import.rb b/app/models/admin/import.rb index 90db439a5d7e2d..13927dbdf4ffdf 100644 --- a/app/models/admin/import.rb +++ b/app/models/admin/import.rb @@ -34,7 +34,7 @@ def csv_data field&.strip when '#severity' field&.strip&.to_sym - when '#reject_media', '#reject_reports', '#obfuscate', '#reject_favourite', '#reject_reply', '#reject_send_sensitive', + when '#reject_media', '#reject_reports', '#obfuscate', '#reject_favourite', '#reject_send_sensitive', '#reject_hashtag', '#reject_straight_follow', '#reject_new_follow', '#hidden', '#detect_invalid_subscription', '#reject_reply_exclude_followers', '#reject_friend', '#block_trends' ActiveModel::Type::Boolean.new.cast(field) diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 350479ddc3c238..a851e17307c594 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -15,7 +15,6 @@ # public_comment :text # obfuscate :boolean default(FALSE), not null # reject_favourite :boolean default(FALSE), not null -# reject_reply :boolean default(FALSE), not null # reject_send_sensitive :boolean default(FALSE), not null # reject_hashtag :boolean default(FALSE), not null # reject_straight_follow :boolean default(FALSE), not null @@ -44,7 +43,6 @@ class DomainBlock < ApplicationRecord where(severity: [:silence, :suspend]) .or(where(reject_media: true)) .or(where(reject_favourite: true)) - .or(where(reject_reply: true)) .or(where(reject_reply_exclude_followers: true)) .or(where(reject_new_follow: true)) .or(where(reject_straight_follow: true)) @@ -64,7 +62,6 @@ def policies [severity.to_sym, reject_media? ? :reject_media : nil, reject_favourite? ? :reject_favourite : nil, - reject_reply? ? :reject_reply : nil, reject_reply_exclude_followers? ? :reject_reply_exclude_followers : nil, reject_send_sensitive? ? :reject_send_sensitive : nil, reject_hashtag? ? :reject_hashtag : nil, @@ -94,10 +91,6 @@ def reject_favourite?(domain) !!rule_for(domain)&.reject_favourite? end - def reject_reply?(domain) - !!rule_for(domain)&.reject_reply? - end - def reject_reply_exclude_followers?(domain) !!rule_for(domain)&.reject_reply_exclude_followers? end @@ -150,7 +143,7 @@ def stricter_than?(other_block) return false if other_block.suspend? && (silence? || noop?) return false if other_block.silence? && noop? - (reject_media || !other_block.reject_media) && (reject_favourite || !other_block.reject_favourite) && (reject_reply || !other_block.reject_reply) && (reject_reply_exclude_followers || !other_block.reject_reply_exclude_followers) && (reject_reports || !other_block.reject_reports) + (reject_media || !other_block.reject_media) && (reject_favourite || !other_block.reject_favourite) && (reject_reply_exclude_followers || !other_block.reject_reply_exclude_followers) && (reject_reports || !other_block.reject_reports) end def public_domain diff --git a/app/serializers/rest/admin/domain_block_serializer.rb b/app/serializers/rest/admin/domain_block_serializer.rb index 33aabdb832b6cb..6a496e2b80ec76 100644 --- a/app/serializers/rest/admin/domain_block_serializer.rb +++ b/app/serializers/rest/admin/domain_block_serializer.rb @@ -2,7 +2,7 @@ class REST::Admin::DomainBlockSerializer < ActiveModel::Serializer attributes :id, :domain, :digest, :created_at, :severity, - :reject_media, :reject_favourite, :reject_reply, :reject_reports, + :reject_media, :reject_favourite, :reject_reports, :reject_reply_exclude_followers, :reject_send_sensitive, :block_trends, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate diff --git a/app/views/admin/domain_blocks/_domain_block_list.html.haml b/app/views/admin/domain_blocks/_domain_block_list.html.haml index 135b8a0ba46051..2b7b3821654d07 100644 --- a/app/views/admin/domain_blocks/_domain_block_list.html.haml +++ b/app/views/admin/domain_blocks/_domain_block_list.html.haml @@ -3,9 +3,6 @@ .fields-group = f.input :reject_favourite, as: :boolean, kmyblue: true, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_favourite'), hint: I18n.t('admin.domain_blocks.reject_favourite_hint') -.fields-group - = f.input :reject_reply, as: :boolean, kmyblue: true, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply'), hint: I18n.t('admin.domain_blocks.reject_reply_hint') - .fields-group = f.input :reject_reply_exclude_followers, as: :boolean, kmyblue: true, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply_exclude_followers'), hint: I18n.t('admin.domain_blocks.reject_reply_exclude_followers_hint') diff --git a/app/views/admin/export_domain_blocks/_domain_block.html.haml b/app/views/admin/export_domain_blocks/_domain_block.html.haml index 4789c4801bfe7f..9657d51e9c2706 100644 --- a/app/views/admin/export_domain_blocks/_domain_block.html.haml +++ b/app/views/admin/export_domain_blocks/_domain_block.html.haml @@ -11,7 +11,6 @@ = f.hidden_field :severity = f.hidden_field :reject_media = f.hidden_field :reject_favourite - = f.hidden_field :reject_reply = f.hidden_field :reject_reply_exclude_followers = f.hidden_field :reject_send_sensitive = f.hidden_field :reject_hashtag diff --git a/config/locales/en.yml b/config/locales/en.yml index 3e2645b86bbb96..c1d4d1f2eea429 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -457,7 +457,6 @@ en: reject_media_hint: Removes locally stored media files and refuses to download any in the future. Irrelevant for suspensions reject_new_follow: Reject follows reject_new_follow_hint: Reject follows in the future - reject_reply: Reject replies reject_reply_exclude_followers: Reject mentions/references exclude followers reject_reply_hint: Reject replies in the future reject_reply_exclude_followers_hint: Reject replies exclude followers in the future @@ -574,7 +573,6 @@ en: reject_media: Reject media reject_new_follow: Reject follows reject_straight_follow: Reject straight follow - reject_reply: Reject reply reject_reply_exclude_followers: Reject reply/reference exclude followers reject_reports: Reject reports silence: Limit diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 666b8efb679c82..e495d13e4dd1ba 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -452,7 +452,6 @@ ja: reject_media_hint: ローカルに保存されたメディアファイルを削除し、今後のダウンロードを拒否します。停止とは無関係です reject_new_follow: 新規フォローを拒否 reject_new_follow_hint: 今後の新規フォローを拒否します。停止とは無関係です - reject_reply: リプライを拒否 reject_reply_exclude_followers: フォロー相手以外からのメンションと参照を拒否 reject_reply_hint: 今後のリプライを拒否します。停止とは無関係です reject_reply_exclude_followers_hint: 今後のリプライを拒否します。停止とは無関係です @@ -566,7 +565,6 @@ ja: reject_hashtag: ハッシュタグを拒否 reject_media: メディアを拒否する reject_new_follow: 新規フォローを拒否 - reject_reply: リプライを拒否 reject_reply_exclude_followers: フォロー相手以外からのメンション・参照を拒否 reject_reports: 通報を拒否 reject_send_sensitive: センシティブ投稿配送なし diff --git a/db/migrate/20240229233617_remove_reject_reply_from_domain_blocks.rb b/db/migrate/20240229233617_remove_reject_reply_from_domain_blocks.rb new file mode 100644 index 00000000000000..a60162966eb970 --- /dev/null +++ b/db/migrate/20240229233617_remove_reject_reply_from_domain_blocks.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveRejectReplyFromDomainBlocks < ActiveRecord::Migration[7.1] + disable_ddl_transaction! + + def change + safety_assured { remove_column :domain_blocks, :reject_reply, :boolean, null: false, default: false } + end +end diff --git a/db/schema.rb b/db/schema.rb index 649d9d4471f002..65568b2f21bb11 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: 2024_02_27_225017) do +ActiveRecord::Schema[7.1].define(version: 2024_02_29_233617) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -565,7 +565,6 @@ t.text "public_comment" t.boolean "obfuscate", default: false, null: false t.boolean "reject_favourite", default: false, null: false - t.boolean "reject_reply", default: false, null: false t.boolean "reject_send_sensitive", default: false, null: false t.boolean "reject_hashtag", default: false, null: false t.boolean "reject_straight_follow", default: false, null: false diff --git a/lib/tasks/dangerous.rake b/lib/tasks/dangerous.rake index 729eda9f358cdf..43ab95d53eabee 100644 --- a/lib/tasks/dangerous.rake +++ b/lib/tasks/dangerous.rake @@ -92,6 +92,7 @@ namespace :dangerous do 20240227033337 20240227222450 20240227225017 + 20240229233617 ) # Removed: account_groups target_tables = %w( @@ -147,7 +148,7 @@ namespace :dangerous do %w(domain_blocks reject_friend), %w(domain_blocks reject_hashtag), %w(domain_blocks reject_new_follow), - %w(domain_blocks reject_reply), + # Removed: domain_blocks reject_reply %w(domain_blocks reject_reply_exclude_followers), # Removed: domain_blocks reject_send_dissubscribable # Removed: domain_blocks reject_send_media diff --git a/spec/controllers/admin/export_domain_blocks_controller_spec.rb b/spec/controllers/admin/export_domain_blocks_controller_spec.rb index b4e60e55a937a7..991387400fc1a7 100644 --- a/spec/controllers/admin/export_domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/export_domain_blocks_controller_spec.rb @@ -22,7 +22,7 @@ Fabricate(:domain_block, domain: 'bad.domain', severity: 'silence', public_comment: 'bad server') Fabricate(:domain_block, domain: 'worse.domain', severity: 'suspend', reject_media: true, reject_reports: true, public_comment: 'worse server', obfuscate: true) Fabricate(:domain_block, domain: 'reject.media', severity: 'noop', reject_media: true, public_comment: 'reject media and test unicode characters ♥') - Fabricate(:domain_block, domain: 'little.spam', severity: 'noop', public_comment: 'has some spams', reject_favourite: true, reject_reply: true, reject_straight_follow: true) + Fabricate(:domain_block, domain: 'little.spam', severity: 'noop', public_comment: 'has some spams', reject_favourite: true, reject_straight_follow: true) Fabricate(:domain_block, domain: 'no.op', severity: 'noop', public_comment: 'noop') get :export, params: { format: :csv } @@ -48,11 +48,11 @@ def domain_blocks_csv_file end it 'renders page with extended domain blocks' do - expect(assigns(:domain_blocks).map { |block| [block.domain, block.reject_favourite, block.reject_reply, block.reject_friend] }).to contain_exactly( - ['bad.domain', false, false, false], - ['worse.domain', false, false, false], - ['reject.media', false, false, false], - ['little.spam', true, true, false] + expect(assigns(:domain_blocks).map { |block| [block.domain, block.reject_favourite, block.reject_friend] }).to contain_exactly( + ['bad.domain', false, false], + ['worse.domain', false, false], + ['reject.media', false, false], + ['little.spam', true, false] ) end diff --git a/spec/fixtures/files/domain_blocks.csv b/spec/fixtures/files/domain_blocks.csv index 066e6b7d985909..bb9daa1f68fcd2 100644 --- a/spec/fixtures/files/domain_blocks.csv +++ b/spec/fixtures/files/domain_blocks.csv @@ -1,5 +1,5 @@ -#domain,#severity,#reject_media,#reject_reports,#public_comment,#obfuscate,#reject_favourite,#reject_reply,#reject_send_sensitive,#reject_hashtag,#reject_straight_follow,#reject_new_follow,#hidden,#detect_invalid_subscription,#reject_reply_exclude_followers,#reject_friend,#block_trends -bad.domain,silence,false,false,bad server,false,false,false,false,false,false,false,false,false,false,false,false -worse.domain,suspend,true,true,worse server,true,false,false,false,false,false,false,false,false,false,false,false -reject.media,noop,true,false,reject media and test unicode characters ♥,false,false,false,false,false,false,false,false,false,false,false,false -little.spam,noop,false,false,has some spams,false,true,true,false,false,true,false,false,false,false,false,false +#domain,#severity,#reject_media,#reject_reports,#public_comment,#obfuscate,#reject_favourite,#reject_send_sensitive,#reject_hashtag,#reject_straight_follow,#reject_new_follow,#hidden,#detect_invalid_subscription,#reject_reply_exclude_followers,#reject_friend,#block_trends +bad.domain,silence,false,false,bad server,false,false,false,false,false,false,false,false,false,false,false +worse.domain,suspend,true,true,worse server,true,false,false,false,false,false,false,false,false,false,false +reject.media,noop,true,false,reject media and test unicode characters ♥,false,false,false,false,false,false,false,false,false,false,false +little.spam,noop,false,false,has some spams,false,true,false,false,true,false,false,false,false,false,false diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 5c668f1e3abdcf..7c91f55203eb11 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -869,36 +869,6 @@ def activity_for_object(json) end end - context 'with mentions domain block reject_reply' do - before do - Fabricate(:domain_block, domain: 'example.com', severity: :noop, reject_reply: true) - subject.perform - end - - let(:custom_before) { true } - let(:recipient) { Fabricate(:account) } - - let(:object_json) do - { - id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join, - type: 'Note', - content: 'Lorem ipsum', - tag: [ - { - type: 'Mention', - href: ActivityPub::TagManager.instance.uri_for(recipient), - }, - ], - } - end - - it 'creates status' do - status = sender.statuses.first - - expect(status).to be_nil - end - end - context 'with mentions domain block reject_reply_exclude_followers' do before do Fabricate(:domain_block, domain: 'example.com', severity: :noop, reject_reply_exclude_followers: true) diff --git a/spec/requests/api/v1/admin/domain_blocks_spec.rb b/spec/requests/api/v1/admin/domain_blocks_spec.rb index b0978da04c492b..9f7431b9c0fedb 100644 --- a/spec/requests/api/v1/admin/domain_blocks_spec.rb +++ b/spec/requests/api/v1/admin/domain_blocks_spec.rb @@ -62,7 +62,6 @@ reject_hashtag: domain_block.reject_hashtag, detect_invalid_subscription: domain_block.detect_invalid_subscription, reject_new_follow: domain_block.reject_new_follow, - reject_reply: domain_block.reject_reply, reject_reply_exclude_followers: domain_block.reject_reply_exclude_followers, reject_send_sensitive: domain_block.reject_send_sensitive, reject_straight_follow: domain_block.reject_straight_follow, @@ -112,7 +111,6 @@ reject_hashtag: domain_block.reject_hashtag, detect_invalid_subscription: domain_block.detect_invalid_subscription, reject_new_follow: domain_block.reject_new_follow, - reject_reply: domain_block.reject_reply, reject_reply_exclude_followers: domain_block.reject_reply_exclude_followers, reject_send_sensitive: domain_block.reject_send_sensitive, reject_straight_follow: domain_block.reject_straight_follow, @@ -145,7 +143,6 @@ reject_hashtag: domain_block.reject_hashtag, detect_invalid_subscription: domain_block.detect_invalid_subscription, reject_new_follow: domain_block.reject_new_follow, - reject_reply: domain_block.reject_reply, reject_reply_exclude_followers: domain_block.reject_reply_exclude_followers, reject_send_sensitive: domain_block.reject_send_sensitive, reject_straight_follow: domain_block.reject_straight_follow,