discourse/plugins/poll/lib
Gabriel Grubba 1e48a5d535
FIX: Respect poll result visibility for ranked-choice outcomes (#40578)
Ranked-choice polls always serialized `ranked_choice_outcome` (the
computed winner and round-by-round activity) regardless of the poll's
`results` setting, unlike vote counts and voter lists, which are gated
by `Poll#can_see_results?`.


The outcome was therefore displayed to users who should not yet see
results on `on_vote`, `on_close`, and `staff_only` polls — through the
topic view, the vote/remove-vote responses, and the MessageBus
broadcast.

- Gate `ranked_choice_outcome` in `PollSerializer` behind
`can_see_results?`, matching the other result fields.
- Stop manually re-appending the outcome in `vote`/`remove_vote` so the
serializer's gating is authoritative.
- Serialize the MessageBus payload as an anonymous user so the
topic-wide broadcast only carries data any viewer may see, matching
`PollsUpdater.publish_changes`.
- Don't render an empty results panel to a non-staff voter on a
`staff_only` poll; show the ballot and the staff-only notice instead.



Relates to /t/-/185090
And Patch 998

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 12:04:38 -03:00
..
poll DEV: Clean up scope resolution operators in plugins (#34979) 2025-09-30 14:36:34 +02:00
poll.rb FIX: Respect poll result visibility for ranked-choice outcomes (#40578) 2026-06-04 12:04:38 -03:00
polls_updater.rb FEATURE: dynamic poll support (#34368) 2025-08-19 16:43:36 +10:00
polls_validator.rb DEV: Clean up scope resolution operators in plugins (#34979) 2025-09-30 14:36:34 +02:00
post_extension.rb DEV: Enable Style/RedundantSelf rubocop rule (#40098) 2026-05-19 19:27:45 +02:00
post_validator.rb
ranked_choice.rb FIX: poll ranked choice result algo majority check (#28191) 2024-08-02 08:51:26 +02:00
user_extension.rb DEV: Update rubocop-discourse to latest version 2024-03-04 15:08:35 +01:00