diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index 3eb7b50d3f..a4818aa2f2 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -78,15 +78,15 @@ module Admin end def update_params - params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate) + params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_send_not_public_searchability, :reject_send_unlisted_dissubscribable, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_reports, :private_comment, :public_comment, :obfuscate) end def resource_params - params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate) + params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_send_not_public_searchability, :reject_send_unlisted_dissubscribable, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_reports, :private_comment, :public_comment, :obfuscate) 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_reports, :private_comment, :public_comment, :obfuscate]) + params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_send_not_public_searchability, :reject_send_unlisted_dissubscribable, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_reports, :private_comment, :public_comment, :obfuscate]) end def action_from_button diff --git a/app/controllers/api/v1/admin/domain_blocks_controller.rb b/app/controllers/api/v1/admin/domain_blocks_controller.rb index 2fea6c12b1..bbb7e2ad58 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_reports, :private_comment, :public_comment, :obfuscate) + params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :reject_send_not_public_searchability, :reject_send_unlisted_dissubscribable, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :private_comment, :public_comment, :obfuscate) end def insert_pagination_headers @@ -101,6 +101,6 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController end def resource_params - params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reports, :private_comment, :public_comment, :obfuscate) + params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_send_not_public_searchability, :reject_send_unlisted_dissubscribable, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_reports, :private_comment, :public_comment, :obfuscate) end end diff --git a/app/lib/status_reach_finder.rb b/app/lib/status_reach_finder.rb index cbcc0e6b61..0e04c541a1 100644 --- a/app/lib/status_reach_finder.rb +++ b/app/lib/status_reach_finder.rb @@ -22,7 +22,7 @@ class StatusReachFinder if @status.reblog? [] else - Account.where(id: reached_account_ids).inboxes + Account.where(id: reached_account_ids).where.not(domain: banned_domains).inboxes end end @@ -93,4 +93,15 @@ class StatusReachFinder def unsafe? @options[:unsafe] end + + def banned_domains + blocks = [] + blocks << DomainBlock.where(reject_send_not_public_searchability: true).pluck(:domain) if @status.computed_searchability != 'public' + blocks << DomainBlock.where(reject_send_unlisted_dissubscribable: true).pluck(:domain) if @status.unlisted_visibility? && @status.account.dissubscribable + blocks << DomainBlock.where(reject_send_public_unlisted: true).pluck(:domain) if @status.public_unlisted_visibility? + blocks << DomainBlock.where(reject_send_dissubscribable: true).pluck(:domain) if @status.account.dissubscribable + blocks << DomainBlock.where(reject_send_media: true).pluck(:domain) if @status.with_media? + blocks << DomainBlock.where(reject_send_sensitive: true).pluck(:domain) if (@status.with_media? && @status.sensitive) || @status.spoiler_text + return blocks.uniq + end end diff --git a/app/models/account_statuses_filter.rb b/app/models/account_statuses_filter.rb index 068ab329e9..ee8b8ec2cf 100644 --- a/app/models/account_statuses_filter.rb +++ b/app/models/account_statuses_filter.rb @@ -34,6 +34,10 @@ class AccountStatusesFilter def initial_scope if suspended? Status.none + elsif domain_block != nil && (domain_block&.reject_send_not_public_searchability || domain_block&.reject_send_unlisted_dissubscribable || + domain_block&.reject_send_public_unlisted || domain_block&.reject_send_media || domain_block&.reject_send_sensitive || + domain_block&.reject_send_sensitive) + Status.none elsif anonymous? account.statuses.where(visibility: %i(public unlisted public_unlisted)) elsif author? @@ -131,4 +135,8 @@ class AccountStatusesFilter def truthy_param?(key) ActiveModel::Type::Boolean.new.cast(params[key]) end + + def domain_block + @domain_block = DomainBlock.find_by(domain: @account&.domain) + end end diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 2d864e95c4..25b002bef0 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -4,18 +4,24 @@ # # Table name: domain_blocks # -# id :bigint(8) not null, primary key -# domain :string default(""), not null -# created_at :datetime not null -# updated_at :datetime not null -# severity :integer default("silence") -# reject_media :boolean default(FALSE), not null -# reject_reports :boolean default(FALSE), not null -# private_comment :text -# public_comment :text -# obfuscate :boolean default(FALSE), not null -# reject_favourite :boolean default(FALSE), not null -# reject_reply :boolean default(FALSE), not null +# id :bigint(8) not null, primary key +# domain :string default(""), not null +# created_at :datetime not null +# updated_at :datetime not null +# severity :integer default("silence") +# reject_media :boolean default(FALSE), not null +# reject_reports :boolean default(FALSE), not null +# private_comment :text +# 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_not_public_searchability :boolean default(FALSE), not null +# reject_send_unlisted_dissubscribable :boolean default(FALSE), not null +# reject_send_public_unlisted :boolean default(FALSE), not null +# reject_send_dissubscribable :boolean default(FALSE), not null +# reject_send_media :boolean default(FALSE), not null +# reject_send_sensitive :boolean default(FALSE), not null # class DomainBlock < ApplicationRecord diff --git a/app/serializers/rest/admin/domain_block_serializer.rb b/app/serializers/rest/admin/domain_block_serializer.rb index f82abba16f..bcc8246d99 100644 --- a/app/serializers/rest/admin/domain_block_serializer.rb +++ b/app/serializers/rest/admin/domain_block_serializer.rb @@ -3,6 +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_send_unlisted_dissubscribable, + :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :private_comment, :public_comment, :obfuscate def id diff --git a/app/views/admin/domain_blocks/edit.html.haml b/app/views/admin/domain_blocks/edit.html.haml index 5cf43397ad..b433d88ee5 100644 --- a/app/views/admin/domain_blocks/edit.html.haml +++ b/app/views/admin/domain_blocks/edit.html.haml @@ -23,6 +23,24 @@ .fields-group = f.input :reject_reply, as: :boolean, 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_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_unlisted_dissubscribable, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_unlisted_dissubscribable'), hint: I18n.t('admin.domain_blocks.reject_send_unlisted_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_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_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') + + .fields-group + = f.input :reject_send_sensitive, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_sensitive'), hint: I18n.t('admin.domain_blocks.reject_send_sensitive_hint') + .fields-group = f.input :reject_reports, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reports'), hint: I18n.t('admin.domain_blocks.reject_reports_hint') diff --git a/app/views/admin/domain_blocks/new.html.haml b/app/views/admin/domain_blocks/new.html.haml index df78adc0d7..68be819bb7 100644 --- a/app/views/admin/domain_blocks/new.html.haml +++ b/app/views/admin/domain_blocks/new.html.haml @@ -23,6 +23,24 @@ .fields-group = f.input :reject_reply, as: :boolean, 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_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_unlisted_dissubscribable, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_unlisted_dissubscribable'), hint: I18n.t('admin.domain_blocks.reject_send_unlisted_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_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_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') + + .fields-group + = f.input :reject_send_sensitive, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_send_sensitive'), hint: I18n.t('admin.domain_blocks.reject_send_sensitive_hint') + .fields-group = f.input :reject_reports, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_reports'), hint: I18n.t('admin.domain_blocks.reject_reports_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 05a9571bc9..9919ce29ab 100644 --- a/app/views/admin/export_domain_blocks/_domain_block.html.haml +++ b/app/views/admin/export_domain_blocks/_domain_block.html.haml @@ -12,6 +12,12 @@ = f.hidden_field :reject_media = f.hidden_field :reject_favourite = f.hidden_field :reject_reply + = f.hidden_field :reject_send_not_public_searchability + = f.hidden_field :reject_send_unlisted_dissubscribable + = 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_reports = f.hidden_field :obfuscate = f.hidden_field :private_comment diff --git a/config/locales/en.yml b/config/locales/en.yml index 612bb4b27a..7cbd8761fd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -420,6 +420,18 @@ en: reject_reply_hint: Reject replies 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: 購読拒否アカウントの未収載投稿を配送しない + reject_send_unlisted_dissubscribable_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です undo: Undo domain block view: View domain block email_domain_blocks: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index b5bde81ea8..e79e97c80a 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -413,6 +413,18 @@ ja: reject_reply_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: 購読拒否アカウントの未収載投稿を配送しない + reject_send_unlisted_dissubscribable_hint: 相手サーバーからのフェッチは防げません。停止とは無関係です undo: ドメインブロックを戻す view: ドメインブロックを表示 email_domain_blocks: diff --git a/db/migrate/20230427072650_add_reject_sending_to_domain_blocks.rb b/db/migrate/20230427072650_add_reject_sending_to_domain_blocks.rb new file mode 100644 index 0000000000..0679cb3003 --- /dev/null +++ b/db/migrate/20230427072650_add_reject_sending_to_domain_blocks.rb @@ -0,0 +1,10 @@ +class AddRejectSendingToDomainBlocks < ActiveRecord::Migration[6.1] + def change + add_column :domain_blocks, :reject_send_not_public_searchability, :boolean, null: false, default: false + add_column :domain_blocks, :reject_send_unlisted_dissubscribable, :boolean, null: false, default: false + add_column :domain_blocks, :reject_send_public_unlisted, :boolean, null: false, default: false + add_column :domain_blocks, :reject_send_dissubscribable, :boolean, null: false, default: false + add_column :domain_blocks, :reject_send_media, :boolean, null: false, default: false + add_column :domain_blocks, :reject_send_sensitive, :boolean, null: false, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index adb2b6914a..df5bd58832 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.define(version: 2023_04_27_022606) do +ActiveRecord::Schema.define(version: 2023_04_27_072650) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -470,6 +470,12 @@ ActiveRecord::Schema.define(version: 2023_04_27_022606) do 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_not_public_searchability", default: false, null: false + t.boolean "reject_send_unlisted_dissubscribable", default: false, null: false + t.boolean "reject_send_public_unlisted", default: false, null: false + t.boolean "reject_send_dissubscribable", default: false, null: false + t.boolean "reject_send_media", default: false, null: false + t.boolean "reject_send_sensitive", default: false, null: false t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true end