Skip to content

feat: switch pastéis mode and give pastéis from the API - #557

Merged
xHeaven merged 3 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-pasteis
Oct 19, 2026
Merged

xHeaven merged 3 commits into
dev-null-sh:productionfrom
simonhamp:feat/api-pasteis

Conversation

@simonhamp

@simonhamp simonhamp commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Lets the mobile app use pastéis mode the way the web does: switch it on or off, give pastéis, and show the counts. It follows #130, which added the signed API, and is one of a few small PRs for the endpoints the app (NativePHP/dev-null-app) uses on top of it.

Endpoints

All signed.

Request Answer
PUT /api/v1/me/pasteis-mode with {"enabled": true or false} Runs UpdateUserPasteisMode, like the switch in settings, and answers like GET /api/v1/me
POST /api/v1/commits/{id}/pasteis Runs CreateCommitPastel with the web's rules. 200 with the commit as its page shows it, plus pasteis_remaining, pasteis_resets_at and author_pasteis_received, the author's new total

Giving a pastel needs the mode on, someone else's commit the user may see, and one of the user's 10 a day, which come back at 00:00 UTC. With none left it's a 422 with the new code pasteis_exhausted and the web's message. It keeps the web's limit of 60 a minute.

GET /api/v1/me, and the answer after signing in on a new device, now carry pasteis_mode, pasteis_remaining, pasteis_resets_at and pasteis_received, from a new CurrentUserResource so only the user gets them. Signed commits always carry pasteis_count, and signed profiles pasteis_received.

Worth checking

  • Commits and profiles carry the counts whether the mode is on or off. The app only shows them in pastéis mode, like the web, but sending them either way keeps the app's cached answers right when the mode changes.
  • The settings PR (feat: sync from GitHub and save the lane color from the API #554) also adds a CurrentUserResource, for its own fields on /me. Whichever of the two merges second will conflict there, and the fix is to keep both sets of fields.
  • The saved commits PR (feat: star and save commits from the API #550) has a test that lists every field of a saved commit. Whichever of the two merges second needs 'pasteis_count' => 0 added to that list in BookmarkControllerTest.

Testing

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

The app's pastéis mode (NativePHP/dev-null-app#12) has been running against these endpoints on a phone.

The mobile app gets the web's pastéis mode, so it needs the same two
writes and the counts.

PUT /api/v1/me/pasteis-mode runs UpdateUserPasteisMode, like the switch
in the web's settings, and answers like GET /api/v1/me. That answer, and
the one after signing in, now carry pasteis_mode, pasteis_remaining,
pasteis_resets_at and pasteis_received, which only the signed-in user
gets.

POST /api/v1/commits/{commit}/pasteis runs CreateCommitPastel with the
web's rules: the mode is on, the commit is someone else's and the user
may see it, ten a day that come back at 00:00 UTC, and 60 a minute. It
answers with the commit as its page shows it, plus pasteis_remaining,
pasteis_resets_at and author_pasteis_received. With none left it is a
422 with the new pasteis_exhausted code and the web's message.

Signed commits now always carry pasteis_count and signed profiles
pasteis_received. The web only shows them in pastéis mode and so does
the app, but sending them either way keeps the app's kept answers right
when the mode changes.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@xHeaven
xHeaven merged commit 6340638 into dev-null-sh:production Oct 19, 2026
4 of 5 checks passed
@simonhamp
simonhamp deleted the feat/api-pasteis branch October 19, 2026 23:12
jubianchi added a commit to jubianchi/dev-null.sh that referenced this pull request Oct 22, 2026
The API's pastéis route (dev-null-sh#557) came with an unnamed `throttle:60,1`,
meant to share the web's 60 a minute: both keyed on the user alone.
With the web route on the `pasteis` limiter, the two drifted apart,
and the API test still incremented the old unnamed key, so nothing
caught it. The API route now uses `pasteis` too, and a test checks
that sixty pastéis on the web leave none for the API.

🤖 Generated with Claude Code
Claude-Session: https://claude.ai/code/session_01Dmjb753wbaMdaJa9vr3pKV
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.

3 participants