Skip to content
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 @@ -149,7 +149,7 @@ workflows:
context : org-global
filters:
branches:
only: ['develop', 'migration-setup', 'pm-1610']
only: ['develop', 'migration-setup', 'pm-1613']
- deployProd:
context : org-global
filters:
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export const TEMPLATE_IDS = {
PROJECT_MEMBER_INVITED: 'd-b47a25b103604bc28fc0ce77e77fb681',
INFORM_PM_COPILOT_APPLICATION_ACCEPTED: 'd-b35d073e302b4279a1bd208fcfe96f58',
COPILOT_ALREADY_PART_OF_PROJECT: 'd-003d41cdc9de4bbc9e14538e8f2e0585',
COPILOT_APPLICATION_ACCEPTED: 'd-eef5e7568c644940b250e76d026ced5b',
}
export const REGEX = {
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
Expand Down
24 changes: 24 additions & 0 deletions src/routes/copilotOpportunity/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,30 @@ module.exports = [
transaction: t,
});

const sendEmailToCopilot = async () => {
const memberDetails = await util.getMemberDetailsByUserIds([application.userId], req.log, req.id);
const member = memberDetails[0];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the getMemberDetailsByUserIds function to manage cases where the member details cannot be retrieved.

req.log.debug(`Sending email notification to accepted copilot`);
const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_EMAIL;
const copilotPortalUrl = config.get('copilotPortalUrl');
const requestData = copilotRequest.data;
createEvent(emailEventType, {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that createEvent handles errors gracefully, especially if the email sending fails. Consider adding a try-catch block around this call.

data: {
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}`,
opportunity_title: requestData.opportunityTitle,
start_date: moment.utc(requestData.startDate).format('DD-MM-YYYY'),
user_name: member ? member.handle : "",
},
sendgrid_template_id: TEMPLATE_IDS.COPILOT_APPLICATION_ACCEPTED,
recipients: [member.email],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if member.email is defined before using it in the recipients array to prevent potential runtime errors.

version: 'v3',
}, req.log);

req.log.debug(`Email sent to copilot`);
};

await sendEmailToCopilot();

// Cancel other applications
const otherApplications = await models.CopilotApplication.findAll({
where: {
Expand Down