fix: ensure livechat callbacks fire only on actual updates + code quality improvements#38476
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
WalkthroughFour files receive targeted improvements: callback invocation is now conditional in livechat utilities (executed only when records are modified), a clarifying comment update in OAuth2 URI parsing, a new test case for empty message parsing, and a documentation typo correction in message reaction context. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. 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. Comment |
|
|
Hi maintainers! I realize this PR contains multiple unrelated changes (callback fix, typo correction, comment update, and test addition). As a first-time contributor, I'm still learning the best practices. I'm happy to close this and split into separate PRs if that would be preferred. Please let me know how you'd like me to proceed. I'll ensure future contributions follow the one-change-per-PR practice. |
|
Hi maintainers, I’m closing this PR because it bundled multiple unrelated changes and is now superseded by smaller, single-concern PRs to make review easier. I’ve split the original changes into focused follow-ups (livechat callback fix, apps-engine typo fix, OAuth comment clarification, and empty-message parsing test). Thanks for the guidance and patience while I learned the preferred contribution workflow. |
Summary
This PR addresses several code quality improvements across the Rocket.Chat codebase, focusing on bug fixes, documentation accuracy, and test coverage enhancement.
Motivation
While exploring the codebase, I identified the following opportunities for improvement:
Livechat Callback Optimization: The
livechat.setUserStatusLivechatcallback was firing regardless of whether a database update actually occurred, potentially causing unnecessary processing and spurious notifications.Documentation Typo: A spelling error in the Apps-Engine type definitions could cause confusion for developers integrating with the API.
Code Clarity: A TODO comment in the OAuth URI parsing function was unclear about the function's intentional behavior.
Test Coverage Gap: Empty message edge case was not covered in the markdown parsing tests.
Changes Made
Bug Fix: Livechat Status Callback
File:
apps/meteor/app/livechat/server/lib/utils.tsMoved
callbacks.runAsync('livechat.setUserStatusLivechat', ...)inside theif (modifiedCount > 0)conditional blocks in bothsetUserStatusLivechat()andsetUserStatusLivechatIf()functions. This ensures callbacks only execute when the database state actually changes, preventing unnecessary event processing.Before: Callback fired on every function call
After: Callback fires only when
modifiedCount > 0Documentation Fix: Typo Correction
File:
packages/apps-engine/src/definition/messages/IMessageReactionContext.tsFixed typo in JSDoc comment:
recieved→receivedDocumentation Improvement: OAuth URI Parsing
File:
apps/meteor/app/oauth2-server-config/server/admin/functions/parseUriList.tsReplaced ambiguous TODO comment with clear documentation explaining the function's intentional behavior of normalizing URIs to a comma-delimited string for consistent storage.
Test Coverage: Empty Message Handling
File:
apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.tsAdded unit test to verify that
parseMessageTextToAstMarkdown()correctly returns an emptymdarray when the message content is empty. This ensures the edge case is covered and prevents potential regressions.Testing
Type of Change
Checklist
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests