Use a separate email client for sending alerts
This commit is contained in:
@@ -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<AuthUser>): Promise<void> {
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user