Skip to content

Commit

Permalink
Make configurational with environment vars for Reject spammer
Browse files Browse the repository at this point in the history
  • Loading branch information
rosylilly authored and 204504bySE committed Feb 19, 2024
1 parent ac07c8a commit 6f1076a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/lib/activitypub/activity/create.rb
Expand Up @@ -85,7 +85,6 @@ def process_status
@status = Status.create!(@params)
attach_tags(@status)

# Delete status on zero follower user and nearly created account with include some replies
if like_a_spam?
@status = nil
raise ActiveRecord::Rollback
Expand Down Expand Up @@ -457,12 +456,15 @@ def quote_from_url(url)
nil
end

SPAM_FILTER_MINIMUM_FOLLOWERS = ENV.fetch('SPAM_FILTER_MINIMUM_FOLLOWERS', 0).to_i
SPAM_FILTER_MINIMUM_CREATE_DAYS = ENV.fetch('SPAM_FILTER_MINIMUM_CREATE_DAYS', 1).to_i
SPAM_FILTER_MINIMUM_MENTIONS = ENV.fetch('SPAM_FILTER_MINIMUM_MENTIONS', 1).to_i
def like_a_spam?
(
!@status.account.local? &&
@status.account.followers_count.zero? &&
@status.account.created_at > 1.day.ago &&
@mentions.count >= 2
@status.account.followers_count > SPAM_FILTER_MINIMUM_FOLLOWERS &&
@status.account.created_at > SPAM_FILTER_MINIMUM_CREATE_DAYS.day.ago &&
@mentions.count > SPAM_FILTER_MINIMUM_MENTIONS
)
end
end

0 comments on commit 6f1076a

Please sign in to comment.