stackernews / stacker.news

Internet communities that pay you Bitcoin
https://stacker.news
MIT License
403 stars 105 forks source link

Make Polls Anonymous #1197

Closed SatsAllDay closed 3 weeks ago

SatsAllDay commented 1 month ago

Description

Closes #1192

Introduce a PollBlindVote DB table that tracks when a user votes in a poll, but does not track which choice they made.

Alter the PollVote DB table to remove the userId column, meaning PollVote now tracks poll votes anonymously - it captures votes per poll option, but does not track which user submitted the vote.

Update the poll_vote DB function to work with both tables now.

Update the item.poll resolver to calculate meVoted based on the PollBlindVote table instead of PollVote.

No longer resolve meVoted on PollOptions.

No longer show a checkmark on the PollOption which was selected by the current user.

Screenshots

image

Additional Context

With this approach, if a user votes on a poll, but the voted PollOption is deleted during the poll edit window, that user will not be able to vote again, since we don't track which PollOption the user voted for.

Checklist

Are your changes backwards compatible? Please answer below: A DB migration was introduced which deletes some existing data, and API fields were removed, so not really backwards compatible, but the migration should keep all the data that we want to keep.

Did you QA this? Could we deploy this straight to production? Please answer below: Yes, I did.

For frontend changes: Tested on mobile? Please answer below: I did not test on mobile, given the limited scope of the UI changes.

Did you introduce any new environment variables? If so, call them out explicitly here: No.

huumn commented 3 weeks ago

Try as I might I couldn't fault it :)