From 3eca8cce1ce501aebcbf140e8c7fe90316d75ff6 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 29 Jul 2025 10:59:16 +0200 Subject: [PATCH] Add second set of blocked text that applies to accounts regardless of account age (#35563) --- app/lib/antispam.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/lib/antispam.rb b/app/lib/antispam.rb index 4ebf1924854..69c862a5c10 100644 --- a/app/lib/antispam.rb +++ b/app/lib/antispam.rb @@ -33,9 +33,7 @@ class Antispam end def local_preflight_check!(status) - return unless spammy_texts.any? { |spammy_text| status.text.include?(spammy_text) } - return unless suspicious_reply_or_mention?(status) - return unless status.account.created_at >= ACCOUNT_AGE_EXEMPTION.ago + return unless considered_spam?(status) report_if_needed!(status.account) @@ -44,10 +42,26 @@ class Antispam private + def considered_spam?(status) + (all_time_suspicious?(status) || recent_suspicious?(status)) && suspicious_reply_or_mention?(status) + end + + def all_time_suspicious?(status) + all_time_spammy_texts.any? { |spammy_text| status.text.include?(spammy_text) } + end + + def recent_suspicious?(status) + status.account.created_at >= ACCOUNT_AGE_EXEMPTION.ago && spammy_texts.any? { |spammy_text| status.text.include?(spammy_text) } + end + def spammy_texts redis.smembers('antispam:spammy_texts') end + def all_time_spammy_texts + redis.smembers('antispam:all_time_spammy_texts') + end + def suspicious_reply_or_mention?(status) parent = status.thread return true if parent.present? && !Follow.exists?(account_id: parent.account_id, target_account: status.account_id)