Skip to content

Commit

Permalink
Changed mailing logic to get receivers out of database not envs anymore
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Oberndörfer <[email protected]>
  • Loading branch information
flo0852 committed Dec 7, 2024
1 parent 68fccde commit 6ae49f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions apps/backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ MAIL_HOST=smtp.example.com
MAIL_PORT=465
MAIL_USER=[email protected]
MAIL_PASSWORD=topsecret
MAIL_FROM=[email protected]
MAILING_LIST=[email protected],[email protected]
MAIL_FROM=[email protected]
14 changes: 12 additions & 2 deletions apps/backend/src/app/utils/mail/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ export class MailService {
}

async sendAlertMail(alert: Alert) {
const receivers =
this.configService.getOrThrow<string>('MAILING_LIST').split(',') || [];
const receiverEntities = await this.getAllMailReceiver();

if (receiverEntities.length === 0) {
this.logger.log('No mail receivers found. Skipping sending mail');
return;
}
const receivers = receiverEntities
.map((receiver) => receiver.mail)
.join(',')
.split(',');

console.log('receivers', receivers);

let reason = '';
let description = '';
Expand Down

0 comments on commit 6ae49f9

Please sign in to comment.