Skip to content

Release v1.15.9 #6288

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 6 commits into from
Apr 7, 2022
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 @@ -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