@@ -109,6 +109,7 @@ async function getDataForInterview (interview, jobCandidate, job) {
109
109
* Sends notifications to all the teams which have candidates available for review
110
110
*/
111
111
async function sendCandidatesAvailableNotifications ( ) {
112
+ localLogger . debug ( '[sendCandidatesAvailableNotifications]: Looking for due records...' )
112
113
const jobsDao = await Job . findAll ( {
113
114
include : [ {
114
115
model : JobCandidate ,
@@ -190,6 +191,7 @@ async function sendCandidatesAvailableNotifications () {
190
191
* Sends reminders to the hosts and guests about their upcoming interview(s)
191
192
*/
192
193
async function sendInterviewComingUpNotifications ( ) {
194
+ localLogger . debug ( '[sendInterviewComingUpNotifications]: Looking for due records...' )
193
195
const currentTime = moment . utc ( )
194
196
const timestampFilter = {
195
197
[ Op . or ] : [ ]
@@ -239,7 +241,7 @@ async function sendInterviewComingUpNotifications () {
239
241
if ( ! _ . isEmpty ( interview . hostEmail ) ) {
240
242
sendNotification ( { } , {
241
243
template : 'taas.notification.interview-coming-up-host' ,
242
- recipients : [ interview . hostEmail ] ,
244
+ recipients : [ { email : interview . hostEmail } ] ,
243
245
data : {
244
246
...data ,
245
247
notificationType : {
@@ -258,7 +260,7 @@ async function sendInterviewComingUpNotifications () {
258
260
// send guest emails
259
261
sendNotification ( { } , {
260
262
template : 'taas.notification.interview-coming-up-guest' ,
261
- recipients : interview . guestEmails ,
263
+ recipients : interview . guestEmails . map ( ( email ) => ( { email } ) ) ,
262
264
data : {
263
265
...data ,
264
266
notificationType : {
@@ -281,6 +283,7 @@ async function sendInterviewComingUpNotifications () {
281
283
* Sends reminder to the interview host after it ends to change the interview status
282
284
*/
283
285
async function sendInterviewCompletedNotifications ( ) {
286
+ localLogger . debug ( '[sendInterviewCompletedNotifications]: Looking for due records...' )
284
287
const window = moment . duration ( config . INTERVIEW_COMPLETED_MATCH_WINDOW )
285
288
const rangeStart = moment . utc ( ) . subtract ( moment . duration ( config . INTERVIEW_COMPLETED_PAST_TIME ) )
286
289
const rangeEnd = rangeStart . clone ( ) . add ( window )
@@ -323,7 +326,7 @@ async function sendInterviewCompletedNotifications () {
323
326
324
327
sendNotification ( { } , {
325
328
template : 'taas.notification.interview-awaits-resolution' ,
326
- recipients : [ interview . hostEmail ] ,
329
+ recipients : [ { email : interview . hostEmail } ] ,
327
330
data : {
328
331
...data ,
329
332
notificationType : {
@@ -344,6 +347,7 @@ async function sendInterviewCompletedNotifications () {
344
347
* to update the job candidate status
345
348
*/
346
349
async function sendPostInterviewActionNotifications ( ) {
350
+ localLogger . debug ( '[sendPostInterviewActionNotifications]: Looking for due records...' )
347
351
const completedJobCandidates = await JobCandidate . findAll ( {
348
352
where : {
349
353
status : constants . JobCandidateStatus . INTERVIEW
@@ -353,7 +357,10 @@ async function sendPostInterviewActionNotifications () {
353
357
as : 'interviews' ,
354
358
required : true ,
355
359
where : {
356
- status : constants . Interviews . Status . Completed
360
+ status : constants . Interviews . Status . Completed ,
361
+ startTimestamp : {
362
+ [ Op . lte ] : moment . utc ( ) . subtract ( moment . duration ( config . POST_INTERVIEW_ACTION_MATCH_WINDOW ) )
363
+ }
357
364
}
358
365
} ]
359
366
} )
@@ -436,6 +443,7 @@ async function sendPostInterviewActionNotifications () {
436
443
* Sends reminders to all members of teams which have atleast one upcoming resource booking expiration
437
444
*/
438
445
async function sendResourceBookingExpirationNotifications ( ) {
446
+ localLogger . debug ( '[sendResourceBookingExpirationNotifications]: Looking for due records...' )
439
447
const currentTime = moment . utc ( )
440
448
const maxEndDate = currentTime . clone ( ) . add ( moment . duration ( config . RESOURCE_BOOKING_EXPIRY_TIME ) )
441
449
@@ -543,7 +551,7 @@ async function sendResourceBookingExpirationNotifications () {
543
551
async function sendNotification ( currentUser , data , webNotifications = [ ] ) {
544
552
const template = emailTemplates [ data . template ]
545
553
const dataCC = data . cc || [ ]
546
- const templateCC = template . cc || [ ]
554
+ const templateCC = ( template . cc || [ ] ) . map ( email => ( { email } ) )
547
555
const dataRecipients = data . recipients || [ ]
548
556
const templateRecipients = ( template . recipients || [ ] ) . map ( email => ( { email } ) )
549
557
const subjectBody = {
@@ -557,14 +565,14 @@ async function sendNotification (currentUser, data, webNotifications = []) {
557
565
)
558
566
}
559
567
560
- const recipients = _ . map ( _ . uniq ( [ ...dataRecipients , ...templateRecipients ] ) , function ( r ) { return { email : r } } )
568
+ const recipients = _ . uniq ( [ ...dataRecipients , ...templateRecipients ] )
561
569
const emailData = {
562
570
serviceId : 'email' ,
563
571
type : data . template ,
564
572
details : {
565
573
from : data . from || template . from ,
566
574
recipients,
567
- cc : _ . map ( _ . uniq ( [ ...dataCC , ...templateCC ] ) , function ( r ) { return { email : r } } ) ,
575
+ cc : _ . uniq ( [ ...dataCC , ...templateCC ] ) ,
568
576
data : { ...data . data , ...subjectBody } ,
569
577
sendgridTemplateId : template . sendgridTemplateId ,
570
578
version : 'v3'
0 commit comments