diff --git a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx index ddcef338e..d4abdc63b 100644 --- a/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx +++ b/apps/dokploy/components/dashboard/settings/notifications/handle-notifications.tsx @@ -446,6 +446,7 @@ export const HandleNotifications = ({ notificationId }: Props) => { serverUrl: notification.gotify?.serverUrl, name: notification.name, dockerCleanup: notification.dockerCleanup, + serverThreshold: notification.serverThreshold, }); } else if (notification.notificationType === "ntfy") { form.reset({ @@ -681,6 +682,7 @@ export const HandleNotifications = ({ notificationId }: Props) => { name: data.name, dockerCleanup: dockerCleanup, decoration: data.decoration, + serverThreshold: serverThreshold, notificationId: notificationId || "", gotifyId: notification?.gotifyId || "", }); @@ -698,6 +700,7 @@ export const HandleNotifications = ({ notificationId }: Props) => { priority: data.priority, name: data.name, dockerCleanup: dockerCleanup, + serverThreshold: serverThreshold, notificationId: notificationId || "", ntfyId: notification?.ntfyId || "", }); diff --git a/packages/server/src/db/schema/notification.ts b/packages/server/src/db/schema/notification.ts index 3caf23d13..3551f971f 100644 --- a/packages/server/src/db/schema/notification.ts +++ b/packages/server/src/db/schema/notification.ts @@ -433,6 +433,7 @@ export const apiCreateGotify = notificationsSchema name: true, appDeploy: true, dockerCleanup: true, + serverThreshold: true, }) .extend({ serverUrl: z.string().min(1), @@ -468,6 +469,7 @@ export const apiCreateNtfy = notificationsSchema name: true, appDeploy: true, dockerCleanup: true, + serverThreshold: true, }) .extend({ serverUrl: z.string().min(1), diff --git a/packages/server/src/services/notification.ts b/packages/server/src/services/notification.ts index 2c8247f0c..c0b7fdf38 100644 --- a/packages/server/src/services/notification.ts +++ b/packages/server/src/services/notification.ts @@ -561,6 +561,7 @@ export const createGotifyNotification = async ( volumeBackup: input.volumeBackup, dokployRestart: input.dokployRestart, dockerCleanup: input.dockerCleanup, + serverThreshold: input.serverThreshold, notificationType: "gotify", organizationId: organizationId, }) @@ -593,6 +594,7 @@ export const updateGotifyNotification = async ( volumeBackup: input.volumeBackup, dokployRestart: input.dokployRestart, dockerCleanup: input.dockerCleanup, + serverThreshold: input.serverThreshold, organizationId: input.organizationId, }) .where(eq(notifications.notificationId, input.notificationId)) @@ -655,6 +657,7 @@ export const createNtfyNotification = async ( volumeBackup: input.volumeBackup, dokployRestart: input.dokployRestart, dockerCleanup: input.dockerCleanup, + serverThreshold: input.serverThreshold, notificationType: "ntfy", organizationId: organizationId, }) @@ -687,6 +690,7 @@ export const updateNtfyNotification = async ( volumeBackup: input.volumeBackup, dokployRestart: input.dokployRestart, dockerCleanup: input.dockerCleanup, + serverThreshold: input.serverThreshold, organizationId: input.organizationId, }) .where(eq(notifications.notificationId, input.notificationId)) diff --git a/packages/server/src/utils/notifications/server-threshold.ts b/packages/server/src/utils/notifications/server-threshold.ts index 2c1ad8902..a8749a349 100644 --- a/packages/server/src/utils/notifications/server-threshold.ts +++ b/packages/server/src/utils/notifications/server-threshold.ts @@ -369,22 +369,28 @@ export const sendServerThresholdNotifications = async ( `Server: ${payload.ServerName}\nType: ${payload.Type}\nCurrent: ${payload.Value.toFixed(2)}%\nThreshold: ${payload.Threshold.toFixed(2)}%\nMessage: ${payload.Message}\nTime: ${date.toLocaleString()}`, ); } + + if (teams) { + await sendTeamsNotification(teams, { + title: `⚠️ Server ${payload.Type} Alert`, + facts: [ + { name: "Server Name", value: payload.ServerName }, + { name: "Type", value: payload.Type }, + { + name: "Current Value", + value: `${payload.Value.toFixed(2)}%`, + }, + { + name: "Threshold", + value: `${payload.Threshold.toFixed(2)}%`, + }, + { name: "Time", value: date.toLocaleString() }, + { name: "Message", value: payload.Message }, + ], + }); + } } catch (error) { console.log(error); } - - if (teams) { - await sendTeamsNotification(teams, { - title: `⚠️ Server ${payload.Type} Alert`, - facts: [ - { name: "Server Name", value: payload.ServerName }, - { name: "Type", value: payload.Type }, - { name: "Current Value", value: `${payload.Value.toFixed(2)}%` }, - { name: "Threshold", value: `${payload.Threshold.toFixed(2)}%` }, - { name: "Time", value: date.toLocaleString() }, - { name: "Message", value: payload.Message }, - ], - }); - } } };