Skip to content

Commit 958667d

Browse files
author
James Cori
committed
Merge branch 'develop'
2 parents 52e3c3b + 9e03df5 commit 958667d

File tree

2 files changed

+28
-74
lines changed

2 files changed

+28
-74
lines changed

config/template.json

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"urlcode": "$ { challenge.id }",
1515
"group": {
1616
"name": "${ challenge.name }",
17-
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
18-
"type": "secret"
17+
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this forum, thanks!",
18+
"privacy": "secret",
19+
"type": "challenge"
1920
},
2021
"categories": [
2122
{
@@ -28,18 +29,6 @@
2829
"announce": 1,
2930
"closed": 1
3031
},
31-
{
32-
"title": "Base Code",
33-
"body": "See attached.",
34-
"announce": 0,
35-
"closed": 0
36-
},
37-
{
38-
"title": "Coding Structure",
39-
"body": "Please see the attached document from the client and make sure you follow the required structure and guidelines. This is a critical requriement.",
40-
"announce": 0,
41-
"closed": 0
42-
},
4332
{
4433
"title": "Please give us feedback on this challenge!",
4534
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
@@ -54,7 +43,7 @@
5443
"discussions": [
5544
{
5645
"title": "Welcome!",
57-
"body": "Please read the requirements carefully, we tried to be clear and simple with the specs. However, if you still have questions let me know, I'll be glad to help you.",
46+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
5847
"announce": 0,
5948
"closed": 0
6049
}
@@ -69,7 +58,8 @@
6958
"group": {
7059
"name": "${ challenge.name }",
7160
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
72-
"type": "secret"
61+
"privacy": "secret",
62+
"type": "challenge"
7363
},
7464
"categories": [
7565
{
@@ -82,18 +72,6 @@
8272
"announce": 1,
8373
"closed": 1
8474
},
85-
{
86-
"title": "Base Code",
87-
"body": "See attached.",
88-
"announce": 0,
89-
"closed": 0
90-
},
91-
{
92-
"title": "Coding Structure",
93-
"body": "Please see the attached document from the client and make sure you follow the required structure and guidelines. This is a critical requriement.",
94-
"announce": 0,
95-
"closed": 0
96-
},
9775
{
9876
"title": "Please give us feedback on this challenge!",
9977
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
@@ -108,7 +86,7 @@
10886
"discussions": [
10987
{
11088
"title": "Welcome!",
111-
"body": "Please read the requirements carefully, we tried to be clear and simple with the specs. However, if you still have questions let me know, I'll be glad to help you.",
89+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
11290
"announce": 0,
11391
"closed": 0
11492
}
@@ -129,7 +107,8 @@
129107
"group": {
130108
"name": "${ challenge.name }",
131109
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
132-
"type": "secret"
110+
"privacy": "secret",
111+
"type": "challenge"
133112
},
134113
"discussions": [
135114
{
@@ -146,7 +125,7 @@
146125
},
147126
{
148127
"title": "Welcome!",
149-
"body": "Please read the requirements carefully, we tried to be clear and simple with the specs. However, if you still have questions let me know, I'll be glad to help you.",
128+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
150129
"announce": 0,
151130
"closed": 0
152131
},
@@ -171,7 +150,8 @@
171150
"group": {
172151
"name": "${ challenge.name }",
173152
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
174-
"type": "secret"
153+
"privacy": "secret",
154+
"type": "challenge"
175155
},
176156
"categories": [
177157
{
@@ -184,18 +164,6 @@
184164
"announce": 1,
185165
"closed": 1
186166
},
187-
{
188-
"title": "Base Code",
189-
"body": "See attached.",
190-
"announce": 0,
191-
"closed": 0
192-
},
193-
{
194-
"title": "Coding Structure",
195-
"body": "Please see the attached document from the client and make sure you follow the required structure and guidelines. This is a critical requriement.",
196-
"announce": 0,
197-
"closed": 0
198-
},
199167
{
200168
"title": "Please give us feedback on this challenge!",
201169
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
@@ -210,7 +178,7 @@
210178
"discussions": [
211179
{
212180
"title": "Welcome!",
213-
"body": "Please read the requirements carefully, we tried to be clear and simple with the specs. However, if you still have questions let me know, I'll be glad to help you.",
181+
"body": "Please read the requirements carefully. If you have questions, please let me know, I'll be glad to help you.",
214182
"announce": 0,
215183
"closed": 0
216184
}

src/services/vanilla.js

Lines changed: 15 additions & 29 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,40 +92,18 @@ 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}'`)
107-
// if User is added => watch the category
108-
for (const category of categories) {
109-
await vanillaClient.watchCategory(category.categoryID, vanillaUser.userID, { watched: true })
110-
logger.info(`The user ${vanillaUser.name} watches categoryID=${category.categoryID} associated with challenge ${challengeId}`)
111-
await vanillaClient.followCategory(category.categoryID, { followed: true, userID: vanillaUser.userID })
112-
logger.info(`The user ${vanillaUser.name} follows categoryID=${category.categoryID} associated with challenge ${challengeId}`)
113-
}
114104
break
115105
}
116106
case constants.USER_ACTIONS.KICK: {
117-
// if User is removed => don't watch the category
118-
for (const category of categories) {
119-
await vanillaClient.watchCategory(category.categoryID, vanillaUser.userID, { watched: false })
120-
logger.info(`The user ${vanillaUser.name} stopped watching categoryID=${category.categoryID} associated with challenge ${challengeId}`)
121-
await vanillaClient.followCategory(category.categoryID, { followed: false, userID: vanillaUser.userID })
122-
logger.info(`The user ${vanillaUser.name} unfollows categoryID=${category.categoryID} associated with challenge ${challengeId}`)
123-
}
124107
await vanillaClient.removeUserFromGroup(group.groupID, vanillaUser.userID)
125108
logger.info(`The user '${vanillaUser.name}' was removed from the group '${group.name}'`)
126109
break
@@ -220,6 +203,7 @@ async function createVanillaGroup (challenge) {
220203
const groupDescriptionTemplate = _.template(groupTemplate.group.description)
221204
const { body: group } = await vanillaClient.createGroup({
222205
name: groupNameTemplate({ challenge }),
206+
privacy: groupTemplate.group.privacy,
223207
type: groupTemplate.group.type,
224208
description: groupDescriptionTemplate({ challenge }),
225209
challengeID: `${challenge.id}`,
@@ -247,7 +231,8 @@ async function createVanillaGroup (challenge) {
247231
name: challenge.name,
248232
urlcode: `${challenge.id}`,
249233
parentCategoryID: parentCategory[0].categoryID,
250-
displayAs: groupTemplate.categories ? constants.VANILLA.CATEGORY_DISPLAY_STYLE.CATEGORIES : constants.VANILLA.CATEGORY_DISPLAY_STYLE.DISCUSSIONS
234+
displayAs: groupTemplate.categories ? constants.VANILLA.CATEGORY_DISPLAY_STYLE.CATEGORIES : constants.VANILLA.CATEGORY_DISPLAY_STYLE.DISCUSSIONS,
235+
groupID: group.groupID
251236
})
252237

253238
logger.info(`The '${challengeCategory.name}' category was created`)
@@ -258,7 +243,8 @@ async function createVanillaGroup (challenge) {
258243
const { body: childCategory } = await vanillaClient.createCategory({
259244
name: item.name,
260245
urlcode: `${urlCodeTemplate({ challenge })}`,
261-
parentCategoryID: challengeCategory.categoryID
246+
parentCategoryID: challengeCategory.categoryID,
247+
groupID: group.groupID
262248
})
263249
logger.info(`The '${item.name}' category was created`)
264250
await createDiscussions(group, challenge, item.discussions, childCategory)
@@ -270,7 +256,7 @@ async function createVanillaGroup (challenge) {
270256
}
271257

272258
for (const member of members) {
273-
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 })
274260
}
275261

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

0 commit comments

Comments
 (0)