Skip to content

Release 2021/02/25 (v1.7.9) #5395

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 41 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6a419f1
adding sort options in buckets
PrakashDurlabhji Sep 29, 2020
79e582b
minor fix
PrakashDurlabhji Oct 3, 2020
52d38b6
sort by changes
PrakashDurlabhji Oct 12, 2020
7521450
Update sort.js
PrakashDurlabhji Jan 6, 2021
75b1ae5
Update sort.js
PrakashDurlabhji Jan 6, 2021
4860b55
Growsurf for gigs init
kkartunov Feb 4, 2021
b7ef040
Merge branch 'master' into gig-referrals
kkartunov Feb 4, 2021
86335f2
Fixed tests
kkartunov Feb 4, 2021
19b4560
Adding new env vars for #5340
kkartunov Feb 4, 2021
f032edf
ci: on dev
kkartunov Feb 8, 2021
46333dd
add debug key
kkartunov Feb 8, 2021
ebeb559
Docker config fix
kkartunov Feb 11, 2021
7a8d95d
XHR pending check
kkartunov Feb 11, 2021
2bfd397
XHR panding fixes
kkartunov Feb 12, 2021
9581f7e
Referral form updates
kkartunov Feb 12, 2021
eccbaa1
Pending request fix
kkartunov Feb 12, 2021
a741864
Pending fix retry
kkartunov Feb 12, 2021
81dd552
Pending retry
kkartunov Feb 12, 2021
c6267f1
test sendgrid/mail for pending
kkartunov Feb 15, 2021
f036993
Fixed tests
kkartunov Feb 15, 2021
57b2c2f
Sending emails via API directly due lib bug
kkartunov Feb 15, 2021
456a7e8
updates to lates design
kkartunov Feb 18, 2021
0a8b6e1
Fixes for leaderboards
kkartunov Feb 19, 2021
7ee60e7
ci: on test
kkartunov Feb 19, 2021
9b2d8c1
Merge branch 'issue_4982' of https://github.com/PrakashDurlabhji/comm…
luizrrodrigues Feb 19, 2021
6279f6e
Merge branch 'PrakashDurlabhji-issue_4982' into add-sort-options
luizrrodrigues Feb 19, 2021
64658f0
ci: Deploy add-sort-options to Stag env
luizrrodrigues Feb 19, 2021
bf6842b
Fix #5300
kkartunov Feb 23, 2021
08fa33b
Fix #5354
kkartunov Feb 23, 2021
e4a86c8
add how it works link
kkartunov Feb 23, 2021
f1ea8f6
updated email base url
kkartunov Feb 23, 2021
5b03e14
final tweaks referral
kkartunov Feb 23, 2021
61eb569
ci: on qa
kkartunov Feb 24, 2021
8677805
Challenge listing sort - Hide TimeToRegister and TimeToSubmit
luizrrodrigues Feb 25, 2021
4734a15
Merge branch 'develop' into gig-referrals
luizrrodrigues Feb 25, 2021
86a5935
Merge branch 'develop' into add-sort-options
luizrrodrigues Feb 25, 2021
7e6cf67
Merge pull request #5391 from topcoder-platform/add-sort-options
luizrrodrigues Feb 25, 2021
7a4c0f8
Merge pull request #5392 from topcoder-platform/gig-referrals
luizrrodrigues Feb 25, 2021
42abb08
Merge pull request #5393 from topcoder-platform/gigs-housekeep
luizrrodrigues Feb 25, 2021
344523f
Merge branch 'develop' into tco-leaderboards-fixes
luizrrodrigues Feb 25, 2021
0d5ada6
Merge pull request #5394 from topcoder-platform/tco-leaderboards-fixes
luizrrodrigues Feb 25, 2021
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
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ workflows:
filters:
branches:
only:
- free
- gigs-housekeep
# This is beta env for production soft releases
- "build-prod-beta":
context : org-global
Expand All @@ -304,7 +304,6 @@ workflows:
branches:
only:
- develop
- nav-vanilla-forum
- "approve-smoke-test-on-staging":
type: approval
requires:
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ ARG AUTH_SECRET
ARG COMMUNITY_APP_URL
ARG GSHEETS_API_KEY

# Gig work referrals
ARG SENDGRID_API_KEY
ARG GROWSURF_API_KEY
ARG GROWSURF_CAMPAIGN_ID

################################################################################
# Setting of environment variables in the Docker image.

Expand Down Expand Up @@ -121,6 +126,9 @@ ENV CONTENTFUL_EDU_CDN_API_KEY=$CONTENTFUL_EDU_CDN_API_KEY
ENV CONTENTFUL_EDU_PREVIEW_API_KEY=$CONTENTFUL_EDU_PREVIEW_API_KEY
ENV RECRUITCRM_API_KEY=$RECRUITCRM_API_KEY
ENV COMMUNITY_APP_URL=$COMMUNITY_APP_URL
ENV SENDGRID_API_KEY=$SENDGRID_API_KEY
ENV GROWSURF_API_KEY=$GROWSURF_API_KEY
ENV GROWSURF_CAMPAIGN_ID=$GROWSURF_CAMPAIGN_ID
ENV GSHEETS_API_KEY=$GSHEETS_API_KEY

################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exports[`Default render 1`] = `
id="textAreaInput"
onChange={[Function]}
placeholder=""
readOnly={false}
/>
</div>
`;
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ docker build -t $TAG \
--build-arg CONTENTFUL_COMCAST_CDN_API_KEY=$CONTENTFUL_COMCAST_CDN_API_KEY \
--build-arg CONTENTFUL_COMCAST_PREVIEW_API_KEY=$CONTENTFUL_COMCAST_PREVIEW_API_KEY \
--build-arg RECRUITCRM_API_KEY=$RECRUITCRM_API_KEY \
--build-arg SENDGRID_API_KEY=$SENDGRID_API_KEY \
--build-arg GROWSURF_API_KEY=$GROWSURF_API_KEY \
--build-arg GROWSURF_CAMPAIGN_ID=$GROWSURF_CAMPAIGN_ID \
--build-arg GSHEETS_API_KEY=$GSHEETS_API_KEY \
--build-arg COMMUNITY_APP_URL=$COMMUNITY_APP_URL .

Expand Down
3 changes: 3 additions & 0 deletions config/custom-environment-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ module.exports = {
},

RECRUITCRM_API_KEY: 'RECRUITCRM_API_KEY',
GROWSURF_API_KEY: 'GROWSURF_API_KEY',
SENDGRID_API_KEY: 'SENDGRID_API_KEY',
},
GROWSURF_CAMPAIGN_ID: 'GROWSURF_CAMPAIGN_ID',
AUTH_CONFIG: {
AUTH0_URL: 'TC_M2M_AUTH0_URL',
AUTH0_AUDIENCE: 'TC_M2M_AUDIENCE',
Expand Down
10 changes: 10 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ module.exports = {
},

RECRUITCRM_API_KEY: '',
GROWSURF_API_KEY: '',
SENDGRID_API_KEY: '',
},

GROWSURF_CAMPAIGN_ID: '',
GROWSURF_COOKIE: '_tc_gigs_ref',
GROWSURF_COOKIE_SETTINGS: {
secure: true,
domain: '',
expires: 7, // days
},

GSHEETS_API_KEY: 'AIzaSyBRdKySN5JNCb2H6ZxJdTTvp3cWU51jiOQ',
Expand Down
2 changes: 2 additions & 0 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import mailChimpRouter from './routes/mailchimp';
import mockDocuSignFactory from './__mocks__/docu-sign-mock';
import recruitCRMRouter from './routes/recruitCRM';
import mmLeaderboardRouter from './routes/mmLeaderboard';
import growsurfRouter from './routes/growsurf';
import gSheetsRouter from './routes/gSheet';

/* Dome API for topcoder communities */
Expand Down Expand Up @@ -138,6 +139,7 @@ async function onExpressJsSetup(server) {
server.use('/api/mailchimp', mailChimpRouter);
server.use('/api/recruit', recruitCRMRouter);
server.use('/api/mml', mmLeaderboardRouter);
server.use('/api/growsurf', growsurfRouter);
server.use('/api/gsheets', gSheetsRouter);

// serve demo api
Expand Down
20 changes: 20 additions & 0 deletions src/server/routes/growsurf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* The routes related to Growsurf integration
*/

import express from 'express';
import GrowsurfService from '../services/growsurf';

const cors = require('cors');

const routes = express.Router();

// Enables CORS on those routes according config above
// ToDo configure CORS for set of our trusted domains
routes.use(cors());
routes.options('*', cors());

routes.get('/participants', (req, res) => new GrowsurfService().getParticipant(req, res).then(res.send.bind(res)));
routes.post('/participants', (req, res) => new GrowsurfService().getOrCreateParticipant(req, res).then(res.send.bind(res)));

export default routes;
3 changes: 3 additions & 0 deletions src/server/routes/mailchimp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import express from 'express';
import MailchimpService from '../services/mailchimp';
import { sendEmail } from '../services/sendGrid';

const routes = express.Router();
/* Sets Access-Control-Allow-Origin header to avoid CORS error.
Expand All @@ -28,4 +29,6 @@ routes.get('/campaign-folders', (req, res) => new MailchimpService().getCampaign

routes.get('/campaigns', (req, res) => new MailchimpService().getCampaigns(req).then(res.send.bind(res)));

routes.post('/email', (req, res) => sendEmail(req, res).then(res.send.bind(res)));

export default routes;
96 changes: 96 additions & 0 deletions src/server/services/growsurf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Server-side functions necessary for effective integration with growsurf
*/
import fetch from 'isomorphic-fetch';
import config from 'config';

/**
* Auxiliary class that handles communication with growsurf
*/
export default class GrowsurfService {
/**
* Creates a new service instance.
* @param {String} baseUrl The base API endpoint.
*/
constructor(baseUrl = 'https://api.growsurf.com/v2') {
this.private = {
baseUrl,
apiKey: config.SECRET.GROWSURF_API_KEY,
authorization: `Bearer ${config.SECRET.GROWSURF_API_KEY}`,
};
}

/**
* Gets get participant by email or id.
* @return {Promise}
* @param {Object} req the request.
* @param {Object} res the response.
*/
async getParticipant(req, res) {
const { participantId } = req.query;
const response = await fetch(`${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${participantId}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: this.private.authorization,
},
});
if (response.status >= 300) {
res.status(response.status);
return {
error: await response.json(),
code: response.status,
url: `${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${participantId}`,
};
}
const data = await response.json();
return data;
}

