Skip to content

Commit 82c1908

Browse files
authored
Merge pull request #846 from topcoder-platform/pm-1613
feat(PM-1613): Send notification to copilot who are accepted
2 parents e38365b + 97ca82e commit 82c1908

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ workflows:
149149
context : org-global
150150
filters:
151151
branches:
152-
only: ['develop', 'migration-setup', 'pm-1610']
152+
only: ['develop', 'migration-setup', 'pm-1613']
153153
- deployProd:
154154
context : org-global
155155
filters:

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ export const TEMPLATE_IDS = {
313313
PROJECT_MEMBER_INVITED: 'd-b47a25b103604bc28fc0ce77e77fb681',
314314
INFORM_PM_COPILOT_APPLICATION_ACCEPTED: 'd-b35d073e302b4279a1bd208fcfe96f58',
315315
COPILOT_ALREADY_PART_OF_PROJECT: 'd-003d41cdc9de4bbc9e14538e8f2e0585',
316+
COPILOT_APPLICATION_ACCEPTED: 'd-eef5e7568c644940b250e76d026ced5b',
316317
}
317318
export const REGEX = {
318319
URL: /^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,15})+(\:[0-9]{2,5})?(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=;]*)?$/, // eslint-disable-line

src/routes/copilotOpportunity/assign.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,30 @@ module.exports = [
203203
transaction: t,
204204
});
205205

206+
const sendEmailToCopilot = async () => {
207+
const memberDetails = await util.getMemberDetailsByUserIds([application.userId], req.log, req.id);
208+
const member = memberDetails[0];
209+
req.log.debug(`Sending email notification to accepted copilot`);
210+
const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_EMAIL;
211+
const copilotPortalUrl = config.get('copilotPortalUrl');
212+
const requestData = copilotRequest.data;
213+
createEvent(emailEventType, {
214+
data: {
215+
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}`,
216+
opportunity_title: requestData.opportunityTitle,
217+
start_date: moment.utc(requestData.startDate).format('DD-MM-YYYY'),
218+
user_name: member ? member.handle : "",
219+
},
220+
sendgrid_template_id: TEMPLATE_IDS.COPILOT_APPLICATION_ACCEPTED,
221+
recipients: [member.email],
222+
version: 'v3',
223+
}, req.log);
224+
225+
req.log.debug(`Email sent to copilot`);
226+
};
227+
228+
await sendEmailToCopilot();
229+
206230
// Cancel other applications
207231
const otherApplications = await models.CopilotApplication.findAll({
208232
where: {

0 commit comments

Comments
 (0)