mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FEATURE: Show votes in an "on voted" poll to the creator
This required properly plumbing the guardian into the serializer. Notably, the default state in the client was not changed - if you haven't voted in the poll, you need to click the button to view the results instead of the results being immediately visible on page load. Implements https://meta.discourse.org/t/-/138108
This commit is contained in:
@ -93,7 +93,7 @@ module DiscoursePoll
|
||||
|
||||
if has_changed
|
||||
polls = ::Poll.includes(poll_options: :poll_votes).where(post: post)
|
||||
polls = ActiveModel::ArraySerializer.new(polls, each_serializer: PollSerializer, root: false).as_json
|
||||
polls = ActiveModel::ArraySerializer.new(polls, each_serializer: PollSerializer, root: false, scope: Guardian.new(nil)).as_json
|
||||
post.publish_message!("/polls/#{post.topic_id}", post_id: post.id, polls: polls)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user