fix(notification): the badge congratulations dialog can always be dismissed - #1633
Open
rstrzelecki-inne-projekty wants to merge 1 commit into
Open
rstrzelecki-inne-projekty wants to merge 1 commit into
rstrzelecki-inne-projekty wants to merge 1 commit into
Conversation
…missed Closing the dialog calls PUT /notification/read/state, which returned success while doing nothing whenever the notification row behind the alert was gone or belonged to somebody else: the guard returned early and the alert stayed in the red dot cache, so /notification/status kept serving the same badge_award and the dialog came back on every page load with no way to close it. A revoked badge deletes its notification, which is exactly how the rows go missing. The alert now leaves the cache before the notification row is looked up. The cache key is built from the caller's own user id, so a request can only ever clear the caller's own alert. The test fails on the current code and passes with the fix.
rstrzelecki-inne-projekty
pushed a commit
to rstrzelecki-inne-projekty/answer
that referenced
this pull request
Sep 22, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
The "congratulations, you earned a badge" dialog reads its content from the red dot cache (
GET /notification/status→badge_award). Closing it callsPUT /answer/api/v1/notification/read/state, andNotificationService.ClearIDUnReaddoes this:When the notification row behind the alert is missing, the method returns
nil, the endpoint answers200, and the alert is never removed./notification/statuskeeps returning the samebadge_award, so the dialog comes back on the next page load — and there is no way to close it, because every attempt takes the same early return.The rows do go missing in practice: revoking a badge deletes its notification while the alert stays in the cache. The same early return also skips the cleanup when the notification is already read or belongs to another user.
Observed on a live instance:
PUT /notification/read/stateanswered{"code":200}repeatedly while/notification/statuskept serving the samebadge_award, whosenotification_idno longer appeared in/notification/page.Change
The alert is removed from the cache before the notification row is looked up. The cache key is built from the caller's own user id (
RedDotCacheKey+ the login user), so a request can only ever clear the caller's own alert — passing somebody else's notification id does nothing to them.Tests
internal/service/notification/badge_alert_test.goputs an alert in the cache, has the repository report the notification as missing, dismisses it and asserts the alert is gone. It fails on the current code ("the badge alert is still there, the dialog would come back") and passes with the fix.