-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix problem #453
base: dev
Are you sure you want to change the base?
Fix problem #453
Conversation
WalkthroughThe changes in the Changes
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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: 1
🧹 Nitpick comments (2)
service/src/main/java/greencity/security/service/PasswordRecoveryServiceImpl.java (2)
79-83
: Consider extracting the name determination logic into a utility method.The recipient name determination logic is duplicated later in the file. Let's improve maintainability by extracting it into a reusable method.
+ private String determineRecipientName(User user) { + if (user.getName() != null && !user.getName().isBlank()) { + return user.getName(); + } + if (user.getFirstName() != null && !user.getFirstName().isBlank()) { + return user.getFirstName(); + } + return "User"; + } @Transactional @Override public void updatePasswordUsingToken(OwnRestoreDto form) { // ... existing code ... - String recipientName = (user.getName() != null && !user.getName().isBlank()) - ? user.getName() - : (user.getFirstName() != null && !user.getFirstName().isBlank() - ? user.getFirstName() - : "User"); + String recipientName = determineRecipientName(user); // ... rest of the method
79-90
: Consider adding documentation for the name determination logic.While the implementation is solid, it would be helpful to document the name selection priority and fallback strategy in the class or method documentation. This would help other developers understand the intended behavior.
Add a comment block explaining the logic:
/** * Determines the recipient name for email communications using the following priority: * 1. User's name (if present and not blank) * 2. User's first name (if present and not blank) * 3. Fallback to "User" if no valid name is available * * @param user the user entity * @return the determined recipient name */ private String determineRecipientName(User user) { // ... implementation }Also applies to: 122-129
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
service/src/main/java/greencity/security/service/PasswordRecoveryServiceImpl.java
(2 hunks)
String recipientName = (user.getFirstName() != null && !user.getFirstName().isBlank()) | ||
? user.getFirstName() | ||
: (user.getName() != null && !user.getName().isBlank() | ||
? user.getName() | ||
: "User"); |
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.
Align the name priority logic with the previous implementation.
The name determination logic here prioritizes firstName
over name
, while the previous implementation does the opposite. This inconsistency could lead to different name selections in different scenarios.
- String recipientName = (user.getFirstName() != null && !user.getFirstName().isBlank())
- ? user.getFirstName()
- : (user.getName() != null && !user.getName().isBlank()
- ? user.getName()
- : "User");
+ String recipientName = determineRecipientName(user);
Committable suggestion skipped: line range outside the PR's diff.
Add check if user have name use it in other way use first_name
Summary by CodeRabbit