Skip to content

feat: start polls from the API - #662

Merged
xHeaven merged 7 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-commit-polls
Oct 22, 2026
Merged

xHeaven merged 7 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-commit-polls

Conversation

@simonhamp

@simonhamp simonhamp commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Lets the mobile app start a poll with a new commit or a quote, as the web's composer does. 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 now takes an optional poll:

{"body": "Tabs or spaces?", "poll": {"options": ["Tabs", "Spaces"], "duration": 1440}}

The rules are the web's own, from CreateCommitRequest::attachmentRules(): 2 to 4 options of up to 50 characters, no two the same ignoring case, and a duration in minutes, one of 60, 1440, 4320 or 10080. A reply can't have a poll, so poll next to parent_id is a 422, as on the web. The poll goes through the web's CreateCommit, so option labels get their emoji shortcodes replaced.

The 201 has the commit with its poll. The poll opens when the commit is approved, so a pending commit's poll has no closes_at yet, and an admin's opens right away.

Testing

Everything CI runs passes on this branch locally: Pint, Rector, the JS lint, PHPStan, tsc, type coverage, and all 3,256 tests at 100% coverage.

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.

A new commit or a quote from the app can carry a poll, with the web's
rules for its options and duration. A reply can't, as on the web.
@simonhamp
simonhamp marked this pull request as ready for review October 19, 2026 23:50
@xHeaven
xHeaven merged commit 8b66758 into dev-null-sh:production Oct 22, 2026
5 checks passed
@simonhamp
simonhamp deleted the feat/api-commit-polls branch October 22, 2026 10:10
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