FIX: properly secure poll message bus

Co-authored-by: Sam <sam.saffron@gmail.com>
This commit is contained in:
Régis Hanol
2018-12-05 21:27:49 +01:00
parent 8aff99761a
commit aea2d8bbeb
4 changed files with 76 additions and 18 deletions

View File

@ -102,7 +102,7 @@ after_initialize do
serialized_poll = PollSerializer.new(poll, root: false).as_json
payload = { post_id: post_id, polls: [serialized_poll] }
MessageBus.publish("/polls/#{post.topic_id}", payload)
post.publish_message!("/polls/#{post.topic_id}", payload)
[serialized_poll, options]
end
@ -137,7 +137,7 @@ after_initialize do
serialized_poll = PollSerializer.new(poll, root: false).as_json
payload = { post_id: post_id, polls: [serialized_poll] }
MessageBus.publish("/polls/#{post.topic_id}", payload)
post.publish_message!("/polls/#{post.topic_id}", payload)
serialized_poll
end
@ -425,7 +425,7 @@ after_initialize do
unless post.is_first_post?
polls = ActiveModel::ArraySerializer.new(post.polls, each_serializer: PollSerializer, root: false).as_json
MessageBus.publish("/polls/#{post.topic_id}", post_id: post.id, polls: polls)
post.publish_message!("/polls/#{post.topic_id}", post_id: post.id, polls: polls)
end
end