Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject spammer #1941

Merged
merged 1 commit into from Feb 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/lib/activitypub/activity/create.rb
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