Add second set of blocked text that applies to accounts regardless of account age (#35563)

This commit is contained in:
Claire 2025-07-29 10:59:16 +02:00 committed by GitHub
parent d299b0d576
commit 3eca8cce1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)