Skip to content

Commit 768a174

Browse files
Merge branch 'feature/self-service-email' of https://github.com/topcoder-platform/challenge-api into feature/self-service-email
2 parents 89d8b0e + 797e66f commit 768a174

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

config/default.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ module.exports = {
6666

6767
MANAGER_ROLE_ID: process.env.MANAGER_ROLE_ID || '0e9c6879-39e4-4eb6-b8df-92407890faf1',
6868
OBSERVER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '2a4dc376-a31c-4d00-b173-13934d89e286',
69+
CLIENT_MANAGER_ROLE_ID: process.env.OBSERVER_ROLE_ID || '9b2f1905-8128-42da-85df-ed64410f4781',
6970

7071
// health check timeout in milliseconds
7172
HEALTH_CHECK_TIMEOUT: process.env.HEALTH_CHECK_TIMEOUT || 3000,
@@ -96,5 +97,6 @@ module.exports = {
9697
},
9798

9899
EMAIL_FROM: process.env.EMAIL_FROM || 'no-reply@topcoder.com',
99-
SELF_SERVICE_EMAIL_CC_ACCOUNTS: process.env.SELF_SERVICE_EMAIL_CC_ACCOUNTS ? _.map(process.env.SELF_SERVICE_EMAIL_CC_ACCOUNTS.split(','), email => ({ email })) : []
100+
SELF_SERVICE_EMAIL_CC_ACCOUNTS: process.env.SELF_SERVICE_EMAIL_CC_ACCOUNTS ? _.map(process.env.SELF_SERVICE_EMAIL_CC_ACCOUNTS.split(','), email => ({ email })) : [],
101+
SELF_SERVICE_WHITELIST_HANDLES: process.env.SELF_SERVICE_WHITELIST_HANDLES || ['TCConnCopilot', 'sstestcopilot']
100102
}

src/services/ChallengeService.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,12 +1077,21 @@ async function createChallenge (currentUser, challenge, userToken) {
10771077
body: ret
10781078
})
10791079

1080-
// if created by a user, add user as a manager
1081-
if (currentUser.handle) {
1082-
// logger.debug(`Adding user as manager ${currentUser.handle}`)
1083-
await helper.createResource(ret.id, ret.createdBy, config.MANAGER_ROLE_ID)
1084-
} else {
1085-
// logger.debug(`Not adding manager ${currentUser.sub} ${JSON.stringify(currentUser)}`)
1080+
//If the challenge is self-service, add the creating user as the "client manager", *not* the manager
1081+
//This is necessary for proper handling of the vanilla embed on the self-service work item dashboard
1082+
if(challenge.legacy.selfService) {
1083+
if (currentUser.handle) {
1084+
await helper.createResource(ret.id, ret.createdBy, config.CLIENT_MANAGER_ROLE_ID)
1085+
}
1086+
}
1087+
else{
1088+
// if created by a user, add user as a manager, but only if *not* a self-service challenge
1089+
if (currentUser.handle) {
1090+
// logger.debug(`Adding user as manager ${currentUser.handle}`)
1091+
await helper.createResource(ret.id, ret.createdBy, config.MANAGER_ROLE_ID)
1092+
} else {
1093+
// logger.debug(`Not adding manager ${currentUser.sub} ${JSON.stringify(currentUser)}`)
1094+
}
10861095
}
10871096

10881097
// post bus event

0 commit comments

Comments
 (0)