-
Notifications
You must be signed in to change notification settings - Fork 56
feat(PM-1173): Notify all copilots on copilot opportunity #815
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 1 commit
79fdf6f
4b8c9f7
0c54ecf
223b7bd
82dd797
9793dcc
5b29f65
a29f1c9
deaed3a
d4ed7a9
91f23ab
fb9b8a9
31a2b66
ae5952d
c16d06e
190c04c
4c98fe7
0ad22c3
cc5a28d
b52b16e
5fbd197
49356d6
e34f785
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,23 +59,19 @@ module.exports = (req, data, existingTransaction) => { | |
const roles = await util.getRolesByRoleName('copilot', req.log, req.id); | ||
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. The function 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. Conver role name to enum/constant. Do not use hardcoded names. |
||
req.log.info("getting subjects for roles", roles[0]); | ||
const { subjects = [] } = await util.getRoleInfo(roles[0], req.log, req.id); | ||
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. The log message for getting subjects for roles has been removed. If this was intentional, ensure that the removal does not affect the debugging process. If not, consider reinstating it for better traceability. |
||
const emailEventType = CONNECT_NOTIFICATION_EVENT.COPILOT_OPPORTUNITY_CREATED; | ||
const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_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. The change of |
||
const copilotPortalUrl = config.get('copilotPortalUrl'); | ||
req.log.info("Sending emails to all copilots about new opportunity"); | ||
subjects.forEach(subject => { | ||
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. Consider handling the case where |
||
req.log.info("Each copilot members", subject); | ||
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. The log message 'Each copilot members' could be more descriptive. Consider including more context, such as the copilot's handle or email, to make the logs more informative. 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. The log message for the copilot portal URL has been removed. If this was intentional, ensure that the removal does not affect the ability to trace the URL being used. If not, consider reinstating it for better traceability. |
||
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. The log statement 'Each copilot members' was removed. If this was intentional, ensure that the logging is still sufficient for debugging purposes. If not, consider adding a relevant log statement to track each copilot being notified. |
||
data: { | ||
handle: subject.handle, | ||
user_name: subject.handle, | ||
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. The key 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. Consider using camelCase for consistency with JavaScript naming conventions. Change |
||
opportunityDetailsUrl: `${copilotPortalUrl}/opportunity/${opportunity.id}`, | ||
}, | ||
sendgrid_template_id: "d-3efdc91da580479d810c7acd50a4c17f", | ||
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. The addition of 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. Move the template id to constant. |
||
recipients: [subject.email], | ||
version: 'v3', | ||
from: { | ||
name: config.get('EMAIL_INVITE_FROM_NAME'), | ||
email: config.get('EMAIL_INVITE_FROM_EMAIL'), | ||
}, | ||
categories: [`${process.env.NODE_ENV}:${emailEventType}`.toLowerCase()], | ||
version: '433b1688-c543-4656-a295-efcbea57444d', | ||
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. The |
||
}, req.log); | ||
}); | ||
|
||
|
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.
The change from
COPILOT_OPPORTUNITY_CREATED
toEXTERNAL_ACTION_EMAIL
seems to alter the meaning of the event. Ensure that this change aligns with the intended functionality described in the pull request. If the intention is to notify all copilots, verify that the event name accurately reflects this purpose.