diff --git a/app/client/api-client/types.gen.ts b/app/client/api-client/types.gen.ts index 2790e840..a7ab7053 100644 --- a/app/client/api-client/types.gen.ts +++ b/app/client/api-client/types.gen.ts @@ -2034,6 +2034,7 @@ export type GetScheduleNotificationsResponses = { notifyOnFailure: boolean; notifyOnStart: boolean; notifyOnSuccess: boolean; + notifyOnWarning: boolean; scheduleId: number; }>; }; @@ -2047,6 +2048,7 @@ export type UpdateScheduleNotificationsData = { notifyOnFailure: boolean; notifyOnStart: boolean; notifyOnSuccess: boolean; + notifyOnWarning: boolean; }>; }; path: { @@ -2122,6 +2124,7 @@ export type UpdateScheduleNotificationsResponses = { notifyOnFailure: boolean; notifyOnStart: boolean; notifyOnSuccess: boolean; + notifyOnWarning: boolean; scheduleId: number; }>; }; diff --git a/app/client/modules/backups/components/schedule-notifications-config.tsx b/app/client/modules/backups/components/schedule-notifications-config.tsx index 40358c96..820e72b7 100644 --- a/app/client/modules/backups/components/schedule-notifications-config.tsx +++ b/app/client/modules/backups/components/schedule-notifications-config.tsx @@ -24,6 +24,7 @@ type NotificationAssignment = { destinationId: number; notifyOnStart: boolean; notifyOnSuccess: boolean; + notifyOnWarning: boolean; notifyOnFailure: boolean; }; @@ -57,6 +58,7 @@ export const ScheduleNotificationsConfig = ({ scheduleId, destinations }: Props) destinationId: assignment.destinationId, notifyOnStart: assignment.notifyOnStart, notifyOnSuccess: assignment.notifyOnSuccess, + notifyOnWarning: assignment.notifyOnWarning, notifyOnFailure: assignment.notifyOnFailure, }); } @@ -72,6 +74,7 @@ export const ScheduleNotificationsConfig = ({ scheduleId, destinations }: Props) destinationId: id, notifyOnStart: false, notifyOnSuccess: false, + notifyOnWarning: true, notifyOnFailure: true, }); @@ -87,7 +90,10 @@ export const ScheduleNotificationsConfig = ({ scheduleId, destinations }: Props) setHasChanges(true); }; - const toggleEvent = (destinationId: number, event: "notifyOnStart" | "notifyOnSuccess" | "notifyOnFailure") => { + const toggleEvent = ( + destinationId: number, + event: "notifyOnStart" | "notifyOnSuccess" | "notifyOnWarning" | "notifyOnFailure", + ) => { const assignment = assignments.get(destinationId); if (!assignment) return; @@ -119,6 +125,7 @@ export const ScheduleNotificationsConfig = ({ scheduleId, destinations }: Props) destinationId: assignment.destinationId, notifyOnStart: assignment.notifyOnStart, notifyOnSuccess: assignment.notifyOnSuccess, + notifyOnWarning: assignment.notifyOnWarning, notifyOnFailure: assignment.notifyOnFailure, }); } @@ -193,7 +200,8 @@ export const ScheduleNotificationsConfig = ({ scheduleId, destinations }: Props) Destination Start Success - Failure + Warnings + Failures @@ -226,6 +234,13 @@ export const ScheduleNotificationsConfig = ({ scheduleId, destinations }: Props) onCheckedChange={() => toggleEvent(destination.id, "notifyOnSuccess")} /> + + toggleEvent(destination.id, "notifyOnWarning")} + /> + notificationDestinationsTable.id, { onDelete: "cascade" }), notifyOnStart: int("notify_on_start", { mode: "boolean" }).notNull().default(false), notifyOnSuccess: int("notify_on_success", { mode: "boolean" }).notNull().default(false), + notifyOnWarning: int("notify_on_warning", { mode: "boolean" }).notNull().default(true), notifyOnFailure: int("notify_on_failure", { mode: "boolean" }).notNull().default(true), createdAt: int("created_at", { mode: "number" }).notNull().default(sql`(unixepoch() * 1000)`), }, diff --git a/app/server/modules/notifications/notifications.dto.ts b/app/server/modules/notifications/notifications.dto.ts index 65d682f6..887a93ae 100644 --- a/app/server/modules/notifications/notifications.dto.ts +++ b/app/server/modules/notifications/notifications.dto.ts @@ -190,6 +190,7 @@ export const scheduleNotificationAssignmentSchema = type({ destinationId: "number", notifyOnStart: "boolean", notifyOnSuccess: "boolean", + notifyOnWarning: "boolean", notifyOnFailure: "boolean", createdAt: "number", destination: notificationDestinationSchema, @@ -227,6 +228,7 @@ export const updateScheduleNotificationsBody = type({ destinationId: "number", notifyOnStart: "boolean", notifyOnSuccess: "boolean", + notifyOnWarning: "boolean", notifyOnFailure: "boolean", }).array(), }); diff --git a/app/server/modules/notifications/notifications.service.ts b/app/server/modules/notifications/notifications.service.ts index 4099d8b4..3c5c0f8b 100644 --- a/app/server/modules/notifications/notifications.service.ts +++ b/app/server/modules/notifications/notifications.service.ts @@ -253,6 +253,7 @@ const updateScheduleNotifications = async ( destinationId: number; notifyOnStart: boolean; notifyOnSuccess: boolean; + notifyOnWarning: boolean; notifyOnFailure: boolean; }>, ) => { @@ -300,8 +301,9 @@ const sendBackupNotification = async ( return assignment.notifyOnStart; case "success": return assignment.notifyOnSuccess; - case "failure": case "warning": + return assignment.notifyOnWarning; + case "failure": return assignment.notifyOnFailure; default: return false;