mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Add second set of blocked text that applies to accounts regardless of account age (#35563)
This commit is contained in:
parent
d299b0d576
commit
3eca8cce1c
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user