diff --git a/apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts b/apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts index 07d4d4055..193524ec0 100644 --- a/apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts +++ b/apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts @@ -180,11 +180,10 @@ export class ReminderEmailsController { { mentorshipMatchAgeInDays: 14 } ) - // TODO: Uncomment and merge this two weeks after the first reminder is sent - // const mentorshipMatchesWithMentorAndMenteeDetails_4weeks = - // await this.reminderEmailsService.getMentorsAndMenteesWithoutMentoringSessionsLogged( - // { mentorshipMatchAgeInDays: 28 } - // ) + const mentorshipMatchesWithMentorAndMenteeDetails_4weeks = + await this.reminderEmailsService.getMentorsAndMenteesWithoutMentoringSessionsLogged( + { mentorshipMatchAgeInDays: 28 } + ) if ( Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_2weeks).length > 0 @@ -200,19 +199,26 @@ export class ReminderEmailsController { ) } - // TODO: Uncomment and merge this two weeks after the first reminder is sent - // if ( - // Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).length > 0 - // ) { - // // send reminder emails - // Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).forEach( - // async (key) => { - // await this.reminderEmailsService.sendLogMentoringSessionsReminder( - // mentorshipMatchesWithMentorAndMenteeDetails_4weeks[key], - // 28 - // ) - // } - // ) - // } + if ( + Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).length > 0 + ) { + // send reminder emails + Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).forEach( + async (key) => { + await this.reminderEmailsService.sendLogMentoringSessionsReminder( + mentorshipMatchesWithMentorAndMenteeDetails_4weeks[key], + 28 + ) + } + ) + } + + return { + message: `Mentoring Session Loggging Reminder emails sent: 1st: ${ + Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_2weeks).length + }, 2nd: ${ + Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).length + }`, + } } } diff --git a/apps/nestjs-api/src/reminder-emails/reminder-emails.service.ts b/apps/nestjs-api/src/reminder-emails/reminder-emails.service.ts index d7aa0223f..b5a91234c 100644 --- a/apps/nestjs-api/src/reminder-emails/reminder-emails.service.ts +++ b/apps/nestjs-api/src/reminder-emails/reminder-emails.service.ts @@ -233,6 +233,7 @@ export class ReminderEmailsService { const mentorshipMatchesWithSessionsCount = {} as Record< string, { + mentorshipMatchId: string, menteeId: string mentorId: string mentoringSessionsCount: number @@ -252,6 +253,7 @@ export class ReminderEmailsService { // Step 2.2: Fill the object with the mentorship match id as key and the mentee id, mentor id and the count of mentoring sessions mentorshipMatchesWithSessionsCount[match.props.id] = { + mentorshipMatchId: match.props.id, menteeId: match.props.menteeId, mentorId: match.props.mentorId, mentoringSessionsCount: mentoringSessions.length, @@ -304,6 +306,7 @@ export class ReminderEmailsService { ) result[key] = { + mentorshipMatchId: value.mentorshipMatchId, menteeFirstName: mentee?.props.firstName, menteeEmail: mentee?.props.email, mentorFirstName: mentor?.props.firstName, @@ -591,6 +594,7 @@ export class ReminderEmailsService { async sendLogMentoringSessionsReminder( { + mentorshipMatchId, menteeFirstName, menteeEmail, mentorFirstName, @@ -646,6 +650,7 @@ export class ReminderEmailsService { ) .replace(/{{{Recipient.FirstName}}}/g, mentorFirstName) .replace(/\${matchMadeActiveOn}/g, matchMadeActiveOn) + .replace(/\${logMentoringSessionUrl}/g, `https://connect.redi-school.org/app/mentorships/${mentorshipMatchId}`) const menteeParams = { Destination: {