Skip to content

Commit 26f74f8

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Add setting to disable the anti-spam (mastodon#11296)
* Add environment variable to disable the anti-spam * Move antispam setting to admin settings * Fix typo * antispam → spam_check
1 parent 704f606 commit 26f74f8

7 files changed

Lines changed: 18 additions & 1 deletion

File tree

app/controllers/admin/dashboard_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def index
3030
@trending_hashtags = TrendingTags.get(7)
3131
@profile_directory = Setting.profile_directory
3232
@timeline_preview = Setting.timeline_preview
33+
@spam_check_enabled = Setting.spam_check_enabled
3334
end
3435

3536
private

app/lib/spam_check.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(status)
1414
end
1515

1616
def skip?
17-
already_flagged? || trusted? || no_unsolicited_mentions? || solicited_reply?
17+
disabled? || already_flagged? || trusted? || no_unsolicited_mentions? || solicited_reply?
1818
end
1919

2020
def spam?
@@ -80,6 +80,10 @@ def digest_with_algorithm
8080

8181
private
8282

83+
def disabled?
84+
!Setting.spam_check_enabled
85+
end
86+
8387
def remove_mentions(text)
8488
return text.gsub(Account::MENTION_RE, '') if @status.local?
8589

app/models/form/admin_settings.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Form::AdminSettings
2828
thumbnail
2929
hero
3030
mascot
31+
spam_check_enabled
3132
).freeze
3233

3334
BOOLEAN_KEYS = %i(
@@ -39,6 +40,7 @@ class Form::AdminSettings
3940
show_known_fediverse_at_about_page
4041
preview_sensitive_media
4142
profile_directory
43+
spam_check_enabled
4244
).freeze
4345

4446
UPLOAD_KEYS = %i(

app/views/admin/dashboard/index.html.haml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
= feature_hint(link_to(t('admin.dashboard.feature_timeline_preview'), edit_admin_settings_path), @timeline_preview)
5252
%li
5353
= feature_hint(link_to(t('admin.dashboard.feature_relay'), admin_relays_path), @relay_enabled)
54+
%li
55+
= feature_hint(link_to(t('admin.dashboard.feature_spam_check'), edit_admin_settings_path), @spam_check_enabled)
5456

5557
.dashboard__widgets__versions
5658
%div

app/views/admin/settings/edit.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
.fields-group
6767
= f.input :profile_directory, as: :boolean, wrapper: :with_label, label: t('admin.settings.profile_directory.title'), hint: t('admin.settings.profile_directory.desc_html')
6868

69+
.fields-group
70+
= f.input :spam_check_enabled, as: :boolean, wrapper: :with_label, label: t('admin.settings.spam_check_enabled.title'), hint: t('admin.settings.spam_check_enabled.desc_html')
71+
6972
%hr.spacer/
7073

7174
.fields-group

config/locales/en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ en:
251251
feature_profile_directory: Profile directory
252252
feature_registrations: Registrations
253253
feature_relay: Federation relay
254+
feature_spam_check: Anti-spam
254255
feature_timeline_preview: Timeline preview
255256
features: Features
256257
hidden_service: Federation with hidden services
@@ -450,6 +451,9 @@ en:
450451
desc_html: You can write your own privacy policy, terms of service or other legalese. You can use HTML tags
451452
title: Custom terms of service
452453
site_title: Server name
454+
spam_check_enabled:
455+
desc_html: Mastodon can auto-silence and auto-report accounts based on measures such as detecting accounts who send repeated unsolicited messages. There may be false positives.
456+
title: Anti-spam
453457
thumbnail:
454458
desc_html: Used for previews via OpenGraph and API. 1200x630px recommended
455459
title: Server thumbnail

config/settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ defaults: &defaults
6161
activity_api_enabled: true
6262
peers_api_enabled: true
6363
show_known_fediverse_at_about_page: true
64+
spam_check_enabled: true
6465

6566
development:
6667
<<: *defaults

0 commit comments

Comments
 (0)