-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: handle null message in CustomPushNotification to prevent crashes #6678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Caution Review failedThe pull request is closed. WalkthroughAdds an early null check in extractMessage of CustomPushNotification to return an empty string when message is null; existing parsing and substring logic remain unchanged and no public signatures were modified. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
android/app/src/main/java/chat/rocket/reactnative/notification/CustomPushNotification.java (1)
247-253
: Skip/handle empty notification messages (avoid blank notifications)
- Use extractMessage(...) when setting content text in getNotificationBuilder so the notification body matches MessagingStyle; if the result is empty/null, use a fallback (e.g., title) or omit setContentText.
- Before calling InboxStyle.addLine(message) and MessagingStyle.addMessage(m, ...), skip adding when message == null or m.trim().isEmpty().
- Alternatively, have extractMessage return null for “no message” and treat null as “do not display” in the two places above.
File: android/app/src/main/java/chat/rocket/reactnative/notification/CustomPushNotification.java — methods: getNotificationBuilder, notificationStyle, extractMessage.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
android/app/src/main/java/chat/rocket/reactnative/notification/CustomPushNotification.java
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: ESLint and Test / run-eslint-and-test
🔇 Additional comments (1)
android/app/src/main/java/chat/rocket/reactnative/notification/CustomPushNotification.java (1)
244-246
: LGTM! Critical null safety improvement.The null check for the message parameter in extractMessage is a critical improvement that will prevent crashes when null messages are encountered in push notifications. The early return of an empty string when message is null is appropriate, as it allows the notification processing to continue gracefully rather than crashing.
Based on the PR objectives, this addresses the referenced crash issue and follows Android development best practices for null safety. The implementation is minimal, focused, and doesn't alter the existing logic flow for non-null cases.
Android Build Available Rocket.Chat Experimental 4.65.0.107405 Internal App Sharing: https://play.google.com/apps/test/RQVpXLytHNc/ahAO29uNTd4bhj_J_nvWjZXAuz0QPUU7KSP4Fqq3GsQEJmW4YSzGIB9NgWXi6i-aKCmznl-kiLWTy4ajDWLkwUuseH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
370b8f6
to
2ef7d97
Compare
Proposed changes
Issue(s)
#6661 (comment)
How to test or reproduce
Screenshots
Types of changes
Checklist
Further comments
Summary by CodeRabbit
Bug Fixes
Improvements