FIX: poll plugin wasn't working when the OP was deleted

Alternatively fixes issue reported -> https://meta.discourse.org/t/bug-with-flag-as-spam/25359
This commit is contained in:
Régis Hanol 2015-02-18 20:33:05 +01:00
parent fed9943d90
commit f916087e81

View file

@ -6,20 +6,16 @@ module ::PollPlugin
end
def is_poll?
if !@post.post_number.nil? and @post.post_number > 1
# Not a new post, and also not the first post.
return false
end
# Not a new post, and also not the first post.
return false if @post.post_number.present? && @post.post_number > 1
topic = @post.topic
# Topic is not set in a couple of cases in the Discourse test suite.
return false if topic.nil?
return false if topic.nil? || topic.user.nil?
if @post.post_number.nil? and topic.highest_post_number > 0
# New post, but not the first post in the topic.
return false
end
# New post, but not the first post in the topic.
return false if @post.post_number.nil? && topic.highest_post_number > 0
I18n.with_locale(topic.user.effective_locale) do
topic.title =~ /^(#{I18n.t('poll.prefix').strip}|#{I18n.t('poll.closed_prefix').strip})\s?:/i