Skip to content

Commit

Permalink
mail service changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chelsea-EYDS committed Jan 27, 2025
1 parent 99b9c89 commit 0c7ce56
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions backend/src/mail/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,25 +238,25 @@ export class MailService {

const existingMail = await mailQB.getMany();

const existingEmails =
existingMail.length > 0 && existingMail.map((itm) => itm.email);

this.logger.log(
`Total existing emails to filter: ${existingEmails?.length}`,
);

const filteredContexts = mail.contexts.filter(
(itm) => !existingEmails?.includes(itm.to[0]),
);
if (existingMail?.length > 0) {
const existingEmails = existingMail.map((itm) => itm.email);
this.logger.log(
`Total existing emails to filter: ${existingEmails?.length}`,
);

const filteredContexts = mail.contexts.filter(
(itm) => !existingEmails?.includes(itm.to[0]),
);

if (existingEmails?.length > 0) {
mail.contexts = filteredContexts;
}

if (existingEmails.length > 0) {
mail.contexts = filteredContexts;
this.logger.log(
`Total emails to be sent (after filter existing): ${mail.contexts?.length}`,
);
}

this.logger.log(
`Total emails to be sent (after filter existing): ${mail.contexts?.length}`,
);

if (mail.contexts.length === 0) {
this.logger.log('No valid emails to send');
return;
Expand Down

0 comments on commit 0c7ce56

Please sign in to comment.