chore: correctly return server default notification preference when value is false#39142
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
WalkthroughThe change replaces a truthy check with an explicit undefined check in a notification preference utility function. This allows falsy server values (0, '', false) to be returned as valid server-derived preferences instead of being treated as absent. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1217 🏁 Script executed: Length of output: 631 🏁 Script executed: Length of output: 1768 🏁 Script executed: Length of output: 91 🏁 Script executed: Length of output: 0 🏁 Script executed: Length of output: 25266 🏁 Script executed: Length of output: 0
✅ The Fix is CorrectWhat Changed: // Before
if (serverValue)
// After
if (typeof serverValue !== 'undefined')Why It's Better:
Settings ContextFrom the codebase, notification preferences can be:
All of these are now properly handled. Great catch on this bug! 🎯 |
|
@KevLehman please take a look at this if you have time , thankyou :) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #39142 +/- ##
===========================================
+ Coverage 70.71% 70.72% +0.01%
===========================================
Files 3195 3195
Lines 113095 113095
Branches 20498 20489 -9
===========================================
+ Hits 79970 79986 +16
+ Misses 31082 31059 -23
- Partials 2043 2050 +7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Problem
getUserNotificationPreferencechecks server defaults using:if (
serverValue)This ignores valid falsy values such as
falseand0.As a result, when an admin sets Desktop Notifications default to Disabled, the API returns null/undefined instead of the configured default.
Reproduction
/api/v1/users.getPreferencesSolution
Check for undefined instead of truthiness:
This preserves valid
falsyconfiguration values.Impact
Ensures server default notification settings are respected and correctly returned by the API.
COMM-144
Summary by CodeRabbit