diff --git a/src/config/config.ts b/src/config/config.ts index 018e4d20d9..3d9a1c5fdd 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -149,6 +149,7 @@ export class Configuration { contact: { supportMail: process.env.SUPPORT_MAIL || 'support@dfx.swiss', monitoringMail: process.env.MONITORING_MAIL || 'monitoring@dfx.swiss', + liqMail: process.env.LIQ_MAIL || 'liq@dfx.swiss', noReplyMail: process.env.NOREPLY_MAIL || 'noreply@dfx.swiss', }, }; diff --git a/src/notification/entities/mail/base/mail.ts b/src/notification/entities/mail/base/mail.ts index 5a1e380ed0..debf920e28 100644 --- a/src/notification/entities/mail/base/mail.ts +++ b/src/notification/entities/mail/base/mail.ts @@ -3,7 +3,7 @@ import { NotificationType } from 'src/notification/enums'; import { Notification, NotificationOptions, NotificationMetadata } from '../../notification.entity'; export interface MailParams { - to: string; + to: string | string[]; subject: string; salutation: string; body: string; @@ -26,7 +26,7 @@ export class Mail extends Notification { name: 'DFX.swiss', address: GetConfig().mail.contact.noReplyMail, }; - readonly #to: string; + readonly #to: string | string[]; readonly #cc: string; readonly #bcc: string; readonly #template: string = GetConfig().mail.defaultMailTemplate; @@ -66,7 +66,7 @@ export class Mail extends Notification { return { name, address }; } - get to(): string { + get to(): string | string[] { return this.#to; } diff --git a/src/notification/entities/mail/error-monitoring-mail.ts b/src/notification/entities/mail/error-monitoring-mail.ts index cf848d6691..6b1e52534e 100644 --- a/src/notification/entities/mail/error-monitoring-mail.ts +++ b/src/notification/entities/mail/error-monitoring-mail.ts @@ -1,4 +1,5 @@ import { GetConfig } from 'src/config/config'; +import { MailContext } from 'src/notification/enums'; import { NotificationMetadata, NotificationOptions } from '../notification.entity'; import { Mail } from './base/mail'; @@ -13,8 +14,11 @@ export interface ErrorMonitoringMailParams { export class ErrorMonitoringMail extends Mail { constructor(params: ErrorMonitoringMailParams) { + const to = [GetConfig().mail.contact.monitoringMail]; + ErrorMonitoringMail.isLiqMail(params) && to.push(GetConfig().mail.contact.liqMail); + const _params = { - to: GetConfig().mail.contact.monitoringMail, + to: to, subject: `${params.subject} (${GetConfig().environment.toUpperCase()})`, salutation: 'Hi DFX Tech Support', body: ErrorMonitoringMail.createBody(params.errors), @@ -25,6 +29,12 @@ export class ErrorMonitoringMail extends Mail { super(_params); } + private static isLiqMail(params: ErrorMonitoringMailParams): boolean { + return [MailContext.BUY_CRYPTO, MailContext.DEX, MailContext.PAYOUT, MailContext.PRICING].includes( + params.metadata?.context, + ); + } + static createBody(errors: string[]): string { const env = GetConfig().environment.toUpperCase(); diff --git a/src/notification/services/mail.service.ts b/src/notification/services/mail.service.ts index 3a00e704e7..8fd64eb521 100644 --- a/src/notification/services/mail.service.ts +++ b/src/notification/services/mail.service.ts @@ -9,6 +9,7 @@ export interface MailOptions { contact: { supportMail: string; monitoringMail: string; + liqMail: string; noReplyMail: string; }; }