@@ -87,7 +87,15 @@ async function manageVanillaUser (data) {
87
87
await vanillaClient . updateUser ( vanillaUser . userID , userData )
88
88
}
89
89
90
- const { body : categories } = await vanillaClient . getCategoriesByParentUrlCode ( challengeId )
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
+ }
91
99
92
100
// Choose action to perform
93
101
switch ( action ) {
@@ -100,6 +108,8 @@ async function manageVanillaUser (data) {
100
108
for ( const category of categories ) {
101
109
await vanillaClient . watchCategory ( category . categoryID , vanillaUser . userID , { watched : true } )
102
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 } ` )
103
113
}
104
114
break
105
115
}
@@ -108,6 +118,8 @@ async function manageVanillaUser (data) {
108
118
for ( const category of categories ) {
109
119
await vanillaClient . watchCategory ( category . categoryID , vanillaUser . userID , { watched : false } )
110
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 } ` )
111
123
}
112
124
await vanillaClient . removeUserFromGroup ( group . groupID , vanillaUser . userID )
113
125
logger . info ( `The user '${ vanillaUser . name } ' was removed from the group '${ group . name } '` )
@@ -169,7 +181,10 @@ async function createVanillaGroup (challenge) {
169
181
}
170
182
171
183
const { body : project } = await topcoderApi . getProject ( challenge . projectId )
172
- const copilots = _ . filter ( project . members , { role : constants . TOPCODER . ROLE_COPILOT } )
184
+ const members = _ . filter ( project . members , member => {
185
+ return member . role === constants . TOPCODER . ROLE_COPILOT || member . role === constants . TOPCODER . ROLE_MANAGER
186
+ } )
187
+
173
188
const challengesForums = _ . filter ( template . categories , [ 'name' , constants . VANILLA . CHALLENGES_FORUM ] )
174
189
if ( ! challengesForums ) {
175
190
throw new Error ( `The '${ constants . VANILLA . CHALLENGES_FORUM } ' category wasn't found in the template json file` )
@@ -253,8 +268,8 @@ async function createVanillaGroup (challenge) {
253
268
await createDiscussions ( group , challenge , groupTemplate . discussions , challengeCategory )
254
269
}
255
270
256
- for ( const copilot of copilots ) {
257
- await manageVanillaUser ( { challengeId : challenge . id , action : constants . USER_ACTIONS . INVITE , handle : copilot . handle } )
271
+ for ( const member of members ) {
272
+ await manageVanillaUser ( { challengeId : challenge . id , action : constants . USER_ACTIONS . INVITE , handle : member . handle } )
258
273
}
259
274
260
275
challengeDetailsDiscussion . url = `${ challengeCategory . url } `
0 commit comments