Browse Source

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

Fix #12113
master^2
Eugen Rochko 1 week ago
parent
commit
b5f7e12817
No account linked to committer's email address

+ 1
- 6
app/lib/spam_check.rb View File

@@ -44,7 +44,6 @@ class SpamCheck
44 44
   end
45 45
 
46 46
   def flag!
47
-    auto_silence_account!
48 47
     auto_report_status!
49 48
   end
50 49
 
@@ -134,17 +133,13 @@ class SpamCheck
134 133
     text.gsub(/\s+/, ' ').strip
135 134
   end
136 135
 
137
-  def auto_silence_account!
138
-    @account.silence!
139
-  end
140
-
141 136
   def auto_report_status!
142 137
     status_ids = Status.where(visibility: %i(public unlisted)).where(id: matching_status_ids).pluck(:id) + [@status.id] if @status.distributable?
143 138
     ReportService.new.call(Account.representative, @account, status_ids: status_ids, comment: I18n.t('spam_check.spam_detected_and_silenced'))
144 139
   end
145 140
 
146 141
   def already_flagged?
147
-    @account.silenced?
142
+    @account.silenced? || @account.targeted_reports.unresolved.where(account_id: -99).exists?
148 143
   end
149 144
 
150 145
   def trusted?

+ 1
- 1
app/models/account.rb View File

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

+ 12
- 0
app/models/admin/account_action.rb View File

@@ -62,6 +62,8 @@ class Admin::AccountAction
62 62
 
63 63
   def process_action!
64 64
     case type
65
+    when 'none'
66
+      handle_resolve!
65 67
     when 'disable'
66 68
       handle_disable!
67 69
     when 'silence'
@@ -103,6 +105,16 @@ class Admin::AccountAction
103 105
     end
104 106
   end
105 107
 
108
+  def handle_resolve!
109
+    if with_report? && report.account_id == -99 && target_account.trust_level == Account::TRUST_LEVELS[:untrusted]
110
+      # This is an automated report and it is being dismissed, so it's
111
+      # a false positive, in which case update the account's trust level
112
+      # to prevent further spam checks
113
+
114
+      target_account.update(trust_level: Account::TRUST_LEVELS[:trusted])
115
+    end
116
+  end
117
+
106 118
   def handle_disable!
107 119
     authorize(target_account.user, :disable?)
108 120
     log_action(:disable, target_account.user)

+ 1
- 1
config/locales/en.yml View File

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

+ 0
- 4
spec/lib/spam_check_spec.rb View File

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

Loading…
Cancel
Save