mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-08 21:48:02 +02:00
🚧 process test alert
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user