Messenger group not saving options#627
Merged
Merged
Conversation
…n struts action, added return type to methods for new method workflow
2 tasks
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refactors the MsgMessengerAdmin2Action to fully support add, remove, and create operations by integrating them into the execute dispatch flow and ensuring they return a Struts result (NONE) to preserve page state when navigating away and back. Class diagram for updated MsgMessengerAdmin2Action methodsclassDiagram
class MsgMessengerAdmin2Action {
+String execute()
+String add()
+String remove()
+String create()
+String fetch()
}
MsgMessengerAdmin2Action --> MessengerGroupManager
class MessengerGroupManager {
+void addMember(loggedInInfo, contactIdentifier, groupId)
+void removeMember(loggedInInfo, contactIdentifier, groupId)
+void removeGroup(loggedInInfo, groupId)
+void addGroup(loggedInInfo, groupName, parentId)
}
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Extract the common request parameter parsing and ‘return NONE’ logic into a shared helper to reduce duplication in add/remove/create methods.
- In create(), consider returning the fetch() result instead of hard-coding NONE so the view refresh uses the same path as other operations.
- Rather than a long if-else chain in execute(), explore Struts2 dynamic method invocation or action annotations to simplify your dispatch logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract the common request parameter parsing and ‘return NONE’ logic into a shared helper to reduce duplication in add/remove/create methods.
- In create(), consider returning the fetch() result instead of hard-coding NONE so the view refresh uses the same path as other operations.
- Rather than a long if-else chain in execute(), explore Struts2 dynamic method invocation or action annotations to simplify your dispatch logic.
## Individual Comments
### Comment 1
<location> `src/main/java/ca/openosp/openo/messenger/config/pageUtil/MsgMessengerAdmin2Action.java:164-168` </location>
<code_context>
*/
@SuppressWarnings("unused")
- public void add() {
+ public String add() {
LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);
String memberId = request.getParameter("member");
</code_context>
<issue_to_address>
**issue (bug_risk):** Return type of 'add', 'remove', and 'create' changed to String, but NONE may not be defined or may not match expected return values.
Verify that NONE is properly defined and used as the return value, consistent with framework requirements, to prevent runtime issues.
</issue_to_address>
### Comment 2
<location> `src/main/java/ca/openosp/openo/messenger/config/pageUtil/MsgMessengerAdmin2Action.java:164-168` </location>
<code_context>
messengerGroupManager.addMember(loggedInInfo, contactIdentifier, Integer.parseInt(groupId));
}
request.setAttribute("success", true);
+
+ return NONE;
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Setting 'success' attribute to true unconditionally may mask errors.
Set 'success' to true only if addMember completes without errors or exceptions, ensuring accurate status reporting.
```suggestion
String groupId = request.getParameter("group");
try {
messengerGroupManager.addMember(loggedInInfo, contactIdentifier, Integer.parseInt(groupId));
request.setAttribute("success", true);
} catch (Exception e) {
request.setAttribute("success", false);
// Optionally log the exception or set an error message attribute
}
return NONE;
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
yingbull
approved these changes
Sep 24, 2025
yingbull
approved these changes
Sep 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed an issue where messenger groups would not save when leaving the page and going back
Summary by Sourcery
Ensure messenger group operations return appropriate Struts results to preserve changes across page navigation
Bug Fixes:
Enhancements: