@@ -44,12 +44,12 @@ async function getProjectWithId (projectId) {
4444
4545/**
4646 * extract the members of projects and build recipients list out of them
47- * we can use `userId ` to identify recipients
47+ * we can use `email ` to identify recipients
4848 * @param project the project
4949 * @returns {string[] } array of recipients
5050 */
5151function buildProjectTeamRecipients ( project ) {
52- const recipients = _ . unionBy ( _ . map ( project . members , m => _ . pick ( m , 'userId ' ) ) , 'userId ' )
52+ const recipients = _ . unionBy ( _ . map ( project . members , m => _ . pick ( m , 'email ' ) ) , 'email ' )
5353 if ( _ . isEmpty ( recipients ) ) {
5454 localLogger . error ( `No recipients for projectId:${ project . id } ` , 'buildProjectTeamRecipients' )
5555 }
@@ -276,11 +276,11 @@ async function sendInterviewComingUpNotifications () {
276276 const data = await getDataForInterview ( interview )
277277 if ( ! data ) { continue }
278278
279- if ( ! _ . isEmpty ( interview . hostEmail ) ) {
279+ if ( ! _ . isEmpty ( data . hostEmail ) ) {
280280 data . startTime = formatInterviewTime ( interview , { forInterviewHost : true } )
281281 sendNotification ( { } , {
282282 template : 'taas.notification.interview-coming-up-host' ,
283- recipients : [ { email : interview . hostEmail } ] ,
283+ recipients : [ { email : data . hostEmail } ] ,
284284 data
285285 } )
286286
@@ -289,12 +289,12 @@ async function sendInterviewComingUpNotifications () {
289289 localLogger . error ( `Interview id: ${ interview . id } host email not present` , 'sendInterviewComingUpNotifications' )
290290 }
291291
292- if ( ! _ . isEmpty ( interview . guestEmails ) ) {
292+ if ( ! _ . isEmpty ( data . guestEmail ) ) {
293293 data . startTime = formatInterviewTime ( interview , { forInterviewGuest : true } )
294294 // send guest emails
295295 sendNotification ( { } , {
296296 template : 'taas.notification.interview-coming-up-guest' ,
297- recipients : interview . guestEmails . map ( ( email ) => ( { email } ) ) ,
297+ recipients : [ { email : data . guestEmail } ] ,
298298 data
299299 } )
300300
@@ -354,22 +354,23 @@ async function sendInterviewCompletedNotifications () {
354354
355355 let sentCount = 0
356356 for ( const interview of interviews ) {
357- if ( _ . isEmpty ( interview . hostEmail ) ) {
358- localLogger . error ( `Interview id: ${ interview . id } host email not present` )
359- continue
360- }
361357 if ( ! jcMap [ interview . jobCandidateId ] || jcMap [ interview . jobCandidateId ] . status !== constants . JobCandidateStatus . INTERVIEW ) {
362358 localLogger . error ( `Interview id: ${ interview . id } job candidate status is not ${ constants . JobCandidateStatus . INTERVIEW } ` )
363359 continue
364360 }
365361
366362 const data = await getDataForInterview ( interview , jcMap [ interview . jobCandidateId ] )
363+
364+ if ( _ . isEmpty ( data . hostEmail ) ) {
365+ localLogger . error ( `Interview id: ${ interview . id } host email not present` )
366+ continue
367+ }
367368 if ( ! data ) { continue }
368369 data . startTime = formatInterviewTime ( interview , { forInterviewHost : true } )
369370
370371 sendNotification ( { } , {
371372 template : 'taas.notification.interview-awaits-resolution' ,
372- recipients : [ { email : interview . hostEmail } ] ,
373+ recipients : [ { email : data . hostEmail } ] ,
373374 data
374375 } )
375376
0 commit comments