mirror of
https://github.com/discourse/discourse-solved.git
synced 2026-09-18 23:31:35 -04:00
FIX: Check if user has existing solution despite trust_level=any for first accepted solution validator used in automation (#377)
There exists a bug in the following trigger (see screenshot) where if the user has an existing solution already, they will still pass validation for "first accepted solution" due to the trust level being "any".
This commit is contained in:
@@ -5,15 +5,15 @@ module DiscourseSolved
|
||||
def self.check(post, trust_level:)
|
||||
return false if post.archetype != Archetype.default
|
||||
return false if !post&.user&.human?
|
||||
return true if trust_level == "any"
|
||||
|
||||
return false if TrustLevel.compare(post&.user&.trust_level, trust_level.to_i)
|
||||
|
||||
if !UserAction.where(user_id: post&.user_id, action_type: UserAction::SOLVED).exists?
|
||||
return true
|
||||
if trust_level != "any" && TrustLevel.compare(post&.user&.trust_level, trust_level.to_i)
|
||||
return false
|
||||
end
|
||||
|
||||
false
|
||||
!DiscourseSolved::SolvedTopic
|
||||
.joins(:answer_post)
|
||||
.where("posts.user_id = ?", post.user_id)
|
||||
.exists?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user