PM-6440 - ensure users are active before assigning them as managers - #61
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
There are correctness/documentation and test-specificity issues to address before the change is reliably validated and accurately documented.
Review effort: Lite
Findings: 3
Open (3)
What changed in this PR
This PR adds a validation step to prevent assigning inactive Topcoder members as engagement managers, by introducing a member-activity lookup in MemberService and enforcing it during the manager assignment flow.
Changes:
- Added
MemberService.isMemberActiveByUserId()to evaluate member activity based on memberstatus. - Enforced an “inactive manager” rejection in
EngagementManagersServiceduring identity resolution. - Extended manager assignment tests to mock/cover the new activity check and added a new error message constant.
| File | Description |
|---|---|
| src/integrations/member.service.ts | Adds status to MemberRecord and introduces isMemberActiveByUserId() based on member status. |
| src/engagements/managers/engagement-managers.service.ts | Calls isMemberActiveByUserId() before allowing manager assignment; rejects inactive members. |
| src/engagements/managers/engagement-managers.service.spec.ts | Updates mocks for the new method and adds a test case for inactive-member rejection. |
| src/common/constants.ts | Adds ERROR_MESSAGES.ManagerInactive for the new validation failure. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.

This pull request adds validation to prevent inactive users from being assigned as engagement managers and introduces supporting tests and methods. The main changes include updating error messages, adding a method to check member activity, and integrating this validation into the assignment flow.
Validation and Error Handling:
ManagerInactivetoERROR_MESSAGESto indicate that inactive members cannot be assigned as managers.EngagementManagersService, before assigning a manager, now checks if the user is active using the newisMemberActiveByUserIdmethod. Throws aBadRequestExceptionwith the new error message if the user is inactive.Member Service Enhancements:
statusandactivefields to theMemberRecordtype and implemented theisMemberActiveByUserIdmethod inMemberServiceto determine if a member is active, handling legacy payloads gracefully. [1] [2]Testing Improvements:
EngagementManagersServicetests to mock and verify the newisMemberActiveByUserIdmethod, including a test case to ensure inactive users are rejected. [1] [2] [3]