Skip to content
Permalink
Browse files

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

Fix #12113
  • Loading branch information...
Gargron committed Oct 9, 2019
1 parent 354fdd3 commit b5f7e12817356b9b1795ab0187fe08d07f13a485
Showing with 15 additions and 12 deletions.
  1. +1 −6 app/lib/spam_check.rb
  2. +1 −1 app/models/account.rb
  3. +12 −0 app/models/admin/account_action.rb
  4. +1 −1 config/locales/en.yml
  5. +0 −4 spec/lib/spam_check_spec.rb
@@ -44,7 +44,6 @@ def spam?
end

def flag!
auto_silence_account!
auto_report_status!
end

@@ -134,17 +133,13 @@ def remove_whitespace(text)
text.gsub(/\s+/, ' ').strip
end

def auto_silence_account!
@account.silence!
end

def auto_report_status!
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'))

This comment has been minimized.

Copy link
@ThibG

ThibG Oct 10, 2019

Collaborator

This string needs to be changed too, as it says the reported user has been silenced, which is not the case anymore.

end

def already_flagged?
@account.silenced?
@account.silenced? || @account.targeted_reports.unresolved.where(account_id: -99).exists?
end

def trusted?
@@ -198,7 +198,7 @@ def silence!(date = Time.now.utc)
end

def unsilence!
update!(silenced_at: nil, trust_level: trust_level == TRUST_LEVELS[:untrusted] ? TRUST_LEVELS[:trusted] : trust_level)
update!(silenced_at: nil)
end

def suspended?
@@ -62,6 +62,8 @@ def types_for_account(account)

def process_action!
case type
when 'none'
handle_resolve!
when 'disable'
handle_disable!
when 'silence'
@@ -103,6 +105,16 @@ def process_reports!
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!
authorize(target_account.user, :disable?)
log_action(:disable, target_account.user)
@@ -497,7 +497,7 @@ en:
title: Custom terms of service
site_title: Server name
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
thumbnail:
desc_html: Used for previews via OpenGraph and API. 1200x630px recommended
@@ -181,10 +181,6 @@ def status_with_html(text, options = {})
described_class.new(status2).flag!
end

it 'silences the account' do
expect(sender.silenced?).to be true
end

it 'creates a report about the account' do
expect(sender.targeted_reports.unresolved.count).to eq 1
end

0 comments on commit b5f7e12

Please sign in to comment.
You can’t perform that action at this time.