Skip to content

Commit

Permalink
Merge pull request #6288 from topcoder-platform/develop
Browse files Browse the repository at this point in the history
Release v1.15.9
  • Loading branch information
luizrrodrigues authored Apr 7, 2022
2 parents b82622f + c665679 commit d5236da
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ workflows:
filters:
branches:
only:
- free
- sanitize-jobs-api
# This is stage env for production QA releases
- "build-prod-staging":
context : org-global
Expand Down
31 changes: 25 additions & 6 deletions src/server/services/recruitCRM.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const CANDIDATE_FIELDS_RESPONSE = [
'salary_expectation',
'custom_fields',
];
const OMIT_CUSTOM_FIELDS = [
'Candidates Link',
'Account Executive',
'Wipro Centralization SPOC',
];

/**
* Send email to Kiril/Nick for debuging gig application errors
Expand All @@ -72,6 +77,18 @@ function notifyKirilAndNick(error) {
});
}

/**
* Sanitize Job before return
* @param {Object} job data from recuitcrm api
*/
function sanitizeJob(job) {
const sJob = _.pick(job, JOB_FIELDS_RESPONSE);
sJob.custom_fields = _.filter(
sJob.custom_fields, f => !_.includes(OMIT_CUSTOM_FIELDS, f.field_name),
);
return sJob;
}

const updateProfileSchema = Joi.object().keys({
phone: Joi.string().required(),
availability: Joi.boolean().required(),
Expand Down Expand Up @@ -154,7 +171,9 @@ export default class RecruitCRMService {
return res.send(error);
}
const data = await response.json();
data.data = _.map(data.data, j => _.pick(j, JOB_FIELDS_RESPONSE));

data.data = _.map(data.data, j => sanitizeJob(j));

return res.send(data);
} catch (err) {
return next(err);
Expand Down Expand Up @@ -190,7 +209,7 @@ export default class RecruitCRMService {
return res.send(error);
}
const data = await response.json();
return res.send(_.pick(data, JOB_FIELDS_RESPONSE));
return res.send(sanitizeJob(data));
} catch (err) {
return next(err);
}
Expand Down Expand Up @@ -242,11 +261,11 @@ export default class RecruitCRMService {
const pageData = await pageDataRsp.json();
data.data = _.flatten(data.data.concat(pageData.data));
}
const toSend = _.map(data.data, j => _.pick(j, JOB_FIELDS_RESPONSE));
const toSend = _.map(data.data, j => sanitizeJob(j));
return toSend;
});
}
const toSend = _.map(data.data, j => _.pick(j, JOB_FIELDS_RESPONSE));
const toSend = _.map(data.data, j => sanitizeJob(j));
return toSend;
} catch (err) {
return err;
Expand Down Expand Up @@ -303,15 +322,15 @@ export default class RecruitCRMService {
const pageData = await pageDataRsp.json();
data.data = _.flatten(data.data.concat(pageData.data));
}
const toSend = _.map(data.data, j => _.pick(j, JOB_FIELDS_RESPONSE));
const toSend = _.map(data.data, j => sanitizeJob(j));
gigsCache.set(CACHE_KEY, toSend);
return res.send(toSend);
})
.catch(e => res.send({
error: e,
}));
}
const toSend = _.map(data.data, j => _.pick(j, JOB_FIELDS_RESPONSE));
const toSend = _.map(data.data, j => sanitizeJob(j));
gigsCache.set(CACHE_KEY, toSend);
return res.send(toSend);
} catch (err) {
Expand Down

0 comments on commit d5236da

Please sign in to comment.