diff --git a/apps/webapp/app/services/email.server.ts b/apps/webapp/app/services/email.server.ts index 5e37a085f..46f971505 100644 --- a/apps/webapp/app/services/email.server.ts +++ b/apps/webapp/app/services/email.server.ts @@ -20,6 +20,17 @@ const client = singleton( }) ); +const alertsClient = singleton( + "alerts-email-client", + () => + new EmailClient({ + apikey: env.ALERT_RESEND_API_KEY, + imagesBaseUrl: env.APP_ORIGIN, + from: env.ALERT_FROM_EMAIL ?? "noreply@alerts.trigger.dev", + replyTo: env.REPLY_TO_EMAIL ?? "help@email.trigger.dev", + }) +); + export async function sendMagicLinkEmail(options: SendEmailOptions): Promise { // Auto redirect when in development mode if (env.NODE_ENV === "development") { @@ -67,3 +78,7 @@ export async function scheduleEmail(data: DeliverEmail, delay?: { seconds: numbe export async function sendEmail(data: DeliverEmail) { return client.send(data); } + +export async function sendAlertEmail(data: DeliverEmail) { + return alertsClient.send(data); +} diff --git a/apps/webapp/app/v3/services/alerts/deliverAlert.server.ts b/apps/webapp/app/v3/services/alerts/deliverAlert.server.ts index 3b3ac7641..780af49a4 100644 --- a/apps/webapp/app/v3/services/alerts/deliverAlert.server.ts +++ b/apps/webapp/app/v3/services/alerts/deliverAlert.server.ts @@ -10,7 +10,7 @@ import { ProjectAlertWebhookProperties, } from "~/models/projectAlert.server"; import { DeploymentPresenter } from "~/presenters/v3/DeploymentPresenter.server"; -import { sendEmail } from "~/services/email.server"; +import { sendAlertEmail, sendEmail } from "~/services/email.server"; import { logger } from "~/services/logger.server"; import { decryptSecret } from "~/services/secrets/secretStore.server"; import { workerQueue } from "~/services/worker.server"; @@ -144,7 +144,7 @@ export class DeliverAlertService extends BaseService { return; } - await sendEmail({ + await sendAlertEmail({ email: "alert-attempt", to: emailProperties.data.email, taskIdentifier: alert.taskRunAttempt.taskRun.taskIdentifier, @@ -177,7 +177,7 @@ export class DeliverAlertService extends BaseService { return; } - await sendEmail({ + await sendAlertEmail({ email: "alert-deployment-failure", to: emailProperties.data.email, version: alert.workerDeployment.version, @@ -197,7 +197,7 @@ export class DeliverAlertService extends BaseService { } case "DEPLOYMENT_SUCCESS": { if (alert.workerDeployment) { - await sendEmail({ + await sendAlertEmail({ email: "alert-deployment-success", to: emailProperties.data.email, version: alert.workerDeployment.version,