Skip to content

Tasks 476 and 477#issuecomment-898886697 #492

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
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
12 changes: 6 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const eventHandlers = require('./src/eventHandlers')
const interviewService = require('./src/services/InterviewService')
const { processScheduler } = require('./src/services/PaymentSchedulerService')
const { sendSurveys } = require('./src/services/SurveyService')
const emailNotificationService = require('./src/services/EmailNotificationService')
const notificationSchedulerService = require('./src/services/NotificationsSchedulerService')

// setup express app
const app = express()
Expand Down Expand Up @@ -105,11 +105,11 @@ const server = app.listen(app.get('port'), () => {
// schedule payment processing
schedule.scheduleJob(config.PAYMENT_PROCESSING.CRON, processScheduler)

schedule.scheduleJob(config.CRON_CANDIDATE_REVIEW, emailNotificationService.sendCandidatesAvailableEmails)
schedule.scheduleJob(config.CRON_INTERVIEW_COMING_UP, emailNotificationService.sendInterviewComingUpEmails)
schedule.scheduleJob(config.CRON_INTERVIEW_COMPLETED, emailNotificationService.sendInterviewCompletedEmails)
schedule.scheduleJob(config.CRON_POST_INTERVIEW, emailNotificationService.sendPostInterviewActionEmails)
schedule.scheduleJob(config.CRON_UPCOMING_RESOURCE_BOOKING, emailNotificationService.sendResourceBookingExpirationEmails)
schedule.scheduleJob(config.CRON_CANDIDATE_REVIEW, notificationSchedulerService.sendCandidatesAvailableNotifications)
schedule.scheduleJob(config.CRON_INTERVIEW_COMING_UP, notificationSchedulerService.sendInterviewComingUpNotifications)
schedule.scheduleJob(config.CRON_INTERVIEW_COMPLETED, notificationSchedulerService.sendInterviewCompletedNotifications)
schedule.scheduleJob(config.CRON_POST_INTERVIEW, notificationSchedulerService.sendPostInterviewActionNotifications)
schedule.scheduleJob(config.CRON_UPCOMING_RESOURCE_BOOKING, notificationSchedulerService.sendResourceBookingExpirationNotifications)
})

if (process.env.NODE_ENV === 'test') {
Expand Down
10 changes: 5 additions & 5 deletions config/email_template.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ module.exports = {
*/
notificationEmailTemplates: {
'taas.notification.job-candidate-resume-viewed': {
subject: 'Topcoder - job candidate resume viewed',
subject: 'Topcoder - Client View Resume for Job {{jobName}}',
body: '',
recipients: [],
from: config.NOTIFICATION_SENDER_EMAIL,
Expand Down Expand Up @@ -161,14 +161,14 @@ module.exports = {
sendgridTemplateId: config.NOTIFICATION_SENDGRID_TEMPLATE_ID
},
'taas.notification.team-created': {
subject: 'Topcoder - Team Created',
subject: 'Topcoder - New Team {{teamName}} Created',
body: '',
recipients: [],
from: config.NOTIFICATION_SENDER_EMAIL,
sendgridTemplateId: config.NOTIFICATION_SENDGRID_TEMPLATE_ID
},
'taas.notification.job-created': {
subject: 'Topcoder - Job Created',
subject: 'Topcoder - New Job {{jobTitle}} Created in Team {{teamName}}',
body: '',
recipients: [],
from: config.NOTIFICATION_SENDER_EMAIL,
Expand All @@ -182,14 +182,14 @@ module.exports = {
sendgridTemplateId: config.NOTIFICATION_SENDGRID_TEMPLATE_ID
},
'taas.notification.job-candidate-selected': {
subject: 'Topcoder - Job Candidate Selected',
subject: 'Topcoder - Job Candidate {{userHandle}} Selected for {{jobTitle}} in Team {{teamName}}',
body: '',
recipients: config.NOTIFICATION_OPS_EMAILS,
from: config.NOTIFICATION_SENDER_EMAIL,
sendgridTemplateId: config.NOTIFICATION_SENDGRID_TEMPLATE_ID
},
'taas.notification.resource-booking-placed': {
subject: 'Topcoder - Resource Booking Placed',
subject: 'Topcoder - Resource Booking {{userHandle}} Placed for Job {{jobTitle}} in Team {{teamName}}',
body: '',
recipients: [],
from: config.NOTIFICATION_SENDER_EMAIL,
Expand Down
42 changes: 26 additions & 16 deletions data/notifications-email-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,23 @@
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Job title</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">No of resource bookings</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Candidates</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Status</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Review</td>
</tr>
{{#each teamJobs}}
<tr style="border:1px solid black;border-collapse:collapse">
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.title}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.jobUrl}} target="_blank" rel="noopener noreferrer">{{this.title}}</a>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.nResourceBookings}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<ul style="list-style-type:none;margin:0;padding:0;">
{{#each this.jobCandidates}}
<li><a href={{../reviewLink}} target="_blank" rel="noopener noreferrer">{{this.handle}}</a></li>
<li>{{this.handle}}</li>
{{/each}}
</ul>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<ul style="list-style-type:none;margin:0;padding:0;">
{{#each this.jobCandidates}}
<li>{{this.status}}</li>
{{/each}}
</ul>
<a href={{this.reviewLink}} target="_blank" rel="noopener noreferrer">Link</a>
</td>
</tr>
{{/each}}
Expand All @@ -136,7 +134,9 @@
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Date and Time</td>
</tr>
<tr>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.jobTitle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.jobUrl}} target="_blank" rel="noopener noreferrer">{{this.jobTitle}}</a>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.handle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.interviewLink}} target="_blank" rel="noopener noreferrer">Link</a></td>
Expand All @@ -160,7 +160,9 @@
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Interviews</td>
</tr>
<tr>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.jobTitle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.jobUrl}} target="_blank" rel="noopener noreferrer">{{this.jobTitle}}</a>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.startTime}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.interviewLink}} target="_blank" rel="noopener noreferrer">Link</a></td>
Expand All @@ -178,7 +180,9 @@
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Interviews</td>
</tr>
<tr>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.jobTitle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.jobUrl}} target="_blank" rel="noopener noreferrer">{{this.jobTitle}}</a>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.handle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.startTime}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
Expand All @@ -205,7 +209,9 @@
</tr>
{{#each teamInterviews}}
<tr>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.jobTitle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.jobUrl}} target="_blank" rel="noopener noreferrer">{{this.jobTitle}}</a>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.handle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.startTime}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
Expand All @@ -224,7 +230,7 @@

