Skip to content

Commit e88a63d

Browse files
rosylillynaaaaaaaaaaaf
authored andcommitted
Reject spammer
1 parent 48acbf4 commit e88a63d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/lib/activitypub/activity/create.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,16 @@ def process_status
8585
ApplicationRecord.transaction do
8686
@status = Status.create!(@params)
8787
attach_tags(@status)
88+
89+
# Delete status on zero follower user and nearly created account with include some replies
90+
if like_a_spam?
91+
@status = nil
92+
raise ActiveRecord::Rollback
93+
end
8894
end
8995

96+
return if @status.nil?
97+
9098
resolve_thread(@status)
9199
fetch_replies(@status)
92100
distribute
@@ -426,4 +434,13 @@ def increment_voters_count!
426434
poll.reload
427435
retry
428436
end
437+
438+
def like_a_spam?
439+
(
440+
!@status.account.local? &&
441+
@status.account.followers_count.zero? &&
442+
@status.account.created_at > 1.day.ago &&
443+
@mentions.count >= 2
444+
)
445+
end
429446
end

0 commit comments

Comments
 (0)