This took me a while to figure out @tgxworld - it looks like validations are skipped for discobot’s replies, and the validations are what builds the post JSON.
My question is: is skip_validations necessary for every discobot reply? If we enabled validations for the poll reply it would work. Is there any downside to that?
Otherwise the following patch works, but you see a flash as the post gets saved a second time:
diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb
index 2139a175cd..d84f4fc16e 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/advanced_user_narrative.rb
@@ -321,7 +321,12 @@ module DiscourseNarrativeBot
RAW
fake_delay
- reply_to(@post, raw)
+
+ # Save the post and poll
+ poll_post = reply_to(@post, raw)
+ generated_poll = DiscoursePoll::PollsValidator.new(poll_post).validate_polls
+ poll_post.custom_fields[DiscoursePoll::POLLS_CUSTOM_FIELD] = generated_poll
+ poll_post.save_custom_fields(true)
else
fake_delay
reply_to(@post, I18n.t("#{I18N_KEY}.poll.not_found", i18n_post_args)) unless @data[:attempted]