FIX: makes sur we have polls before validating

This commit is contained in:
Joffrey JAFFEUX 2017-12-05 12:07:21 -05:00 committed by GitHub
parent daeb7694bc
commit 067d454937
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -312,12 +312,14 @@ after_initialize do
# only care when raw has changed!
return unless self.raw_changed? || force
validator = DiscoursePoll::PostValidator.new(self)
return unless validator.validate_post
validator = DiscoursePoll::PollsValidator.new(self)
return unless (polls = validator.validate_polls)
if !polls.empty?
validator = DiscoursePoll::PostValidator.new(self)
return unless validator.validate_post
end
# are we updating a post?
if self.id.present?
DistributedMutex.synchronize("#{PLUGIN_NAME}-#{self.id}") do