feat(notifications): integrate custom notification handling in server threshold alerts

This commit is contained in:
ChristoferMendes
2025-09-26 17:06:31 -03:00
parent 8a8ed58fef
commit 1ce880bd6d
2 changed files with 181 additions and 124 deletions

View File

@@ -2,6 +2,7 @@ import { and, eq } from "drizzle-orm";
import { db } from "../../db";
import { notifications } from "../../db/schema";
import {
sendCustomNotification,
sendDiscordNotification,
sendSlackNotification,
sendTelegramNotification,
@@ -34,6 +35,7 @@ export const sendServerThresholdNotifications = async (
discord: true,
telegram: true,
slack: true,
custom: true,
},
});
@@ -41,7 +43,7 @@ export const sendServerThresholdNotifications = async (
const typeColor = 0xff0000; // Rojo para indicar alerta
for (const notification of notificationList) {
const { discord, telegram, slack } = notification;
const { discord, telegram, slack, custom } = notification;
if (discord) {
const decorate = (decoration: string, text: string) =>
@@ -151,5 +153,20 @@ export const sendServerThresholdNotifications = async (
],
});
}
if (custom) {
await sendCustomNotification(custom, {
title: `Server ${payload.Type} Alert`,
message: payload.Message,
serverName: payload.ServerName,
type: payload.Type,
currentValue: payload.Value,
threshold: payload.Threshold,
timestamp: date.toISOString(),
date: date.toLocaleString(),
status: "alert",
alertType: "server-threshold",
});
}
}
};