Skip to content

Commit 9e03df5

Browse files
authored
Merge pull request #44 from topcoder-platform/issues-229
Issues-229
2 parents 05f383a + 53aab16 commit 9e03df5

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/services/vanilla.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ const template = require(config.TEMPLATES.TEMPLATE_FILE_PATH)
1717
* @returns {undefined}
1818
*/
1919
async function manageVanillaUser (data) {
20-
const { challengeId, action, handle: username } = data
20+
const { challengeId, action, handle: username, role: projectRole } = data
2121
logger.info(`Managing users for challengeID=${challengeId} ...`)
2222
const { body: groups } = await vanillaClient.searchGroups(challengeId)
2323
const group = groups.length > 0 ? groups[0] : null
24+
25+
// Only members and copilots will receive notifications
26+
const watch = (!projectRole || projectRole === constants.TOPCODER.PROJECT_ROLES.COPILOT) ? 1 : 0
27+
const follow = 1
28+
2429
if (!group) {
2530
throw new Error('The group wasn\'t not found by challengeID')
2631
}
@@ -87,21 +92,13 @@ async function manageVanillaUser (data) {
8792
await vanillaClient.updateUser(vanillaUser.userID, userData)
8893
}
8994

90-
let categories = []
91-
const { body: nestedCategories } = await vanillaClient.getCategoriesByParentUrlCode(challengeId)
92-
categories = nestedCategories
93-
94-
// Some group might not have nested categories
95-
if (categories.length === 0) {
96-
const { body: parentCategory } = await vanillaClient.getCategoryByUrlcode(challengeId)
97-
categories.push(parentCategory)
98-
}
99-
10095
// Choose action to perform
10196
switch (action) {
10297
case constants.USER_ACTIONS.INVITE: {
10398
await vanillaClient.addUserToGroup(group.groupID, {
104-
userID: vanillaUser.userID
99+
userID: vanillaUser.userID,
100+
watch: watch,
101+
follow: follow
105102
})
106103
logger.info(`The user '${vanillaUser.name}' was added to the group '${group.name}'`)
107104
break
@@ -259,7 +256,7 @@ async function createVanillaGroup (challenge) {
259256
}
260257

261258
for (const member of members) {
262-
await manageVanillaUser({ challengeId: challenge.id, action: constants.USER_ACTIONS.INVITE, handle: member.handle })
259+
await manageVanillaUser({ challengeId: challenge.id, action: constants.USER_ACTIONS.INVITE, handle: member.handle, role: member.role })
263260
}
264261

265262
challengeDetailsDiscussion.url = `${challengeCategory.url}`

0 commit comments

Comments
 (0)