/**
* Add participant
* @return {Promise}
* @param {Object} body the request payload.
*/
async addParticipant(body) {
const response = await fetch(`${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: this.private.authorization,
},
body,
});
if (response.status >= 300) {
return {
error: await response.json(),
code: response.status,
url: `${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant`,
body,
private: this.private, // to remove in final release
};
}
const data = await response.json();
return data;
}

/**
* Gets get participant by email or id
* if not exxists create it
* @return {Promise}
* @param {Object} req the request.
* @param {Object} res the response.
*/
async getOrCreateParticipant(req, res) {
const { body } = req;
const result = await this.addParticipant(JSON.stringify({
email: body.email,
firstName: body.firstName,
lastName: body.lastName,
}));
if (result.error) {
res.status(result.code);
}
return result;
}
}
39 changes: 34 additions & 5 deletions src/server/services/recruitCRM.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fetch from 'isomorphic-fetch';
import config from 'config';
import qs from 'qs';
import _ from 'lodash';
import GrowsurfService from './growsurf';

const FormData = require('form-data');

Expand Down Expand Up @@ -188,7 +189,35 @@ export default class RecruitCRMService {
const fileData = new FormData();
fileData.append('resume', file.buffer, file.originalname);
let candidateSlug;
let referralCookie = req.cookies[config.GROWSURF_COOKIE];
if (referralCookie) referralCookie = JSON.parse(referralCookie);
try {
// referral tracking via growsurf
if (referralCookie && referralCookie.gigId === id) {
const gs = new GrowsurfService();
const growRes = await gs.addParticipant(JSON.stringify({
email: form.email,
referredBy: referralCookie.referralId,
referralStatus: 'CREDIT_PENDING',
firstName: form.first_name,
lastName: form.last_name,
metadata: {
gigId: id,
},
}));
// If everything set in Growsurf
// add referral link to candidate profile in recruitCRM
if (!growRes.error) {
form.custom_fields.push({
field_id: 6, value: `https://app.growsurf.com/dashboard/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${growRes.id}`,
});
}
// clear the cookie
res.cookie(config.GROWSURF_COOKIE, '', {
maxAge: 0,
overwrite: true,
});
}
// Check if candidate exsits in the system?
const candidateResponse = await fetch(`${this.private.baseUrl}/v1/candidates/search?email=${form.email}`, {
method: 'GET',
Expand All @@ -197,7 +226,7 @@ export default class RecruitCRMService {
Authorization: this.private.authorization,
},
});
if (candidateResponse.status >= 400) {
if (candidateResponse.status >= 300) {
return res.send({
error: true,
status: candidateResponse.status,
Expand Down Expand Up @@ -231,7 +260,7 @@ export default class RecruitCRMService {
},
body: JSON.stringify(form),
});
if (workCandidateResponse.status >= 400) {
if (workCandidateResponse.status >= 300) {
return res.send({
error: true,
status: workCandidateResponse.status,
Expand All @@ -251,7 +280,7 @@ export default class RecruitCRMService {
},
body: fileData,
});
if (fileCandidateResponse.status >= 400) {
if (fileCandidateResponse.status >= 300) {
return res.send({
error: true,
status: fileCandidateResponse.status,
Expand All @@ -272,7 +301,7 @@ export default class RecruitCRMService {
Authorization: this.private.authorization,
},
});
if (applyResponse.status >= 400) {
if (applyResponse.status >= 300) {
const errObj = await applyResponse.json();
if (errObj.errorCode === 422 && errObj.errorMessage === 'Candidate is already assigned to this job') {
return res.send({
Expand Down Expand Up @@ -301,7 +330,7 @@ export default class RecruitCRMService {
status_id: '10',
}),
});
if (hireStageResponse.status >= 400) {
if (hireStageResponse.status >= 300) {
return res.send({
error: true,
status: hireStageResponse.status,
Expand Down
41 changes: 41 additions & 0 deletions src/server/services/sendGrid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Server-side functions necessary for sending emails via Sendgrid APIs
*/
import config from 'config';
import { logger } from 'topcoder-react-lib';
import fetch from 'isomorphic-fetch';

/**
* Sends emails via the Sendgrid API
* https://sendgrid.com/docs/api-reference/
* @param {Object} req the request
* @param {Object} res the response
*/
export const sendEmail = async (req, res) => {
try {
const msg = req.body;
const response = await fetch('https://api.sendgrid.com/v3/mail/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${config.SECRET.SENDGRID_API_KEY}`,
},
body: JSON.stringify(msg),
});
res.status(response.status);
return {};
} catch (error) {
logger.error(error);
const { message, code, response } = error;
res.status(code || 500);
if (error.response) {
const { headers, body } = response;
return {
message, headers, body,
};
}
return { message };
}
};

export default undefined;
Loading