Skip to content

Commit c090db8

Browse files
committed
Replacing subject placeholders
1 parent 1418cd9 commit c090db8

File tree

4 files changed

+66
-56
lines changed

4 files changed

+66
-56
lines changed

src/eventHandlers/JobCandidateEventHandler.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,28 @@ async function sendJobCandidateSelectedNotification (payload) {
155155
const project = await helper.getProjectById({ isMachine: true }, job.projectId)
156156
const jobUrl = `${config.TAAS_APP_URL}/${project.id}/positions/${job.id}`
157157
const teamUrl = `${config.TAAS_APP_URL}/${project.id}`
158+
const data = {
159+
subject: template.subject,
160+
teamName: project.name,
161+
teamUrl,
162+
jobTitle: job.title,
163+
jobDuration: job.duration,
164+
jobStartDate: helper.formatDateEDT(job.startDate),
165+
userHandle: user.handle,
166+
jobUrl,
167+
notificationType: {
168+
candidateSelected: true
169+
},
170+
description: 'Job Candidate Selected'
171+
}
172+
data.subject = await helper.substituteStringByObject(data.subject, data)
158173
const emailData = {
159174
serviceId: 'email',
160175
type: 'taas.notification.job-candidate-selected',
161176
details: {
162177
from: template.from,
163178
recipients: template.recipients,
164-
data: {
165-
subject: template.subject,
166-
teamName: project.name,
167-
teamUrl,
168-
jobTitle: job.title,
169-
jobDuration: job.duration,
170-
jobStartDate: helper.formatDateEDT(job.startDate),
171-
userHandle: user.handle,
172-
jobUrl,
173-
notificationType: {
174-
candidateSelected: true
175-
},
176-
description: 'Job Candidate Selected'
177-
},
179+
data,
178180
sendgridTemplateId: template.sendgridTemplateId,
179181
version: 'v3'
180182
}

src/eventHandlers/JobEventHandler.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,28 @@ async function sendNotifications (payload) {
8484
}
8585
const template = helper.getEmailTemplatesForKey('notificationEmailTemplates')['taas.notification.job-created']
8686
const project = await helper.getProjectById({ isMachine: true }, payload.value.projectId)
87+
const data = {
88+
subject: template.subject,
89+
teamName: project.name,
90+
teamURL: `${config.TAAS_APP_URL}/${project.id}`,
91+
jobTitle: payload.value.title,
92+
jobURL: `${config.TAAS_APP_URL}/${project.id}/positions/${payload.value.id}`,
93+
jobDuration: payload.value.duration,
94+
jobStartDate: helper.formatDateEDT(payload.value.startDate),
95+
notificationType: {
96+
newJobCreated: true
97+
},
98+
description: 'New Job Created'
99+
}
100+
data.subject = await helper.substituteStringByObject(data.subject, data)
101+
87102
const emailData = {
88103
serviceId: 'email',
89104
type: 'taas.notification.job-created',
90105
details: {
91106
from: template.from,
92107
recipients: _.map(project.members, m => _.pick(m, 'email')),
93-
data: {
94-
subject: template.subject,
95-
teamName: project.name,
96-
teamURL: `${config.TAAS_APP_URL}/${project.id}`,
97-
jobTitle: payload.value.title,
98-
jobURL: `${config.TAAS_APP_URL}/${project.id}/positions/${payload.value.id}`,
99-
jobDuration: payload.value.duration,
100-
jobStartDate: helper.formatDateEDT(payload.value.startDate),
101-
notificationType: {
102-
newJobCreated: true
103-
},
104-
description: 'New Job Created'
105-
},
108+
data,
106109
sendgridTemplateId: template.sendgridTemplateId,
107110
version: 'v3'
108111
}

src/eventHandlers/ResourceBookingEventHandler.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,28 @@ async function sendPlacedNotifications (payload) {
8989
const recipients = _.map(project.members, m => _.pick(m, 'email'))
9090
const jobUrl = `${config.TAAS_APP_URL}/${project.id}/positions/${job.id}`
9191
const teamUrl = `${config.TAAS_APP_URL}/${project.id}`
92+
const data = {
93+
subject: template.subject,
94+
teamName: project.name,
95+
teamUrl,
96+
jobTitle: job.title,
97+
jobUrl,
98+
userHandle: user.handle,
99+
startDate: resourceBooking.startDate,
100+
endDate: resourceBooking.endDate,
101+
notificationType: {
102+
resourceBookingPlaced: true
103+
},
104+
description: 'Resource Booking is Placed'
105+
}
106+
data.subject = await helper.substituteStringByObject(data.subject, data)
92107
const emailData = {
93108
serviceId: 'email',
94109
type: 'taas.notification.resource-booking-placed',
95110
details: {
96111
from: template.from,
97112
recipients,
98-
data: {
99-
subject: template.subject,
100-
teamName: project.name,
101-
teamUrl,
102-
jobTitle: job.title,
103-
jobUrl,
104-
userHandle: user.handle,
105-
startDate: resourceBooking.startDate,
106-
endDate: resourceBooking.endDate,
107-
notificationType: {
108-
resourceBookingPlaced: true
109-
},
110-
description: 'Resource Booking is Placed'
111-
},
113+
data,
112114
sendgridTemplateId: template.sendgridTemplateId,
113115
version: 'v3'
114116
}

src/eventHandlers/TeamEventHandler.js

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,30 @@ const helper = require('../common/helper')
1515
*/
1616
async function sendNotificationEmail (payload) {
1717
const template = helper.getEmailTemplatesForKey('notificationEmailTemplates')['taas.notification.team-created']
18+
const data = {
19+
subject: template.subject,
20+
teamName: payload.project.name,
21+
teamUrl: `${config.TAAS_APP_URL}/${payload.project.id}`,
22+
jobList: _.map(payload.jobs, j => ({
23+
title: j.title,
24+
duration: j.duration,
25+
startDate: helper.formatDateEDT(j.startDate),
26+
jobUrl: `${config.TAAS_APP_URL}/${payload.project.id}/positions/${j.id}`
27+
})),
28+
notificationType: {
29+
newTeamCreated: true
30+
},
31+
description: 'New Team Created'
32+
}
33+
data.subject = await helper.substituteStringByObject(data.subject, data)
34+
1835
const emailData = {
1936
serviceId: 'email',
2037
type: 'taas.notification.team-created',
2138
details: {
2239
from: template.from,
2340
recipients: _.map(payload.project.members, m => _.pick(m, 'email')),
24-
data: {
25-
subject: template.subject,
26-
teamName: payload.project.name,
27-
teamUrl: `${config.TAAS_APP_URL}/${payload.project.id}`,
28-
jobList: _.map(payload.jobs, j => ({
29-
title: j.title,
30-
duration: j.duration,
31-
startDate: helper.formatDateEDT(j.startDate),
32-
jobUrl: `${config.TAAS_APP_URL}/${payload.project.id}/positions/${j.id}`
33-
})),
34-
notificationType: {
35-
newTeamCreated: true
36-
},
37-
description: 'New Team Created'
38-
},
41+
data,
3942
sendgridTemplateId: template.sendgridTemplateId,
4043
version: 'v3'
4144
}

0 commit comments

Comments
 (0)