Skip to content

Messenger group not saving options#627

Merged
yingbull merged 1 commit into
develop/dogfishfrom
622-messenger-group-not-saving-options
Sep 24, 2025
Merged

Messenger group not saving options#627
yingbull merged 1 commit into
develop/dogfishfrom
622-messenger-group-not-saving-options

Conversation

@LiamStanziani

@LiamStanziani LiamStanziani commented Sep 23, 2025

Copy link
Copy Markdown
Collaborator

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:

  • Fixed messenger group add, remove, and create operations not persisting when navigating away and back

Enhancements:

  • Refactored execute() to dispatch "add", "remove", and "create" methods
  • Changed add(), remove(), and create() methods to return String and return NONE to maintain page state

…n struts action, added return type to methods for new method workflow
@LiamStanziani LiamStanziani self-assigned this Sep 23, 2025
@LiamStanziani LiamStanziani linked an issue Sep 23, 2025 that may be closed by this pull request
2 tasks
@sourcery-ai

sourcery-ai Bot commented Sep 23, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This 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 methods

classDiagram
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)
}
Loading

File-Level Changes

Change Details Files
extended execute dispatch logic to route add, remove, and create operations
  • added if branches for “add”, “remove”, and “create” before the existing delete check
  • delegated processing by returning results of add(), remove(), and create() methods
src/main/java/ca/openosp/openo/messenger/config/pageUtil/MsgMessengerAdmin2Action.java
updated add(), remove(), and create() methods to return Struts result
  • changed method signatures from void to String for add(), remove(), and create()
  • appended return NONE at the end of each method to preserve state
src/main/java/ca/openosp/openo/messenger/config/pageUtil/MsgMessengerAdmin2Action.java

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 0207340.
Ensure 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 Files

None

@LiamStanziani LiamStanziani marked this pull request as ready for review September 23, 2025 18:29

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@yingbull yingbull merged commit 245ce3d into develop/dogfish Sep 24, 2025
13 of 15 checks passed
@yingbull yingbull deleted the 622-messenger-group-not-saving-options branch January 8, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Messenger Group Admin isn't saving options

2 participants