Skip to content

feat: allow existing project member to be invited as copilot #835

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

Merged
merged 29 commits into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
25b8b34
fix: removed logic to allow inviting user even if they are already a …
hentrymartin Jul 23, 2025
7831f54
fix: allow copilots to be added even if the existing member
hentrymartin Jul 23, 2025
57a8d00
fix: allow copilots to be added even if the existing member
hentrymartin Jul 23, 2025
1b21d3b
fix: allow copilots to be added even if the existing member
hentrymartin Jul 23, 2025
fa13330
fix: allow copilots to be added even if the existing member
hentrymartin Jul 23, 2025
0536910
fix: allow copilots to be added even if the existing member
hentrymartin Jul 23, 2025
b67a6ba
fix: allow copilots to be added even if the existing member
hentrymartin Jul 23, 2025
f26de03
fix: just switch role if user is already a member
hentrymartin Jul 24, 2025
50d2dac
fix: just switch role if user is already a member
hentrymartin Jul 24, 2025
347caae
fix: debug logs
hentrymartin Jul 24, 2025
d4e4033
fix: debug logs
hentrymartin Jul 24, 2025
ecb836c
fix: debug logs
hentrymartin Jul 24, 2025
279d2f1
fix: update kafka
hentrymartin Jul 24, 2025
3998114
fix: update kafka
hentrymartin Jul 24, 2025
b7c5f95
revert
hentrymartin Jul 24, 2025
bebe265
fix: build
hentrymartin Jul 24, 2025
9385156
fix: added error string and already assigned role
hentrymartin Jul 25, 2025
fdb09e3
fix: added error string and already assigned role
hentrymartin Jul 25, 2025
2dc0ea2
fix: added error string and already assigned role
hentrymartin Jul 25, 2025
13c8c39
fix: added error string and already assigned role
hentrymartin Jul 25, 2025
f73f444
feat: modifications on copilot addition to project
hentrymartin Jul 27, 2025
7fce661
feat: modifications on copilot addition to project
hentrymartin Jul 27, 2025
1f2cba4
feat: modifications on copilot addition to project
hentrymartin Jul 27, 2025
1266652
feat: modifications on copilot addition to project
hentrymartin Jul 27, 2025
c701b1e
fix: complete the copilot requests if the incoming role is observer o…
hentrymartin Jul 27, 2025
1d19d15
fix: complete the copilot requests if the incoming role is observer o…
hentrymartin Jul 27, 2025
af842b0
fix: complete the copilot requests if the incoming role is observer o…
hentrymartin Jul 27, 2025
0d02782
fix: complete the copilot requests if the incoming role is observer o…
hentrymartin Jul 28, 2025
ce575c7
fix: action string
hentrymartin Jul 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ workflows:
context : org-global
filters:
branches:
only: ['develop', 'migration-setup', 'pm-1497']
only: ['develop', 'migration-setup', 'pm-1506']
- deployProd:
context : org-global
filters:
Expand Down
24 changes: 13 additions & 11 deletions src/routes/projectMemberInvites/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,19 @@ module.exports = [
const errorMessageForAlreadyMemberUser = 'User with such handle is already a member of the team.';

if (inviteUserIds) {
// remove members already in the team
_.remove(inviteUserIds, u => _.some(members, (m) => {
const isPresent = m.userId === u;
if (isPresent) {
failed.push(_.assign({}, {
handle: getUserHandleById(m.userId, inviteUsers),
message: errorMessageForAlreadyMemberUser,
}));
}
return isPresent;
}));
if (invite.role !== PROJECT_MEMBER_ROLE.COPILOT) {
// remove members already in the team
_.remove(inviteUserIds, u => _.some(members, (m) => {
const isPresent = m.userId === u;
if (isPresent) {
failed.push(_.assign({}, {
handle: getUserHandleById(m.userId, inviteUsers),
message: errorMessageForAlreadyMemberUser,
}));
}
return isPresent;
}));
}

// for each user invited by `handle` (userId) we have to load they Topcoder Roles,
// so we can check if such a user can be invited with desired Project Role
Expand Down
20 changes: 19 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,25 @@ const projectServiceUtils = {

// check if member is already registered
const existingMember = _.find(members, m => m.userId === member.userId);
if (existingMember) {
// if (existingMember) {
// const err = new Error(`User already registered for role: ${existingMember.role}`);
// err.status = 400;
// return Promise.reject(err);
// }

if (existingMember
&& member.role === PROJECT_MEMBER_ROLE.COPILOT
&& existingMember.role === PROJECT_MEMBER_ROLE.OBSERVER) {
yield models.ProjectMember
.update(
{ deletedBy: req.authUser.userId },
{ where: { userId: existingMember.userId }, transaction}
);
yield models.ProjectMember.destroy({
where: { userId: existingMember.userId },
transaction
});
} else if (existingMember) {
const err = new Error(`User already registered for role: ${existingMember.role}`);
err.status = 400;
return Promise.reject(err);
Expand Down