Add domain block sending params

This commit is contained in:
KMY 2023-04-27 17:40:39 +09:00
parent 98ced6d69e
commit 401847d8cc
13 changed files with 128 additions and 19 deletions

View file

@ -78,15 +78,15 @@ module Admin
end end
def update_params 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 end
def resource_params 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 end
def form_domain_block_batch_params 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 end
def action_from_button def action_from_button

View file

@ -69,7 +69,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
end end
def domain_block_params 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 end
def insert_pagination_headers def insert_pagination_headers
@ -101,6 +101,6 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
end end
def resource_params 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
end end

View file

@ -22,7 +22,7 @@ class StatusReachFinder
if @status.reblog? if @status.reblog?
[] []
else else
Account.where(id: reached_account_ids).inboxes Account.where(id: reached_account_ids).where.not(domain: banned_domains).inboxes
end end
end end
@ -93,4 +93,15 @@ class StatusReachFinder
def unsafe? def unsafe?
@options[:unsafe] @options[:unsafe]
end 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 end

View file

@ -34,6 +34,10 @@ class AccountStatusesFilter
def initial_scope def initial_scope
if suspended? if suspended?
Status.none 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? elsif anonymous?
account.statuses.where(visibility: %i(public unlisted public_unlisted)) account.statuses.where(visibility: %i(public unlisted public_unlisted))
elsif author? elsif author?
@ -131,4 +135,8 @@ class AccountStatusesFilter
def truthy_param?(key) def truthy_param?(key)
ActiveModel::Type::Boolean.new.cast(params[key]) ActiveModel::Type::Boolean.new.cast(params[key])
end end
def domain_block
@domain_block = DomainBlock.find_by(domain: @account&.domain)
end
end end

View file

@ -16,6 +16,12 @@
# obfuscate :boolean default(FALSE), not null # obfuscate :boolean default(FALSE), not null
# reject_favourite :boolean default(FALSE), not null # reject_favourite :boolean default(FALSE), not null
# reject_reply :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 class DomainBlock < ApplicationRecord

View file

@ -3,6 +3,8 @@
class REST::Admin::DomainBlockSerializer < ActiveModel::Serializer class REST::Admin::DomainBlockSerializer < ActiveModel::Serializer
attributes :id, :domain, :created_at, :severity, attributes :id, :domain, :created_at, :severity,
:reject_media, :reject_favourite, :reject_reply, :reject_reports, :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 :private_comment, :public_comment, :obfuscate
def id def id

View file

@ -23,6 +23,24 @@
.fields-group .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') = 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 .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') = 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')

View file

@ -23,6 +23,24 @@
.fields-group .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') = 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 .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') = 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')

View file

@ -12,6 +12,12 @@
= f.hidden_field :reject_media = f.hidden_field :reject_media
= f.hidden_field :reject_favourite = f.hidden_field :reject_favourite
= f.hidden_field :reject_reply = 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 :reject_reports
= f.hidden_field :obfuscate = f.hidden_field :obfuscate
= f.hidden_field :private_comment = f.hidden_field :private_comment

View file

@ -420,6 +420,18 @@ en:
reject_reply_hint: Reject replies in the future reject_reply_hint: Reject replies in the future
reject_reports: Reject reports reject_reports: Reject reports
reject_reports_hint: Ignore all reports coming from this domain. Irrelevant for suspensions 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 undo: Undo domain block
view: View domain block view: View domain block
email_domain_blocks: email_domain_blocks:

View file

@ -413,6 +413,18 @@ ja:
reject_reply_hint: 今後のリプライを拒否します。停止とは無関係です reject_reply_hint: 今後のリプライを拒否します。停止とは無関係です
reject_reports: 通報を拒否 reject_reports: 通報を拒否
reject_reports_hint: このドメインからの通報をすべて無視します。停止とは無関係です 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: ドメインブロックを戻す undo: ドメインブロックを戻す
view: ドメインブロックを表示 view: ドメインブロックを表示
email_domain_blocks: email_domain_blocks:

View file

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

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" 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 "obfuscate", default: false, null: false
t.boolean "reject_favourite", default: false, null: false t.boolean "reject_favourite", default: false, null: false
t.boolean "reject_reply", 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 t.index ["domain"], name: "index_domain_blocks_on_domain", unique: true
end end