Repository navigation
feat: sync from GitHub and save the lane color from the API - #554
Merged
Merged
Conversation
The mobile app's Account screen now works like the web's profile settings, so it needs the same two writes. PUT /api/v1/me/github runs UpdateUserProfile, like Sync from GitHub. It shares the web's profile-syncs limit of one a minute, which now answers API requests with a rate_limited JSON error instead of a redirect. When GitHub can't be reached the app gets a 503 with github_sync_failed and the web's message. PUT /api/v1/me/lane runs UpdateUserLane with the web's rules: a lane from 0 to 5, null for Automatic, or a custom color as lowercase #rrggbb with a null lane, as the web's color picker does. Both answer like GET /api/v1/me. That answer, and the one after signing in, now also carry preferred_lane (a lane, a custom color or null), automatic_lane, sponsors_url and github_synced_at, which only the signed-in user gets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lets the mobile app's Account screen do what the web's profile settings do: sync the profile from GitHub and pick a lane color. 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. Both writes answer like
GET /api/v1/me.PUT /api/v1/me/githubUpdateUserProfile, like Sync from GitHub.503with the new codegithub_sync_failedand the web's message when GitHub can't be reached.429withrate_limitedover the web's limit of one sync a minute.PUT /api/v1/me/lanewith{"lane": 0-5 or null, "color": "#rrggbb"}UpdateUserLanewith the web's rules.nullmeans Automatic.coloris a custom color for the web's color picker, only with anulllane.GET /api/v1/me, and the answer after signing in on a new device, now also carry what only the user sees in settings:preferred_lane(a lane, a custom color, ornull),automatic_lane,sponsors_urlandgithub_synced_at. They come from a newCurrentUserResource, so other people's profiles never get them.Worth checking
profile-syncslimiter now answers API requests with arate_limitedJSON error, and keeps the toast and redirect for the web.CurrentUserResourcefor its own fields on/me. Whichever of the two merges second will conflict there, and the fix is to keep both sets of fields.Testing
Everything CI runs passes on this branch locally: Pint, Rector, the JS lint, PHPStan, tsc, type coverage, and all 2,977 tests at 100% coverage.
The app's Account screen has been running against these endpoints on a phone.