discourse-solved/lib/discourse_solved/first_accepted_post_solution_validator.rb
Natalie Tay e82c6ae1ca
DEV: Autoload and segregate features to prep for migration (#341)
This commit autoloads plugin files, and also extracts features into their own modules.
- `plugin.rb` is smaller
- external plugins like discourse-automation and discourse-assign have their own entrypoints
- solved filters as well
2025-03-21 11:45:19 +08:00

20 lines
517 B
Ruby

# frozen_string_literal: true
module DiscourseSolved
class FirstAcceptedPostSolutionValidator
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
end
false
end
end
end