Skip to content

Commit 7b4edde

Browse files
authored
Merge pull request #832 from topcoder-platform/PM-1187_copilots-notification-via-slack
PM-1187 copilots notification via slack
2 parents bd92a3b + f79f42b commit 7b4edde

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

config/custom-environment-variables.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"AUTH0_PROXY_SERVER_URL" : "AUTH0_PROXY_SERVER_URL",
5454
"connectUrl": "CONNECT_URL",
5555
"workManagerUrl": "WORK_MANAGER_URL",
56+
"copilotsSlackEmail": "COPILOTS_SLACK_EMAIL",
5657
"accountsAppUrl": "ACCOUNTS_APP_URL",
5758
"inviteEmailSubject": "INVITE_EMAIL_SUBJECT",
5859
"inviteEmailSectionTitle": "INVITE_EMAIL_SECTION_TITLE",

config/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"workManagerUrl": "https://challenges.topcoder-dev.com",
5757
"copilotPortalUrl": "https://copilots.topcoder-dev.com",
5858
"accountsAppUrl": "https://accounts.topcoder-dev.com",
59+
"copilotsSlackEmail": "[email protected]",
5960
"MAX_REVISION_NUMBER": 100,
6061
"UNIQUE_GMAIL_VALIDATION": false,
6162
"pageSize": 20,

config/production.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"copilotPortalUrl": "https://copilots.topcoder.com",
55
"sfdcBillingAccountNameField": "Billing_Account_name__c",
66
"sfdcBillingAccountMarkupField": "Mark_up__c",
7-
"sfdcBillingAccountActiveField": "Active__c"
7+
"sfdcBillingAccountActiveField": "Active__c",
8+
"copilotsSlackEmail": "[email protected]"
89
}

src/routes/copilotRequest/approveRequest.service.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,25 @@ module.exports = (req, data, existingTransaction) => {
6767
const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_EMAIL;
6868
const copilotPortalUrl = config.get('copilotPortalUrl');
6969
req.log.info("Sending emails to all copilots about new opportunity");
70-
subjects.forEach(subject => {
71-
createEvent(emailEventType, {
72-
data: {
73-
user_name: subject.handle,
74-
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}`,
75-
work_manager_url: config.get('workManagerUrl'),
76-
opportunity_type: getCopilotTypeLabel(type),
77-
opportunity_title: opportunityTitle,
78-
start_date: moment.utc(startDate).format("YYYY-MM-DD HH:mm:ss [UTC]"),
79-
},
80-
sendgrid_template_id: TEMPLATE_IDS.CREATE_REQUEST,
81-
recipients: [subject.email],
82-
version: 'v3',
83-
}, req.log);
84-
});
70+
71+
const sendNotification = (userName, recipient) => createEvent(emailEventType, {
72+
data: {
73+
user_name: userName,
74+
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}`,
75+
work_manager_url: config.get('workManagerUrl'),
76+
opportunity_type: getCopilotTypeLabel(type),
77+
opportunity_title: opportunityTitle,
78+
start_date: moment.utc(startDate).format("YYYY-MM-DD HH:mm:ss [UTC]"),
79+
},
80+
sendgrid_template_id: TEMPLATE_IDS.CREATE_REQUEST,
81+
recipients: [recipient],
82+
version: 'v3',
83+
}, req.log);
84+
85+
subjects.forEach(subject => sendNotification(subject.handle, subject.email));
86+
87+
// send email to notify via slack
88+
sendNotification('Copilots', config.copilotsSlackEmail);
8589

8690
req.log.info("Finished sending emails to copilots");
8791

0 commit comments

Comments
 (0)