Skip to content

feat: vote on polls from the API - #663

Merged
xHeaven merged 2 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-poll-votes
Oct 22, 2026
Merged

xHeaven merged 2 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-poll-votes

Conversation

@simonhamp

@simonhamp simonhamp commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Lets the mobile app vote on a poll, as the web's Vote button does. So far the app could only show polls. It follows #130 and is one of a few small PRs for the endpoints the app (NativePHP/dev-null-app) uses on top of it.

Endpoint

POST /api/v1/commits/{id}/poll/votes takes the option id and answers 200 with the commit as its page shows it, so the app gets the poll with its results straight away.

It uses the web's CreateCommitPollVote and OpenPoll, so the rules are the web's:

  • Votes are final. A second vote is a 422 on option: "You have already voted on this poll."
  • Authors see their results instead of voting: "You can't vote on your own poll."
  • A poll that isn't open yet, or has closed, is a 422 that says so.
  • A missing option, or an option of another poll, is a 422.
  • Muting someone doesn't stop a vote on their poll.

A commit the user may not see (pending, rejected, deleted or across a block) is a 404, like starring one. The web answers 403 there, but the API hides what the user can't see.

Testing

Everything CI runs passes on this branch locally: Pint, Rector, the JS lint, PHPStan, tsc, type coverage, and all 3,623 tests at 100% coverage. KNOWLEDGE_BASE.md lists voting among what a signed request can do.

The app side is NativePHP/dev-null-app#24. It ran against all four of these PRs merged together on an iOS simulator: photos from the library with a description, a poll, the preview, a reply with a photo, and a vote.

Answers with the commit as its page shows it, so the app gets the poll's
results once the vote is in. Votes are final and authors can't vote, as
on the web.
@simonhamp
simonhamp force-pushed the feat/api-poll-votes branch from 85a7237 to 3f74eb3 Compare October 21, 2026 00:54
@xHeaven
xHeaven merged commit 1ca6538 into dev-null-sh:production Oct 22, 2026
5 checks passed
@simonhamp
simonhamp deleted the feat/api-poll-votes branch October 22, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants