Skip to content

Commit

Permalink
Reject spammer
Browse files Browse the repository at this point in the history
  • Loading branch information
rosylilly authored and fono09 committed Feb 18, 2024
1 parent e6a4927 commit 9529aae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/lib/activitypub/activity/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ def process_status
ApplicationRecord.transaction do
@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
end
end

return if @status.nil?

resolve_thread(@status)
fetch_replies(@status)
distribute
Expand Down Expand Up @@ -426,4 +434,13 @@ def increment_voters_count!
poll.reload
retry
end

def like_a_spam?
(
!@status.account.local? &&
@status.account.followers_count.zero? &&
@status.account.created_at > 1.day.ago &&
@mentions.count >= 2
)
end
end

0 comments on commit 9529aae

Please sign in to comment.