Skip to content

Commit

Permalink
Remove: #608 ドメインブロック「リプライを拒否」 (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode authored Mar 1, 2024
1 parent dc3aabb commit 76b2419
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 82 deletions.
6 changes: 3 additions & 3 deletions app/controllers/admin/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/admin/export_domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -86,7 +85,6 @@ def export_headers
#public_comment
#obfuscate
#reject_favourite
#reject_reply
#reject_send_sensitive
#reject_hashtag
#reject_straight_follow
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/admin/domain_blocks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
9 changes: 0 additions & 9 deletions app/lib/activitypub/activity/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/admin/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 1 addition & 8 deletions app/models/domain_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/rest/admin/domain_block_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/domain_blocks/_domain_block_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: 今後のリプライを拒否します。停止とは無関係です
Expand Down Expand Up @@ -566,7 +565,6 @@ ja:
reject_hashtag: ハッシュタグを拒否
reject_media: メディアを拒否する
reject_new_follow: 新規フォローを拒否
reject_reply: リプライを拒否
reject_reply_exclude_followers: フォロー相手以外からのメンション・参照を拒否
reject_reports: 通報を拒否
reject_send_sensitive: センシティブ投稿配送なし
Expand Down
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/tasks/dangerous.rake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ namespace :dangerous do
20240227033337
20240227222450
20240227225017
20240229233617
)
# Removed: account_groups
target_tables = %w(
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/admin/export_domain_blocks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions spec/fixtures/files/domain_blocks.csv
Original file line number Diff line number Diff line change
@@ -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
30 changes: 0 additions & 30 deletions spec/lib/activitypub/activity/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions spec/requests/api/v1/admin/domain_blocks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 76b2419

Please sign in to comment.