Skip to content

Commit

Permalink
Reject spammer
Browse files Browse the repository at this point in the history
  • Loading branch information
rosylilly committed Feb 18, 2024
1 parent 198e893 commit d3518f4
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 @@ -83,8 +83,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 d3518f4

Please sign in to comment.