fix(comments): dismiss mention notifications and clear unread badge when viewed in activity sidebar - #60617
fix(comments): dismiss mention notifications and clear unread badge when viewed in activity sidebar#60617miaulalala wants to merge 1 commit into
Conversation
… in activity sidebar
Add a `DELETE /notifications/dismiss/{id}` endpoint to the comments
NotificationsController that marks the `comments/comment/mention`
notification as processed without redirecting.
When comments are loaded in the activity sidebar, the frontend calls
this endpoint for any comment that mentions the current user, so the
notification is cleared from the bell without requiring the user to
navigate via the notification link.
Fixes: nextcloud/activity#2531
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Anna Larch <anna@nextcloud.com>
4142aee to
964ba1c
Compare
|
/backport to stable34 |
|
/backport to stable33 |
…ivity sidebar Backport of #60617 to stable32. When the Activity app integration is active, comments are loaded in the Activity sidebar instead of the Comments tab. The read marker and mention notification dismissal were never triggered in this path, leaving the unread bubble in the file list and keeping mention notifications active. Also adds a new DELETE /notifications/{id} endpoint to dismiss individual mention notifications by comment ID. AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
…hen viewed in activity sidebar Backport of #60617 for stable31. When comments are loaded via the Activity sidebar integration, call markCommentsAsRead() so the file-row unread comment bubble clears after viewing. Also add a DELETE /notifications/{id} endpoint and call it for each comment that mentions the current user so the notification bell clears without navigating via the notification link. Fixes: nextcloud/activity#2531 AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
…ivity sidebar Backport of #60617 to stable32. When the Activity app integration is active, comments are loaded in the Activity sidebar instead of the Comments tab. The read marker and mention notification dismissal were never triggered in this path, leaving the unread bubble in the file list and keeping mention notifications active. Also adds a new DELETE /notifications/{id} endpoint to dismiss individual mention notifications by comment ID. AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
…hen viewed in activity sidebar Backport of #60617 for stable31. When comments are loaded via the Activity sidebar integration, call markCommentsAsRead() so the file-row unread comment bubble clears after viewing. Also add a DELETE /notifications/{id} endpoint and call it for each comment that mentions the current user so the notification bell clears without navigating via the notification link. Fixes: nextcloud/activity#2531 AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
…hen viewed in activity sidebar Backport of #60617 for stable31. When comments are loaded via the Activity sidebar integration, call markCommentsAsRead() so the file-row unread comment bubble clears after viewing. Also add a DELETE /notifications/{id} endpoint and call it for each comment that mentions the current user so the notification bell clears without navigating via the notification link. Fixes: nextcloud/activity#2531 AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
joshtrichards
left a comment
There was a problem hiding this comment.
Production code changes themselves seem fine, other than the share bit already commented on.
The only other note I have is that the Activity-tab code path that detects a current-user mention and sends the dismissal DELETE has no Cypress coverage.
| // Similarly the token is always set by the backend when the | ||
| // share is created. | ||
| this.share._share.token = share.token |
There was a problem hiding this comment.
Not sure what this is for - is this change unrelated to the PR?
There was a problem hiding this comment.
Also I have a suspicion this may be contributing the significant generated dist/ updates in this PR.
| const isMentioned = comment.props?.id && mentions.some((m) => m.mentionType === 'user' && m.mentionId === currentUser.uid) | ||
| if (isMentioned) { | ||
| axios.delete(generateUrl('/apps/comments/notifications/{id}', { id: comment.props.id })) | ||
| .catch(() => {}) |
There was a problem hiding this comment.
Rather than 100% silently discarding every DAV and notification failure maybe log a debug-level message with the file/comment ID and error so there's still some observability.
| $this->markProcessed($comment, $currentUser); | ||
| return new DataResponse([]); | ||
| } catch (\Exception $e) { | ||
| return new DataResponse([], Http::STATUS_NOT_FOUND); |
There was a problem hiding this comment.
Not necessarily a blocker for this narrow endpoint, but narrowing the caught exception to comment lookup related failures would avoid masking unrelated errors as missing comments and improve diagnosability.
| cy.visit('/apps/files') | ||
|
|
||
| // Verify badge is present first | ||
| getInlineActionEntryForFile('commented-file.txt', 'comments-unread') |
There was a problem hiding this comment.
Is this guaranteed to exercise the Activity path (the comments-activity-tab.ts implementation updated in this PR) rather than the old comments sidebar?
server/apps/comments/src/utils/activity.ts
Lines 8 to 13 in f5b5225
| .should('not.exist') | ||
| }) | ||
|
|
||
| it('badge stays absent after closing and re-opening the sidebar', () => { |
There was a problem hiding this comment.
Says "after closing and re-opening the sidebar" but only closes it, no?
Summary
markCommentsAsRead()(DAV PROPPATCH) so the file-row unread comment bubble clears after viewingnode.update({ 'comments-unread': 0 })so the bubble disappears without waiting for a PROPFIND refreshDELETE /apps/comments/notifications/{id}endpoint that marks acomments/comment/mentionnotification as processed without redirectingWithout this, opening the Activity sidebar for a file never triggered a DAV read-marker update, so the unread comment bubble persisted in the Files list even after viewing all comments. The notification bell also kept showing comment-mention notifications after the user had already read them in the sidebar.
Fixes: nextcloud/activity#2531
Test plan
DELETE /apps/comments/notifications/{id}endpoint returns 200 for a valid comment id, 403 if not logged in, 404 for unknown idsNOCOVERAGE=1 ./autotest.sh sqlite apps/comments/tests/Unit/Controller/NotificationsTest.phpcypress/e2e/comments/comments-unread.cy.ts🤖 Generated with Claude Code