Skip to content

Commit

Permalink
Merge pull request #187 from topcoder-platform/dev
Browse files Browse the repository at this point in the history
Changes in community and broadcast notification
  • Loading branch information
sachin-maheshwari authored Mar 26, 2020
2 parents 0ded256 + f1bab75 commit 34e23e7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ workflows:
context : org-global
filters:
branches:
only: [dev, 'bug/rate-limit']
only: [dev, 'bug/community-notification']
- "build-prod":
context : org-global
filters:
Expand Down
11 changes: 7 additions & 4 deletions src/common/broadcastAPIHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,18 @@ async function checkUserSkillsAndTracks(userId, bulkMessage, m) {
/**
* checking if user participated in specific challenges
*/
let key = t.toLowerCase()
if (key === "develop") {
let key = t.toUpperCase()
if (key === "DEVLOP") {
trackMatch = uDevChallenges > 0 ? true : trackMatch
} else if (key === "design") {
} else if (key === "DESIGN") {
trackMatch = uDesignChallenges > 0 ? true : trackMatch
} else if (key === "data_science") {
} else if (key === "DATA_SCIENCE") {
trackMatch = uDSChallenges > 0 ? true : trackMatch
}
// checking bacic member profile track preference
trackMatch = (_.indexOf(_.get(m[0], "tracks"), key) >= 0) ? true : trackMatch
})

} else {
trackMatch = true // no condition, means allow for all
}
Expand Down
16 changes: 13 additions & 3 deletions src/common/tcApiHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function* getUsersByHandles(handles) {
return [];
}
// use 'OR' to link the handle matches
const query = _.map(handles, (h) => 'handle:"' + h.trim().replace('"', '\\"') + '"').join(' OR ');
const query = _.map(handles, (h) => 'handle:"' + h.trim().replace('"', '\\"') + '"').join(' OR ');
return yield searchUsersByQuery(query);
}

Expand Down Expand Up @@ -188,10 +188,20 @@ function* notifyUserViaEmail(user, message) {
* @returns {Object} the challenge details
*/
function* getChallenge(challengeId) {
// this is public API, M2M token is not needed
const token = yield getM2MToken();
// this is public API, but some challege is not accessable so using m2m token
const url = `${config.TC_API_V4_BASE_URL}/challenges/${challengeId}`;
logger.info(`calling public challenge api ${url}`);
const res = yield request.get(url);
const res = yield request
.get(url)
.set('Authorization', `Bearer ${token}`)
.catch((err) => {
const errorDetails = _.get(err, 'message');
throw new Error(
`Error in call public challenge api by id ${challengeId}` +
(errorDetails ? ' Server response: ' + errorDetails : '')
);
});
if (!_.get(res, 'body.result.success')) {
throw new Error(`Failed to get challenge by id ${challengeId}`);
}
Expand Down

0 comments on commit 34e23e7

Please sign in to comment.