Skip to content

Changes in community and broadcast notification #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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