Repository navigation
Conversation
…ts them too The web kept the Replies/Quotes/Stars/Mentions/Follows/Moderation choice in a cookie per browser, so the API could not read it and every unread_notifications_count it sent counted every kind. The choice now lives in users.notification_types, a browser's old cookie is taken over the first time it is seen, and PUT /api/v1/me/notification-types lets apps change it.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Summary
The notifications page remembers which kinds you want to see (Replies, Quotes, Stars, Mentions, Follows, Moderation) in a cookie per user. The API can't read that cookie, so every
unread_notifications_countthe API sends counts every kind. In the mobile app (NativePHP/dev-null-app#178) you pick the kinds on a settings screen, but the badge on the Notifications tab still counts the ones you turned off.This keeps the choice on the user instead, so the web, the API and every browser see the same one.
Changes
users.notification_typescolumn. It holds the same value?type=takes:all,noneor a comma list.nullmeans never chosen and shows everything.ListNotificationsRequest::type()saves the choice through a newUpdateUserNotificationTypesaction instead of queuing a cookie.rememberedType()reads the column. If the column is still empty and the browser has a valid old cookie, it takes that value over and expires the cookie, so nobody loses their filter on deploy.UsersUpdated(UserUpdate::Notifications) when the value actually changes, so paging through the list with the same?type=does nothing extra. When it does change, other open tabs refresh their count.NotificationGroupsQuery::unreadCount()now defaults to the user's saved kinds instead ofall. That covers every API controller that addsunread_notifications_count, without touching each one. Passing a type still overrides it.GET /api/v1/notifications?type=...now saves the type too, the same as the web. Without?type=it lists the saved kinds, as the web does.GET /api/v1/me/settingshasnotification_types, and the data export has it underprofile.KNOWLEDGE_BASE.md, and the notifications paragraph now says the filter follows the account.API
PUT /api/v1/me/notification-types, signed like the rest of/api/v1/me.{ "type": "replies,mentions" }typeis required and takes the same values as the list's?type=. It answers200with the saved value and the unread count, which now only counts those kinds:{ "data": { "type": "replies,mentions" }, "unread_notifications_count": 3 }A bad value gets
422witherrors.type. Unsigned requests get401.Validation
Local, PHP 8.5.12, PostgreSQL with its own test database:
vendor/bin/pint --teston the changed files: passrector --dry-run: passphpstan: pass, no errorspest --type-coverage --min=100: 100%NotificationInboxTest, the newUserNotificationTypesControllerTest,ExportControllerTest,HandleInertiaRequestsTest,NotificationGroupsQueryTest, all oftests/Feature/Controllers/Api): 1158 passed--ci: 6126 tests, 6107 passed and 19 failed. All 19 are intests/Feature/CommitScriptTest.phpand fail the same way on unchangedproductionhere (the shell script sandbox doesn't run on this machine), so they are not from this change. The suite ran with all three of my API PRs merged together.bun run test:unit,test:lint,test:types: not run, no JS or TS changed.Independent review
A read-only Claude review agent with the repo's
.ai/guidelinesand the diff againstproductionat 2ef29e7, head 7df935e: CODE: PASS. It pointed out two things to decide on, both covered above: the API list now saves?type=, and the first cookie takeover writes during a GET (once per user). Visual review doesn't apply, the web UI is unchanged.Limitations
?type=will now get the user's saved kinds instead of everything. The app's next release reads and sets them.?type=, their old cookie stays until it expires. It is never read again.