mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-08 13:38:33 +02:00
23 lines
760 B
TypeScript
23 lines
760 B
TypeScript
import logger from "@server/logger";
|
|
import type { TestAlertContext } from "@server/routers/alertRule/types";
|
|
import { sendAlertEmail } from "./sendAlertEmail";
|
|
|
|
export async function processTestAlerts(context: TestAlertContext) {
|
|
const emailActions = context.actions.filter(
|
|
(action) => action.type === "email"
|
|
);
|
|
// Process email actions
|
|
for (const action of emailActions) {
|
|
try {
|
|
const recipients = await resolveEmailRecipients(
|
|
action.emailActionId
|
|
);
|
|
if (recipients.length > 0) {
|
|
await sendAlertEmail(recipients, context);
|
|
}
|
|
} catch (err) {
|
|
logger.error(`processAlerts: failed to send alert email`, err);
|
|
}
|
|
}
|
|
}
|