@@ -109,6 +109,7 @@ async function getDataForInterview (interview, jobCandidate, job) {
109109 * Sends notifications to all the teams which have candidates available for review
110110 */
111111async function sendCandidatesAvailableNotifications ( ) {
112+ localLogger . debug ( '[sendCandidatesAvailableNotifications]: Looking for due records...' )
112113 const jobsDao = await Job . findAll ( {
113114 include : [ {
114115 model : JobCandidate ,
@@ -190,6 +191,7 @@ async function sendCandidatesAvailableNotifications () {
190191 * Sends reminders to the hosts and guests about their upcoming interview(s)
191192 */
192193async function sendInterviewComingUpNotifications ( ) {
194+ localLogger . debug ( '[sendInterviewComingUpNotifications]: Looking for due records...' )
193195 const currentTime = moment . utc ( )
194196 const timestampFilter = {
195197 [ Op . or ] : [ ]
@@ -239,7 +241,7 @@ async function sendInterviewComingUpNotifications () {
239241 if ( ! _ . isEmpty ( interview . hostEmail ) ) {
240242 sendNotification ( { } , {
241243 template : 'taas.notification.interview-coming-up-host' ,
242- recipients : [ interview . hostEmail ] ,
244+ recipients : [ { email : interview . hostEmail } ] ,
243245 data : {
244246 ...data ,
245247 notificationType : {
@@ -258,7 +260,7 @@ async function sendInterviewComingUpNotifications () {
258260 // send guest emails
259261 sendNotification ( { } , {
260262 template : 'taas.notification.interview-coming-up-guest' ,
261- recipients : interview . guestEmails ,
263+ recipients : interview . guestEmails . map ( ( email ) => ( { email } ) ) ,
262264 data : {
263265 ...data ,
264266 notificationType : {
@@ -281,6 +283,7 @@ async function sendInterviewComingUpNotifications () {
281283 * Sends reminder to the interview host after it ends to change the interview status
282284 */
283285async function sendInterviewCompletedNotifications ( ) {
286+ localLogger . debug ( '[sendInterviewCompletedNotifications]: Looking for due records...' )
284287 const window = moment . duration ( config . INTERVIEW_COMPLETED_MATCH_WINDOW )
285288 const rangeStart = moment . utc ( ) . subtract ( moment . duration ( config . INTERVIEW_COMPLETED_PAST_TIME ) )
286289 const rangeEnd = rangeStart . clone ( ) . add ( window )
@@ -323,7 +326,7 @@ async function sendInterviewCompletedNotifications () {
323326
324327 sendNotification ( { } , {
325328 template : 'taas.notification.interview-awaits-resolution' ,
326- recipients : [ interview . hostEmail ] ,
329+ recipients : [ { email : interview . hostEmail } ] ,
327330 data : {
328331 ...data ,
329332 notificationType : {
@@ -344,6 +347,7 @@ async function sendInterviewCompletedNotifications () {
344347 * to update the job candidate status
345348 */
346349async function sendPostInterviewActionNotifications ( ) {
350+ localLogger . debug ( '[sendPostInterviewActionNotifications]: Looking for due records...' )
347351 const completedJobCandidates = await JobCandidate . findAll ( {
348352 where : {
349353 status : constants . JobCandidateStatus . INTERVIEW
@@ -353,7 +357,10 @@ async function sendPostInterviewActionNotifications () {
353357 as : 'interviews' ,
354358 required : true ,
355359 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+ }
357364 }
358365 } ]
359366 } )
@@ -436,6 +443,7 @@ async function sendPostInterviewActionNotifications () {
436443 * Sends reminders to all members of teams which have atleast one upcoming resource booking expiration
437444 */
438445async function sendResourceBookingExpirationNotifications ( ) {
446+ localLogger . debug ( '[sendResourceBookingExpirationNotifications]: Looking for due records...' )
439447 const currentTime = moment . utc ( )
440448 const maxEndDate = currentTime . clone ( ) . add ( moment . duration ( config . RESOURCE_BOOKING_EXPIRY_TIME ) )
441449
@@ -543,7 +551,7 @@ async function sendResourceBookingExpirationNotifications () {
543551async function sendNotification ( currentUser , data , webNotifications = [ ] ) {
544552 const template = emailTemplates [ data . template ]
545553 const dataCC = data . cc || [ ]
546- const templateCC = template . cc || [ ]
554+ const templateCC = ( template . cc || [ ] ) . map ( email => ( { email } ) )
547555 const dataRecipients = data . recipients || [ ]
548556 const templateRecipients = ( template . recipients || [ ] ) . map ( email => ( { email } ) )
549557 const subjectBody = {
@@ -557,14 +565,14 @@ async function sendNotification (currentUser, data, webNotifications = []) {
557565 )
558566 }
559567
560- const recipients = _ . map ( _ . uniq ( [ ...dataRecipients , ...templateRecipients ] ) , function ( r ) { return { email : r } } )
568+ const recipients = _ . uniq ( [ ...dataRecipients , ...templateRecipients ] )
561569 const emailData = {
562570 serviceId : 'email' ,
563571 type : data . template ,
564572 details : {
565573 from : data . from || template . from ,
566574 recipients,
567- cc : _ . map ( _ . uniq ( [ ...dataCC , ...templateCC ] ) , function ( r ) { return { email : r } } ) ,
575+ cc : _ . uniq ( [ ...dataCC , ...templateCC ] ) ,
568576 data : { ...data . data , ...subjectBody } ,
569577 sendgridTemplateId : template . sendgridTemplateId ,
570578 version : 'v3'
0 commit comments