mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: FlagSockpuppets should not flag a post if a post of that user was already rejected by staff (#9328)
* FIX: FlagSockpuppets should not flag a post if a post of that user was already rejected by staff * Update spec/services/flag_sockpuppets_spec.rb Co-Authored-By: Robin Ward <robin.ward@gmail.com> Co-authored-by: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
@@ -19,8 +19,6 @@ class SpamRule::FlagSockpuppets
|
||||
|
||||
def reply_is_from_sockpuppet?
|
||||
return false if @post.try(:post_number) == 1
|
||||
|
||||
first_post = @post.topic.posts.by_post_number.first
|
||||
return false if first_post.user.nil?
|
||||
|
||||
!first_post.user.staff? &&
|
||||
@@ -41,11 +39,22 @@ class SpamRule::FlagSockpuppets
|
||||
locale: SiteSetting.default_locale
|
||||
)
|
||||
|
||||
PostActionCreator.create(Discourse.system_user, @post, :spam, message: message)
|
||||
flag_post(@post, message)
|
||||
|
||||
if (first_post = @post.topic.posts.by_post_number.first).try(:user).try(:new_user?)
|
||||
PostActionCreator.create(Discourse.system_user, first_post, :spam, message: message)
|
||||
end
|
||||
flag_post(first_post, message) if first_post&.user&.new_user?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def flag_post(post, message)
|
||||
can_trust_user = ReviewableFlaggedPost.where(status: Reviewable.statuses[:rejected], target_created_by: post.user).exists?
|
||||
return if can_trust_user
|
||||
|
||||
PostActionCreator.create(Discourse.system_user, post, :spam, message: message)
|
||||
end
|
||||
|
||||
def first_post
|
||||
@first_post ||= @post.topic.posts.by_post_number.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user