Skip to content

fix(PM-1497): Add opportunity title and type in apply copilot email #834

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 3 commits into from
Jul 23, 2025
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-1494_1']
only: ['develop', 'migration-setup', 'pm-1497']
- deployProd:
context : org-global
filters:
Expand Down
10 changes: 10 additions & 0 deletions src/routes/copilotOpportunityApply/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import util from '../../util';
import { PERMISSION } from '../../permissions/constants';
import { CONNECT_NOTIFICATION_EVENT, COPILOT_OPPORTUNITY_STATUS, TEMPLATE_IDS, USER_ROLE } from '../../constants';
import { createEvent } from '../../services/busApi';
import { getCopilotTypeLabel } from '../../utils/copilot';

const applyCopilotRequestValidations = {
body: Joi.object().keys({
Expand Down Expand Up @@ -41,6 +42,12 @@ module.exports = [
where: {
id: copilotOpportunityId,
},
include: [

Choose a reason for hiding this comment

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

Consider specifying the attributes you need from the copilotRequest model to optimize the query and reduce unnecessary data retrieval.

{
model: models.CopilotRequest,
as: 'copilotRequest',
},
],
}).then(async (opportunity) => {
if (!opportunity) {
const err = new Error('No opportunity found');
Expand Down Expand Up @@ -92,12 +99,15 @@ module.exports = [

const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_EMAIL;
const copilotPortalUrl = config.get('copilotPortalUrl');
const requestData = opportunity.copilotRequest.data;
listOfSubjects.forEach((subject) => {
createEvent(emailEventType, {
data: {
user_name: subject.handle,
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}#applications`,
work_manager_url: config.get('workManagerUrl'),
opportunity_type: getCopilotTypeLabel(requestData.projectType),

Choose a reason for hiding this comment

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

Ensure that getCopilotTypeLabel function handles all possible values of requestData.projectType to avoid potential errors or unexpected behavior.

opportunity_title: requestData.opportunityTitle,

Choose a reason for hiding this comment

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

Consider adding validation to ensure requestData.opportunityTitle is not null or undefined before using it, to prevent potential issues in the email content.

},
sendgrid_template_id: TEMPLATE_IDS.APPLY_COPILOT,
recipients: [subject.email],
Expand Down