mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
feat: added heath_error_count and the cron for health check agent errors
This commit is contained in:
@@ -6,27 +6,6 @@ import {eq} from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
|
||||
export async function sendNotificationsBackupRestore(database: DatabaseWith, event: EventKind) {
|
||||
// if (!database.alertPolicies || database.alertPolicies.length === 0) {
|
||||
// return [];
|
||||
// }
|
||||
//
|
||||
// const activePolicies = database.alertPolicies.filter(policy =>
|
||||
// policy.enabled && policy.eventKinds.includes(event)
|
||||
// );
|
||||
//
|
||||
// const settings = await db.query.setting.findFirst({
|
||||
// where: eq(drizzleDb.schemas.setting.name, "system"),
|
||||
// with: {notificationChannel: true},
|
||||
// });
|
||||
//
|
||||
// const defaultPolicy = settings?.notificationChannel
|
||||
// ? [{
|
||||
// id: null,
|
||||
// notificationChannelId: settings.notificationChannel.id,
|
||||
// enabled: settings.notificationChannel.enabled,
|
||||
// }]
|
||||
// : [];
|
||||
|
||||
|
||||
const settings = await db.query.setting.findFirst({
|
||||
where: eq(drizzleDb.schemas.setting.name, "system"),
|
||||
@@ -38,6 +17,7 @@ export async function sendNotificationsBackupRestore(database: DatabaseWith, eve
|
||||
id: null,
|
||||
notificationChannelId: settings.notificationChannel.id,
|
||||
enabled: settings.notificationChannel.enabled,
|
||||
eventKinds: ["error_backup" , "error_restore"]
|
||||
}]
|
||||
: [];
|
||||
|
||||
@@ -79,6 +59,7 @@ export async function sendNotificationsBackupRestore(database: DatabaseWith, eve
|
||||
success_backup: `Backup Notification`,
|
||||
success_restore: `Restore Notification`,
|
||||
weekly_report: `Weekly Report Notification`,
|
||||
error_health_agent: "Health Agent Notification",
|
||||
};
|
||||
|
||||
const payload: EventPayload = {
|
||||
|
||||
@@ -18,4 +18,4 @@ export interface EventPayload {
|
||||
data?: Record<string, any>;
|
||||
}
|
||||
|
||||
export type EventKind = ("error_backup" | "error_restore" | "success_restore" | "success_backup" | "weekly_report")
|
||||
export type EventKind = ("error_backup" | "error_restore" | "success_restore" | "success_backup" | "weekly_report" | "error_health_agent")
|
||||
|
||||
Reference in New Issue
Block a user