2021-11-12 10:00:48 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class FirstAcceptedPostSolutionValidator
|
|
|
|
def self.check(post, trust_level:)
|
|
|
|
return false if post.archetype != Archetype.default
|
|
|
|
return false if !post&.user&.human?
|
2022-12-23 15:36:08 -05:00
|
|
|
return true if trust_level == "any"
|
2021-11-12 10:00:48 -05:00
|
|
|
|
2022-12-23 15:36:08 -05:00
|
|
|
return false if TrustLevel.compare(post&.user&.trust_level, trust_level.to_i)
|
2021-11-12 10:00:48 -05:00
|
|
|
|
|
|
|
if !UserAction.where(user_id: post&.user_id, action_type: UserAction::SOLVED).exists?
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|