{{#if notificationType.upcomingResourceBookingExpiration}}
<span style="font-weight:bold;">Team Name:</span>
{{teamName}}
<a href={{this.teamUrl}} target="_blank" rel="noopener noreferrer">{{teamName}}</a>
<table style="font-size:13px;border:1px solid black;border-collapse:collapse;width:95%;">
<tr style="font-weight:bold;border:1px solid black;border-collapse:collapse">
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">Job title</td>
Expand All @@ -233,8 +239,12 @@
</tr>
{{#each teamResourceBookings}}
<tr>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.jobTitle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.handle}}</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.jobUrl}} target="_blank" rel="noopener noreferrer">{{this.jobTitle}}</a>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">
<a href={{this.resourceBookingUrl}} target="_blank" rel="noopener noreferrer">{{this.handle}}</a>
</td>
<td style="border:1px solid black;border-collapse:collapse;text-align:center;line-height:1.5;">{{this.endDate}}</td>
</tr>
{{/each}}
Expand All @@ -246,7 +256,7 @@

Your resume for the job "{{jobName}}" has been viewed by the client. <br/>
{{/if}}

{{#if notificationType.newTeamCreated}}
<span style="font-weight:bold;">Team:</span>
<a href={{teamUrl}} target="_blank" rel="noopener noreferrer">{{teamName}}</a>
Expand Down
30 changes: 16 additions & 14 deletions src/eventHandlers/JobCandidateEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,28 @@ async function sendJobCandidateSelectedNotification (payload) {
const project = await helper.getProjectById({ isMachine: true }, job.projectId)
const jobUrl = `${config.TAAS_APP_URL}/${project.id}/positions/${job.id}`
const teamUrl = `${config.TAAS_APP_URL}/${project.id}`
const data = {
subject: template.subject,
teamName: project.name,
teamUrl,
jobTitle: job.title,
jobDuration: job.duration,
jobStartDate: helper.formatDateEDT(job.startDate),
userHandle: user.handle,
jobUrl,
notificationType: {
candidateSelected: true
},
description: 'Job Candidate Selected'
}
data.subject = await helper.substituteStringByObject(data.subject, data)
const emailData = {
serviceId: 'email',
type: 'taas.notification.job-candidate-selected',
details: {
from: template.from,
recipients: template.recipients,
data: {
subject: template.subject,
teamName: project.name,
teamUrl,
jobTitle: job.title,
jobDuration: job.duration,
jobStartDate: helper.formatDateEDT(job.startDate),
userHandle: user.handle,
jobUrl,
notificationType: {
candidateSelected: true
},
description: 'Job Candidate Selected'
},
data,
sendgridTemplateId: template.sendgridTemplateId,
version: 'v3'
}
Expand Down
29 changes: 16 additions & 13 deletions src/eventHandlers/JobEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,28 @@ async function sendNotifications (payload) {
}
const template = helper.getEmailTemplatesForKey('notificationEmailTemplates')['taas.notification.job-created']
const project = await helper.getProjectById({ isMachine: true }, payload.value.projectId)
const data = {
subject: template.subject,
teamName: project.name,
teamURL: `${config.TAAS_APP_URL}/${project.id}`,
jobTitle: payload.value.title,
jobURL: `${config.TAAS_APP_URL}/${project.id}/positions/${payload.value.id}`,
jobDuration: payload.value.duration,
jobStartDate: helper.formatDateEDT(payload.value.startDate),
notificationType: {
newJobCreated: true
},
description: 'New Job Created'
}
data.subject = await helper.substituteStringByObject(data.subject, data)

const emailData = {
serviceId: 'email',
type: 'taas.notification.job-created',
details: {
from: template.from,
recipients: _.map(project.members, m => _.pick(m, 'email')),
data: {
subject: template.subject,
teamName: project.name,
teamURL: `${config.TAAS_APP_URL}/${project.id}`,
jobTitle: payload.value.title,
jobURL: `${config.TAAS_APP_URL}/${project.id}/positions/${payload.value.id}`,
jobDuration: payload.value.duration,
jobStartDate: helper.formatDateEDT(payload.value.startDate),
notificationType: {
newJobCreated: true
},
description: 'New Job Created'
},
data,
sendgridTemplateId: template.sendgridTemplateId,
version: 'v3'
}
Expand Down
30 changes: 16 additions & 14 deletions src/eventHandlers/ResourceBookingEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,28 @@ async function sendPlacedNotifications (payload) {
const recipients = _.map(project.members, m => _.pick(m, 'email'))
const jobUrl = `${config.TAAS_APP_URL}/${project.id}/positions/${job.id}`
const teamUrl = `${config.TAAS_APP_URL}/${project.id}`
const data = {
subject: template.subject,
teamName: project.name,
teamUrl,
jobTitle: job.title,
jobUrl,
userHandle: user.handle,
startDate: resourceBooking.startDate,
endDate: resourceBooking.endDate,
notificationType: {
resourceBookingPlaced: true
},
description: 'Resource Booking is Placed'
}
data.subject = await helper.substituteStringByObject(data.subject, data)
const emailData = {
serviceId: 'email',
type: 'taas.notification.resource-booking-placed',
details: {
from: template.from,
recipients,
data: {
subject: template.subject,
teamName: project.name,
teamUrl,
jobTitle: job.title,
jobUrl,
userHandle: user.handle,
startDate: resourceBooking.startDate,
endDate: resourceBooking.endDate,
notificationType: {
resourceBookingPlaced: true
},
description: 'Resource Booking is Placed'
},
data,
sendgridTemplateId: template.sendgridTemplateId,
version: 'v3'
}
Expand Down
33 changes: 18 additions & 15 deletions src/eventHandlers/TeamEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@ const helper = require('../common/helper')
*/
async function sendNotificationEmail (payload) {
const template = helper.getEmailTemplatesForKey('notificationEmailTemplates')['taas.notification.team-created']
const data = {
subject: template.subject,
teamName: payload.project.name,
teamUrl: `${config.TAAS_APP_URL}/${payload.project.id}`,
jobList: _.map(payload.jobs, j => ({
title: j.title,
duration: j.duration,
startDate: helper.formatDateEDT(j.startDate),
jobUrl: `${config.TAAS_APP_URL}/${payload.project.id}/positions/${j.id}`
})),
notificationType: {
newTeamCreated: true
},
description: 'New Team Created'
}
data.subject = await helper.substituteStringByObject(data.subject, data)

const emailData = {
serviceId: 'email',
type: 'taas.notification.team-created',
details: {
from: template.from,
recipients: _.map(payload.project.members, m => _.pick(m, 'email')),
data: {
subject: template.subject,
teamName: payload.project.name,
teamUrl: `${config.TAAS_APP_URL}/${payload.project.id}`,
jobList: _.map(payload.jobs, j => ({
title: j.title,
duration: j.duration,
startDate: helper.formatDateEDT(j.startDate),
jobUrl: `${config.TAAS_APP_URL}/${payload.project.id}/positions/${j.id}`
})),
notificationType: {
newTeamCreated: true
},
description: 'New Team Created'
},
data,
sendgridTemplateId: template.sendgridTemplateId,
version: 'v3'
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/JobCandidateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const logger = require('../common/logger')
const errors = require('../common/errors')
const models = require('../models')
const JobService = require('./JobService')
const EmailNotificationService = require('./EmailNotificationService')
const NotificationSchedulerService = require('./NotificationsSchedulerService')
const JobCandidate = models.JobCandidate
const esClient = helper.getESClient()

Expand Down Expand Up @@ -376,7 +376,7 @@ async function downloadJobCandidateResume (currentUser, id) {
const { handle } = await helper.getUserById(jobCandidate.userId, true)
const { email } = await helper.getMemberDetailsByHandle(handle)

await EmailNotificationService.sendEmail(currentUser, {
await NotificationSchedulerService.sendNotification(currentUser, {
template: 'taas.notification.job-candidate-resume-viewed',
recipients: [email],
data: {
Expand Down
Loading