Remove auto-silence behaviour from spam check (#12117)

Fix #12113
pull/12116/head
Eugen Rochko 2019-10-09 07:11:23 +02:00 committed by GitHub
parent 354fdd317e
commit b5f7e12817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 12 deletions

View File

@ -44,7 +44,6 @@ class SpamCheck
end end
def flag! def flag!
auto_silence_account!
auto_report_status! auto_report_status!
end end
@ -134,17 +133,13 @@ class SpamCheck
text.gsub(/\s+/, ' ').strip text.gsub(/\s+/, ' ').strip
end end
def auto_silence_account!
@account.silence!
end
def auto_report_status! def auto_report_status!
status_ids = Status.where(visibility: %i(public unlisted)).where(id: matching_status_ids).pluck(:id) + [@status.id] if @status.distributable? status_ids = Status.where(visibility: %i(public unlisted)).where(id: matching_status_ids).pluck(:id) + [@status.id] if @status.distributable?
ReportService.new.call(Account.representative, @account, status_ids: status_ids, comment: I18n.t('spam_check.spam_detected_and_silenced')) ReportService.new.call(Account.representative, @account, status_ids: status_ids, comment: I18n.t('spam_check.spam_detected_and_silenced'))
end end
def already_flagged? def already_flagged?
@account.silenced? @account.silenced? || @account.targeted_reports.unresolved.where(account_id: -99).exists?
end end
def trusted? def trusted?

View File

@ -198,7 +198,7 @@ class Account < ApplicationRecord
end end
def unsilence! def unsilence!
update!(silenced_at: nil, trust_level: trust_level == TRUST_LEVELS[:untrusted] ? TRUST_LEVELS[:trusted] : trust_level) update!(silenced_at: nil)
end end
def suspended? def suspended?

View File

@ -62,6 +62,8 @@ class Admin::AccountAction
def process_action! def process_action!
case type case type
when 'none'
handle_resolve!
when 'disable' when 'disable'
handle_disable! handle_disable!
when 'silence' when 'silence'
@ -103,6 +105,16 @@ class Admin::AccountAction
end end
end end
def handle_resolve!
if with_report? && report.account_id == -99 && target_account.trust_level == Account::TRUST_LEVELS[:untrusted]
# This is an automated report and it is being dismissed, so it's
# a false positive, in which case update the account's trust level
# to prevent further spam checks
target_account.update(trust_level: Account::TRUST_LEVELS[:trusted])
end
end
def handle_disable! def handle_disable!
authorize(target_account.user, :disable?) authorize(target_account.user, :disable?)
log_action(:disable, target_account.user) log_action(:disable, target_account.user)

View File

@ -497,7 +497,7 @@ en:
title: Custom terms of service title: Custom terms of service
site_title: Server name site_title: Server name
spam_check_enabled: spam_check_enabled:
desc_html: Mastodon can auto-silence and auto-report accounts that send repeated unsolicited messages. There may be false positives. desc_html: Mastodon can auto-report accounts that send repeated unsolicited messages. There may be false positives.
title: Anti-spam automation title: Anti-spam automation
thumbnail: thumbnail:
desc_html: Used for previews via OpenGraph and API. 1200x630px recommended desc_html: Used for previews via OpenGraph and API. 1200x630px recommended

View File

@ -181,10 +181,6 @@ RSpec.describe SpamCheck do
described_class.new(status2).flag! described_class.new(status2).flag!
end end
it 'silences the account' do
expect(sender.silenced?).to be true
end
it 'creates a report about the account' do it 'creates a report about the account' do
expect(sender.targeted_reports.unresolved.count).to eq 1 expect(sender.targeted_reports.unresolved.count).to eq 1
end end