-
Notifications
You must be signed in to change notification settings - Fork 55
feat(PM-1613): Send notification to copilot who are accepted #846
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]; | ||
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, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure that |
||
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], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if |
||
version: 'v3', | ||
}, req.log); | ||
|
||
req.log.debug(`Email sent to copilot`); | ||
}; | ||
|
||
await sendEmailToCopilot(); | ||
|
||
// Cancel other applications | ||
const otherApplications = await models.CopilotApplication.findAll({ | ||
where: { | ||
|
There was a problem hiding this comment.
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.