feat(notifications): add custom notification support for database backup status

This commit is contained in:
ChristoferMendes
2025-09-26 17:06:06 -03:00
parent 0e2f1e2832
commit a181b7b8b8
@@ -5,6 +5,7 @@ import { renderAsync } from "@react-email/components";
import { format } from "date-fns"; import { format } from "date-fns";
import { and, eq } from "drizzle-orm"; import { and, eq } from "drizzle-orm";
import { import {
sendCustomNotification,
sendDiscordNotification, sendDiscordNotification,
sendEmailNotification, sendEmailNotification,
sendGotifyNotification, sendGotifyNotification,
@@ -44,11 +45,12 @@ export const sendDatabaseBackupNotifications = async ({
slack: true, slack: true,
gotify: true, gotify: true,
ntfy: true, ntfy: true,
custom: true,
}, },
}); });
for (const notification of notificationList) { for (const notification of notificationList) {
const { email, discord, telegram, slack, gotify, ntfy } = notification; const { email, discord, telegram, slack, gotify, ntfy, custom } = notification;
if (email) { if (email) {
const template = await renderAsync( const template = await renderAsync(
@@ -238,5 +240,21 @@ export const sendDatabaseBackupNotifications = async ({
], ],
}); });
} }
if (custom) {
await sendCustomNotification(custom, {
title: `Database Backup ${type === "success" ? "Successful" : "Failed"}`,
message: type === "success" ? "Database backup completed successfully" : "Database backup failed",
projectName,
applicationName,
databaseType,
databaseName,
type,
errorMessage: errorMessage || "",
timestamp: date.toISOString(),
date: date.toLocaleString(),
status: type,
});
}
} }
}; };