Skip to content

Commit 34e23e7

Browse files
author
sachin-maheshwari
authoredMar 26, 2020
Merge pull request #187 from topcoder-platform/dev
Changes in community and broadcast notification
2 parents 0ded256 + f1bab75 commit 34e23e7

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed
 

‎.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ workflows:
102102
context : org-global
103103
filters:
104104
branches:
105-
only: [dev, 'bug/rate-limit']
105+
only: [dev, 'bug/community-notification']
106106
- "build-prod":
107107
context : org-global
108108
filters:

‎src/common/broadcastAPIHelper.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,18 @@ async function checkUserSkillsAndTracks(userId, bulkMessage, m) {
151151
/**
152152
* checking if user participated in specific challenges
153153
*/
154-
let key = t.toLowerCase()
155-
if (key === "develop") {
154+
let key = t.toUpperCase()
155+
if (key === "DEVLOP") {
156156
trackMatch = uDevChallenges > 0 ? true : trackMatch
157-
} else if (key === "design") {
157+
} else if (key === "DESIGN") {
158158
trackMatch = uDesignChallenges > 0 ? true : trackMatch
159-
} else if (key === "data_science") {
159+
} else if (key === "DATA_SCIENCE") {
160160
trackMatch = uDSChallenges > 0 ? true : trackMatch
161161
}
162+
// checking bacic member profile track preference
163+
trackMatch = (_.indexOf(_.get(m[0], "tracks"), key) >= 0) ? true : trackMatch
162164
})
165+
163166
} else {
164167
trackMatch = true // no condition, means allow for all
165168
}

‎src/common/tcApiHelper.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function* getUsersByHandles(handles) {
8484
return [];
8585
}
8686
// use 'OR' to link the handle matches
87-
const query = _.map(handles, (h) => 'handle:"' + h.trim().replace('"', '\\"') + '"').join(' OR ');
87+
const query = _.map(handles, (h) => 'handle:"' + h.trim().replace('"', '\\"') + '"').join(' OR ');
8888
return yield searchUsersByQuery(query);
8989
}
9090

@@ -188,10 +188,20 @@ function* notifyUserViaEmail(user, message) {
188188
* @returns {Object} the challenge details
189189
*/
190190
function* getChallenge(challengeId) {
191-
// this is public API, M2M token is not needed
191+
const token = yield getM2MToken();
192+
// this is public API, but some challege is not accessable so using m2m token
192193
const url = `${config.TC_API_V4_BASE_URL}/challenges/${challengeId}`;
193194
logger.info(`calling public challenge api ${url}`);
194-
const res = yield request.get(url);
195+
const res = yield request
196+
.get(url)
197+
.set('Authorization', `Bearer ${token}`)
198+
.catch((err) => {
199+
const errorDetails = _.get(err, 'message');
200+
throw new Error(
201+
`Error in call public challenge api by id ${challengeId}` +
202+
(errorDetails ? ' Server response: ' + errorDetails : '')
203+
);
204+
});
195205
if (!_.get(res, 'body.result.success')) {
196206
throw new Error(`Failed to get challenge by id ${challengeId}`);
197207
}

0 commit comments

Comments
 (0)
Please sign in to comment.