From 5ba8141df9f2768037d75baf9eac7e03e0cbfe0e Mon Sep 17 00:00:00 2001 From: KMY Date: Wed, 10 Jan 2024 18:20:12 +0900 Subject: [PATCH] =?UTF-8?q?Remove:=20#372=20=E5=89=8A=E9=99=A4=E4=BA=88?= =?UTF-8?q?=E5=AE=9A=E3=81=AE=E3=83=89=E3=83=A1=E3=82=A4=E3=83=B3=E3=83=96?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=82=AF=E9=A0=85=E7=9B=AE=E3=82=92=E3=81=84?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=82=93=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/domain_blocks_controller.rb | 6 ++--- .../api/v1/admin/domain_blocks_controller.rb | 4 ++-- app/lib/account_statuses_filter.rb | 24 +++++++++++++++---- app/lib/status_reach_finder.rb | 3 --- app/models/domain_block.rb | 3 --- app/policies/status_policy.rb | 5 +--- .../rest/admin/domain_block_serializer.rb | 4 ++-- app/views/admin/domain_blocks/edit.html.haml | 9 ------- app/views/admin/domain_blocks/new.html.haml | 9 ------- .../_domain_block.html.haml | 3 --- config/locales/en.yml | 6 ----- config/locales/ja.yml | 9 ------- .../api/v1/admin/domain_blocks_spec.rb | 6 ----- 13 files changed, 27 insertions(+), 64 deletions(-) diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index ed8f425de9..f4039ca8f3 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -88,17 +88,17 @@ module Admin end def update_params - params.require(:domain_block).permit(: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, + params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :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_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, + params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :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, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, + params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden]) end diff --git a/app/controllers/api/v1/admin/domain_blocks_controller.rb b/app/controllers/api/v1/admin/domain_blocks_controller.rb index c1a45145cb..130e58dc4d 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 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController end 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, + params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden) end @@ -102,7 +102,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController end 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, + params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden) end end diff --git a/app/lib/account_statuses_filter.rb b/app/lib/account_statuses_filter.rb index 9a4a2b5d6e..e470a2ff11 100644 --- a/app/lib/account_statuses_filter.rb +++ b/app/lib/account_statuses_filter.rb @@ -29,9 +29,8 @@ class AccountStatusesFilter available_searchabilities = [:public, :unlisted, :private, :direct, :limited, nil] available_visibilities = [:public, :public_unlisted, :login, :unlisted, :private, :direct, :limited] - available_searchabilities = [:public] if domain_block&.reject_send_not_public_searchability - available_visibilities -= [:public_unlisted] if domain_block&.reject_send_public_unlisted || (domain_block&.detect_invalid_subscription && @account.user&.setting_reject_public_unlisted_subscription) - available_visibilities -= [:unlisted] if domain_block&.detect_invalid_subscription && @account.user&.setting_reject_unlisted_subscription + available_visibilities -= [:public_unlisted] if (domain_block&.detect_invalid_subscription || misskey_software?) && @account.user&.setting_reject_public_unlisted_subscription + available_visibilities -= [:unlisted] if (domain_block&.detect_invalid_subscription || misskey_software?) && @account.user&.setting_reject_unlisted_subscription available_visibilities -= [:login] if current_account.nil? scope.merge!(scope.where(spoiler_text: ['', nil])) if domain_block&.reject_send_sensitive @@ -44,7 +43,7 @@ class AccountStatusesFilter private def initial_scope - if (suspended? || (domain_block&.reject_send_dissubscribable && @account.dissubscribable)) || domain_block&.reject_send_media || blocked? + if suspended? || domain_block&.reject_send_media || blocked? Status.none elsif anonymous? account.statuses.where(visibility: %i(public unlisted public_unlisted)) @@ -156,6 +155,21 @@ class AccountStatusesFilter end def domain_block - @domain_block = DomainBlock.find_by(domain: @account&.domain) + return nil if @account.nil? || @account.local? + + @domain_block = DomainBlock.find_by(domain: @account.domain) + end + + def misskey_software? + return false if @account.nil? || @account.local? + return false if instance_info.nil? + + %w(misskey cherrypick).include?(instance_info.software) + end + + def instance_info + return @instance_info if defined?(@instance_info) + + @instance_info = InstanceInfo.find_by(domain: @account.domain) end end diff --git a/app/lib/status_reach_finder.rb b/app/lib/status_reach_finder.rb index c7069c7dac..e67f3a9f33 100644 --- a/app/lib/status_reach_finder.rb +++ b/app/lib/status_reach_finder.rb @@ -143,9 +143,6 @@ class StatusReachFinder [] else blocks = DomainBlock.where(domain: nil) - blocks = blocks.or(DomainBlock.where(reject_send_not_public_searchability: true)) if status.compute_searchability != 'public' - blocks = blocks.or(DomainBlock.where(reject_send_public_unlisted: true)) if status.public_unlisted_visibility? - blocks = blocks.or(DomainBlock.where(reject_send_dissubscribable: true)) if status.account.dissubscribable blocks = blocks.or(DomainBlock.where(reject_send_media: true)) if status.with_media? blocks = blocks.or(DomainBlock.where(reject_send_sensitive: true)) if (status.with_media? && status.sensitive) || status.spoiler_text? blocks.pluck(:domain).uniq diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 37703fec99..9d78db0fc1 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -59,9 +59,6 @@ class DomainBlock < ApplicationRecord reject_favourite? ? :reject_favourite : nil, reject_reply? ? :reject_reply : nil, reject_reply_exclude_followers? ? :reject_reply_exclude_followers : nil, - reject_send_not_public_searchability? ? :reject_send_not_public_searchability : nil, - reject_send_public_unlisted? ? :reject_send_public_unlisted : nil, - reject_send_dissubscribable? ? :reject_send_dissubscribable : nil, reject_send_media? ? :reject_send_media : nil, reject_send_sensitive? ? :reject_send_sensitive : nil, reject_hashtag? ? :reject_hashtag : nil, diff --git a/app/policies/status_policy.rb b/app/policies/status_policy.rb index 335abe9e92..585f54146b 100644 --- a/app/policies/status_policy.rb +++ b/app/policies/status_policy.rb @@ -121,10 +121,7 @@ class StatusPolicy < ApplicationPolicy (@domain_block.detect_invalid_subscription && status.public_unlisted_visibility? && status.account.user&.setting_reject_public_unlisted_subscription) || (@domain_block.detect_invalid_subscription && status.public_visibility? && status.account.user&.setting_reject_unlisted_subscription) else - (@domain_block.reject_send_not_public_searchability && status.compute_searchability != 'public') || - (@domain_block.reject_send_public_unlisted && status.public_unlisted_visibility?) || - (@domain_block.reject_send_dissubscribable && status.account.dissubscribable) || - (@domain_block.detect_invalid_subscription && status.public_unlisted_visibility? && status.account.user&.setting_reject_public_unlisted_subscription) || + (@domain_block.detect_invalid_subscription && status.public_unlisted_visibility? && status.account.user&.setting_reject_public_unlisted_subscription) || (@domain_block.detect_invalid_subscription && status.public_visibility? && status.account.user&.setting_reject_unlisted_subscription) || (@domain_block.reject_send_media && status.with_media?) || (@domain_block.reject_send_sensitive && ((status.with_media? && status.sensitive) || status.spoiler_text?)) diff --git a/app/serializers/rest/admin/domain_block_serializer.rb b/app/serializers/rest/admin/domain_block_serializer.rb index e7cdc40ad1..a4776ba4ce 100644 --- a/app/serializers/rest/admin/domain_block_serializer.rb +++ b/app/serializers/rest/admin/domain_block_serializer.rb @@ -3,8 +3,8 @@ class REST::Admin::DomainBlockSerializer < ActiveModel::Serializer attributes :id, :domain, :created_at, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, - :reject_send_not_public_searchability, :reject_reply_exclude_followers, - :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, + :reject_reply_exclude_followers, + :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate diff --git a/app/views/admin/domain_blocks/edit.html.haml b/app/views/admin/domain_blocks/edit.html.haml index 4a59178c08..9f189d4ee6 100644 --- a/app/views/admin/domain_blocks/edit.html.haml +++ b/app/views/admin/domain_blocks/edit.html.haml @@ -23,15 +23,6 @@ .fields-group = f.input :reject_reply_exclude_followers, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply_exclude_followers'), hint: I18n.t('admin.domain_blocks.reject_reply_exclude_followers_hint') - .fields-group - = f.input :reject_send_not_public_searchability, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_not_public_searchability'), hint: I18n.t('admin.domain_blocks.reject_send_not_public_searchability_hint') - - .fields-group - = f.input :reject_send_dissubscribable, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_dissubscribable'), hint: I18n.t('admin.domain_blocks.reject_send_dissubscribable_hint') - - .fields-group - = f.input :reject_send_public_unlisted, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_public_unlisted'), hint: I18n.t('admin.domain_blocks.reject_send_public_unlisted_hint') - .fields-group = f.input :reject_send_media, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_media'), hint: I18n.t('admin.domain_blocks.reject_send_media_hint') diff --git a/app/views/admin/domain_blocks/new.html.haml b/app/views/admin/domain_blocks/new.html.haml index bb64b515fd..e6649485fa 100644 --- a/app/views/admin/domain_blocks/new.html.haml +++ b/app/views/admin/domain_blocks/new.html.haml @@ -23,15 +23,6 @@ .fields-group = f.input :reject_reply_exclude_followers, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reply_exclude_followers'), hint: I18n.t('admin.domain_blocks.reject_reply_exclude_followers_hint') - .fields-group - = f.input :reject_send_not_public_searchability, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_not_public_searchability'), hint: I18n.t('admin.domain_blocks.reject_send_not_public_searchability_hint') - - .fields-group - = f.input :reject_send_dissubscribable, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_dissubscribable'), hint: I18n.t('admin.domain_blocks.reject_send_dissubscribable_hint') - - .fields-group - = f.input :reject_send_public_unlisted, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_public_unlisted'), hint: I18n.t('admin.domain_blocks.reject_send_public_unlisted_hint') - .fields-group = f.input :reject_send_media, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_media'), hint: I18n.t('admin.domain_blocks.reject_send_media_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 6b2f0227f5..360a2e7384 100644 --- a/app/views/admin/export_domain_blocks/_domain_block.html.haml +++ b/app/views/admin/export_domain_blocks/_domain_block.html.haml @@ -13,9 +13,6 @@ = f.hidden_field :reject_favourite = f.hidden_field :reject_reply = f.hidden_field :reject_reply_exclude_followers - = f.hidden_field :reject_send_not_public_searchability - = f.hidden_field :reject_send_public_unlisted - = f.hidden_field :reject_send_dissubscribable = f.hidden_field :reject_send_media = f.hidden_field :reject_send_sensitive = f.hidden_field :reject_hashtag diff --git a/config/locales/en.yml b/config/locales/en.yml index ecb59c9463..8e32d3f273 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -438,14 +438,8 @@ en: reject_reply_exclude_followers_hint: Reject replies exclude followers in the future reject_reports: Reject reports reject_reports_hint: Ignore all reports coming from this domain. Irrelevant for suspensions - reject_send_dissubscribable: 購読拒否アカウントの投稿を配送しない - reject_send_dissubscribable_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です reject_send_media: 画像付き投稿を配送しない reject_send_media_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です - reject_send_not_public_searchability: 検索許可が「誰でも」でない投稿を配送しない - reject_send_not_public_searchability_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です - reject_send_public_unlisted: ローカル公開投稿を配送しない - reject_send_public_unlisted_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です reject_send_sensitive: センシティブな投稿を配送しない reject_send_sensitive_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です reject_send_unlisted_dissubscribable: 購読拒否アカウントの未収載投稿を配送しない diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 89684ce637..9977523292 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -432,14 +432,8 @@ ja: reject_reply_exclude_followers_hint: 今後のリプライを拒否します。停止とは無関係です reject_reports: 通報を拒否 reject_reports_hint: このドメインからの通報をすべて無視します。停止とは無関係です - reject_send_dissubscribable: 購読拒否アカウントの投稿を配送しない - reject_send_dissubscribable_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です reject_send_media: 画像付き投稿を配送しない reject_send_media_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です - reject_send_not_public_searchability: 検索許可が「誰でも」でない投稿を配送しない - reject_send_not_public_searchability_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です - reject_send_public_unlisted: ローカル公開投稿を配送しない - reject_send_public_unlisted_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です reject_send_sensitive: センシティブな投稿を配送しない reject_send_sensitive_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です reject_send_unlisted_dissubscribable: 購読拒否アカウントの未収載投稿を配送しない @@ -518,10 +512,7 @@ ja: reject_reply: リプライを拒否 reject_reply_exclude_followers: フォロー相手以外からのリプライを拒否 reject_reports: 通報を拒否 - reject_send_dissubscribable: 購読拒否投稿配送なし reject_send_media: メディア付き投稿配送なし - reject_send_not_public_searchability: 検索許可全て投稿配送なし - reject_send_public_unlisted: ローカル公開投稿配送なし reject_send_sensitive: センシティブ投稿配送なし reject_send_unlisted_dissubscribable: 購読拒否未収載投稿配送なし reject_straight_follow: フォローを制限 diff --git a/spec/requests/api/v1/admin/domain_blocks_spec.rb b/spec/requests/api/v1/admin/domain_blocks_spec.rb index 1432e52623..c5fa7f15fb 100644 --- a/spec/requests/api/v1/admin/domain_blocks_spec.rb +++ b/spec/requests/api/v1/admin/domain_blocks_spec.rb @@ -78,10 +78,7 @@ RSpec.describe 'Domain Blocks' do 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_dissubscribable: domain_block.reject_send_dissubscribable, reject_send_media: domain_block.reject_send_media, - reject_send_not_public_searchability: domain_block.reject_send_not_public_searchability, - reject_send_public_unlisted: domain_block.reject_send_public_unlisted, reject_send_sensitive: domain_block.reject_send_sensitive, reject_straight_follow: domain_block.reject_straight_follow, } @@ -130,10 +127,7 @@ RSpec.describe 'Domain Blocks' do 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_dissubscribable: domain_block.reject_send_dissubscribable, reject_send_media: domain_block.reject_send_media, - reject_send_not_public_searchability: domain_block.reject_send_not_public_searchability, - reject_send_public_unlisted: domain_block.reject_send_public_unlisted, reject_send_sensitive: domain_block.reject_send_sensitive, reject_straight_follow: domain_block.reject_straight_follow, }